Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release to prod #107

Merged
merged 51 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
6b9b0a0
build(deps): bump @babel/traverse from 7.16.7 to 7.23.7
dependabot[bot] Jan 5, 2024
3ebc8b2
build(deps): bump semver from 5.7.1 to 5.7.2
dependabot[bot] Jan 5, 2024
c76f210
build(deps): bump word-wrap from 1.2.3 to 1.2.5
dependabot[bot] Jan 5, 2024
b3cfbba
build(deps): bump browserify-sign from 4.2.1 to 4.2.2
dependabot[bot] Jan 5, 2024
c3b5d00
refactor: extract evmTxForm
q20274982 Dec 20, 2023
a7f45f6
feat: add BatchTxEditor
q20274982 Dec 22, 2023
035e585
enhance: optional revert and improve empty tx express
q20274982 Dec 27, 2023
c634065
Merge pull request #80 from blocto/feat/evm-batch-tx-panel
q20274982 Jan 9, 2024
72215ee
fix: set EvmBatchTxEditor's revert default value to false
q20274982 Jan 9, 2024
af7a2a8
feat: sort revert flag's order
q20274982 Jan 9, 2024
847b1cd
Merge pull request #83 from blocto/dependabot/npm_and_yarn/babel/trav…
mordochi Jan 9, 2024
eb479eb
Merge pull request #84 from blocto/dependabot/npm_and_yarn/semver-5.7.2
mordochi Jan 9, 2024
3a9cbe6
Merge pull request #85 from blocto/dependabot/npm_and_yarn/word-wrap-…
mordochi Jan 9, 2024
e37fab0
Merge pull request #86 from blocto/dependabot/npm_and_yarn/browserify…
mordochi Jan 9, 2024
ee1fa3f
build(deps): bump follow-redirects from 1.15.2 to 1.15.4
dependabot[bot] Jan 9, 2024
ff09018
fix: use built-in select menu
akira02 Jan 10, 2024
beec95c
fix: catch evm send editor error
akira02 Jan 10, 2024
7b834fa
Merge pull request #87 from blocto/fix/evm-editor-imporve
akira02 Jan 10, 2024
572b77f
fix: build warning
akira02 Jan 10, 2024
3efff6d
Merge pull request #88 from blocto/fix/adjust-revert-default-value
q20274982 Jan 10, 2024
a8063a2
Merge pull request #90 from blocto/fix/build-warn
akira02 Jan 10, 2024
ae2434f
Merge pull request #89 from blocto/dependabot/npm_and_yarn/follow-red…
mordochi Jan 11, 2024
e307696
fix: send batch transactions
mordochi Jan 26, 2024
fe07952
Merge pull request #91 from blocto/bugfix/fix-send-batch
mordochi Jan 29, 2024
042e135
feat: add batchTransaction Transfer template button
sanyu1225 Feb 4, 2024
01cb4f4
Merge pull request #92 from blocto/feat/batch-template
sanyu1225 Feb 5, 2024
0d29bf2
feat: batch template add mintNFT (scroll testnet)
sanyu1225 Feb 6, 2024
c1c1d8b
Merge pull request #93 from blocto/feat/batch-template
sanyu1225 Feb 7, 2024
92343af
feat: add dockerfile
sanyu1225 Feb 20, 2024
b844ded
Merge pull request #94 from blocto/feat/support-docker
sanyu1225 Feb 20, 2024
94789df
feat: support aptos server from env
sanyu1225 Feb 24, 2024
caeda47
Merge pull request #96 from blocto/feat/aptos-server-inject-env
sanyu1225 Feb 26, 2024
7e2d744
feat: add l2 blast
q20274982 Mar 4, 2024
6c74071
build: update blocto sdk
q20274982 Mar 8, 2024
e090841
Merge pull request #98 from blocto/feat/add-l2-blast
q20274982 Mar 8, 2024
a1e56c9
build: update blocto sdk
q20274982 Mar 12, 2024
874946a
Merge pull request #99 from blocto/build/update-blocto-sdk
q20274982 Mar 12, 2024
8c903ec
feat: deprecate goerli testnet
sanyu1225 Apr 12, 2024
959af85
feat: add swap template
sanyu1225 Apr 12, 2024
fb546d8
fix: mint nft template only for Scroll
sanyu1225 Apr 12, 2024
0800e0e
feat: evm default testnet chainId
sanyu1225 Apr 12, 2024
5e3b9e6
fix: remove goreli config
sanyu1225 Apr 12, 2024
83aae34
fix: remove goreli config
sanyu1225 Apr 12, 2024
1994883
Merge pull request #102 from blocto/feat/deprecate-goerli
sanyu1225 Apr 12, 2024
f0c0e21
Merge pull request #103 from blocto/feat/add-swap-template
sanyu1225 Apr 12, 2024
6608f57
feat: migration testnet polygon_mumbai to polygon_amoy
sanyu1225 Apr 29, 2024
27b25be
chore: update asana project id
mordochi Apr 30, 2024
684f540
feat: update polygon_test contract addr
sanyu1225 May 2, 2024
92c96fa
Merge pull request #105 from blocto/chore/asana-link
mordochi May 2, 2024
a3801ff
feat: update sdk version
sanyu1225 May 3, 2024
2e2ff20
Merge pull request #104 from blocto/feat/polygon-testnet
sanyu1225 May 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/create-asana-attachment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
with:
asana-secret: ${{ secrets.ASANA_SECRET }}
allowed-projects: |
1201812548509877
1207145524635866
1207160002492686
1204161964711931
- name: Log output status
run: echo "Status is ${{ steps.postAttachment.outputs.status }}"
run: echo "Status is ${{ steps.postAttachment.outputs.status }}"
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

