Skip to content

Commit

Permalink
Extend named accounts with ERC-20 and ERC-721 tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
buberdds committed Nov 12, 2024
1 parent d773412 commit 7776616
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions .changelog/1632.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Extend named accounts with ERC-20 and ERC-721 tokens
12 changes: 7 additions & 5 deletions src/app/components/Account/AccountLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const WithTypographyAndLink: FC<{
}

interface Props {
addressAsName?: boolean
scope: SearchScope
address: string

Expand Down Expand Up @@ -79,6 +80,7 @@ interface Props {
}

export const AccountLink: FC<Props> = ({
addressAsName,
scope,
address,
alwaysTrim,
Expand All @@ -93,7 +95,7 @@ export const AccountLink: FC<Props> = ({
// isError, // Use this to indicate that we have failed to load the name for this account
} = useAccountMetadata(scope, address)
const accountName = accountMetadata?.name // TODO: we should also use the description

const showAccountName = !addressAsName && accountName
const to = RouteUtils.getAccountRoute(scope, address)

const extraTooltipWithIcon = extraTooltip ? (
Expand All @@ -119,13 +121,13 @@ export const AccountLink: FC<Props> = ({
<MaybeWithTooltip
title={
<div>
{accountName && <Box sx={{ fontWeight: 'bold' }}>{accountName}</Box>}
{showAccountName && <Box sx={{ fontWeight: 'bold' }}>{accountName}</Box>}
<Box sx={{ fontWeight: 'normal' }}>{address}</Box>
{extraTooltipWithIcon}
</div>
}
>
{accountName ? trimLongString(accountName, 12, 0) : trimLongString(address, 6, 6)}
{showAccountName ? trimLongString(accountName, 12, 0) : trimLongString(address, 6, 6)}
</MaybeWithTooltip>
</WithTypographyAndLink>
)
Expand All @@ -138,7 +140,7 @@ export const AccountLink: FC<Props> = ({
return (
<WithTypographyAndLink to={to} labelOnly={labelOnly}>
<MaybeWithTooltip title={extraTooltipWithIcon}>
{accountName ? (
{showAccountName ? (
<span>
<HighlightedText text={accountName} pattern={highlightedPartOfName} /> ({address})
</span>
Expand All @@ -157,7 +159,7 @@ export const AccountLink: FC<Props> = ({
<WithTypographyAndLink to={to} mobile labelOnly={labelOnly}>
<>
<AdaptiveHighlightedText
text={accountName}
text={showAccountName ? accountName : ''}
pattern={highlightedPartOfName}
extraTooltip={extraTooltip}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/Tokens/TokenDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const TokenDetails: FC<{
<dt>{t(isMobile ? 'common.smartContract_short' : 'common.smartContract')}</dt>
<dd>
<span>
<AccountLink scope={token} address={token.eth_contract_addr ?? token.contract_addr} />
<AccountLink addressAsName scope={token} address={token.eth_contract_addr ?? token.contract_addr} />
<CopyToClipboard value={token.eth_contract_addr ?? token.contract_addr} />
</span>
</dd>
Expand Down
1 change: 1 addition & 0 deletions src/app/components/Tokens/TokenList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const TokenList = (props: TokensProps) => {
content: (
<span>
<AccountLink
addressAsName
scope={token}
address={token.eth_contract_addr ?? token.contract_addr}
alwaysTrim
Expand Down
12 changes: 6 additions & 6 deletions src/app/data/oasis-account-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ import { hasTextMatch } from '../components/HighlightedText/text-matching'
const dataSources: Record<Network, Partial<Record<Layer, string>>> = {
[Network.mainnet]: {
[Layer.consensus]:
'https://raw.githubusercontent.com/oasisprotocol/nexus/main/named-addresses/mainnet_consensus.json',
'https://raw.githubusercontent.com/buberdds/nexus/main/named-addresses/mainnet_consensus.json',
[Layer.emerald]:
'https://raw.githubusercontent.com/oasisprotocol/nexus/main/named-addresses/mainnet_emerald.json',
'https://raw.githubusercontent.com/buberdds/nexus/main/named-addresses/mainnet_emerald.json',
[Layer.sapphire]:
'https://raw.githubusercontent.com/oasisprotocol/nexus/main/named-addresses/mainnet_sapphire.json',
'https://raw.githubusercontent.com/buberdds/nexus/main/named-addresses/mainnet_sapphire.json',
},
[Network.testnet]: {
[Layer.consensus]:
'https://raw.githubusercontent.com/oasisprotocol/nexus/main/named-addresses/testnet_consensus.json',
'https://raw.githubusercontent.com/buberdds/nexus/main/named-addresses/testnet_consensus.json',
[Layer.emerald]:
'https://raw.githubusercontent.com/oasisprotocol/nexus/main/named-addresses/testnet_emerald.json',
'https://raw.githubusercontent.com/buberdds/nexus/main/named-addresses/testnet_emerald.json',
[Layer.sapphire]:
'https://raw.githubusercontent.com/oasisprotocol/nexus/main/named-addresses/testnet_sapphire.json',
'https://raw.githubusercontent.com/buberdds/nexus/main/named-addresses/testnet_sapphire.json',
},
[Network.localnet]: {
[Layer.consensus]: undefined,
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/TokenDashboardPage/TokenDetailsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const TokenDetailsCard: FC<{ scope: SearchScope; address: string; searchT
)}
<dt>{t(isMobile ? 'common.smartContract_short' : 'common.smartContract')}</dt>
<dd>
<AccountLink scope={account} address={account.address_eth || account.address} />
<AccountLink addressAsName scope={account} address={account.address_eth || account.address} />
<CopyToClipboard value={account.address_eth || account.address} />
</dd>

Expand Down

0 comments on commit 7776616

Please sign in to comment.