Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MetaMask connector does not enforce chain in transactions (mobile). #4551

Open
1 task done
babkenmes opened this issue Feb 20, 2025 · 4 comments
Open
1 task done

MetaMask connector does not enforce chain in transactions (mobile). #4551

babkenmes opened this issue Feb 20, 2025 · 4 comments

Comments

@babkenmes
Copy link

Check existing issues

Describe the bug

When the chain sync is lost between the dApp and the MetaMask wallet application (e.g., due to a slow connection, connection reset, or MetaMask app restart), the dApp fails to recover and cannot enforce the correct chain in transactions.

Link to Minimal Reproducible Example

No response

Steps To Reproduce

Wrong chain reproduction

  • Connect MetaMask wallet using multiple chains in configs
  • Change the network from the wallet and close the wallet app
  • Now in the dApp the chain is the initial one and you can not sync and get the updated network chain ID
  • Initiate a transaction with chain ID and it will execute on the wrong chain

What Wagmi package(s) are you using?

@wagmi/connectors

Wagmi Package(s) Version(s)

[email protected]

Viem Version

[email protected]

TypeScript Version

No response

Anything else?

WalletConnect connector does enforce chain ID, it seems that the issue is with MetaMask SDK which does not support chain ID in eth_sendTransaction. I’m opening this issue here since the connector is implemented in this repository.

@christopherferreira9
Copy link

Hi @babkenmes ! Coming from the MetaMaskSDK here, do you see this happening with iOS, Android or both platforms?

@babkenmes
Copy link
Author

Hi @christopherferreira9. I have only tested it on iOS so far.

@christopherferreira9
Copy link

We are aware of this issue when using Android. Because all communication to send the new chainId is encrypted, closing the Wallet faster than the wallet is able to send this update will result in a missing event. In theory, this can happen in any time if the network conditions aren't at its best.
We're already planing to work towards changing this but for the time being we don't have an established ETA for it just yet.

It seems to be working under normal conditions but a network throttle can certainly cause these issues.

Screen.Recording.2025-02-21.at.1.35.40.PM.mov

@babkenmes
Copy link
Author

babkenmes commented Feb 21, 2025

Thank you for your quick response and explanation. In our case, the issue arises when users unknowingly initiate transfers from the wrong chain, putting them in a potentially risky situation.
In our dApp, we have fixed the issue by implementing the WalletConnect connector.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants