explorer: Display more decimals for small token prices (#21276)

This commit is contained in:
Justin Starry
2021-11-15 13:45:49 +01:00
committed by GitHub
parent 647aa92667
commit 47e6848fbf

View File

@ -108,8 +108,12 @@ function FungibleTokenMintAccountCard({
const coinInfo = useCoinGecko(tokenInfo?.extensions?.coingeckoId); const coinInfo = useCoinGecko(tokenInfo?.extensions?.coingeckoId);
let tokenPriceInfo; let tokenPriceInfo;
let tokenPriceDecimals = 2;
if (coinInfo?.status === CoingeckoStatus.Success) { if (coinInfo?.status === CoingeckoStatus.Success) {
tokenPriceInfo = coinInfo.coinInfo; tokenPriceInfo = coinInfo.coinInfo;
if (tokenPriceInfo && tokenPriceInfo.price < 1) {
tokenPriceDecimals = 6;
}
} }
return ( return (
@ -130,7 +134,7 @@ function FungibleTokenMintAccountCard({
</span> </span>
</h4> </h4>
<h1 className="mb-0"> <h1 className="mb-0">
${tokenPriceInfo.price.toFixed(2)}{" "} ${tokenPriceInfo.price.toFixed(tokenPriceDecimals)}{" "}
{tokenPriceInfo.price_change_percentage_24h > 0 && ( {tokenPriceInfo.price_change_percentage_24h > 0 && (
<small className="change-positive"> <small className="change-positive">
&uarr;{" "} &uarr;{" "}