rainbow-me / rainbowkit

The best way to connect a wallet 🌈 🧰

Home Page:https://rainbowkit.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[bug] Every time we connect with walletconnect, it will connect to a different chain

futantan opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

RainbowKit Version

2.1.1

wagmi Version

1.4.11

Current Behavior

Every time we connect with walletconnect, it will connect to a different chain.
Even I added initialChain={137} to RainbowKitProvider component

Expected Behavior

Connect to initialChain

Steps To Reproduce

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

No response

Anything else?

No response

commented

@futantan Which wallet are you using ? I tried with Rainbow wallet and works fine. You can even test it in our example dApp here https://rainbowkit-example.vercel.app

commented

Also if you can provide a small reproducible example that'd be super helpful

CleanShot.2024-05-31.at.20.21.15.mp4

hi @magiziz thanks for your quick response, I added a video recording, I'm using OKX web3 wallet

commented

@futantan This seems to be a OKX wallet specific issue. For most wallets it should work fine.

hi @magiziz actually this only happen for RainbowKit 2.x, for 1.x version, it works fine.
we find this after upgrading to 2.x

commented

@futantan I see. Seems to be either a WalletConnect issue with wagmi v2 or the way how OKX wallet handles the WalletConnect connection. Going to pass this to the wagmi team and come back to you as soon as possible 👍

commented

@futantan Looked into this a bit more and seems like the code is the same for Wagmi v1 here, and for v2 here.

I've tested this with a few wallets and they work fine, but for some wallets it might not connect to the desired chain. This might be an issue with their latest WalletConnect peer dependency (@walletconnect/ethereum-provider).

You can reproduce this by calling connect function from useConnect hook and pass in a custom chainId. Here is the documentation if it's helpful https://wagmi.sh/react/api/hooks/useConnect#mutate.

If you feel like this is a bug you can raise an issue on Wagmi's repo here https://github.com/wevm/wagmi.