Skip to content

Commit

Permalink
Top accounts: show public tag next to address (#2163)
Browse files Browse the repository at this point in the history
* Public tags: remove references to old tags from the code

Fixes #1894

* show name tag of proxy contracts in list views
  • Loading branch information
tom2drum authored Aug 21, 2024
1 parent f58a3e9 commit 9cf6ce9
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 18 deletions.
3 changes: 1 addition & 2 deletions ui/addresses/AddressesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ const AddressesTable = ({ items, totalSupply, pageStartIndex, top, isLoading }:
<Thead top={ top }>
<Tr>
<Th width="64px">Rank</Th>
<Th width={ hasPercentage ? '30%' : '40%' }>Address</Th>
<Th width="20%" pl={ 10 }>Public tag</Th>
<Th width={ hasPercentage ? '50%' : '60%' }>Address</Th>
<Th width={ hasPercentage ? '20%' : '25%' } isNumeric>{ `Balance ${ currencyUnits.ether }` }</Th>
{ hasPercentage && <Th width="15%" isNumeric>Percentage</Th> }
<Th width="15%" isNumeric>Txn count</Th>
Expand Down
24 changes: 12 additions & 12 deletions ui/addresses/AddressesTableItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Tr, Td, Text, Skeleton } from '@chakra-ui/react';
import { Tr, Td, Text, Skeleton, Flex } from '@chakra-ui/react';
import BigNumber from 'bignumber.js';
import React from 'react';

Expand Down Expand Up @@ -35,17 +35,17 @@ const AddressesTableItem = ({
</Skeleton>
</Td>
<Td>
<AddressEntity
address={ item }
isLoading={ isLoading }
fontWeight={ 700 }
my="2px"
/>
</Td>
<Td pl={ 10 }>
{ item.public_tags && item.public_tags.length ? item.public_tags.map(tag => (
<Tag key={ tag.label } isLoading={ isLoading } isTruncated>{ tag.display_name }</Tag>
)) : null }
<Flex alignItems="center" columnGap={ 2 }>
<AddressEntity
address={ item }
isLoading={ isLoading }
fontWeight={ 700 }
my="2px"
/>
{ item.public_tags && item.public_tags.length ? item.public_tags.map(tag => (
<Tag key={ tag.label } isLoading={ isLoading } isTruncated>{ tag.display_name }</Tag>
)) : null }
</Flex>
</Td>
<Td isNumeric>
<Skeleton isLoaded={ !isLoading } display="inline-block" maxW="100%">
Expand Down
11 changes: 9 additions & 2 deletions ui/pages/Accounts.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,23 @@ const addresses: AddressesResponse = {
...addressMocks.withName,
tx_count: '1',
coin_balance: '12345678901234567890000',
}, {
},
{
...addressMocks.token,
tx_count: '109123890123',
coin_balance: '22222345678901234567890000',
ens_domain_name: null,
}, {
},
{
...addressMocks.withoutName,
tx_count: '11',
coin_balance: '1000000000000000000',
},
{
...addressMocks.eoa,
tx_count: '420',
coin_balance: '123456',
},
],
total_supply: '25222000',
next_page_params: null,
Expand Down
1 change: 1 addition & 0 deletions ui/pages/Address.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ const AddressPageContent = () => {

const tags: Array<EntityTag> = React.useMemo(() => {
return [
...(addressQuery.data?.public_tags?.map((tag) => ({ slug: tag.label, name: tag.display_name, tagType: 'custom' as const, ordinal: -1 })) || []),
!addressQuery.data?.is_contract ? { slug: 'eoa', name: 'EOA', tagType: 'custom' as const, ordinal: -1 } : undefined,
config.features.validators.isEnabled && addressQuery.data?.has_validated_blocks ?
{ slug: 'validator', name: 'Validator', tagType: 'custom' as const, ordinal: 10 } :
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions ui/shared/entities/address/AddressEntity.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from 'react';
import { AddressHighlightProvider } from 'lib/contexts/addressHighlight';
import * as addressMock from 'mocks/address/address';
import * as implementationsMock from 'mocks/address/implementations';
import * as metadataMock from 'mocks/metadata/address';
import { test, expect } from 'playwright/lib';

import AddressEntity from './AddressEntity';
Expand Down Expand Up @@ -100,6 +101,18 @@ test.describe('proxy contract', () => {
await expect(page.getByText('Proxy contract')).toBeVisible();
await expect(page).toHaveScreenshot();
});

test('with name tag', async({ render, page }) => {
const component = await render(
<AddressEntity
address={{ ...addressMock.contract, metadata: { reputation: 1, tags: [ metadataMock.nameTag ] } }}
/>,
);

await component.getByText(/quack/i).hover();
await expect(page.getByText('Proxy contract')).toBeVisible();
await expect(page).toHaveScreenshot();
});
});

test.describe('loading', () => {
Expand Down
6 changes: 4 additions & 2 deletions ui/shared/entities/address/AddressEntityContentProxy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const AddressEntityContentProxy = (props: ContentProps) => {
}

const colNum = Math.min(implementations.length, 3);
const nameTag = props.address.metadata?.tags.find(tag => tag.tagType === 'name')?.name;

const implementationName = implementations.length === 1 && implementations[0].name ? implementations[0].name : undefined;

return (
Expand All @@ -29,8 +31,8 @@ const AddressEntityContentProxy = (props: ContentProps) => {
<Box display="inline-flex" w="100%">
<EntityBase.Content
{ ...props }
truncation={ implementationName || props.address.name ? 'tail' : props.truncation }
text={ implementationName || props.address.name || props.address.hash }
truncation={ nameTag || implementationName || props.address.name ? 'tail' : props.truncation }
text={ nameTag || implementationName || props.address.name || props.address.hash }
/>
</Box>
</PopoverTrigger>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9cf6ce9

Please sign in to comment.