.env
.env

# IntelijIDEA
.idea
18 changes: 18 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:16-alpine

WORKDIR /app

COPY package*.json yarn.lock ./
RUN apk add --no-cache yarn

RUN apk add --no-cache python3
ENV PYTHON=/usr/bin/python3

RUN apk add --no-cache make g++

RUN yarn install
COPY . ./

EXPOSE 3001

CMD ["yarn", "start"]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dependencies": {
"@blocto/dappauth": "^2.1.0",
"@blocto/fcl": "^1.0.0-alpha.1",
"@blocto/sdk": "^0.9.0-beta.3",
"@blocto/sdk": "^0.10.2",
"@chakra-ui/icons": "^1.1.1",
"@chakra-ui/react": "^1.7.4",
"@emotion/react": "^11",
Expand Down
98 changes: 25 additions & 73 deletions src/components/EvmChainSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
import React, { useEffect, useState } from "react";
import {
Button,
Menu,
MenuButton,
MenuList,
MenuItem,
MenuGroup,
MenuDivider,
} from "@chakra-ui/react";
import { ChevronDownIcon } from "@chakra-ui/icons";
import React from "react";
import { Select } from "@chakra-ui/react";
import { ReactJSXElement } from "@emotion/react/types/jsx-namespace";
import { supportedChains, bloctoSDK, useEthereum } from "../services/evm";

