From aa5d71243eedb618b9ef72650b52d1a00b70ac34 Mon Sep 17 00:00:00 2001 From: Jagoda Berry Rybacka Date: Thu, 9 Nov 2023 15:52:51 +0100 Subject: [PATCH] Fix "max" button for balances above 999 Don't try to parse strings with comma separated thousands as numbers. --- src/shared/components/TokenAmountInput.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/shared/components/TokenAmountInput.tsx b/src/shared/components/TokenAmountInput.tsx index bd7593d94..d1f671f29 100644 --- a/src/shared/components/TokenAmountInput.tsx +++ b/src/shared/components/TokenAmountInput.tsx @@ -1,5 +1,9 @@ import React from "react" -import { userAmountToBigInt, bigIntToDisplayUserAmount } from "shared/utils" +import { + userAmountToBigInt, + bigIntToDisplayUserAmount, + bigIntToUserAmount, +} from "shared/utils" import { selectTokenBalanceByAddress, selectTokenSymbolByAddress, @@ -55,8 +59,6 @@ export default function TokenAmountInput({ selectTokenSymbolByAddress(state, tokenAddress) ) - const maxAmount = bigIntToDisplayUserAmount(balance) - const validate = (value: string) => { const result = handleValidate(value, balance) const hasError = "error" in result @@ -68,7 +70,9 @@ export default function TokenAmountInput({ return (
{label && ( -
{`${label} ${maxAmount} ${symbol}`}
+
{`${label} ${bigIntToDisplayUserAmount( + balance + )} ${symbol}`}
)} { event.preventDefault() - onChange(maxAmount) + onChange(bigIntToUserAmount(balance)) }} > Max