Files
explore/ui/crossChain/transfers/TokenTransfersCrossChainTableItem.tsx
tom goriunovandGitHub e6e83ee4e7 Add cross-chain transaction tracking and visualization (#3227)
* envs and feature setup

* home page layout

* cross-chain txs page

* cross-chain transfers page

* cross-chain transfers on tx page

* cross-chain messages on tx page

* cross-chain tx page

* cross-chain tx details token transfers

* stats and counters for lists

* migrate to new API version

* add swagger

* mobile lists

* placeholder views on address page

* tests

* fix adaptive tabs initial state when there is only one tab in the list

* tweaks

* bug fixes

* fix tests

* update screenshots

* migrate to new api version

* add chain label tooltip, copy button to txs in lists and same address highlight

* list views on address page

* fix tests

* fix links to current address in the list views

* update tooltips

* update tables layout

* review fixes

* fix spelling

* update screenshots

* update screenshot
2026-02-19 15:14:32 +01:00

160 lines
5.4 KiB
TypeScript

import { chakra, VStack } from '@chakra-ui/react';
import React from 'react';
import type { InterchainTransfer } from '@blockscout/interchain-indexer-types';
import config from 'configs/app';
import { TableCell, TableRow } from 'toolkit/chakra/table';
import { mdash } from 'toolkit/utils/htmlEntities';
import AddressFromToIcon from 'ui/shared/address/AddressFromToIcon';
import CrossChainBridgeLink from 'ui/shared/crossChain/CrossChainBridgeLink';
import CrossChainFromToTag from 'ui/shared/crossChain/CrossChainFromToTag';
import AddressEntityInterchain from 'ui/shared/entities/address/AddressEntityInterchain';
import CrossChainMessageEntity from 'ui/shared/entities/crossChainMessage/CrossChainMessageEntity';
import TxEntityInterchain from 'ui/shared/entities/tx/TxEntityInterchain';
import ChainLabel from 'ui/shared/externalChains/ChainLabel';
import CrossChainTxsStatusTag from 'ui/shared/statusTag/CrossChainTxsStatusTag';
import TimeWithTooltip from 'ui/shared/time/TimeWithTooltip';
import TokenValueInterchain from 'ui/shared/value/TokenValueInterchain';
interface Props {
data: InterchainTransfer;
isLoading?: boolean;
currentAddress?: string;
}
const TokenTransfersCrossChainTableItem = ({ data, isLoading, currentAddress }: Props) => {
const dashElement = <chakra.span color="text.secondary" lineHeight="24px">{ mdash }</chakra.span>;
return (
<TableRow>
<TableCell w="42px">
<CrossChainTxsStatusTag status={ data.status } loading={ isLoading }/>
</TableCell>
{ currentAddress && (
<TableCell>
<CrossChainFromToTag
type={ data.sender?.hash.toLowerCase() === currentAddress.toLowerCase() && config.chain.id === data.source_chain?.id ? 'out' : 'in' }
isLoading={ isLoading }
/>
</TableCell>
) }
<TableCell maxW="150px">
<VStack alignItems="start">
{ data.source_token && (
<TokenValueInterchain
token={ data.source_token }
amount={ data.source_amount }
chain={ data.source_chain }
loading={ isLoading }
lineHeight="24px"
/>
) }
{
data.sender ? (
<AddressEntityInterchain
chain={ data.source_chain }
address={ data.sender }
isLoading={ isLoading }
truncation="constant"
noIcon
currentAddress={ currentAddress }
textStyle="xs"
/>
) : dashElement
}
</VStack>
</TableCell>
<TableCell>
<AddressFromToIcon type="unspecified" isLoading={ isLoading } mt={ 0.5 }/>
</TableCell>
<TableCell maxW="150px">
<VStack alignItems="start">
{ data.destination_token && (
<TokenValueInterchain
token={ data.destination_token }
amount={ data.destination_amount }
chain={ data.destination_chain }
loading={ isLoading }
lineHeight="24px"
/>
) }
{
data.recipient ? (
<AddressEntityInterchain
chain={ data.destination_chain }
address={ data.recipient }
isLoading={ isLoading }
truncation="constant"
noIcon
currentAddress={ currentAddress }
textStyle="xs"
/>
) : dashElement
}
</VStack>
</TableCell>
<TableCell maxW="150px">
<VStack alignItems="start">
{ data.source_transaction_hash ? (
<TxEntityInterchain
chain={ data.source_chain }
hash={ data.source_transaction_hash }
isLoading={ isLoading }
noIcon
truncation="constant"
lineHeight="24px"
/>
) : dashElement }
<ChainLabel
data={ data.source_chain }
isLoading={ isLoading }
color="text.secondary"
textStyle="xs"
gap={ 1 }
/>
</VStack>
</TableCell>
<TableCell maxW="150px">
<VStack alignItems="start">
{ data.destination_transaction_hash ? (
<TxEntityInterchain
chain={ data.destination_chain }
hash={ data.destination_transaction_hash }
isLoading={ isLoading }
noIcon
truncation="constant"
lineHeight="24px"
/>
) : dashElement }
<ChainLabel
data={ data.destination_chain }
isLoading={ isLoading }
color="text.secondary"
textStyle="xs"
gap={ 1 }
/>
</VStack>
</TableCell>
<TableCell>
<CrossChainBridgeLink data={ data.bridge } isLoading={ isLoading } lineHeight="24px"/>
</TableCell>
<TableCell>
<CrossChainMessageEntity id={ data.message_id } isLoading={ isLoading } lineHeight="24px"/>
</TableCell>
<TableCell>
<TimeWithTooltip
timestamp={ data.send_timestamp || data.receive_timestamp }
isLoading={ isLoading }
color="text.secondary"
lineHeight="24px"
whiteSpace="nowrap"
/>
</TableCell>
</TableRow>
);
};
export default React.memo(TokenTransfersCrossChainTableItem);