From f4067a137ef6f259c80c8d38dd22cd5af698862e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Nguyen?= Date: Wed, 20 Apr 2022 16:30:27 +0200 Subject: [PATCH] Fix amount calculation in send max when fees exceed spendable amount (#1900) --- src/families/celo/js-getTransactionStatus.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/families/celo/js-getTransactionStatus.ts b/src/families/celo/js-getTransactionStatus.ts index 5358f36d4c..41133e8601 100644 --- a/src/families/celo/js-getTransactionStatus.ts +++ b/src/families/celo/js-getTransactionStatus.ts @@ -29,10 +29,12 @@ const getTransactionStatus = async ( const estimatedFees = transaction.fees || new BigNumber(0); - const amount = useAllAmount + let amount = useAllAmount ? account.spendableBalance.minus(estimatedFees) : new BigNumber(transaction.amount); + if (amount.lt(0)) amount = new BigNumber(0); + if (amount.lte(0) && !transaction.useAllAmount) { errors.amount = new AmountRequired(); }