Closed siosio34 closed 5 months ago
Hi @siosio34 .
As we've said before in those other issues, MetaMask only supports a subset of the WalletConnect protocol.
In fact, there are two parts for it.
The first is that wallet_switchEthereumChain
will work the first time the user tries to change chain programatically but in all subsequent requests the wallet gets no request whatsoever. Without a request there is no possibility of acting upon.
Here's an example:
ethersProvider.provider.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: '0xa4b1' }]
})
Here's the video:
https://github.com/MetaMask/metamask-mobile/assets/104831203/4e96c86f-e911-4f0f-8c38-a52f6cad35cf
Details about the video:
The second part to it is that if the dapp is on a different chain that the wallet has active and the user tries to sign he should get a request asking to switch to the Chain on the dapp side:
https://github.com/MetaMask/metamask-mobile/assets/104831203/6d355e5b-6b96-4cda-a14b-9e008526f858
I hope to have clarified this issue.
@christopherferreira9
The first thing you said is that you think this issue is caused by WalletConnect not sending any requests to the Metamask wallet?
If no logs are received, I think the opinion is valid and I think I will have to ask WalletConnect about the issue again.
Hey @siosio34 @christopherferreira9, chiming in from WalletConnect team. I think there is misunderstanding in the expectations how chain switching should work and how its actually working. In WalletConnect v2, chain switching is done locally on the dapp side on all chains that were approved in the session. This means that users can switch between all approved chains without being required to approve the switch in their wallets.
If user tries to switch to chain that is not yet approved, the switch chain is sent to the wallet for approval. This allows the wallet to switch to that chain but also update the current session with appropriate address for that new chain.
This behaviour is consistent with @christopherferreira9 explanation above where only the first chain switch is sent to the wallet and all after are done locally without any request to the wallet.The chains were already approved for the session after all.
I hope this clarifies how chain switching works and why sometimes you're not receiving any prompt in the wallet
@ganchoradkov I understand what you are saying. However, although it also depends on the issue link in the text, the two issues below do not seem to be a normal flow for the average user. If this was intentional, please let me know.
first Unlike desktops, chain change requests do not work smoothly on mobile devices. second If it is connected to a chain different from Ethereum, the chain is unnecessarily switched to the Ethereum chain when calling the sign function.
In WalletConnect v2, chain switching is done locally on the dapp side on all chains that were approved in the session. This means that users can switch between all approved chains without being required to approve the switch in their wallets.
I'm currently struggling with this, in combination with the limitation of metamask only supporting 1 network for the requiredNamespace. https://github.com/WalletConnect/WalletConnectKotlinV2/issues/1325
If we can only request 1 network, the user can never switch between all approved chains, because they can only request 1.
Hi all. I'm closing this issue but I'll be sure to reference it if we ever change this behaviour when interacting with WalletConnect.
Describe the bug
There are many issues where switch chain does not work within walletconnect as shown below.
https://github.com/MetaMask/metamask-mobile/issues/6655 https://github.com/MetaMask/metamask-mobile/issues/7206 https://github.com/MetaMask/metamask-mobile/issues/7878 https://github.com/WalletConnect/walletconnect-monorepo/issues/4089 https://github.com/wevm/wagmi/issues/3350 https://github.com/wevm/references/issues/393
If other wallet applications don't work, you'd think it's an issue with walletconnect, but it hasn't been resolved only in metamask mobile for several months.
This issue has been posted not only on MetaMask but also on wagmi and walletconnect repo. However, they are saying that it is not their fault because this issue only occurred on MetaMask Mobile, and in fact, it seems that this issue is a MetaMask Mobile issue. I'm wondering if the reason it hasn't been resolved for several months is a technical issue or if it's just not planned for support in the future.
Depending on the answer, we need to change the UX so that the switchNetwork function is not called for mobile users.
Expected behavior
No response
Screenshots/Recordings
No response
Steps to reproduce
call switchNetwork in metamask mobile via walletconnect2
Error messages or log output
No response
Version
all metamask mobile version
Build type
None
Device
all device
Operating system
iOS, Android
Additional context
No response
Severity
No response