Skip to content

Commit

Permalink
[LIVE-13596] Bugfix - Remove NotEnoughBalanceInParentAccount error …
Browse files Browse the repository at this point in the history
…from coin-evm (#7531)

* Remove `NotEnoughBalanceInParentAccount` error
from amount validation, the test is redundant with `validateGas` tests

* changeset
  • Loading branch information
lambertkevin committed Aug 7, 2024
1 parent 641cc17 commit d213d81
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/two-rabbits-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/coin-evm": patch
---

Remove `NotEnoughBalanceInParentAccount` error from `validateAmount` check in `getTransactionStatus` as it was redundant with a `validateGas` test
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
InvalidAddress,
MaxFeeTooLow,
NotEnoughBalance,
NotEnoughBalanceInParentAccount,
NotEnoughGas,
PriorityFeeHigherThanMaxFee,
PriorityFeeTooHigh,
Expand Down Expand Up @@ -242,18 +241,15 @@ describe("EVM Family", () => {
);
});

it("should detected parent account not having enough fund for a token transaction and have an error", async () => {
it("should detect token account not having enough balance for a tx and have an error", async () => {
const res = await getTransactionStatus(
{
...account,
balance: new BigNumber(0),
},
{ ...account, subAccounts: [{ ...tokenAccount, balance: new BigNumber(0) }] },
erc20Transaction,
);

expect(res.errors).toEqual(
expect.objectContaining({
amount: new NotEnoughBalanceInParentAccount(),
amount: new NotEnoughBalance(),
}),
);
});
Expand Down
5 changes: 1 addition & 4 deletions libs/coin-modules/coin-evm/src/getTransactionStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
InvalidAddress,
MaxFeeTooLow,
NotEnoughBalance,
NotEnoughBalanceInParentAccount,
NotEnoughGas,
PriorityFeeHigherThanMaxFee,
PriorityFeeTooHigh,
Expand Down Expand Up @@ -118,9 +117,7 @@ const validateAmount = (
errors.amount = new AmountRequired(); // "Amount required"
} else if (totalSpent.isGreaterThan(account.balance)) {
// if not enough to make the transaction
errors.amount = isTokenTransaction
? new NotEnoughBalanceInParentAccount() // Insufficient balance in the parent account
: new NotEnoughBalance(); // "Sorry, insufficient funds"
errors.amount = new NotEnoughBalance(); // "Sorry, insufficient funds"
}
return [errors, warnings];
};
Expand Down

0 comments on commit d213d81

Please sign in to comment.