Skip to content

Commit

Permalink
fix: use 0 as max token amount if balance is not enough for gas
Browse files Browse the repository at this point in the history
  • Loading branch information
micaelae committed May 8, 2024
1 parent e345fed commit 05d26b8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions ui/ducks/send/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -1065,9 +1065,14 @@ const slice = createSlice({
16,
).add(new Numeric(state.gasTotalForLayer1 ?? '0x0', 16));

amount = new Numeric(draftTransaction.sendAsset.balance, 16)
.minus(_gasTotal)
.toString();
amount = new Numeric(
draftTransaction.sendAsset.balance,
16,
).lessThanOrEqualTo(_gasTotal)
? '0'
: new Numeric(draftTransaction.sendAsset.balance, 16)
.minus(_gasTotal)
.toString();
}
slice.caseReducers.updateSendAmount(state, {
payload: amount,
Expand Down Expand Up @@ -2743,7 +2748,7 @@ export function signTransaction() {
from: txParams.from,
to: txParams.to,
value: txParams.value,
gas: unapprovedTx.userEditedGasLimit
gas: unapprovedTx?.userEditedGasLimit
? unapprovedTx.txParams.gas
: txParams.gas,
};
Expand Down

0 comments on commit 05d26b8

Please sign in to comment.