From 7707460d321cc33adf5fe51275f28e9524c69b38 Mon Sep 17 00:00:00 2001 From: lukaw3d Date: Thu, 12 Sep 2024 15:28:58 +0200 Subject: [PATCH 1/2] Extract AbiPlaygroundLink into a component --- .../AbiPlaygroundLink.tsx | 45 +++++++++++++++++++ .../ContractVerificationIcon/index.tsx | 33 +------------- 2 files changed, 47 insertions(+), 31 deletions(-) create mode 100644 src/app/components/ContractVerificationIcon/AbiPlaygroundLink.tsx diff --git a/src/app/components/ContractVerificationIcon/AbiPlaygroundLink.tsx b/src/app/components/ContractVerificationIcon/AbiPlaygroundLink.tsx new file mode 100644 index 000000000..4e9083e9b --- /dev/null +++ b/src/app/components/ContractVerificationIcon/AbiPlaygroundLink.tsx @@ -0,0 +1,45 @@ +import { FC } from 'react' +import { Trans, useTranslation } from 'react-i18next' +import Link from '@mui/material/Link' +import { Layer } from '../../../oasis-nexus/api' +import { SearchScope } from '../../../types/searchScope' +import { Network } from '../../../types/network' +import * as externalLinks from '../../utils/externalLinks' + +export const AbiPlaygroundLink: FC<{ + address_eth: string + scope: SearchScope +}> = ({ address_eth, scope }) => { + const { t } = useTranslation() + + const scopeToPlaygroundURL: Record>> = { + [Network.mainnet]: { + [Layer.emerald]: `${externalLinks.dapps.abiPlayground}?network=42262&contractAddress=${address_eth}`, + [Layer.sapphire]: `${externalLinks.dapps.abiPlayground}?network=23294&contractAddress=${address_eth}`, + }, + [Network.testnet]: { + [Layer.emerald]: `${externalLinks.dapps.abiPlayground}?network=42261&contractAddress=${address_eth}`, + [Layer.sapphire]: `${externalLinks.dapps.abiPlayground}?network=23295&contractAddress=${address_eth}`, + }, + } + const abiPlaygroundLinkProps = { + href: scopeToPlaygroundURL[scope.network]?.[scope.layer], + rel: 'noopener noreferrer', + target: '_blank', + sx: { fontWeight: 400, color: 'inherit', textDecoration: 'underline' }, + } + + if (!abiPlaygroundLinkProps.href) return null + return ( + + {' | '} + , + }} + /> + + ) +} diff --git a/src/app/components/ContractVerificationIcon/index.tsx b/src/app/components/ContractVerificationIcon/index.tsx index 28404d2fc..5497cd903 100644 --- a/src/app/components/ContractVerificationIcon/index.tsx +++ b/src/app/components/ContractVerificationIcon/index.tsx @@ -7,10 +7,9 @@ import { styled } from '@mui/material/styles' import { COLORS } from '../../../styles/theme/colors' import Link from '@mui/material/Link' import Typography from '@mui/material/Typography' -import { Layer } from '../../../oasis-nexus/api' import { SearchScope } from '../../../types/searchScope' -import { Network } from '../../../types/network' import * as externalLinks from '../../utils/externalLinks' +import { AbiPlaygroundLink } from './AbiPlaygroundLink' type VerificationStatus = 'verified' | 'unverified' @@ -77,23 +76,6 @@ export const VerificationIcon: FC<{ const Component = noLink ? Box : Link const componentProps = noLink ? {} : sourcifyLinkProps - const scopeToPlaygroundURL: Record>> = { - [Network.mainnet]: { - [Layer.emerald]: `${externalLinks.dapps.abiPlayground}?network=42262&contractAddress=${address_eth}`, - [Layer.sapphire]: `${externalLinks.dapps.abiPlayground}?network=23294&contractAddress=${address_eth}`, - }, - [Network.testnet]: { - [Layer.emerald]: `${externalLinks.dapps.abiPlayground}?network=42261&contractAddress=${address_eth}`, - [Layer.sapphire]: `${externalLinks.dapps.abiPlayground}?network=23295&contractAddress=${address_eth}`, - }, - } - const abiPlaygroundLinkProps = { - href: scopeToPlaygroundURL[scope.network]?.[scope.layer], - rel: 'noopener noreferrer', - target: '_blank', - sx: { fontWeight: 400, color: 'inherit', textDecoration: 'underline' }, - } - return ( <> @@ -112,18 +94,7 @@ export const VerificationIcon: FC<{ SourcifyLink: , }} /> - {abiPlaygroundLinkProps.href && ( - - {' | '} - , - }} - /> - - )} + ) : ( From 07c18a6931091a0197a8256d0b7629a701dd2caf Mon Sep 17 00:00:00 2001 From: lukaw3d Date: Thu, 12 Sep 2024 15:29:52 +0200 Subject: [PATCH 2/2] Link to abi-playground from ERC-1167 Minimal Proxy contracts Related to e14c0ff81fa5cb3086d4b6e1fdb565b721b1f0ad --- .changelog/1540.feature.md | 1 + src/app/components/Account/RuntimeAccountDetailsView.tsx | 7 ++++++- src/app/pages/TokenDashboardPage/TokenDetailsCard.tsx | 7 ++++++- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .changelog/1540.feature.md diff --git a/.changelog/1540.feature.md b/.changelog/1540.feature.md new file mode 100644 index 000000000..1ed1c8978 --- /dev/null +++ b/.changelog/1540.feature.md @@ -0,0 +1 @@ +Detect ERC-1167 Minimal Proxy contracts diff --git a/src/app/components/Account/RuntimeAccountDetailsView.tsx b/src/app/components/Account/RuntimeAccountDetailsView.tsx index 3506a7bc3..e9b850c27 100644 --- a/src/app/components/Account/RuntimeAccountDetailsView.tsx +++ b/src/app/components/Account/RuntimeAccountDetailsView.tsx @@ -23,6 +23,8 @@ import { FiatMoneyAmount } from '../Balance/FiatMoneyAmount' import { getFiatCurrencyForScope, showFiatValues } from '../../../config' import { CardEmptyState } from '../CardEmptyState' import { extractMinimalProxyERC1167 } from '../ContractVerificationIcon/extractMinimalProxyERC1167' +import { AbiPlaygroundLink } from '../ContractVerificationIcon/AbiPlaygroundLink' +import Box from '@mui/material/Box' type RuntimeAccountDetailsViewProps = { isLoading?: boolean @@ -108,7 +110,10 @@ export const RuntimeAccountDetailsView: FC = ({ <>
{t('contract.verification.proxyERC1167')}
- + + + +
)} diff --git a/src/app/pages/TokenDashboardPage/TokenDetailsCard.tsx b/src/app/pages/TokenDashboardPage/TokenDetailsCard.tsx index 6cd050243..fcb2b9443 100644 --- a/src/app/pages/TokenDashboardPage/TokenDetailsCard.tsx +++ b/src/app/pages/TokenDashboardPage/TokenDetailsCard.tsx @@ -22,6 +22,8 @@ import { RoundedBalance } from 'app/components/RoundedBalance' import { HighlightedText } from '../../components/HighlightedText' import { RuntimeBalanceDisplay } from '../../components/Balance/RuntimeBalanceDisplay' import { extractMinimalProxyERC1167 } from '../../components/ContractVerificationIcon/extractMinimalProxyERC1167' +import { AbiPlaygroundLink } from '../../components/ContractVerificationIcon/AbiPlaygroundLink' +import Box from '@mui/material/Box' export const TokenDetailsCard: FC<{ scope: SearchScope; address: string; searchTerm: string }> = ({ scope, @@ -71,7 +73,10 @@ export const TokenDetailsCard: FC<{ scope: SearchScope; address: string; searchT <>
{t('contract.verification.proxyERC1167')}
- + + + +
)}