Commit ba2a3e2e authored by tom's avatar tom

internal txs for address

parent 6781c5e1
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';
...@@ -70,19 +70,19 @@ const AddressInternalTxs = ({ scrollRef, shouldRender = true, isQueryEnabled = t ...@@ -70,19 +70,19 @@ const AddressInternalTxs = ({ scrollRef, shouldRender = true, isQueryEnabled = t
const content = data?.items ? ( const content = data?.items ? (
<> <>
<Show below="lg" ssr={ false }> <Box hideFrom="lg">
<InternalTxsList data={ data.items } currentAddress={ hash } isLoading={ isPlaceholderData }/> <InternalTxsList data={ data.items } currentAddress={ hash } isLoading={ isPlaceholderData }/>
</Show> </Box>
<Hide below="lg" ssr={ false }> <Box hideBelow="lg">
<InternalTxsTable data={ data.items } currentAddress={ hash } isLoading={ isPlaceholderData }/> <InternalTxsTable data={ data.items } currentAddress={ hash } isLoading={ isPlaceholderData }/>
</Hide> </Box>
</> </>
) : null ; ) : null ;
const actionBar = ( const actionBar = (
<ActionBar mt={ -6 } justifyContent="left"> <ActionBar mt={ -6 } justifyContent="left">
<AddressTxsFilter <AddressTxsFilter
defaultFilter={ filterValue } initialValue={ filterValue }
onFilterChange={ handleFilterChange } onFilterChange={ handleFilterChange }
hasActiveFilter={ Boolean(filterValue) } hasActiveFilter={ Boolean(filterValue) }
isLoading={ pagination.isLoading } isLoading={ pagination.isLoading }
...@@ -100,12 +100,13 @@ const AddressInternalTxs = ({ scrollRef, shouldRender = true, isQueryEnabled = t ...@@ -100,12 +100,13 @@ const AddressInternalTxs = ({ scrollRef, shouldRender = true, isQueryEnabled = t
return ( return (
<DataListDisplay <DataListDisplay
isError={ isError } isError={ isError }
items={ data?.items } itemsNum={ data?.items.length }
filterProps={{ emptyFilteredText: `Couldn${ apos }t find any transaction that matches your query.`, hasActiveFilters: Boolean(filterValue) }} filterProps={{ emptyFilteredText: `Couldn${ apos }t find any transaction that matches your query.`, hasActiveFilters: Boolean(filterValue) }}
emptyText="There are no internal transactions for this address." emptyText="There are no internal transactions for this address."
content={ content }
actionBar={ actionBar } actionBar={ actionBar }
/> >
{ content }
</DataListDisplay>
); );
}; };
......
...@@ -6,9 +6,9 @@ import type { InternalTransaction } from 'types/api/internalTransaction'; ...@@ -6,9 +6,9 @@ import type { InternalTransaction } from 'types/api/internalTransaction';
import config from 'configs/app'; import config from 'configs/app';
import { currencyUnits } from 'lib/units'; import { currencyUnits } from 'lib/units';
import { Badge } from 'toolkit/chakra/badge';
import { Skeleton } from 'toolkit/chakra/skeleton';
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 TxEntity from 'ui/shared/entities/tx/TxEntity'; import TxEntity from 'ui/shared/entities/tx/TxEntity';
import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
...@@ -38,7 +38,7 @@ const InternalTxsListItem = ({ ...@@ -38,7 +38,7 @@ const InternalTxsListItem = ({
return ( return (
<ListItemMobile rowGap={ 3 }> <ListItemMobile rowGap={ 3 }>
<Flex columnGap={ 2 }> <Flex columnGap={ 2 }>
{ typeTitle && <Tag colorScheme="cyan" isLoading={ isLoading }>{ typeTitle }</Tag> } { typeTitle && <Badge colorPalette="cyan" loading={ isLoading }>{ typeTitle }</Badge> }
<TxStatus status={ success ? 'ok' : 'error' } errorText={ error } isLoading={ isLoading }/> <TxStatus status={ success ? 'ok' : 'error' } errorText={ error } isLoading={ isLoading }/>
</Flex> </Flex>
<Flex justifyContent="space-between" width="100%"> <Flex justifyContent="space-between" width="100%">
...@@ -56,14 +56,13 @@ const InternalTxsListItem = ({ ...@@ -56,14 +56,13 @@ const InternalTxsListItem = ({
fontSize="sm" fontSize="sm"
/> />
</Flex> </Flex>
<HStack spacing={ 1 }> <HStack gap={ 1 }>
<Skeleton isLoaded={ !isLoading } fontSize="sm" fontWeight={ 500 }>Block</Skeleton> <Skeleton loading={ isLoading } fontSize="sm" fontWeight={ 500 }>Block</Skeleton>
<BlockEntity <BlockEntity
isLoading={ isLoading } isLoading={ isLoading }
number={ blockNumber } number={ blockNumber }
noIcon noIcon
fontSize="sm" textStyle="sm"
lineHeight={ 5 }
/> />
</HStack> </HStack>
<AddressFromTo <AddressFromTo
...@@ -73,9 +72,9 @@ const InternalTxsListItem = ({ ...@@ -73,9 +72,9 @@ const InternalTxsListItem = ({
isLoading={ isLoading } isLoading={ isLoading }
w="100%" w="100%"
/> />
<HStack spacing={ 3 }> <HStack gap={ 3 }>
<Skeleton isLoaded={ !isLoading } fontSize="sm" fontWeight={ 500 }>Value { currencyUnits.ether }</Skeleton> <Skeleton loading={ isLoading } fontSize="sm" fontWeight={ 500 }>Value { currencyUnits.ether }</Skeleton>
<Skeleton isLoaded={ !isLoading } fontSize="sm" color="text_secondary" minW={ 6 }> <Skeleton loading={ isLoading } fontSize="sm" color="text_secondary" minW={ 6 }>
<span>{ BigNumber(value).div(BigNumber(10 ** config.chain.currency.decimals)).toFormat() }</span> <span>{ BigNumber(value).div(BigNumber(10 ** config.chain.currency.decimals)).toFormat() }</span>
</Skeleton> </Skeleton>
</HStack> </HStack>
......
import { Table, Tbody, Tr, Th } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import type { InternalTransaction } from 'types/api/internalTransaction'; import type { InternalTransaction } from 'types/api/internalTransaction';
import { AddressHighlightProvider } from 'lib/contexts/addressHighlight'; import { AddressHighlightProvider } from 'lib/contexts/addressHighlight';
import { currencyUnits } from 'lib/units'; import { currencyUnits } from 'lib/units';
import { default as Thead } from 'ui/shared/TheadSticky'; import { TableBody, TableColumnHeader, TableHeaderSticky, TableRoot, TableRow } from 'toolkit/chakra/table';
import InternalTxsTableItem from './InternalTxsTableItem'; import InternalTxsTableItem from './InternalTxsTableItem';
...@@ -18,19 +17,19 @@ interface Props { ...@@ -18,19 +17,19 @@ interface Props {
const InternalTxsTable = ({ data, currentAddress, isLoading }: Props) => { const InternalTxsTable = ({ data, currentAddress, isLoading }: Props) => {
return ( return (
<AddressHighlightProvider> <AddressHighlightProvider>
<Table> <TableRoot>
<Thead top={ 68 }> <TableHeaderSticky top={ 68 }>
<Tr> <TableRow>
<Th width="15%">Parent txn hash</Th> <TableColumnHeader width="15%">Parent txn hash</TableColumnHeader>
<Th width="15%">Type</Th> <TableColumnHeader width="15%">Type</TableColumnHeader>
<Th width="10%">Block</Th> <TableColumnHeader width="10%">Block</TableColumnHeader>
<Th width="40%">From/To</Th> <TableColumnHeader width="40%">From/To</TableColumnHeader>
<Th width="20%" isNumeric> <TableColumnHeader width="20%" isNumeric>
Value { currencyUnits.ether } Value { currencyUnits.ether }
</Th> </TableColumnHeader>
</Tr> </TableRow>
</Thead> </TableHeaderSticky>
<Tbody> <TableBody>
{ data.map((item, index) => ( { data.map((item, index) => (
<InternalTxsTableItem <InternalTxsTableItem
key={ item.transaction_hash + '_' + index } key={ item.transaction_hash + '_' + index }
...@@ -39,8 +38,8 @@ const InternalTxsTable = ({ data, currentAddress, isLoading }: Props) => { ...@@ -39,8 +38,8 @@ const InternalTxsTable = ({ data, currentAddress, isLoading }: Props) => {
isLoading={ isLoading } isLoading={ isLoading }
/> />
)) } )) }
</Tbody> </TableBody>
</Table> </TableRoot>
</AddressHighlightProvider> </AddressHighlightProvider>
); );
......
import { Tr, Td, Box, Flex } from '@chakra-ui/react'; import { Flex } from '@chakra-ui/react';
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import React from 'react'; import React from 'react';
import type { InternalTransaction } from 'types/api/internalTransaction'; import type { InternalTransaction } from 'types/api/internalTransaction';
import config from 'configs/app'; import config from 'configs/app';
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 TxEntity from 'ui/shared/entities/tx/TxEntity'; import TxEntity from 'ui/shared/entities/tx/TxEntity';
import TxStatus from 'ui/shared/statusTag/TxStatus'; import TxStatus from 'ui/shared/statusTag/TxStatus';
...@@ -34,8 +35,8 @@ const InternalTxsTableItem = ({ ...@@ -34,8 +35,8 @@ const InternalTxsTableItem = ({
const toData = to ? to : createdContract; const toData = to ? to : createdContract;
return ( return (
<Tr alignItems="top"> <TableRow alignItems="top">
<Td verticalAlign="middle"> <TableCell verticalAlign="middle">
<Flex rowGap={ 3 } flexDir="column"> <Flex rowGap={ 3 } flexDir="column">
<TxEntity <TxEntity
hash={ txnHash } hash={ txnHash }
...@@ -53,41 +54,38 @@ const InternalTxsTableItem = ({ ...@@ -53,41 +54,38 @@ const InternalTxsTableItem = ({
fontSize="sm" fontSize="sm"
/> />
</Flex> </Flex>
</Td> </TableCell>
<Td verticalAlign="middle"> <TableCell verticalAlign="middle">
<Flex rowGap={ 2 } flexWrap="wrap"> <Flex rowGap={ 3 } flexDir="column">
{ typeTitle && ( { typeTitle && (
<Box w="126px" display="inline-block"> <Badge colorPalette="cyan" loading={ isLoading }>{ typeTitle }</Badge>
<Tag colorScheme="cyan" mr={ 5 } isLoading={ isLoading }>{ typeTitle }</Tag>
</Box>
) } ) }
<TxStatus status={ success ? 'ok' : 'error' } errorText={ error } isLoading={ isLoading }/> <TxStatus status={ success ? 'ok' : 'error' } errorText={ error } isLoading={ isLoading }/>
</Flex> </Flex>
</Td> </TableCell>
<Td verticalAlign="middle"> <TableCell verticalAlign="middle">
<BlockEntity <BlockEntity
isLoading={ isLoading } isLoading={ isLoading }
number={ blockNumber } number={ blockNumber }
noIcon noIcon
fontSize="sm" textStyle="sm"
lineHeight={ 5 }
fontWeight={ 500 } fontWeight={ 500 }
/> />
</Td> </TableCell>
<Td verticalAlign="middle"> <TableCell verticalAlign="middle">
<AddressFromTo <AddressFromTo
from={ from } from={ from }
to={ toData } to={ toData }
current={ currentAddress } current={ currentAddress }
isLoading={ isLoading } isLoading={ isLoading }
/> />
</Td> </TableCell>
<Td isNumeric verticalAlign="middle"> <TableCell isNumeric verticalAlign="middle">
<Skeleton isLoaded={ !isLoading } display="inline-block" minW={ 6 }> <Skeleton loading={ isLoading } display="inline-block" minW={ 6 }>
{ BigNumber(value).div(BigNumber(10 ** config.chain.currency.decimals)).toFormat() } { BigNumber(value).div(BigNumber(10 ** config.chain.currency.decimals)).toFormat() }
</Skeleton> </Skeleton>
</Td> </TableCell>
</Tr> </TableRow>
); );
}; };
......
...@@ -201,12 +201,12 @@ const AddressPageContent = () => { ...@@ -201,12 +201,12 @@ const AddressPageContent = () => {
component: <AddressTokens shouldRender={ !isTabsLoading } isQueryEnabled={ areQueriesEnabled }/>, component: <AddressTokens shouldRender={ !isTabsLoading } isQueryEnabled={ areQueriesEnabled }/>,
subTabs: TOKEN_TABS, subTabs: TOKEN_TABS,
}, },
// { {
// id: 'internal_txns', id: 'internal_txns',
// title: 'Internal txns', title: 'Internal txns',
// count: addressTabsCountersQuery.data?.internal_transactions_count, count: addressTabsCountersQuery.data?.internal_transactions_count,
// component: <AddressInternalTxs scrollRef={ tabsScrollRef } shouldRender={ !isTabsLoading } isQueryEnabled={ areQueriesEnabled }/>, component: <AddressInternalTxs scrollRef={ tabsScrollRef } shouldRender={ !isTabsLoading } isQueryEnabled={ areQueriesEnabled }/>,
// }, },
addressTabsCountersQuery.data?.celo_election_rewards_count ? { addressTabsCountersQuery.data?.celo_election_rewards_count ? {
id: 'epoch_rewards', id: 'epoch_rewards',
title: 'Epoch rewards', title: 'Epoch rewards',
......
import { Hide, Show } from '@chakra-ui/react'; import { Box } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import useIsMobile from 'lib/hooks/useIsMobile'; import useIsMobile from 'lib/hooks/useIsMobile';
...@@ -42,12 +42,12 @@ const InternalTxs = () => { ...@@ -42,12 +42,12 @@ const InternalTxs = () => {
const content = data?.items ? ( const content = data?.items ? (
<> <>
<Show below="lg" ssr={ false }> <Box hideFrom="lg">
<InternalTxsList data={ data.items } isLoading={ isPlaceholderData }/> <InternalTxsList data={ data.items } isLoading={ isPlaceholderData }/>
</Show> </Box>
<Hide below="lg" ssr={ false }> <Box hideBelow="lg">
<InternalTxsTable data={ data.items } isLoading={ isPlaceholderData }/> <InternalTxsTable data={ data.items } isLoading={ isPlaceholderData }/>
</Hide> </Box>
</> </>
) : null; ) : null;
...@@ -59,11 +59,12 @@ const InternalTxs = () => { ...@@ -59,11 +59,12 @@ const InternalTxs = () => {
/> />
<DataListDisplay <DataListDisplay
isError={ isError } isError={ isError }
items={ data?.items } itemsNum={ data?.items.length }
emptyText="There are no internal transactions." emptyText="There are no internal transactions."
content={ content }
actionBar={ actionBar } actionBar={ actionBar }
/> >
{ content }
</DataListDisplay>
</> </>
); );
}; };
......
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