From b8d6ae23acd69f3f790ee1e1e01f9471b41d4c9c Mon Sep 17 00:00:00 2001 From: lukaw3d Date: Thu, 12 Sep 2024 08:14:50 +0200 Subject: [PATCH] fixup! Detect ERC-1167 Minimal Proxy contracts --- .../Account/RuntimeAccountDetailsView.tsx | 9 +++------ ...roxyERC1167.ts => extractMinimalProxyERC1167.ts} | 13 ++----------- .../pages/TokenDashboardPage/TokenDetailsCard.tsx | 9 +++------ 3 files changed, 8 insertions(+), 23 deletions(-) rename src/app/components/ContractVerificationIcon/{isMinimalProxyERC1167.ts => extractMinimalProxyERC1167.ts} (73%) diff --git a/src/app/components/Account/RuntimeAccountDetailsView.tsx b/src/app/components/Account/RuntimeAccountDetailsView.tsx index bff2cb7e29..3506a7bc3f 100644 --- a/src/app/components/Account/RuntimeAccountDetailsView.tsx +++ b/src/app/components/Account/RuntimeAccountDetailsView.tsx @@ -22,10 +22,7 @@ import { calculateFiatValue } from '../Balance/hooks' import { FiatMoneyAmount } from '../Balance/FiatMoneyAmount' import { getFiatCurrencyForScope, showFiatValues } from '../../../config' import { CardEmptyState } from '../CardEmptyState' -import { - extractMinimalProxyERC1167, - isMinimalProxyERC1167, -} from '../ContractVerificationIcon/isMinimalProxyERC1167' +import { extractMinimalProxyERC1167 } from '../ContractVerificationIcon/extractMinimalProxyERC1167' type RuntimeAccountDetailsViewProps = { isLoading?: boolean @@ -107,11 +104,11 @@ export const RuntimeAccountDetailsView: FC = ({ )} - {isMinimalProxyERC1167(account) && ( + {extractMinimalProxyERC1167(account) && ( <>
{t('contract.verification.proxyERC1167')}
- +
)} diff --git a/src/app/components/ContractVerificationIcon/isMinimalProxyERC1167.ts b/src/app/components/ContractVerificationIcon/extractMinimalProxyERC1167.ts similarity index 73% rename from src/app/components/ContractVerificationIcon/isMinimalProxyERC1167.ts rename to src/app/components/ContractVerificationIcon/extractMinimalProxyERC1167.ts index 38fbdb743e..99afe1ad5e 100644 --- a/src/app/components/ContractVerificationIcon/isMinimalProxyERC1167.ts +++ b/src/app/components/ContractVerificationIcon/extractMinimalProxyERC1167.ts @@ -3,17 +3,8 @@ import { base64ToHex } from '../../utils/helpers' import { toChecksumAddress } from '@ethereumjs/util' /** https://eips.ethereum.org/EIPS/eip-1167 */ -export function isMinimalProxyERC1167(account: RuntimeAccount) { - try { - extractMinimalProxyERC1167(account) - return true - } catch (e) { - return false - } -} - export function extractMinimalProxyERC1167(account: RuntimeAccount) { - if (!account?.evm_contract?.runtime_bytecode) throw new Error('Not ERC-1167') + if (!account?.evm_contract?.runtime_bytecode) return undefined const hexBytecode = base64ToHex(account.evm_contract.runtime_bytecode) @@ -28,5 +19,5 @@ export function extractMinimalProxyERC1167(account: RuntimeAccount) { )?.[1] if (proxyToAddress2) return toChecksumAddress(`0x00000000${proxyToAddress2}`) - throw new Error('Not ERC-1167') + return undefined } diff --git a/src/app/pages/TokenDashboardPage/TokenDetailsCard.tsx b/src/app/pages/TokenDashboardPage/TokenDetailsCard.tsx index 83343d0c8d..6cd0502430 100644 --- a/src/app/pages/TokenDashboardPage/TokenDetailsCard.tsx +++ b/src/app/pages/TokenDashboardPage/TokenDetailsCard.tsx @@ -21,10 +21,7 @@ import { tokenHoldersContainerId } from '../../pages/TokenDashboardPage/TokenHol import { RoundedBalance } from 'app/components/RoundedBalance' import { HighlightedText } from '../../components/HighlightedText' import { RuntimeBalanceDisplay } from '../../components/Balance/RuntimeBalanceDisplay' -import { - extractMinimalProxyERC1167, - isMinimalProxyERC1167, -} from '../../components/ContractVerificationIcon/isMinimalProxyERC1167' +import { extractMinimalProxyERC1167 } from '../../components/ContractVerificationIcon/extractMinimalProxyERC1167' export const TokenDetailsCard: FC<{ scope: SearchScope; address: string; searchTerm: string }> = ({ scope, @@ -70,11 +67,11 @@ export const TokenDetailsCard: FC<{ scope: SearchScope; address: string; searchT /> - {isMinimalProxyERC1167(account) && ( + {extractMinimalProxyERC1167(account) && ( <>
{t('contract.verification.proxyERC1167')}
- +
)}