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

Update prod #76

Merged
merged 76 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
efa78e1
chore: add prettierrc
akira02 Jul 11, 2023
8ced3d7
refactor: evm editor
akira02 Jul 17, 2023
5e0d6a4
fix: wrong chain id in SignTypedDataEditor
akira02 Jul 17, 2023
1a12d6e
fix: chain name
akira02 Jul 19, 2023
e410756
feat: add response section to evm editor
akira02 Jul 19, 2023
7a0773d
feat: add signature verify button
akira02 Jul 19, 2023
a577117
feat: add userOp editor
akira02 Jul 19, 2023
fea0b2b
fix: sign typed data verify
akira02 Jul 20, 2023
a8ec2e3
feat: add userOp templates
akira02 Jul 20, 2023
988aa4e
feat: add getUserOperationReceipt button
akira02 Jul 20, 2023
e976af9
feat: add send transaction page
akira02 Jul 20, 2023
123d695
feat: add evm contract editor
akira02 Jul 20, 2023
1f028f7
feat: add contract template and fix contract editor
akira02 Jul 21, 2023
d4ae36d
fix: better experience
akira02 Jul 21, 2023
2d1fb07
feat: add valuedapp address for all net
akira02 Jul 21, 2023
bdceec3
fix: evm editor button margin
dependabot[bot] Mar 2, 2023
783e829
feat: add send erc20 contract template
akira02 Jul 24, 2023
564981f
fix: help decode contract read and get receipt
akira02 Jul 25, 2023
881149d
fix: seperate decodeType
akira02 Jul 25, 2023
d709aa0
fix: remove unnecessary
akira02 Jul 25, 2023
b7bed20
chore: move abi together
akira02 Jul 25, 2023
2393a84
chore: review fix
akira02 Jul 28, 2023
1102433
chore: update evm sign domain id to number
akira02 Jul 28, 2023
90173a7
feat: add array type for aptos script
akira02 Jul 28, 2023
d092af5
Merge pull request #54 from blocto/refactor/evm-editor
akira02 Jul 28, 2023
cdb7ec2
chore: update sdk to 0.5.5-beta.0
akira02 Jul 31, 2023
e94f87a
fix: update sdk to 0.5.5-beta.2
akira02 Aug 1, 2023
6f9c829
feat: add eth_sign method
akira02 Aug 1, 2023
95b6e96
fix: catch err if contract abi not right
akira02 Aug 1, 2023
144122d
Merge pull request #55 from blocto/chore/update-sdk-0.5.5
akira02 Aug 1, 2023
d2cedc0
feat: add mainnet hint on evm
akira02 Aug 2, 2023
c3ba42d
fix: remove listener when useEthereum unmount
akira02 Aug 2, 2023
221947a
feat: rename flow trigger error template
akira02 Aug 2, 2023
781d2c0
Merge pull request #56 from blocto/feat/evm-mainnet-hint
akira02 Aug 4, 2023
0e3dc62
chore: update js sdk to 0.5.5-beta.3
akira02 Aug 7, 2023
de49ffe
chore: remove userop template setvalue
akira02 Aug 7, 2023
525754d
fix: use web3js to convert sending hex value
akira02 Aug 7, 2023
aa8c2a5
Merge pull request #58 from blocto/fix/small-fixs
akira02 Aug 9, 2023
de476f8
fix: remove duplicate 0x
mordochi Aug 14, 2023
d8709ca
Merge pull request #59 from blocto/bugfix/duplicate-0x
mordochi Aug 14, 2023
52b5f14
chore: update sdk to 0.6.0-beta.4
akira02 Aug 16, 2023
df362d1
chore: update sdk to 0.6.0-beta.5
akira02 Aug 16, 2023
61f03c7
Merge pull request #60 from blocto/chore/update-sdk
akira02 Aug 16, 2023
0431779
feat: add test cases for Aptos
mordochi Aug 19, 2023
5c6abd7
refactor: format args in editor
mordochi Aug 21, 2023
7c036c8
fix: fix typo
mordochi Aug 21, 2023
3e0a7f8
Merge pull request #61 from blocto/feature/aptos-test-cases
mordochi Aug 21, 2023
46f5296
chore: remove solana
akira02 Aug 21, 2023
783a857
Merge pull request #62 from blocto/chore/update-sdk
mordochi Aug 22, 2023
d5e72ee
chore: update sdk to 0.6.0-beta.7
akira02 Aug 28, 2023
3d5fe15
Merge pull request #63 from blocto/chore/update-sdk-0.6.0-beta.7
akira02 Aug 28, 2023
861ad90
chore: update blocto sdk to 0.7.0-beta.1
akira02 Sep 4, 2023
a2119c7
Merge pull request #64 from blocto/chore/update-sdk-0.7.0-beta.1
akira02 Sep 5, 2023
6282162
fix: fix optimism chain id hex format
mordochi Sep 12, 2023
368d1a4
Merge pull request #65 from blocto/bugfix/fix-op-chain-id
mordochi Sep 12, 2023
670345f
feat: update the custom paymaster for all chains
mordochi Sep 14, 2023
6c552c8
feat: add sendTx feat to UserOp template
q20274982 Sep 18, 2023
00f1f79
feat: hide otherParam when sendTx by sendUserOp way
q20274982 Oct 2, 2023
bcf36f2
fix: fix sendTx's params passing
q20274982 Oct 2, 2023
a0d9a32
Merge pull request #66 from blocto/feature/paymaster
mordochi Oct 2, 2023
3ff71e8
Merge pull request #67 from blocto/feat/userOp-add-tx-form
q20274982 Oct 11, 2023
31cac51
chore: update sdk to 0.7.1-beta.0
sanyu1225 Oct 20, 2023
c904a65
Merge pull request #70 from blocto/feat/update-sdk
sanyu1225 Oct 20, 2023
e0d7374
fix: yarn install update lock file
sanyu1225 Oct 20, 2023
37d4ef8
fix: eslint error
sanyu1225 Oct 20, 2023
d88ea1e
Merge pull request #71 from blocto/feat/update-sdk
sanyu1225 Oct 20, 2023
de5a53c
feat: update sdk version
sanyu1225 Oct 26, 2023
23a51a6
Merge pull request #72 from blocto/feat/update-sdk
sanyu1225 Oct 26, 2023
8b194b6
feat: update sdk version
sanyu1225 Oct 27, 2023
abf4b44
Merge pull request #73 from blocto/enhance/sdk-version
sanyu1225 Oct 27, 2023
dce3506
feat: update sdk to 0.8.1-beta.0
q20274982 Nov 2, 2023
0a96c84
Merge pull request #74 from blocto/feat/update-sdk
q20274982 Nov 2, 2023
d628d32
build: update fcl version
mordochi Nov 23, 2023
6f8b5c4
Merge pull request #68 from blocto/enhance/update-fcl
mordochi Nov 23, 2023
125e8fc
enhance: update infura key
mordochi Dec 5, 2023
01fe173
Merge pull request #75 from blocto/enhance/replace-infura-key
mordochi Dec 5, 2023
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
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
REACT_APP_DAPP_ID=
REACT_APP_NETWORK=testnet
REACT_APP_NETWORK=testnet
REACT_APP_INFURA_KEY=
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": true,
"trailingComma": "es5",
"printWidth": 80
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@blocto/dappauth": "^2.1.0",
"@blocto/fcl": "^1.0.0-alpha.1",
"@blocto/sdk": "^0.5.0",
"@blocto/sdk": "0.8.1-beta.0",
"@chakra-ui/icons": "^1.1.1",
"@chakra-ui/react": "^1.7.4",
"@emotion/react": "^11",
"@emotion/styled": "^11",
"@onflow/types": "^1.0.0",
"@solana/buffer-layout": "^4.0.0",
"@solana/web3.js": "^1.36.0",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
Expand All @@ -20,9 +19,11 @@
"@types/react": "^17.0.38",
"@types/react-dom": "^17.0.11",
"elliptic": "^6.5.4",
"eth-eip712-util": "^2.3.1",
"framer-motion": "^4",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-json-view": "^1.21.3",
"react-scripts": "4.0.3",
"sha3": "^2.1.4",
"typescript": "^4.5.4",
Expand Down Expand Up @@ -62,6 +63,7 @@
"prettier": "^2.5.1"
},
"resolutions": {
"react-error-overlay": "6.0.9"
"react-error-overlay": "6.0.9",
"acorn": "npm:acorn-with-stage3"
}
}
94 changes: 81 additions & 13 deletions src/components/AptosEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,36 @@ const MenuGroups = [
{ title: "Resource", templates: AptosResourceTemplate },
];

const formatTransactionArgs = (args: Arg[] | undefined) => {
const NUMBERS = [AptosArgTypes.U8, AptosArgTypes.U16, AptosArgTypes.U32];

const formatArg = (type: AptosArgTypes, value: any): any => {
if (NUMBERS.includes(type)) {
return +value;
}

if (type === AptosArgTypes.Bool && value) {
return JSON.parse(value.toLowerCase());
}

if (
(type === AptosArgTypes.Array || type === AptosArgTypes.Object) &&
value
) {
try {
return JSON.parse(value);
} catch (error) {}
}

return value;
};

const formatSigningArgs = (args: Arg[] | undefined) => {
return args?.reduce((initial: { [key: string]: any }, currentValue: Arg) => {
if (currentValue.name) {
initial[currentValue.name] =
currentValue.type === AptosArgTypes.Number
? +currentValue.value
: currentValue.type === AptosArgTypes.Bool && currentValue.value
? JSON.parse(currentValue.value.toLowerCase())
: currentValue.value;
initial[currentValue.name] = formatArg(
currentValue.type,
currentValue.value
);
}
return initial;
}, {}) as AptosTypes.SignMessagePayload;
Expand All @@ -58,7 +79,7 @@ const AptosEditor = (): ReactJSXElement => {
const handleSignMessage = useCallback((args) => {
return new Promise<AptosTypes.SignMessageResponse>((resolve) => {
const aptos = ChainServices[Chains.Aptos]?.bloctoSDK?.aptos;
resolve(aptos.signMessage(formatTransactionArgs(args)));
resolve(aptos.signMessage(formatSigningArgs(args)));
});
}, []);

Expand All @@ -69,8 +90,24 @@ const AptosEditor = (): ReactJSXElement => {
method?: (...param: any[]) => Promise<any>
) => {
return new Promise<string>((resolve, reject) => {
method?.(contractInfo, args)
.then((hash) => resolve(hash))
const typeArgs = args
?.filter((arg: any) => arg.type === "type_arg")
.map((arg: any) => arg.value);
const normalArgs = args
?.filter((arg: any) => arg.type !== "type_arg")
.map((arg: any) => formatArg(arg.type, arg.value));

const { moduleName, method: moduleMethod } = contractInfo;
const funcName = `${moduleName.value}::${moduleMethod.value}`;
const transaction = {
arguments: normalArgs,
function: funcName,
type: "entry_function_payload",
type_arguments: typeArgs,
};

method?.(transaction)
.then(({ hash }) => resolve(hash))
.catch((error) => {
reject(error);
toast({
Expand All @@ -90,12 +127,43 @@ const AptosEditor = (): ReactJSXElement => {
script: string,
args?: Arg[],
method?: (...param: any[]) => Promise<any>,
scriptInfo?: Record<string, PerInfo>,
scriptInfo?: Record<"bytecode", PerInfo>,
scriptAbi?: Record<AptosScriptAbiKeys, PerScriptAbi>
) => {
return new Promise<string>((resolve, reject) => {
method?.(scriptInfo, args, scriptAbi)
.then((hash) => resolve(hash))
const typeArgs = args
?.filter((arg: any) => arg.type === "type_arg")
.map((arg: any) => arg.value);
const normalArgs = args
?.filter((arg: any) => arg.type !== "type_arg")
.map((arg: any) => formatArg(arg.type, arg.value));

if (!scriptInfo || !scriptAbi) {
return reject("scriptInfo or scriptAbi is undefined");
}

const { bytecode } = scriptInfo;
const abi = Object.keys(scriptAbi).reduce<Record<string, any>>(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
(initial, currentValue: AptosScriptAbiKeys) => {
initial[currentValue] = scriptAbi[currentValue].format
? scriptAbi[currentValue].format?.(scriptAbi[currentValue].value)
: scriptAbi[currentValue].value;
return initial;
},
{}
);

const transaction = {
type: "script_payload",
code: { bytecode: bytecode.value, abi },
type_arguments: typeArgs,
arguments: normalArgs,
};

method?.(transaction)
.then(({ hash }) => resolve(hash))
.catch((error) => {
reject(error);
toast({
Expand Down
99 changes: 77 additions & 22 deletions src/components/EvmChainSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,88 @@
import React, { useContext } from "react";
import { Button, Menu, MenuButton, MenuList, MenuItem } from "@chakra-ui/react";
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 { startCase } from "lodash";
import { ReactJSXElement } from "@emotion/react/types/jsx-namespace";
import { Context } from "../context/Context";
import { EvmChain } from "../types/ChainTypes";
import { supportedChains, bloctoSDK, useEthereum } from "../services/evm";

const supportedMainnetChains = supportedChains.filter(
({ environment }) => environment === "mainnet"
);
const supportedTestnetChains = supportedChains.filter(
({ environment }) => environment === "testnet"
);

const EvmChainSelect: React.FC = ({}): ReactJSXElement => {
const { chain, switchChain } = useContext(Context);
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="130px">
{startCase(chain)}
<MenuButton as={Button} rightIcon={<ChevronDownIcon />} width="200px">
{chainName}
</MenuButton>
<MenuList>
{Object.values(EvmChain).map((chain) => (
<MenuItem
key={chain}
pl={5}
color="gray.700"
onClick={() => {
if (switchChain) {
switchChain(chain);
}
}}
>
{startCase(chain)}
</MenuItem>
))}
<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>
);
Expand Down
Loading
Loading