MetaMask / metamask-mobile

Mobile web browser providing access to websites that use the Ethereum blockchain
https://metamask.io
Other
2.16k stars 1.11k forks source link

wallet_switchEthereumChain not working from outside of metamask browser. #3546

Open frndxyz opened 2 years ago

frndxyz commented 2 years ago

Description

"wallet_switchEthereumChain" , "wallet_addEthereumChain" call not switching/adding chains when calling by wallet connect from native mobile browsers.

but it works when using metamask browser interface.

gantunesr commented 2 years ago

Hi @frndxyz, we're working on supporting both RPC methods for WalletConnect, can you indicate the dapp where the issue is presented?

mickeymond commented 2 years ago

@gantunesr I am adding this here because I thought it is an observation I made that will be useful to resolve this issue but if it is not prompt me or remove it.

I am using Metamask Mobile v4.0.1(814) at the moment.

@frndxyz I was looking for an issue that covered my observation above and yours was the quite closest one. Please let me know if we are both heading in the same direction.

tommasini commented 2 years ago

Thanks for reporting! Could you check if this is still happening on the last version, please?

mhm13dev commented 1 year ago

wallet_switchEthereumChain is not working anymore when using with Wallet Connect V2

mhm13dev commented 1 year ago

Here is an example with Wallet Connect V2 which does not switch the chain

https://github.com/mhm13dev/wagmi-wallet-connect-v2/tree/switch-eth-chain-wc-v2-metamask

mickeymond commented 1 year ago

@mhm13dev If you are trying to communicate that MetaMask Mobile does not support Wallet Connect V2 then I agree with you. I just tried connecting to an old project (https://nsfw.app) that I worked on some time ago that I am sure still uses Wallet Connect V1 and it was all good. However, connecting to something like https://app.ens.domains does not even give any prompt for a connection to be established.

I am using MetaMask Mobile v6.6.0(1114)

mhm13dev commented 1 year ago

@mickeymond Metamask Android v7 now supports Wallet Connect V2. I used it today.

Now the problem is that if I want to switch the chain while using Wallet Connect V2, the Metamask doesn't prompt me for changing the chain.

That's what I am reporting here.

mickeymond commented 1 year ago

@mickeymond Metamask Android v7 now supports Wallet Connect V2. I used it today.

Now the problem is that if I want to switch the chain while using Wallet Connect V2, the Metamask doesn't prompt me for changing the chain.

That's what I am reporting here.

@mhm13dev That is very interesting because I have been checking updates on the Google Play store and I see no updates for V7. I am in Ghana. Should I expect some delays?

mhm13dev commented 1 year ago

@mickeymond I am not sure how google play store schedule the releases.

I just updated today but google play store says it was updated on June 7. Screenshot_20230617-171440.jpg

Holybasil commented 1 year ago

IOS 16.5 + MetaMask v7.0.1(1126) + ConnectWallet V2

the Metamask doesn't prompt a "switch network" modal and doesn't throw error as well.

try{
    provider.request({
        method: "wallet_switchEthereumChain",
        params: [
          {
            chainId: numberToHex(id),
          },
        ],
    })
}catch(error){
    console.log(error) // nothing output
}

In the meanwhile, "wallet_addEthereumChain" works well. I hope that "wallet_switchEthereumChain" performs as well as it does in the MetaMask extension.

jurosh commented 5 months ago

Same issue here - WalletConnect on MM Android connecting to dApp on Desktop Browser. Using Ethers & Ethereum WalletConnect provider.

There is just no error after wallet_switchEthereumChain - it just returns null as success promise resolve which is incorrect when there is no chain. We don't know that we should call to add new chain - add call itself works.

In this issues seems to be also reported similar bug https://github.com/MetaMask/metamask-mobile/issues/6655

Edit: Adding chain is also not reliable at all. Needed to restart android app to make it pop-up.

calummoore commented 3 months ago

experiencing the same thing, the first wallet_switchEthereumChain works, but any further switches to new chains are just ignored by metamask.

Switching back to an existing chain, does switch the network (via walletconnect wc), but then metamask ignores any signatures sent to the "switched" network.