diff --git a/src/app/components/Account/index.tsx b/src/app/components/Account/index.tsx index 100cc87a26..5781294ee4 100644 --- a/src/app/components/Account/index.tsx +++ b/src/app/components/Account/index.tsx @@ -22,6 +22,7 @@ import { TokenPriceInfo } from '../../../coin-gecko/api' import { ContractCreatorInfo } from './ContractCreatorInfo' import { ContractVerificationIcon } from '../ContractVerificationIcon' import { TokenLink } from '../Tokens/TokenLink' +import BigNumber from 'bignumber.js' export const StyledAvatarContainer = styled('dt')(({ theme }) => ({ '&&': { @@ -154,7 +155,7 @@ export const Account: FC = ({ account, token, isLoading, tokenPric
{t('common.fiatValueInUSD', { - value: parseFloat(balance) * tokenFiatValue, + value: new BigNumber(balance).multipliedBy(tokenFiatValue).toFixed(), formatParams: { value: { currency: 'USD', diff --git a/src/app/pages/TransactionDetailPage/CurrentFiatValue.tsx b/src/app/pages/TransactionDetailPage/CurrentFiatValue.tsx index 53fc9b62cf..15f4e8ecba 100644 --- a/src/app/pages/TransactionDetailPage/CurrentFiatValue.tsx +++ b/src/app/pages/TransactionDetailPage/CurrentFiatValue.tsx @@ -6,6 +6,7 @@ import Tooltip from '@mui/material/Tooltip' import { CoinGeckoReferral } from '../../components/CoinGeckoReferral' import HelpIcon from '@mui/icons-material/Help' import { TokenPriceInfo } from '../../../coin-gecko/api' +import BigNumber from 'bignumber.js' type CurrentFiatValueProps = Pick & { amount: string @@ -17,7 +18,7 @@ export const CurrentFiatValue: FC = ({ amount, price, has {t('common.fiatValueInUSD', { - value: parseFloat(amount) * price, + value: new BigNumber(amount).multipliedBy(price).toFixed(), formatParams: { value: { currency: 'USD', diff --git a/src/app/pages/TransactionDetailPage/__tests__/CurrentFiatValue.test.tsx b/src/app/pages/TransactionDetailPage/__tests__/CurrentFiatValue.test.tsx index 0bea5120f4..fab153459a 100644 --- a/src/app/pages/TransactionDetailPage/__tests__/CurrentFiatValue.test.tsx +++ b/src/app/pages/TransactionDetailPage/__tests__/CurrentFiatValue.test.tsx @@ -10,7 +10,7 @@ describe('CurrentFiatValue', () => { price={0.55555} />, ) - expect(screen.getByText('$555,550,000,055,555,000,000,000,000,000,000,000,000.00')).toBeInTheDocument() + expect(screen.getByText('$555,550,000,055,555,000,005,555,500,000,555,550,000.06')).toBeInTheDocument() expect(screen.getByText('CoinGecko')).toBeInTheDocument() }) }) diff --git a/src/locales/__tests__/i18n-formatting.test.ts b/src/locales/__tests__/i18n-formatting.test.ts index 91e129db44..7ae1fb3014 100644 --- a/src/locales/__tests__/i18n-formatting.test.ts +++ b/src/locales/__tests__/i18n-formatting.test.ts @@ -29,7 +29,7 @@ test('formatting fiat currency with i18n', () => { const { result } = renderHook(() => { const { t } = useTranslation() return t('does_not_exist.use_default', '{{value, currency}}', { - value: 123.456789, + value: '111222333444555666777888999.111222333444555666', formatParams: { value: { currency: 'USD', @@ -38,7 +38,7 @@ test('formatting fiat currency with i18n', () => { }) as string }) - expect(result.current).toBe('$123.46') + expect(result.current).toBe('$111,222,333,444,555,666,777,888,999.11') }) test('formatting block sizes with i18n', () => {