-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Public tags: dedicated tag page (#2217)
* page layout * text with results number * fix ts * tests * add quotes to network id env value * fix null balance and result num * fix mobile layout
- Loading branch information
Showing
23 changed files
with
380 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { NextPage } from 'next'; | ||
import dynamic from 'next/dynamic'; | ||
import React from 'react'; | ||
|
||
import PageNextJs from 'nextjs/PageNextJs'; | ||
|
||
const AccountsLabelSearch = dynamic(() => import('ui/pages/AccountsLabelSearch'), { ssr: false }); | ||
|
||
const Page: NextPage = () => { | ||
return ( | ||
<PageNextJs pathname="/accounts/label/[slug]"> | ||
<AccountsLabelSearch/> | ||
</PageNextJs> | ||
); | ||
}; | ||
|
||
export default Page; | ||
|
||
export { accountsLabelSearch as getServerSideProps } from 'nextjs/getServerSideProps'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { HStack, Skeleton } from '@chakra-ui/react'; | ||
import BigNumber from 'bignumber.js'; | ||
import React from 'react'; | ||
|
||
import type { AddressesItem } from 'types/api/addresses'; | ||
|
||
import config from 'configs/app'; | ||
import { currencyUnits } from 'lib/units'; | ||
import AddressEntity from 'ui/shared/entities/address/AddressEntity'; | ||
import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile'; | ||
|
||
type Props = { | ||
item: AddressesItem; | ||
isLoading?: boolean; | ||
} | ||
|
||
const AddressesLabelSearchListItem = ({ | ||
item, | ||
isLoading, | ||
}: Props) => { | ||
|
||
const addressBalance = BigNumber(item.coin_balance || 0).div(BigNumber(10 ** config.chain.currency.decimals)); | ||
|
||
return ( | ||
<ListItemMobile rowGap={ 3 }> | ||
<AddressEntity | ||
address={ item } | ||
isLoading={ isLoading } | ||
fontWeight={ 700 } | ||
w="100%" | ||
/> | ||
<HStack spacing={ 3 } maxW="100%" alignItems="flex-start"> | ||
<Skeleton isLoaded={ !isLoading } fontSize="sm" fontWeight={ 500 } flexShrink={ 0 }>{ `Balance ${ currencyUnits.ether }` }</Skeleton> | ||
<Skeleton isLoaded={ !isLoading } fontSize="sm" color="text_secondary" minW="0" whiteSpace="pre-wrap"> | ||
<span>{ addressBalance.dp(8).toFormat() }</span> | ||
</Skeleton> | ||
</HStack> | ||
<HStack spacing={ 3 }> | ||
<Skeleton isLoaded={ !isLoading } fontSize="sm" fontWeight={ 500 }>Txn count</Skeleton> | ||
<Skeleton isLoaded={ !isLoading } fontSize="sm" color="text_secondary"> | ||
<span>{ Number(item.tx_count).toLocaleString() }</span> | ||
</Skeleton> | ||
</HStack> | ||
</ListItemMobile> | ||
); | ||
}; | ||
|
||
export default React.memo(AddressesLabelSearchListItem); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Table, Tbody, Tr, Th } from '@chakra-ui/react'; | ||
import React from 'react'; | ||
|
||
import type { AddressesItem } from 'types/api/addresses'; | ||
|
||
import { currencyUnits } from 'lib/units'; | ||
import { default as Thead } from 'ui/shared/TheadSticky'; | ||
|
||
import AddressesLabelSearchTableItem from './AddressesLabelSearchTableItem'; | ||
|
||
interface Props { | ||
items: Array<AddressesItem>; | ||
top: number; | ||
isLoading?: boolean; | ||
} | ||
|
||
const AddressesLabelSearchTable = ({ items, top, isLoading }: Props) => { | ||
return ( | ||
<Table variant="simple" size="sm"> | ||
<Thead top={ top }> | ||
<Tr> | ||
<Th width="70%">Address</Th> | ||
<Th width="15%" isNumeric>{ `Balance ${ currencyUnits.ether }` }</Th> | ||
<Th width="15%" isNumeric>Txn count</Th> | ||
</Tr> | ||
</Thead> | ||
<Tbody> | ||
{ items.map((item, index) => ( | ||
<AddressesLabelSearchTableItem | ||
key={ item.hash + (isLoading ? index : '') } | ||
item={ item } | ||
isLoading={ isLoading } | ||
/> | ||
)) } | ||
</Tbody> | ||
</Table> | ||
); | ||
}; | ||
|
||
export default AddressesLabelSearchTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Tr, Td, Text, Skeleton } from '@chakra-ui/react'; | ||
import BigNumber from 'bignumber.js'; | ||
import React from 'react'; | ||
|
||
import type { AddressesItem } from 'types/api/addresses'; | ||
|
||
import config from 'configs/app'; | ||
import AddressEntity from 'ui/shared/entities/address/AddressEntity'; | ||
|
||
type Props = { | ||
item: AddressesItem; | ||
isLoading?: boolean; | ||
} | ||
|
||
const AddressesLabelSearchTableItem = ({ | ||
item, | ||
isLoading, | ||
}: Props) => { | ||
|
||
const addressBalance = BigNumber(item.coin_balance || 0).div(BigNumber(10 ** config.chain.currency.decimals)); | ||
const addressBalanceChunks = addressBalance.dp(8).toFormat().split('.'); | ||
|
||
return ( | ||
<Tr> | ||
<Td> | ||
<AddressEntity | ||
address={ item } | ||
isLoading={ isLoading } | ||
fontWeight={ 700 } | ||
my="2px" | ||
/> | ||
</Td> | ||
<Td isNumeric> | ||
<Skeleton isLoaded={ !isLoading } display="inline-block" maxW="100%"> | ||
<Text lineHeight="24px" as="span">{ addressBalanceChunks[0] + (addressBalanceChunks[1] ? '.' : '') }</Text> | ||
<Text lineHeight="24px" variant="secondary" as="span">{ addressBalanceChunks[1] }</Text> | ||
</Skeleton> | ||
</Td> | ||
<Td isNumeric> | ||
<Skeleton isLoaded={ !isLoading } display="inline-block" lineHeight="24px"> | ||
{ Number(item.tx_count).toLocaleString() } | ||
</Skeleton> | ||
</Td> | ||
</Tr> | ||
); | ||
}; | ||
|
||
export default React.memo(AddressesLabelSearchTableItem); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from 'react'; | ||
|
||
import type { AddressesMetadataSearchResult } from 'types/api/addresses'; | ||
|
||
import * as addressMocks from 'mocks/address/address'; | ||
import { test, expect } from 'playwright/lib'; | ||
|
||
import AccountsLabelSearch from './AccountsLabelSearch'; | ||
|
||
const addresses: AddressesMetadataSearchResult = { | ||
items: [ | ||
{ | ||
...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: null, | ||
}, | ||
], | ||
next_page_params: null, | ||
}; | ||
|
||
const hooksConfig = { | ||
router: { | ||
query: { | ||
slug: 'euler-finance-exploit', | ||
tagType: 'generic', | ||
tagName: 'Euler finance exploit', | ||
}, | ||
}, | ||
}; | ||
|
||
test('base view +@mobile', async({ render, mockTextAd, mockApiResponse }) => { | ||
await mockTextAd(); | ||
await mockApiResponse( | ||
'addresses_metadata_search', | ||
addresses, | ||
{ | ||
queryParams: { | ||
slug: 'euler-finance-exploit', | ||
tag_type: 'generic', | ||
}, | ||
}, | ||
); | ||
const component = await render(<AccountsLabelSearch/>, { hooksConfig }); | ||
await expect(component).toHaveScreenshot(); | ||
}); |
Oops, something went wrong.