metamask-extension
metamask-extension copied to clipboard
fix: Fix issue 25285 max insufficient funds for gas
Description
When performing a send or swap+send there are two outstanding issues:
- 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.
- 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
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 |
- click on 'Send'
- perform a 'Send' or 'Swap + Send' based on the above table
- 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
After
Pre-merge author checklist
- [ ] I've followed MetaMask Contributor Docs and MetaMask Extension Coding Standards.
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using JSDoc format if applicable
- [ ] I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
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.