Files
explore/ui/verifiedContracts/VerifiedContractsTableItem.tsx
tom goriunovandGitHub ebbee2ba57 Multichain explorer v2 (#3259)
* Support redirect to a correct view from search

* show domains on address page

* migrate to new API version to display address domains

* another api update

* new design for chain widget on home page + tests

* chain widget styles for mobile devices

* ecosystems page

* update types

* add ecosystems to navigation

* address portfolio: pt.1

* portfolio tokens list

* filter portfolio by chain

* skip redirect when navigating to search result by clicking on "show all results" link

* net worth block design

* add filter input to chain select and fix tokens table

* calculate address portfolio

* adjust card logic

* support custom token types in multichain explorer

* handle case when new worth is 0

* add text filter to tokens list

* fixes

* demo envs

* portfolio tests

* ecosystems test

* change signature for getTokenTypes function

* fix adding token to the wallet from the list

* lazy load all address domains

* show contract creator and implementations info

* fix tests

* add poor reputation tokens toggle

* tweaks

* dim celo native tokens

* disable env validator

* fix tests

* remove tokens with 0 usd value from top tokens

* fixes

* preserve selected chain when switching tabs on address page

* add hints to stats widgets on home page

* update envs for demo

* fix portfolio cards and home page

* update styles for contract creator and implementations

* fix select issues

* add chains from cluster to network menu

* hide csv export link on empty logs page

* update screenshots

* rollback select fix

* update cut length calculation for portfolio cards

* fix chain select

* update screenshots

* fix tests

* more fixes

* add sorting to ecosystems table

* fix test

* fixes

* fix loading state in ecosystems page

* review fixes

* fix tests
2026-02-25 10:45:09 +01:00

133 lines
4.9 KiB
TypeScript

import { Flex, chakra } from '@chakra-ui/react';
import React from 'react';
import type { VerifiedContract } from 'types/api/contracts';
import type { ClusterChainConfig } from 'types/multichain';
import formatLanguageName from 'lib/contracts/formatLanguageName';
import { CONTRACT_LICENSES } from 'lib/contracts/licenses';
import { Skeleton } from 'toolkit/chakra/skeleton';
import { TableCell, TableRow } from 'toolkit/chakra/table';
import { Tooltip } from 'toolkit/chakra/tooltip';
import ContractCertifiedLabel from 'ui/shared/ContractCertifiedLabel';
import AddressEntity from 'ui/shared/entities/address/AddressEntity';
import ChainIcon from 'ui/shared/externalChains/ChainIcon';
import IconSvg from 'ui/shared/IconSvg';
import TimeWithTooltip from 'ui/shared/time/TimeWithTooltip';
import NativeCoinValue from 'ui/shared/value/NativeCoinValue';
interface Props {
data: VerifiedContract;
isLoading?: boolean;
chainData?: ClusterChainConfig;
}
const VerifiedContractsTableItem = ({ data, isLoading, chainData }: Props) => {
const license = (() => {
const license = CONTRACT_LICENSES.find((license) => license.type === data.license_type);
if (!license || license.type === 'none') {
return '-';
}
return license.label;
})();
return (
<TableRow>
{ chainData && (
<TableCell>
<ChainIcon data={ chainData } isLoading={ isLoading } mt={ 1 }/>
</TableCell>
) }
<TableCell>
<Flex alignItems="center" mt={ 1 }>
<AddressEntity
address={ data.address }
isLoading={ isLoading }
query={{ tab: 'contract', ...(chainData ? { chain_id: chainData.id } : {}) }}
noCopy
/>
{ data.certified && <ContractCertifiedLabel iconSize={ 5 } boxSize={ 5 } ml={ 2 }/> }
</Flex>
<AddressEntity
address={{ hash: data.address.filecoin?.robust ?? data.address.hash }}
isLoading={ isLoading }
noLink
noIcon
truncation="constant"
my={ 1 }
ml={ 7 }
color="text.secondary"
w="fit-content"
/>
</TableCell>
<TableCell isNumeric>
<NativeCoinValue
amount={ data.coin_balance }
noSymbol
loading={ isLoading }
my={ 1 }
/>
</TableCell>
<TableCell isNumeric>
<Skeleton loading={ isLoading } display="inline-block" my={ 1 }>
{ data.transactions_count ? data.transactions_count.toLocaleString() : '0' }
</Skeleton>
</TableCell>
<TableCell>
<Flex flexWrap="wrap" columnGap={ 2 }>
<Skeleton loading={ isLoading } my={ 1 }>{ formatLanguageName(data.language) }</Skeleton>
{ data.compiler_version && (
<Skeleton loading={ isLoading } color="text.secondary" wordBreak="break-all" my={ 1 } cursor="pointer">
<Tooltip content={ data.compiler_version }>
<span>{ data.compiler_version.split('+')[0] }</span>
</Tooltip>
</Skeleton>
) }
</Flex>
{ data.zk_compiler_version && (
<Flex flexWrap="wrap" columnGap={ 2 } my={ 1 }>
<Skeleton loading={ isLoading } >ZK compiler</Skeleton>
<Skeleton loading={ isLoading } color="text.secondary" wordBreak="break-all">
<span>{ data.zk_compiler_version }</span>
</Skeleton>
</Flex>
) }
</TableCell>
<TableCell>
<Tooltip content="Optimization" disabled={ isLoading }>
<chakra.span display="inline-block">
{ data.optimization_enabled ?
<IconSvg name="check" boxSize={ 6 } color="green.500" cursor="pointer" isLoading={ isLoading }/> :
<IconSvg name="cross" boxSize={ 6 } color="red.600" cursor="pointer" isLoading={ isLoading }/> }
</chakra.span>
</Tooltip>
<Tooltip content="Constructor args" disabled={ isLoading }>
<chakra.span display="inline-block" ml={ 2 }>
{ data.has_constructor_args ?
<IconSvg name="check" boxSize={ 6 } color="green.500" cursor="pointer" isLoading={ isLoading }/> :
<IconSvg name="cross" boxSize={ 6 } color="red.600" cursor="pointer" isLoading={ isLoading }/> }
</chakra.span>
</Tooltip>
</TableCell>
<TableCell>
<Flex alignItems="center" columnGap={ 2 } my={ 1 }>
<IconSvg name="status/success" boxSize={ 4 } color="green.500" isLoading={ isLoading }/>
<TimeWithTooltip
timestamp={ data.verified_at }
isLoading={ isLoading }
color="text.secondary"
/>
</Flex>
</TableCell>
<TableCell>
<Skeleton loading={ isLoading } my={ 1 } display="inline-block">
{ license }
</Skeleton>
</TableCell>
</TableRow>
);
};
export default React.memo(VerifiedContractsTableItem);