GithubHelp home page GithubHelp logo

Comments (6)

christopherferreira9 avatar christopherferreira9 commented on June 13, 2024

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:

chainRequest.mov

Details about the video:

  • Wallet logs on the left, dapp in the middle and screen recording of the wallet on the right
  • At 0:16, right after connecting you can see me tap the "Switch chain" button and that prompts a chain request on the wallet
  • This first chain change request was manually denied on the wallet
  • At 0:26 you can see my prompting the second chain switch (keep in mind that the first request was denied so there hasn't been an approved chain switch request yet)
  • At 0:40 I manually switch chains on the wallet side and that gets synced on the dapp side
  • At 0:52 you can see that no matter how many times I try to prompt a chain switch there are no logs coming in, meaning that there is no request being sent to the wallet.

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:

askbefore.mov

I hope to have clarified this issue.

from metamask-mobile.

siosio34 avatar siosio34 commented on June 13, 2024

@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.

from metamask-mobile.

ganchoradkov avatar ganchoradkov commented on June 13, 2024

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

from metamask-mobile.

siosio34 avatar siosio34 commented on June 13, 2024

@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.

from metamask-mobile.

BradMoeller avatar BradMoeller commented on June 13, 2024

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. WalletConnect/WalletConnectKotlinV2#1325

If we can only request 1 network, the user can never switch between all approved chains, because they can only request 1.

from metamask-mobile.

christopherferreira9 avatar christopherferreira9 commented on June 13, 2024

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.

from metamask-mobile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.