Expand All @@ -21,70 +12,31 @@ const supportedTestnetChains = supportedChains.filter(

const EvmChainSelect: React.FC = ({}): ReactJSXElement => {
const { chainId: currentChainId } = useEthereum();
const [chainName, setChainName] = useState(
supportedChains.find(({ chainId }) => chainId === currentChainId)?.name ||
"Ethereum Goerli"
);
useEffect(() => {
const chainName = supportedChains.find(
({ chainId }) => chainId === currentChainId
)?.name;
if (chainName) {
setChainName(chainName);
}
}, [currentChainId]);

return (
<Menu>
<MenuButton as={Button} rightIcon={<ChevronDownIcon />} width="200px">
{chainName}
</MenuButton>
<MenuList>
<MenuGroup title="Testnet">
{supportedTestnetChains.map(({ name, chainId }) => (
<MenuItem
key={chainId}
pl={5}
color="gray.700"
onClick={() => {
bloctoSDK.ethereum
.request({
method: "wallet_switchEthereumChain",
params: [{ chainId }],
})
.then(() => {
setChainName(name);
});
}}
>
{name}
</MenuItem>
))}
</MenuGroup>
<MenuDivider />
<MenuGroup title="Mainnet">
{supportedMainnetChains.map(({ name, chainId }) => (
<MenuItem
key={chainId}
pl={5}
color="gray.700"
onClick={() => {
bloctoSDK.ethereum
.request({
method: "wallet_switchEthereumChain",
params: [{ chainId }],
})
.then(() => {
setChainName(name);
});
}}
>
{name}
</MenuItem>
))}
</MenuGroup>
</MenuList>
</Menu>
<Select
width="200px"
value={currentChainId || ""}
onChange={(e) => {
bloctoSDK.ethereum.request({
method: "wallet_switchEthereumChain",
params: [{ chainId: e.target.value }],
});
}}
>
<option disabled>Testnet</option>
{supportedTestnetChains.map(({ name, chainId }) => (
<option key={chainId} value={chainId}>
{name}
</option>
))}
<option disabled>Mainnet</option>
{supportedMainnetChains.map(({ name, chainId }) => (
<option key={chainId} value={chainId}>
{name}
</option>
))}
</Select>
);
};

Expand Down
16 changes: 10 additions & 6 deletions src/components/EvmEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import EvmSignEditor from "./EvmEditors/EvmSignEditor";
import EvmUserOpEditor from "./EvmEditors/EvmUserOpEditor";
import EvmSendEditor from "./EvmEditors/EvmSendEditor";
import EvmContractEditor from "./EvmEditors/EvmContractEditor";
import EvmBatchTxEditor from "./EvmEditors/EvmBatchTxEditor";
import type { EthereumTypes } from "@blocto/sdk";
import { bloctoSDK, useEthereum, supportedChains, web3 } from "../services/evm";
import ReactJson from "react-json-view";
Expand Down Expand Up @@ -233,6 +234,7 @@ const EvmEditor = (): ReactJSXElement => {
<Tab>User Operation</Tab>
<Tab>Send</Tab>
<Tab>Contract</Tab>
<Tab>Batch Transaction</Tab>
</TabList>
<TabPanels>
<TabPanel>
Expand All @@ -254,12 +256,7 @@ const EvmEditor = (): ReactJSXElement => {
</TabPanel>
<TabPanel>
<EvmSendEditor
setRequestObject={(params = []) =>
setRequestObject({
method: "eth_sendTransaction",
params,
})
}
setRequestObject={setRequestObject}
account={account}
/>
</TabPanel>
Expand All @@ -271,6 +268,13 @@ const EvmEditor = (): ReactJSXElement => {
chainId={chainId}
/>
</TabPanel>
<TabPanel>
<EvmBatchTxEditor
setRequestObject={setRequestObject}
account={account}
chainId={chainId}
/>
</TabPanel>
</TabPanels>
</Tabs>
</Flex>
Expand Down
183 changes: 183 additions & 0 deletions src/components/EvmEditors/EvmBatchTxEditor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
import React, { useEffect, useState, Dispatch, SetStateAction } from "react";
import {
Box,
Text,
Grid,
Flex,
IconButton,
Radio,
RadioGroup,
Button,
} from "@chakra-ui/react";
import { CloseIcon } from "@chakra-ui/icons";
import { ReactJSXElement } from "@emotion/react/types/jsx-namespace";
import type { EthereumTypes } from "@blocto/sdk";
import EvmTxForm from "./EvmTxForm";
import { web3 } from "../../services/evm";
import erc721Abi from "../../contracts/abi/ERC721.json";

interface EvmBatchTxEditorProps {
setRequestObject: Dispatch<
SetStateAction<EthereumTypes.EIP1193RequestPayload | undefined>
>;
account: string | null;
chainId: string | null;
}

const RevertOptionMap: Record<string, any> = {
false: false,
true: true,
unset: undefined,
};

const EvmBatchTxEditor = ({
setRequestObject,
account,
chainId,
}: EvmBatchTxEditorProps): ReactJSXElement => {
const [revert, setRevert] = useState<string>("false");
const [txs, setTxs] = useState<any[]>();

useEffect(() => {
if (account) {
setRequestObject({
method: "wallet_sendMultiCallTransaction",
params: [
txs,
...(RevertOptionMap[revert] !== undefined
? [RevertOptionMap[revert]]
: []),
],
});
}
}, [account, setRequestObject, revert, txs]);

const addTransfer = () => {
const obj = {
value: "0x1",
to: "0x85fD692D2a075908079261F5E351e7fE0267dB02",
from: account,
};
setTxs((state) => {
return [...(state || []), obj];
});
};

const mintNFT = () => {
// TODO: wait backend provide all evm chain contract address
const contractAddr = "0x6bDa27BB78833658D19049118b73eC7b07815C8A"; // only scroll testnet
const contract = new web3.eth.Contract(erc721Abi as any, contractAddr);
const obj = {
from: account,
to: contractAddr,
data: contract.methods.mint(account).encodeABI(),
};
setTxs((state) => {
return [...(state || []), obj];
});
};

const SwapToken = () => {
const obj = {
from: account,
to: "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD",
data: "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000066053af000000000000000000000000000000000000000000000000000000000000000020b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000038d7ea4c680000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000038d7ea4c680000000000000000000000000000000000000000000000000000000b99e289c676500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002bfff9976782d46cc05630d1f6ebab18b2324d6b140001f41f9840a85d5af5bf1d1762f925bdaddc4201f984000000000000000000000000000000000000000000",
};
setTxs((state) => {
return [...(state || []), obj];
});
};

const removeTransfer = (index: number) => {
setTxs((state) => {
if (Array.isArray(state) && state.length === 1) {
return [];
}
const newParam = [...(state || [])];
return newParam.splice(index, 1);
});
};
return (
<>
<Grid templateRows="repeat(4, min-content)" gap="10px">
<Box fontWeight="bold">Revert</Box>
<RadioGroup
value={revert}
onChange={(e) => {
setRevert(e);
}}
>
<Flex gap="15px">
{Object.keys(RevertOptionMap).map((key) => (
<Radio key={key} value={key}>
{key}
</Radio>
))}
</Flex>
</RadioGroup>

<Grid
alignItems="center"
gap="10px"
gridAutoFlow="column"
justifyContent="left"
>
<Box fontWeight="bold">Transaction</Box>
<Button w="110px" onClick={addTransfer}>
Transfer
</Button>
{chainId === "0x8274f" && (
<Button w="110px" onClick={mintNFT}>
Mint NFT
</Button>
)}
{chainId === "0xaa36a7" && (
<Button w="110px" onClick={SwapToken}>
Swap
</Button>
)}
</Grid>
<Flex flexDir="column" mt={2} pl={4}>
{Array.isArray(txs) &&
txs?.length > 0 &&
txs?.map((value, i: number) => (
<Box key={i}>
<Flex alignItems="center">
<Text fontWeight="bold" mb={2}>
Transaction {i + 1}
</Text>
<IconButton
ml={2}
aria-label="Delete Arg"
isRound
icon={<CloseIcon />}
size="xs"
colorScheme="red"
onClick={() => removeTransfer(i)}
/>
</Flex>
<Flex my="5px" alignItems="center">
<EvmTxForm
key={i}
setTransactionObject={(updatedTxs) => {
if (updatedTxs)
setTxs((prev) => {
const newTxs = [...(prev || [])];
newTxs[i] = updatedTxs[0];
return newTxs;
});
}}
isCustom={true}
account={account}
customParams={value}
/>
</Flex>
</Box>
))}
</Flex>
</Grid>
</>
);
};

export default EvmBatchTxEditor;
Loading
Loading