Skip to content

Commit

Permalink
fix: correct error messages in swap when input blance greater than av…
Browse files Browse the repository at this point in the history
…ailable
  • Loading branch information
kallen-ledger committed Jul 17, 2024
1 parent 88ffec5 commit f717195
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 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 @@ -62,11 +62,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 f717195

Please sign in to comment.