diff --git a/src/logic/tokens/utils/formatAmounts.js b/src/logic/tokens/utils/formatAmount.js similarity index 52% rename from src/logic/tokens/utils/formatAmounts.js rename to src/logic/tokens/utils/formatAmount.js index e3d35935..b1bd325b 100644 --- a/src/logic/tokens/utils/formatAmounts.js +++ b/src/logic/tokens/utils/formatAmount.js @@ -1,9 +1,10 @@ // @flow +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat export const formatAmount = (number: string | number) => { let numberFloat = parseFloat(number) if (numberFloat < 999.999999) { - numberFloat = numberFloat.toFixed(2).toLocaleString() + numberFloat = numberFloat.toFixed(5).toLocaleString() } return numberFloat diff --git a/src/routes/safe/components/Balances/dataFetcher.js b/src/routes/safe/components/Balances/dataFetcher.js index 568a804a..11b5c509 100644 --- a/src/routes/safe/components/Balances/dataFetcher.js +++ b/src/routes/safe/components/Balances/dataFetcher.js @@ -3,6 +3,7 @@ import { List } from 'immutable' import { type Token } from '~/logic/tokens/store/model/token' import { buildOrderFieldFrom, FIXED, type SortRow } from '~/components/Table/sorting' import { type Column } from '~/components/Table/TableHead' +import { formatAmount } from '~/logic/tokens/utils/formatAmount' export const BALANCE_TABLE_ASSET_ID = 'asset' export const BALANCE_TABLE_BALANCE_ID = 'balance' @@ -19,7 +20,7 @@ export const getBalanceData = (activeTokens: List): List => { const rows = activeTokens.map((token: Token) => ({ [BALANCE_TABLE_ASSET_ID]: { name: token.name, logoUri: token.logoUri }, [buildOrderFieldFrom(BALANCE_TABLE_ASSET_ID)]: token.name, - [BALANCE_TABLE_BALANCE_ID]: `${token.balance} ${token.symbol}`, + [BALANCE_TABLE_BALANCE_ID]: `${formatAmount(token.balance)} ${token.symbol}`, [buildOrderFieldFrom(BALANCE_TABLE_BALANCE_ID)]: Number(token.balance), [FIXED]: token.get('symbol') === 'ETH', }))