Files
explore/ui/crossChain/tx/TxCrossChainDetailsTransfers.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

113 lines
4.0 KiB
TypeScript

import { chakra, Flex, GridItem } from '@chakra-ui/react';
import React from 'react';
import type { InterchainTransfer } from '@blockscout/interchain-indexer-types';
import { route } from 'nextjs-routes';
import { Link } from 'toolkit/chakra/link';
import { Skeleton } from 'toolkit/chakra/skeleton';
import AddressFromToIcon from 'ui/shared/address/AddressFromToIcon';
import * as DetailedInfo from 'ui/shared/DetailedInfo/DetailedInfo';
import AddressEntityInterchain from 'ui/shared/entities/address/AddressEntityInterchain';
import IconSvg from 'ui/shared/IconSvg';
import TokenValueInterchain from 'ui/shared/value/TokenValueInterchain';
const MAX_NUM = 5;
interface Props {
data: Array<InterchainTransfer>;
id: string;
isLoading?: boolean;
}
const TxCrossChainDetailsTransfers = ({ data, id, isLoading }: Props) => {
return (
<>
<DetailedInfo.ItemLabel
hint="Tokens moved as part of the cross-chain operation"
isLoading={ isLoading }
>
Token transferred
</DetailedInfo.ItemLabel>
<DetailedInfo.ItemValue position="relative" multiRow>
<Flex
flexDirection="column"
alignItems="flex-start"
rowGap={ 1 }
w="100%"
overflow="hidden"
>
{ data.slice(0, MAX_NUM).map((item, index) => {
return (
<Flex key={ index } alignItems="center" columnGap={ 2 } rowGap={ 0 } flexWrap="wrap">
{ item.sender ? (
<AddressEntityInterchain
address={ item.sender }
isLoading={ isLoading }
chain={ item.source_chain }
noIcon
truncation="constant"
/>
) : <chakra.span color="text.secondary">Unknown</chakra.span> }
<AddressFromToIcon
isLoading={ isLoading }
type="unspecified"
/>
{ item.recipient ? (
<AddressEntityInterchain
address={ item.recipient }
isLoading={ isLoading }
chain={ item.destination_chain }
noIcon
truncation="constant"
/>
) : <chakra.span color="text.secondary">Unknown</chakra.span> }
<Skeleton loading={ isLoading } color="text.secondary">
<span>for</span>
</Skeleton>
{ item.source_token ? (
<TokenValueInterchain
token={ item.source_token }
amount={ item.source_amount }
chain={ item.source_chain }
loading={ isLoading }
/>
) : <chakra.span color="text.secondary">Unknown</chakra.span> }
<AddressFromToIcon
isLoading={ isLoading }
type="unspecified"
/>
{ item.destination_token ? (
<TokenValueInterchain
token={ item.destination_token }
amount={ item.destination_amount }
chain={ item.destination_chain }
loading={ isLoading }
/>
) : <chakra.span color="text.secondary">Unknown</chakra.span> }
</Flex>
);
}) }
</Flex>
</DetailedInfo.ItemValue>
{ data.length > MAX_NUM && (
<>
<GridItem hideBelow="lg"/>
<GridItem fontSize="sm" alignItems="center" display="inline-flex" pl={{ base: '28px', lg: 0 }}>
{ /* FIXME use non-navigation icon */ }
<IconSvg name="navigation/tokens" boxSize={ 6 }/>
<Link
href={ route({ pathname: '/cross-chain-tx/[id]', query: { id, tab: 'transfers' } }) }
>
View all
</Link>
</GridItem>
</>
) }
</>
);
};
export default React.memo(TxCrossChainDetailsTransfers);