Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

bug: incorrect initialization of chains for WalletConnect V2 ethereum provider #469

Closed
1 task done
ElvisKrop opened this issue Aug 8, 2023 · 1 comment
Closed
1 task done

Comments

@ElvisKrop
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

This is applicable to the connection between any dapp that supports more than one network and wallet that doesn't support the first network from the list of supported networks by the previously mentioned dapp.

Expected Behavior

WalletConnect Connector from Wagmi should not pass any chain id to the array of chains during initialization of WalletConnect. In this case all chain ids will be optional. I will allow to initiate the connection even if wallet supports on network from the list of supported networks by the dapp.

Steps To Reproduce

At first let's go to the Revoke Cash:

  1. open revoke.cash in one tab (it uses wagmi)
  2. click "Connect Wallet"
  3. choose "WalletConnect"

The second part:

  1. open app.safe.global
  2. switch to any network supported by revoke.cash, except Ethereum mainnet
  3. open WalletConnect safe app

Then copy the connection link from Revoke Cash and paste on the pre-opened WalletConnect Safe App.

The error in console says:

Connection refused: This Safe Account is in Goerli but the Wallet Connect session proposal is not valid because it contains: 1) A required chain different than Goerli 2) Does not include Goerli between the optional chains 3) No EVM compatible chain is included

What happened:

WalletConnect Safe App is a safe app that allows to use safe as a wallet. However, each safe exists only on one network. Therefore WalletConnect Safe App initiates the connection with only one allowed network.
While dapp supports multiple networks. During initialization of WalletConnect connector from Wagmi dapp passes all chain ids as an argument. Then Wagmi takes all these networks and passes only the first chain id to the Ethereum provider from WalletConnect package. It is not correct, because this array should include required chain ids (see the comment):

The Chains your app intents to use and the peer MUST support. If the peer does not support these chains, the connection will be rejected.
In our case the first chain id is 1 (Ethereum Mainnet), but we need 5 (Goerli Testnet)

Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)

No response

Anything else?

No response

@tmm
Copy link
Member

tmm commented Sep 1, 2023

If this issue still exists in the current version of Wagmi, please create a new issue on the Wagmi repo. Connectors are moving over there.

@tmm tmm closed this as not planned Won't fix, can't repro, duplicate, stale Sep 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants