blocknative / web3-onboard

Client library to onboard users to web3 apps
https://onboard.blocknative.com/
MIT License
854 stars 510 forks source link

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

Closed mbcse closed 1 year ago

mbcse commented 1 year ago

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")

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

taylorjdawson commented 1 year ago

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

saisumit commented 1 year ago

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

saisumit commented 1 year ago
Screenshot 2023-02-27 at 6 52 41 PM
lnbc1QWFyb24 commented 1 year ago

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.

Adamj1232 commented 1 year ago

@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 commented 1 year ago

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

Adamj1232 commented 1 year ago

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

sriramkasyap commented 1 year ago

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?

devamitsharma101 commented 1 year ago

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

Adamj1232 commented 1 year ago

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

devamitsharma101 commented 1 year ago

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

Adamj1232 commented 1 year ago

@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