From 41a2fec50151770a5cd312c968ab145d7cc9ec68 Mon Sep 17 00:00:00 2001 From: teodorus-nathaniel Date: Wed, 24 Jan 2024 21:21:26 +0700 Subject: [PATCH] chore: remove excess commas in balance --- src/components/common/balances/Balance.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/common/balances/Balance.tsx b/src/components/common/balances/Balance.tsx index ac94682e8..b9870e0e0 100644 --- a/src/components/common/balances/Balance.tsx +++ b/src/components/common/balances/Balance.tsx @@ -29,7 +29,10 @@ function format( withMutedDecimals = true, alwaysShowDecimals = false, ): React.ReactNode { - const [prefix, postfix] = formatBalance(value, { + // Remove any excess decimals, because this expects big integers + const balanceValue = value.toString().split('.')[0] + + const [prefix, postfix] = formatBalance(balanceValue, { forceUnit: '-', decimals, withSi: false, @@ -38,7 +41,7 @@ function format( const isShort = _isShort || (withSi && prefix.length >= K_LENGTH && !alwaysShowDecimals) if (prefix.length > M_LENGTH && !alwaysShowDecimals) { - const balance = formatBalance(value, { decimals, withUnit: false }) + const balance = formatBalance(balanceValue, { decimals, withUnit: false }) return ( <> {balance} {currency}