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

Switch Network popup #67

Open
VivekMakwana24 opened this issue Aug 2, 2022 · 15 comments
Open

Switch Network popup #67

VivekMakwana24 opened this issue Aug 2, 2022 · 15 comments

Comments

@VivekMakwana24
Copy link

Hello,

Is there a way in which I can provide a SwitchNetwork popup to the user?

just like the below-attached screenshot

Image from iOS

@VivekMakwana24
Copy link
Author

Does any one have any idea about showing the switch network popup?

@RootSoft
Copy link
Owner

RootSoft commented Aug 8, 2022

Are you trying to show a popup in your own wallet or call the MetaMask switch network popup?

@VivekMakwana24
Copy link
Author

VivekMakwana24 commented Aug 8, 2022

@RootSoft I want to call the MetaMask switchNetwork popup,

@VivekMakwana24
Copy link
Author

@RootSoft Could you please update on this?
Thanks :)

@VivekMakwana24
Copy link
Author

@RootSoft Any update on my query?

@RootSoft
Copy link
Owner

@VivekMakwana24 I don't think it's possible to do that since that's native to MM, and I don't think they provide an API to show the switch network popup. Your best bet would be to ask in the MM repo?

@VivekMakwana24
Copy link
Author

Ok let me check with them,
I have found the below link, do you think it will be useful?
https://community.metamask.io/t/how-to-send-switch-network-request-from-dapp-to-metamask-mobile/13501

@VivekMakwana24
Copy link
Author

VivekMakwana24 commented Aug 17, 2022

@RootSoft
Below is the code that I have tried, but unfortunately I am not getting any response from it.

`

Future<dynamic> switchNetwork() async {
    final request = JsonRpcRequest(
      id: payloadId,
      method: 'wallet_switchEthereumChain',
      params: [
        {
          "chainId": "0xa86a",
        }
      ],
    );

    session.handshakeId = request.id;
    session.handshakeTopic = const Uuid().v4();

    debugPrint("req2 ${request.toJson()}");

    final response = await sendRequest(request, topic: session.handshakeTopic);
    debugPrint("response ${response}");

    return response;
  }

`
Request : {id: 1660718671093646, jsonrpc: 2.0, method: wallet_switchEthereumChain, params: [{chainId: 0xa86a}]}
Response : null

@robmagario
Copy link

Any updates on this issue? I am also trying to switch the network but no luck.

@VivekMakwana24
Copy link
Author

@robmagario No, I have tried by contacting the walletConnect community but no solution yet

@RootSoft
Copy link
Owner

@VivekMakwana24 I think you'll have to dig in the Metamask source code. Maybe build the app and step through it.
Unfortunately, at the moment I don't have a lot of time to dig deep into this. This is more related to Metamask then WC in my opinion.

@olegys
Copy link

olegys commented Oct 1, 2022

@VivekMakwana24 Try this

await connector.sendCustomRequest( method: 'wallet_switchEthereumChain', params: [ { 'chainId': '0x${provider.chainId.toRadixString(16)}', }, ], );

@VivekMakwana24
Copy link
Author

@olegys Did it worked with metamask?

@olegys
Copy link

olegys commented Oct 3, 2022

@VivekMakwana24 Yes

@VivekMakwana24
Copy link
Author

@olegys

This is how I have tried it, But Unfortunately, I am receiving null response.

I tried to call this method before launching the walletURI for connection.

Is it the correct flow?

Screenshot from 2022-10-04 18-45-11

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

4 participants