Commit 359ce166 authored by tom's avatar tom

token transfers page

parent 695a0322
...@@ -4,12 +4,12 @@ import React from 'react'; ...@@ -4,12 +4,12 @@ import React from 'react';
import PageNextJs from 'nextjs/PageNextJs'; import PageNextJs from 'nextjs/PageNextJs';
// const TokenTransfers = dynamic(() => import('ui/pages/TokenTransfers'), { ssr: false }); const TokenTransfers = dynamic(() => import('ui/pages/TokenTransfers'), { ssr: false });
const Page: NextPage = () => { const Page: NextPage = () => {
return ( return (
<PageNextJs pathname="/token-transfers"> <PageNextJs pathname="/token-transfers">
{ /* <TokenTransfers/> */ } <TokenTransfers/>
</PageNextJs> </PageNextJs>
); );
}; };
......
import { Show, Hide } from '@chakra-ui/react'; import { Box } from '@chakra-ui/react';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import React from 'react'; import React from 'react';
...@@ -15,6 +15,7 @@ import useQueryWithPages from 'ui/shared/pagination/useQueryWithPages'; ...@@ -15,6 +15,7 @@ import useQueryWithPages from 'ui/shared/pagination/useQueryWithPages';
import { getTokenFilterValue } from 'ui/tokens/utils'; import { getTokenFilterValue } from 'ui/tokens/utils';
import TokenTransfersListItem from 'ui/tokenTransfers/TokenTransfersListItem'; import TokenTransfersListItem from 'ui/tokenTransfers/TokenTransfersListItem';
import TokenTransfersTable from 'ui/tokenTransfers/TokenTransfersTable'; import TokenTransfersTable from 'ui/tokenTransfers/TokenTransfersTable';
const TokenTransfers = () => { const TokenTransfers = () => {
const router = useRouter(); const router = useRouter();
const [ typeFilter, setTypeFilter ] = React.useState<Array<TokenType>>(getTokenFilterValue(router.query.type) || []); const [ typeFilter, setTypeFilter ] = React.useState<Array<TokenType>>(getTokenFilterValue(router.query.type) || []);
...@@ -34,7 +35,7 @@ const TokenTransfers = () => { ...@@ -34,7 +35,7 @@ const TokenTransfers = () => {
const content = ( const content = (
<> <>
<Show below="lg" ssr={ false }> <Box hideFrom="lg">
{ tokenTransfersQuery.data?.items.map((item, index) => ( { tokenTransfersQuery.data?.items.map((item, index) => (
<TokenTransfersListItem <TokenTransfersListItem
key={ item.transaction_hash + item.log_index + (tokenTransfersQuery.isPlaceholderData ? index : '') } key={ item.transaction_hash + item.log_index + (tokenTransfersQuery.isPlaceholderData ? index : '') }
...@@ -42,14 +43,14 @@ const TokenTransfers = () => { ...@@ -42,14 +43,14 @@ const TokenTransfers = () => {
item={ item } item={ item }
/> />
)) } )) }
</Show> </Box>
<Hide below="lg" ssr={ false }> <Box hideBelow="lg">
<TokenTransfersTable <TokenTransfersTable
items={ tokenTransfersQuery.data?.items } items={ tokenTransfersQuery.data?.items }
top={ tokenTransfersQuery.pagination.isVisible ? ACTION_BAR_HEIGHT_DESKTOP : 0 } top={ tokenTransfersQuery.pagination.isVisible ? ACTION_BAR_HEIGHT_DESKTOP : 0 }
isLoading={ tokenTransfersQuery.isPlaceholderData } isLoading={ tokenTransfersQuery.isPlaceholderData }
/> />
</Hide> </Box>
</> </>
); );
...@@ -74,11 +75,12 @@ const TokenTransfers = () => { ...@@ -74,11 +75,12 @@ const TokenTransfers = () => {
/> />
<DataListDisplay <DataListDisplay
isError={ tokenTransfersQuery.isError } isError={ tokenTransfersQuery.isError }
items={ tokenTransfersQuery.data?.items } itemsNum={ tokenTransfersQuery.data?.items.length }
emptyText="There are no token transfers." emptyText="There are no token transfers."
content={ content }
actionBar={ actionBar } actionBar={ actionBar }
/> >
{ content }
</DataListDisplay>
</> </>
); );
}; };
......
...@@ -90,7 +90,7 @@ const Icon = (props: IconProps) => { ...@@ -90,7 +90,7 @@ const Icon = (props: IconProps) => {
})(); })();
return ( return (
<Tooltip label={ label }> <Tooltip content={ label }>
<Flex marginRight={ styles.marginRight } position="relative"> <Flex marginRight={ styles.marginRight } position="relative">
<AddressIdenticon <AddressIdenticon
size={ props.size === 'lg' ? 30 : 20 } size={ props.size === 'lg' ? 30 : 20 }
......
...@@ -58,12 +58,12 @@ export interface EntityProps extends EntityBase.EntityBaseProps { ...@@ -58,12 +58,12 @@ export interface EntityProps extends EntityBase.EntityBaseProps {
const NftEntity = (props: EntityProps) => { const NftEntity = (props: EntityProps) => {
const partsProps = distributeEntityProps(props); const partsProps = distributeEntityProps(props);
const content = <Content { ...partsProps.content }/>;
return ( return (
<Container w="100%" { ...partsProps.container }> <Container w="100%" { ...partsProps.container }>
<Icon { ...partsProps.icon }/> <Icon { ...partsProps.icon }/>
<Link { ...partsProps.link }> { props.noLink ? content : <Link { ...partsProps.link }>{ content }</Link> }
<Content { ...partsProps.content }/>
</Link>
</Container> </Container>
); );
}; };
......
...@@ -5,8 +5,8 @@ import type { TokenTransfer } from 'types/api/tokenTransfer'; ...@@ -5,8 +5,8 @@ import type { TokenTransfer } from 'types/api/tokenTransfer';
import getCurrencyValue from 'lib/getCurrencyValue'; import getCurrencyValue from 'lib/getCurrencyValue';
import { NFT_TOKEN_TYPE_IDS } from 'lib/token/tokenTypes'; import { NFT_TOKEN_TYPE_IDS } from 'lib/token/tokenTypes';
import Skeleton from 'ui/shared/chakra/Skeleton'; import { Badge } from 'toolkit/chakra/badge';
import Tag from 'ui/shared/chakra/Tag'; import { Skeleton } from 'toolkit/chakra/skeleton';
import AddressEntity from 'ui/shared/entities/address/AddressEntity'; import AddressEntity from 'ui/shared/entities/address/AddressEntity';
import BlockEntity from 'ui/shared/entities/block/BlockEntity'; import BlockEntity from 'ui/shared/entities/block/BlockEntity';
import NftEntity from 'ui/shared/entities/nft/NftEntity'; import NftEntity from 'ui/shared/entities/nft/NftEntity';
...@@ -49,7 +49,7 @@ const TokenTransfersListItem = ({ item, isLoading }: Props) => { ...@@ -49,7 +49,7 @@ const TokenTransfersListItem = ({ item, isLoading }: Props) => {
{ item.method && ( { item.method && (
<> <>
<ListItemMobileGrid.Label isLoading={ isLoading }>Method</ListItemMobileGrid.Label><ListItemMobileGrid.Value> <ListItemMobileGrid.Label isLoading={ isLoading }>Method</ListItemMobileGrid.Label><ListItemMobileGrid.Value>
<Tag isLoading={ isLoading }>{ item.method }</Tag> <Badge loading={ isLoading }>{ item.method }</Badge>
</ListItemMobileGrid.Value> </ListItemMobileGrid.Value>
</> </>
) } ) }
...@@ -88,7 +88,7 @@ const TokenTransfersListItem = ({ item, isLoading }: Props) => { ...@@ -88,7 +88,7 @@ const TokenTransfersListItem = ({ item, isLoading }: Props) => {
<ListItemMobileGrid.Label isLoading={ isLoading }>Amount</ListItemMobileGrid.Label> <ListItemMobileGrid.Label isLoading={ isLoading }>Amount</ListItemMobileGrid.Label>
<ListItemMobileGrid.Value> <ListItemMobileGrid.Value>
<Flex gap={ 2 } overflow="hidden"> <Flex gap={ 2 } overflow="hidden">
<Skeleton isLoaded={ !isLoading } wordBreak="break-all"> <Skeleton loading={ isLoading } wordBreak="break-all">
{ valueStr } { valueStr }
</Skeleton> </Skeleton>
<TokenEntity <TokenEntity
......
import { Table, Tbody, Tr, Th } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import type { TokenTransfer } from 'types/api/tokenTransfer'; import type { TokenTransfer } from 'types/api/tokenTransfer';
import { AddressHighlightProvider } from 'lib/contexts/addressHighlight'; import { AddressHighlightProvider } from 'lib/contexts/addressHighlight';
import { default as Thead } from 'ui/shared/TheadSticky'; import { TableBody, TableColumnHeader, TableHeaderSticky, TableRoot, TableRow } from 'toolkit/chakra/table';
import TokenTransferTableItem from 'ui/tokenTransfers/TokenTransfersTableItem'; import TokenTransferTableItem from 'ui/tokenTransfers/TokenTransfersTableItem';
interface Props { interface Props {
...@@ -16,18 +15,18 @@ interface Props { ...@@ -16,18 +15,18 @@ interface Props {
const TokenTransferTable = ({ items, top, isLoading }: Props) => { const TokenTransferTable = ({ items, top, isLoading }: Props) => {
return ( return (
<AddressHighlightProvider> <AddressHighlightProvider>
<Table variant="simple" size="sm" minW="950px" style={{ tableLayout: 'auto' }}> <TableRoot minW="950px" tableLayout="auto">
<Thead top={ top }> <TableHeaderSticky top={ top }>
<Tr> <TableRow>
<Th>Txn hash</Th> <TableColumnHeader>Txn hash</TableColumnHeader>
<Th>Method</Th> <TableColumnHeader>Method</TableColumnHeader>
<Th>Block</Th> <TableColumnHeader>Block</TableColumnHeader>
<Th>From/To</Th> <TableColumnHeader>From/To</TableColumnHeader>
<Th>Token ID</Th> <TableColumnHeader>Token ID</TableColumnHeader>
<Th isNumeric>Amount</Th> <TableColumnHeader isNumeric>Amount</TableColumnHeader>
</Tr> </TableRow>
</Thead> </TableHeaderSticky>
<Tbody> <TableBody>
{ items?.map((item, index) => ( { items?.map((item, index) => (
<TokenTransferTableItem <TokenTransferTableItem
key={ item.transaction_hash + item.log_index + (isLoading ? index : '') } key={ item.transaction_hash + item.log_index + (isLoading ? index : '') }
...@@ -35,8 +34,8 @@ const TokenTransferTable = ({ items, top, isLoading }: Props) => { ...@@ -35,8 +34,8 @@ const TokenTransferTable = ({ items, top, isLoading }: Props) => {
isLoading={ isLoading } isLoading={ isLoading }
/> />
)) } )) }
</Tbody> </TableBody>
</Table> </TableRoot>
</AddressHighlightProvider> </AddressHighlightProvider>
); );
}; };
......
import { Tr, Td, Flex } from '@chakra-ui/react'; import { Flex } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import type { TokenTransfer } from 'types/api/tokenTransfer'; import type { TokenTransfer } from 'types/api/tokenTransfer';
import getCurrencyValue from 'lib/getCurrencyValue'; import getCurrencyValue from 'lib/getCurrencyValue';
import { NFT_TOKEN_TYPE_IDS } from 'lib/token/tokenTypes'; import { NFT_TOKEN_TYPE_IDS } from 'lib/token/tokenTypes';
import { Badge } from 'toolkit/chakra/badge';
import { Skeleton } from 'toolkit/chakra/skeleton';
import { TableCell, TableRow } from 'toolkit/chakra/table';
import AddressFromTo from 'ui/shared/address/AddressFromTo'; import AddressFromTo from 'ui/shared/address/AddressFromTo';
import Skeleton from 'ui/shared/chakra/Skeleton';
import Tag from 'ui/shared/chakra/Tag';
import BlockEntity from 'ui/shared/entities/block/BlockEntity'; import BlockEntity from 'ui/shared/entities/block/BlockEntity';
import NftEntity from 'ui/shared/entities/nft/NftEntity'; import NftEntity from 'ui/shared/entities/nft/NftEntity';
import TokenEntity from 'ui/shared/entities/token/TokenEntity'; import TokenEntity from 'ui/shared/entities/token/TokenEntity';
...@@ -29,8 +30,8 @@ const TokenTransferTableItem = ({ item, isLoading }: Props) => { ...@@ -29,8 +30,8 @@ const TokenTransferTableItem = ({ item, isLoading }: Props) => {
}) : { valueStr: null }; }) : { valueStr: null };
return ( return (
<Tr> <TableRow>
<Td> <TableCell>
<TxEntity <TxEntity
hash={ item.transaction_hash } hash={ item.transaction_hash }
isLoading={ isLoading } isLoading={ isLoading }
...@@ -46,14 +47,14 @@ const TokenTransferTableItem = ({ item, isLoading }: Props) => { ...@@ -46,14 +47,14 @@ const TokenTransferTableItem = ({ item, isLoading }: Props) => {
fontWeight="400" fontWeight="400"
display="inline-block" display="inline-block"
/> />
</Td> </TableCell>
<Td maxW="120px"> <TableCell maxW="120px">
{ item.method && <Tag isLoading={ isLoading }>{ item.method }</Tag> } { item.method && <Badge loading={ isLoading }>{ item.method }</Badge> }
</Td> </TableCell>
<Td> <TableCell>
<BlockEntity number={ item.block_number } isLoading={ isLoading } noIcon/> <BlockEntity number={ item.block_number } isLoading={ isLoading } noIcon/>
</Td> </TableCell>
<Td> <TableCell>
<AddressFromTo <AddressFromTo
maxW={{ lg: '220px', xl: '320px' }} maxW={{ lg: '220px', xl: '320px' }}
from={ item.from } from={ item.from }
...@@ -61,8 +62,8 @@ const TokenTransferTableItem = ({ item, isLoading }: Props) => { ...@@ -61,8 +62,8 @@ const TokenTransferTableItem = ({ item, isLoading }: Props) => {
isLoading={ isLoading } isLoading={ isLoading }
mode={{ lg: 'compact', xl: 'long' }} mode={{ lg: 'compact', xl: 'long' }}
/> />
</Td> </TableCell>
<Td> <TableCell>
{ item.total && 'token_id' in item.total && item.token && (NFT_TOKEN_TYPE_IDS.includes(item.token.type)) && item.total.token_id !== null ? ( { item.total && 'token_id' in item.total && item.token && (NFT_TOKEN_TYPE_IDS.includes(item.token.type)) && item.total.token_id !== null ? (
<NftEntity <NftEntity
hash={ item.token.address } hash={ item.token.address }
...@@ -71,11 +72,11 @@ const TokenTransferTableItem = ({ item, isLoading }: Props) => { ...@@ -71,11 +72,11 @@ const TokenTransferTableItem = ({ item, isLoading }: Props) => {
maxW="140px" maxW="140px"
/> />
) : '-' } ) : '-' }
</Td> </TableCell>
<Td isNumeric verticalAlign="top"> <TableCell isNumeric verticalAlign="top">
{ (item.token && valueStr) ? ( { (item.token && valueStr) ? (
<Flex gap={ 2 } overflow="hidden" justifyContent="flex-end"> <Flex gap={ 2 } overflow="hidden" justifyContent="flex-end">
<Skeleton isLoaded={ !isLoading } wordBreak="break-all"> <Skeleton loading={ isLoading } wordBreak="break-all">
{ valueStr } { valueStr }
</Skeleton> </Skeleton>
<TokenEntity <TokenEntity
...@@ -90,8 +91,8 @@ const TokenTransferTableItem = ({ item, isLoading }: Props) => { ...@@ -90,8 +91,8 @@ const TokenTransferTableItem = ({ item, isLoading }: Props) => {
</Flex> </Flex>
) : '-' ) : '-'
} }
</Td> </TableCell>
</Tr> </TableRow>
); );
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment