mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
80 lines
3.2 KiB
TypeScript
80 lines
3.2 KiB
TypeScript
import React from 'react';
|
|
|
|
import type { TokenInfo, TokenInstance } from 'types/api/token';
|
|
import type { TokenTransfer } from 'types/api/tokenTransfer';
|
|
|
|
import { AddressHighlightProvider } from 'lib/contexts/addressHighlight';
|
|
import { useMultichainContext } from 'lib/contexts/multichain';
|
|
import { hasTokenIds, hasTokenTransferValue, isConfidentialTokenType, isFungibleTokenType, NFT_TOKEN_TYPE_IDS } from 'lib/token/tokenTypes';
|
|
import { TableBody, TableColumnHeader, TableHeaderSticky, TableRoot, TableRow } from '@luxfi/ui/table';
|
|
import { TruncatedText } from 'toolkit/components/truncation/TruncatedText';
|
|
import * as SocketNewItemsNotice from 'ui/shared/SocketNewItemsNotice';
|
|
import TimeFormatToggle from 'ui/shared/time/TimeFormatToggle';
|
|
import TokenTransferTableItem from 'ui/token/TokenTransfer/TokenTransferTableItem';
|
|
|
|
interface Props {
|
|
data: Array<TokenTransfer>;
|
|
top: number;
|
|
showSocketInfo: boolean;
|
|
showSocketErrorAlert?: boolean;
|
|
socketInfoNum?: number;
|
|
tokenId?: string;
|
|
isLoading?: boolean;
|
|
token: TokenInfo;
|
|
instance?: TokenInstance;
|
|
}
|
|
|
|
const TokenTransferTable = ({ data, top, showSocketInfo, showSocketErrorAlert, socketInfoNum, tokenId, isLoading, token, instance }: Props) => {
|
|
const multichainContext = useMultichainContext();
|
|
const chainData = multichainContext?.chain;
|
|
const tokenType = token.type;
|
|
|
|
return (
|
|
<AddressHighlightProvider>
|
|
<TableRoot minW="950px">
|
|
<TableHeaderSticky top={ top }>
|
|
<TableRow>
|
|
{ chainData && <TableColumnHeader width="38px"/> }
|
|
<TableColumnHeader width="280px">
|
|
Txn hash
|
|
<TimeFormatToggle/>
|
|
</TableColumnHeader>
|
|
<TableColumnHeader width="200px">Method</TableColumnHeader>
|
|
<TableColumnHeader width="224px" className="xl:!w-[380px]">From/To</TableColumnHeader>
|
|
{ (NFT_TOKEN_TYPE_IDS.includes(tokenType)) &&
|
|
<TableColumnHeader width={ hasTokenIds(tokenType) ? '50%' : '100%' }>Token ID</TableColumnHeader>
|
|
}
|
|
{ hasTokenTransferValue(tokenType) && (
|
|
<TableColumnHeader width={ (isFungibleTokenType(tokenType) || isConfidentialTokenType(tokenType)) ? '100%' : '50%' } isNumeric>
|
|
<TruncatedText text={ `Value ${ token?.symbol || '' }` } className="w-full align-middle"/>
|
|
</TableColumnHeader>
|
|
) }
|
|
</TableRow>
|
|
</TableHeaderSticky>
|
|
<TableBody>
|
|
{ showSocketInfo && (
|
|
<SocketNewItemsNotice.Desktop
|
|
showErrorAlert={ showSocketErrorAlert }
|
|
num={ socketInfoNum }
|
|
type="token_transfer"
|
|
isLoading={ isLoading }
|
|
/>
|
|
) }
|
|
{ data.map((item, index) => (
|
|
<TokenTransferTableItem
|
|
key={ item.transaction_hash + item.block_hash + item.log_index + '_' + index }
|
|
{ ...item }
|
|
tokenId={ tokenId }
|
|
instance={ instance }
|
|
isLoading={ isLoading }
|
|
chainData={ chainData }
|
|
/>
|
|
)) }
|
|
</TableBody>
|
|
</TableRoot>
|
|
</AddressHighlightProvider>
|
|
);
|
|
};
|
|
|
|
export default React.memo(TokenTransferTable);
|