metamask-mobile
metamask-mobile copied to clipboard
[FIX] Fixed ERC20 token transfer from Dapps
Description Currently, the app will not allow Dapps ERC20 token transactions unless a gas price is specified in the initial request. The TransactionEditor will prompt an error message stating “Invalid Amount” and the Confirm button will be disabled.
Proposed Solution The proposed solution is that we stop verifying the gasPrice from dapp when we open the Transaction Review component, I believe do not make sense this validation because:
- We mostly don't use the gasPrice sent from dapps, we calculate it through our gas fee controller
- Dapps like uniswap dont send the gasPrice and we update the gasPrice by ourselves
Also updated the error message to be more precise for what's missing
Also did some code cleaning of one variable that weren't being used
Code Impact Low, will just impact the transaction modal of dapp transfers.
Test Cases It's important to test as welll all the types of transactions (legacy, EIP1559, etc).
Case1: (Also it's a way to reproduce the issue on main branch)
- Clone test-dapp from metamask github
- Open test-dapp with your editor
- Follow the read me instructions to run the dapp in localhost
- Remove line 576 to 578 of src/index.js
- Open metamask mobile app
- Browse http://localhost:9011/
- Press Create token
- Press Transfer tokens without gas
- Modal will open and everything will be okay (no warning with "Invalid value" )
TOP13 Dapps test cases
Metamask Test Dapp
| Action name | Main | PR | Error/Warning |
|---|---|---|---|
| Rinkeby Network | |||
| CONNECT | ✅ | ✅ | |
| ETH_ACCOUNTS | ✅ | ✅ | |
| REQUEST PERMISSIONS | ❌ | ❌ | Main & PR - Console Warning: The method wallet_requestPermissions does not exist/is not available |
| GET PERMISSIONS | ❌ | ❌ | Main & PR - Console Warning: The method wallet_getPermissions does not exist/is not available |
| SEND LEGACY TX | ✅ | ✅ | |
| SEND EIP 1559 TX | ✅ | ✅ | |
| DEPLOY CONTRACT | ✅ | ✅ | |
| DEPOSIT | ❌ | ❌ | Main & PR - Console Warning: Insufficient funds for gas * price + value |
| WITHDRAW | ❌ | ❌ | Main & PR - Console Warning: Error: Execution Reverted |
| DEPLOY FAILING CONTRACT | ✅ | ✅ | |
| SEND FAILING TX | ❌ | ❌ | Main & PR - Console Warning: Eror: invalid opcode: INVALID |
| CREATE TOKEN | ✅ | ✅ | |
| ADD TOKEN TO WALLET | ✅ | ✅ | |
| TRANSFER TOKENS | ✅ | ✅ | |
| APPROVE TOKENS | ✅ | ✅ | |
| TRANSFER TOKENS WITHOUT GAS | ✅ | ✅ | |
| APPROVE TOKENS WITHOUT GAS | ✅ | ✅ | |
| DEPLOY COLLECTIBLE | ✅ | ✅ | |
| MINT COLLECTIBLE | ✅ | ✅ | |
| GET ENCRYPTION KEY | ❌ | ❌ | Main & PR - Console Warning: Error: The method eth_getEcryptionPubilcKey does not exist/is not available |
| ETH SIGN | ✅ | ✅ | |
| PERSONAL SIGN | ✅ | ✅ | |
| PERSONAL SIGN VERIFY | ✅ | ✅ | |
| SIGN TYPED DATA | ✅ | ✅ | |
| SIGN TYPED DATA VERIFY | ✅ | ✅ | |
| SIGN TYPED DATA V3 | ✅ | ✅ | |
| SIGN TYPED DATA V3 VERIFY | ✅ | ✅ | |
| SIGN TYPED DATA V4 | ✅ | ✅ | |
| SIGN TYPED DATA V4 VERIFY | ✅ | ✅ | |
| ADD XDAI CHAIN | ✅ | ✅ | |
| SWITCH TO XDAI CHAIN | ✅ | ✅ | |
| SEND FROM | ✅ | ✅ | MAIN & PR - Weird Behaviour: When DAPP choose to give 0 to the Gas Price we are not handling it and the tx will be underpriced. Is this the expected behaviour? |
pancakeswap
| Action name | Main | PR | Error/Warning |
|---|---|---|---|
| Binance Smart Chain | |||
| Swap BNB - CAKE | ✅ | ✅ |
Open sea testnet
| Action name | Main | PR | Error/Warning |
|---|---|---|---|
| rinkeby network | |||
| Buy NFT | ✅ | ✅ |
swap.test.btcs.network
| Action name | Main | PR | Error/Warning |
|---|---|---|---|
| rinkeby network | |||
| Swap | Unable | Unable |
play.pegaxy.io
| Action name | Main | PR | Error/Warning |
|---|---|---|---|
| Polygon Mainnet | |||
| Bid on marketplace | ✅ | ✅ | Did not submitted the bid but everything went's normal. Console warning: error:execution reverted: MarketService: query for nonexistent bider Also after press bid on marketplace we can't do anything more because it's rendered a white screen on the middle of the website |
app.uniswap.org
| Action name | Main | PR | Error/Warning |
|---|---|---|---|
| rinkeby network | |||
| Swap eth -> UNI | ✅ | ✅ |
poocoin.app
| Action name | Main | PR | Error/Warning |
|---|---|---|---|
| Binance Smart Chain | |||
| Swap BNB -> Poocoin | ✅ | ✅ | Console warning: [MetaMask DEBUG]: Error: execution reverted: Pancake Router: INSUFFICIENT_OUTPUT_AMOUNT |
crazydefenseheroes.com
| Action name | Main | PR | Error/Warning |
|---|---|---|---|
| Polygon network | |||
| Swap matic -> Tower | ✅ | ✅ | ONLY PR: If try to swap 0.0001 matic to tower: Main & PR - Console Warning: Insufficient funds for gas * price + value ❌ ONLY MAIN: internal JSON-RPC error ❌ PR & MINA swap 0.001 works ✅ Console warning: null is not an object (evaluating block hash) Console error: Sentry Error: An event processor returned null, will not send event |
| Added tower token to MM | ❌ | ❌ | when Pressed left menu option acitvities after added the token tower: Error in Desktop folder name tower token error |
| UPDATE: crazydefenseheroes swap is not working on the latest test, error from their platform |
validator.test.btcs.network
| Action name | Main | PR | Error/Warning |
|---|---|---|---|
| Every network | |||
| Connect Wallet | ? | ? | It seems to connect in every network but happens weird stuff. When we try to connect, there is a warning that says the network is not recognized, but if you change the network or the wallet, the dapp seems to connect automatically |
sunflower-land.com
| Action name | Main | PR | Error/Warning |
|---|---|---|---|
| Polygon Mainnet | |||
| (quickswap.exchange) Swap matic (0,00001) -> DAI | ✅ | ✅ |
drip.community
| Action name | Main | PR | Error/Warning |
|---|---|---|---|
| Binance Smart Chain mainnet | |||
| Console.warning: Error opening URL: Error: Unable to open URL: about: srcdoc: Add about to LS ApplicationQueriesSchemes in your info.plist. | |||
| Connect wallet | Console.warning: Error: execution reverted: token sold < 0 | ||
| Buy DRIP (0.0001 BNB) | ✅ | ✅ | |
| Sell DRIP (0.001) | ❌ | ✅ | Main: Transaction error internal JSON-RPC error |
traderjoexyz.com
| Action name | Main | PR | Error/Warning |
|---|---|---|---|
| Avalanche C-Chain | |||
| Swap avax -> USDC | ✅ | ✅ |
bakedbeans.io
| Action name | Main | PR | Error/Warning |
|---|---|---|---|
| Binance Smart Chain mainnet | |||
| Connect wallet | Console warning: Error: execution reverted | ||
| Bake beans | ✅ | ✅ |
Screenshots/Recordings
| Bug | Solution |
|---|---|
![]() |
![]() |
Checklist
- [x] There is a related GitHub issue
- [ ] Tests are included if applicable
- [ ] Any added code is fully documented
Issue
Progresses #3999
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.
This PR is still a draft. Please update the PR to be Open. PR's that are Drafts will be removed from QA Board and put back on dev-review.
Any estimated time when this will be merged? Thanks.
We are getting there @tommasini ! Your fix for issue 1 looks good. I did however uncover another bug. A regression bug with gasless transactions. Basically, whenever I try to submit a gasless transaction, I get: [TypeError: undefined is not an object (evaluating 'inputBn.toString')] See screen capture here

