metamask-extension icon indicating copy to clipboard operation
metamask-extension copied to clipboard

fix: Fix issue 25285 max insufficient funds for gas

Open ejwessel opened this issue 8 months ago • 6 comments

Description

When performing a send or swap+send there are two outstanding issues:

  1. swap+send, nativeToken -> ERC20 and "insufficient funds for gas" error message appears. This behavior is incorrect estimation and should only occur when there are insufficient funds for simple send. In other words, the current logic is treating nativeToken -> ERC20 swaps as if they were nativeToken -> nativeToken swaps, which is causing this error.
  2. when swapping between src assets the amount mode max is maintained. Amounts should reset between differently chosen srcAssets.

Fixes are:

  • Hiding the max button when the source token is native, but the destination token is an ERC20
  • Resetting the srcAmount whenever the srcAsset changes

Open in GitHub Codespaces

Related issues

Fixes: https://github.com/MetaMask/metamask-extension/issues/25285

Manual testing steps

For each every combination of srcToken to destToken either being nativeToken or an ERC20 Verify that the insufficient funds message does not show unless it is nativeToken -> nativeToken and there is insufficient funds for gas

when maxing srcToken (current behavior)

srcToken destToken
nativeToken nativeToken
nativeToken ERC20
ERC20 nativeToken
ERC20 ERC20
  1. click on 'Send'
  2. perform a 'Send' or 'Swap + Send' based on the above table
  3. verify that the error message appears only in the situation where there is insufficient native token to pay for gas for a 'Send'

Screenshots/Recordings

Before

Screenshot 2024-06-20 at 00 01 00

After

Screenshot 2024-06-28 at 15 15 43 Screenshot 2024-06-28 at 15 15 46 Screenshot 2024-06-28 at 15 15 53 Screenshot 2024-06-28 at 15 15 56 Screenshot 2024-06-28 at 15 16 16 Screenshot 2024-06-28 at 15 16 24 Screenshot 2024-06-28 at 15 16 32

Pre-merge author checklist

Pre-merge reviewer checklist

  • [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

ejwessel avatar Jun 27 '24 21:06 ejwessel