reown-com / appkit

The full stack toolkit to build onchain app UX
https://reown.com/appkit
Apache License 2.0
4.94k stars 1.41k forks source link

[bug] MetaMask mobile wallet connects successfully with unsupported chain (displays 'Chain 1") #1415

Closed meri-maki closed 1 year ago

meri-maki commented 1 year ago

Link to minimal reproducible example

https://github.com/meri-maki/useSwitchNetwork

Summary

I have a project that should only work with certain chains [polygon, arbitrum, bsc, sepolia] When I connect my mobile Matamask wallet (either with WalletConnect or from list of wallets on mobile) with Etherium chain selected, it connects with no errors

Web3Modal Network button displays it as 'Chain 1'

Снимок экрана 2023-10-23 в 21 19 43

This is very confusing behavior... How is it possible for Metamask to even connect to the unsupported chain?

This can be replicated on local host with min rep example

List of related npm package versions

    "@web3modal/wagmi": "^3.1.0",
    "viem": "^1.16.2",
    "wagmi": "^1.4.3"
glitch-txs commented 1 year ago

MetaMask will connect to the chain you have opened in the mobile wallet app not the website

meri-maki commented 1 year ago

@glitch-txs is there any way around it...? Why it's displayed as "Chain 1"?

meri-maki commented 1 year ago

The one fix I found is to declare defaultChain, but we would like to avoid this behavior

meri-maki commented 1 year ago

@glitch-txs do you think it's reasonable to mention this issue on wagmi? or is this issue exclusive to mm mobile wallet, and there is nothing we can do?

glitch-txs commented 1 year ago

you can open an issue in MetaMask mobile repository, it's on their end only.