From ae0cea24988970d0bf9d9df6540a38c7d05c6f01 Mon Sep 17 00:00:00 2001 From: artemkolodko Date: Fri, 21 Oct 2022 11:51:06 +0100 Subject: [PATCH] Impeove proxy erc20 contracts support --- src/components/ERC20_Pool.tsx | 3 +- src/hooks/ERC20_Pool.ts | 4 ++- .../ContractDetails/AbiMethodView.tsx | 3 +- .../AddressPage/ContractDetails/index.tsx | 34 ++++++++----------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/components/ERC20_Pool.tsx b/src/components/ERC20_Pool.tsx index 8640f05..9c11b93 100644 --- a/src/components/ERC20_Pool.tsx +++ b/src/components/ERC20_Pool.tsx @@ -20,7 +20,8 @@ export function ERC20_Pool() { erc20 = erc20.map((item) => { erc20Map[item.address] = { ...item, - isBridged: isTokenBridged(item.address) + isBridged: isTokenBridged(item.address), + name: item.implementationAddress ? `${item.name} (Proxy)` : item.name }; return { [IndexedDbKeyPath]: item.address, diff --git a/src/hooks/ERC20_Pool.ts b/src/hooks/ERC20_Pool.ts index e47b0f0..3b2a8d6 100644 --- a/src/hooks/ERC20_Pool.ts +++ b/src/hooks/ERC20_Pool.ts @@ -17,7 +17,8 @@ export const useERC20Pool = singletonHook(initValue, () => { erc20.forEach(item => { erc20Map[item.address] = { ...item, - isBridged: isTokenBridged(item.address) + isBridged: isTokenBridged(item.address), + name: item.implementationAddress ? `${item.name} (Proxy)` : item.name }; }) setMode(erc20Map) @@ -55,6 +56,7 @@ export interface Erc20 { image?: string; }; isBridged: boolean; + implementationAddress: string } export type ERC20_Pool = Record; diff --git a/src/pages/AddressPage/ContractDetails/AbiMethodView.tsx b/src/pages/AddressPage/ContractDetails/AbiMethodView.tsx index 9ce0d5d..364076f 100644 --- a/src/pages/AddressPage/ContractDetails/AbiMethodView.tsx +++ b/src/pages/AddressPage/ContractDetails/AbiMethodView.tsx @@ -184,7 +184,7 @@ export const AbiMethodsView = (props: { const itemType = input.type.slice(0, input.type.indexOf('[]')); return ( - + {name} ({input.type}) @@ -296,6 +296,7 @@ export const AbiMethodsView = (props: { {abiMethod.outputs ? abiMethod.outputs.map((input, idx) => { return ( { - if (!!props.sourceCode) { + if (!!props.sourceCode || (props.implementation && props.implementationSourceCode)) { return ( abiMethod.name ? ( - {props.contracts.bytecode || ""} - + } /> @@ -248,7 +247,7 @@ const TabButton = (props: { }; export const VerifiedContractDetails = (props: { - sourceCode: ISourceCode; + sourceCode: ISourceCode | null; address: string; contracts?: AddressDetails | null; shard: number; @@ -269,7 +268,7 @@ export const VerifiedContractDetails = (props: { : (chainId === 1666700000 || chainId === 1666900000); try { - abiString = JSON.stringify(props.sourceCode.abi, null, 4); + abiString = JSON.stringify(props.sourceCode?.abi, null, 4); } catch { } return ( @@ -281,7 +280,7 @@ export const VerifiedContractDetails = (props: { onClick={() => setTab(V_TABS.CODE)} selected={tab === V_TABS.CODE} /> - {props.sourceCode.abi ? ( + {props.sourceCode?.abi ? ( <> - {tab === V_TABS.CODE ? ( + {tab === V_TABS.CODE && props.sourceCode ? ( @@ -357,8 +356,7 @@ export const VerifiedContractDetails = (props: { - + } />} {props.sourceCode.supporting?.sources @@ -368,9 +366,7 @@ export const VerifiedContractDetails = (props: { key={i} label={`Verified ${source.substring(source.lastIndexOf('/') + 1)}`} value={ - - - + } /> })} @@ -382,9 +378,7 @@ export const VerifiedContractDetails = (props: { key={i} label={`Verified ${source.substring(source.lastIndexOf('/') + 1)}`} value={ - - - + } /> })} @@ -421,7 +415,9 @@ export const VerifiedContractDetails = (props: { ) : null} - {tab === V_TABS.READ && props.sourceCode.abi ? ( + {tab === V_TABS.CODE && !props.sourceCode && props.contracts && } + + {tab === V_TABS.READ && props.sourceCode && props.sourceCode.abi ? ( ) : null} - {tab === V_TABS.WRITE && props.sourceCode.abi ? ( + {tab === V_TABS.WRITE && props.sourceCode && props.sourceCode.abi ? (