web3-onboard icon indicating copy to clipboard operation
web3-onboard copied to clipboard

[Bug]: addEthereumChain/setChain Operation On Wallet Connect Not Working

Open mbcse opened this issue 3 years ago • 12 comments

Current Behavior

Once we are connected to meta mask mobile through the wallet connect and try to switch to another chain. These things happen

All this happens on both set chain functions provided by block native and if I do provider.request("switch_ethereumChain")

  • If Network Already exists in meta mask => Switch Chain Happens - No problem
  • If Network Doesn't Exist => Nothing Happens, If I try to do provider.request("wallet_addEthereumChain") it fails and gives an error "The Provider does not have a rpcUrl to make a request for the requested method: wallet_addEthereumChain" or Nothing Happens

On the web3Onbaord demo site as well, the switching chain doesn't work when connected through wallet connect to meta mask mobile.

The setChain of web3onboard also doesn't work for this case!

Expected Behavior

wallet_addEthereumChain request should add a new chain to the meta mask mobile of the user when connected through wallet connect

Steps To Reproduce

No response

What package is affected by this issue?

@web3-onboard/core @web3-onboard/walletconnect

Is this a build or a runtime issue?

Runtime

Package Version

2.8.5-alpha.1

Node Version

v16.19.0

What browsers are you seeing the problem on?

Firefox, Chrome, Safari, Microsoft Edge

Relevant log output

Error: The Provider does not have a rpcUrl to make a request for the requested method: wallet_addEthereumChain

Anything else?

No response

Sanity Check

  • [X] If this is a build issue, I have included my build config. If this is a runtime issue, I have included reproduction steps and/or a Minimal, Reproducible Example.

mbcse avatar Feb 09 '23 14:02 mbcse

@mbcse Thank you for bringing this to our attention we will try to repro and discover what the issue is! Stay tuned here 📻

taylorjdawson avatar Feb 09 '23 22:02 taylorjdawson

any update on this @taylorjdawson, i observe you are still using walletconnect v1 sdk.. they have updated to v2 it seems.

saisumit avatar Feb 27 '23 13:02 saisumit

Screenshot 2023-02-27 at 6 52 41 PM

saisumit avatar Feb 27 '23 13:02 saisumit

Hey @saisumit I am not sure if we have looked in to this yet, but we are actively implementing V2 with the WC team. Keep an eye out for an update soon for V2.

lnbc1QWFyb24 avatar Feb 28 '23 03:02 lnbc1QWFyb24

@saisumit the latest version of walletconnect package integrates v2 of walletconnect as they are sunsetting v1 shortly...can you give it a try when you have a moment? There are a couple of extra init options to get to v2 rolling but shouldnt take more than a few minutes - https://www.npmjs.com/package/@web3-onboard/walletconnect

Adamj1232 avatar Feb 28 '23 21:02 Adamj1232

@saisumit are you still seeing this issue with WalletConnect v2 package?

Adamj1232 avatar Mar 15 '23 16:03 Adamj1232

Closing as the issue is stale and there hasnt been response. Feel free to open if the issue persists.

Adamj1232 avatar Mar 20 '23 17:03 Adamj1232

Hi @Adamj1232 , I am Still facing this issue.

When setChain is called on both onboard or using useSetChain from @web3-onboard/react nothing happens on the wallet app connected via Walletconnect. The functions return false and no error is logged. Tested with rainbow and metamask mobile, the issue is still there.

Here's the packages I am using:

"@web3-onboard/core": "^2.17.0", "@web3-onboard/walletconnect": "2.3.6", "@web3-onboard/react": "^2.8.0",

My Init Script:

const wcV1InitOptions = {
   bridge: "https://bridge.walletconnect.org",
};
const wcV2InitOptions = {
   version: 2,
   /**
    * Project ID associated with [WalletConnect account](https://cloud.walletconnect.com)
    */
   projectId: "XXXXXXXXXXXXX",
   /**
    * Optional function to handle WalletConnect URI when it becomes available
    */
   handleUri: uri => console.log(uri),
};

// initialize the module with options
// If version isn't set it will default to V1 until V1 sunset
const walletConnectModule = walletConnect(wcV2InitOptions || wcV1InitOptions);

export const initWeb3Onboard = init({
   wallets: [injected, ledger, trezor, walletConnectModule, fortmatic],
   chains: supportedChains(),

   apiKey: dappId,
   appMetadata: {
       name,
       icon, // svg string icon
       logo, // svg string logo
       description, // App Description
         explore, // Link to website
   },
   accountCenter: {
       desktop: {
           position: "topRight",
           enabled: false,
           minimal: false,
       },
       mobile: {
           position: "topRight",
           enabled: false,
           minimal: false,
       },
   },
});

Is there anything I am missing here?

sriramkasyap avatar Apr 25 '23 05:04 sriramkasyap

@Adamj1232 WalletConnect V2 does not work. It does not even work on the demo app of web3 onboard. Can you pl look into it.

devamitsharma101 avatar Apr 26 '23 06:04 devamitsharma101

@devamitsharma101 which site(device/browser is also helpful) is this? Which wallet are you trying to connect through WC v2?

Adamj1232 avatar Apr 26 '23 08:04 Adamj1232

@Adamj1232 I'm trying the Connect button on top right corner of the site: https://onboard.blocknative.com/ . There I choose wallet connect and scan the code from metamask on my mobile.

devamitsharma101 avatar Apr 26 '23 08:04 devamitsharma101

@devamitsharma101 MetaMask has not integrated with WalletConnect v2. Please see the WalletConnect blog for more information around support dates and supported wallets - https://medium.com/walletconnect/weve-reset-the-clock-on-the-walletconnect-v1-0-shutdown-now-scheduled-for-june-28-2023-ead2d953b595

Adamj1232 avatar Apr 28 '23 17:04 Adamj1232