Skip to content

Commit

Permalink
Merge pull request #7353 from LedgerHQ/bugfix/LIVE-13376
Browse files Browse the repository at this point in the history
[fix/LIVE-13376]: correct error messages in swap when input balance greater than available
  • Loading branch information
kallen-ledger committed Jul 17, 2024
2 parents 313f81d + 1eaf761 commit cb20061
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .changeset/big-dogs-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@ledgerhq/coin-tron": patch
"@ledgerhq/live-common": patch
---

Throw notenoughgas for tron token remove NotEnoughBalance from useFromAmountStatusMessage
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,6 @@ const getTransactionStatus = async (
errors.amount = useAllAmount ? new NotEnoughBalance() : new AmountRequired();
} else if (amount.gt(balance)) {
errors.amount = new NotEnoughBalance();
} else if (account.type === "TokenAccount" && estimatedFees.gt(acc.balance)) {
errors.amount = new NotEnoughBalance();
}

const energy = (acc.tronResources && acc.tronResources.energy) || new BigNumber(0);
Expand Down Expand Up @@ -262,7 +260,7 @@ const getTransactionStatus = async (
const query = new URLSearchParams({
...(acc?.id ? { account: acc.id } : {}),
});
errors.gasPrice = new NotEnoughGas(undefined, {
errors.gasLimit = new NotEnoughGas(undefined, {
fees: formatCurrencyUnit(getFeesUnit(acc.currency), estimatedFees),
ticker: acc.currency.ticker,
cryptoName: acc.currency.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
NotEnoughGas,
NotEnoughGasSwap,
NotEnoughBalanceSwap,
NotEnoughBalance,
} from "@ledgerhq/errors";
import { Account } from "@ledgerhq/types-live";
import { useMemo } from "react";
Expand Down Expand Up @@ -62,11 +61,9 @@ export const useFromAmountStatusMessage = (
if (transaction?.amount.lte(0)) return undefined;

const [relevantStatus] = statusEntries
.filter(Boolean)
.filter(maybeError => maybeError instanceof Error)
.filter(errorOrWarning => !(errorOrWarning instanceof AmountRequired));
const isRelevantStatus =
(relevantStatus as Error) instanceof NotEnoughGas ||
(relevantStatus as Error) instanceof NotEnoughBalance;
const isRelevantStatus = (relevantStatus as Error) instanceof NotEnoughGas;

if (isRelevantStatus && currency && estimatedFees) {
const query = new URLSearchParams({
Expand Down

0 comments on commit cb20061

Please sign in to comment.