Commit ac7bfb2a authored by Igor Stuev's avatar Igor Stuev Committed by GitHub

Merge pull request #717 from blockscout/token-details-fix

fix total supply for nft
parents cfd7beef 3c29cc82
...@@ -74,9 +74,19 @@ const TokenDetails = ({ tokenQuery }: Props) => { ...@@ -74,9 +74,19 @@ const TokenDetails = ({ tokenQuery }: Props) => {
total_supply: totalSupply, total_supply: totalSupply,
decimals, decimals,
symbol, symbol,
type,
} = tokenQuery.data; } = tokenQuery.data;
const totalValue = totalSupply !== null ? getCurrencyValue({ value: totalSupply, accuracy: 3, accuracyUsd: 2, exchangeRate, decimals }) : undefined; let marketcap;
let totalSupplyValue;
if (type === 'ERC-20') {
const totalValue = totalSupply !== null ? getCurrencyValue({ value: totalSupply, accuracy: 3, accuracyUsd: 2, exchangeRate, decimals }) : undefined;
marketcap = totalValue?.usd;
totalSupplyValue = totalValue?.valueStr;
} else {
totalSupplyValue = Number(totalSupply).toLocaleString('en');
}
return ( return (
<Grid <Grid
...@@ -94,13 +104,13 @@ const TokenDetails = ({ tokenQuery }: Props) => { ...@@ -94,13 +104,13 @@ const TokenDetails = ({ tokenQuery }: Props) => {
{ `$${ exchangeRate }` } { `$${ exchangeRate }` }
</DetailsInfoItem> </DetailsInfoItem>
) } ) }
{ totalValue?.usd && ( { marketcap && (
<DetailsInfoItem <DetailsInfoItem
title="Fully diluted market cap" title="Fully diluted market cap"
hint="Total supply * Price" hint="Total supply * Price"
alignSelf="center" alignSelf="center"
> >
{ `$${ totalValue?.usd }` } { `$${ marketcap }` }
</DetailsInfoItem> </DetailsInfoItem>
) } ) }
<DetailsInfoItem <DetailsInfoItem
...@@ -112,7 +122,7 @@ const TokenDetails = ({ tokenQuery }: Props) => { ...@@ -112,7 +122,7 @@ const TokenDetails = ({ tokenQuery }: Props) => {
> >
<Flex w="100%"> <Flex w="100%">
<Box whiteSpace="nowrap" overflow="hidden"> <Box whiteSpace="nowrap" overflow="hidden">
<HashStringShortenDynamic hash={ totalValue?.valueStr || '0' }/> <HashStringShortenDynamic hash={ totalSupplyValue || '0' }/>
</Box> </Box>
<Box flexShrink={ 0 }> { symbol || '' }</Box> <Box flexShrink={ 0 }> { symbol || '' }</Box>
</Flex> </Flex>
......
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