diff --git a/src/frontend/utils/calculateValue.ts b/src/frontend/utils/calculateValue.ts index 257d090..7db6ba1 100644 --- a/src/frontend/utils/calculateValue.ts +++ b/src/frontend/utils/calculateValue.ts @@ -1,5 +1,5 @@ import web3 from 'web3' -import { utils } from 'ethers' +import { formatUnits } from 'ethers' import { TokenTx, TokenType, TransactionType } from '../../types' import BN from 'bn.js' import { fromWeiNoTrailingComma } from './fromWeiNoTrailingComma' @@ -28,13 +28,15 @@ export const calculateTokenValue = ( ): string => { try { if (txType === TokenType.ERC_20 || txType === TokenType.EVM_Internal) { - const decimalsValue = tokenTx.contractInfo.decimals ? parseInt(tokenTx.contractInfo.decimals) : 18 + const decimalsValue = tokenTx.contractInfo.decimals && !isNaN(parseInt(tokenTx.contractInfo.decimals)) + ? parseInt(tokenTx.contractInfo.decimals) + : 18 return tokenTx.tokenValue === '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' ? 'unlimited' : fullValue - ? utils.formatUnits(tokenTx.tokenValue, decimalsValue) - : roundTokenValue(utils.formatUnits(tokenTx.tokenValue, decimalsValue)) + ? formatUnits(tokenTx.tokenValue, decimalsValue) + : roundTokenValue(formatUnits(tokenTx.tokenValue, decimalsValue)) // : round(web3.utils.fromWei(tokenTx.tokenValue, "ether")); } else if (txType === TokenType.ERC_721) {