[bug] Every time we connect with walletconnect, it will connect to a different chain
Is there an existing issue for this?
- [X] 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
- open https://www.rainbowkit.com/ and connect wallet
- choose WalletConnect
- scan qr code with wallet and disconnect
- repeat
Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)
No response
Anything else?
No response
@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
Also if you can provide a small reproducible example that'd be super helpful
https://github.com/rainbow-me/rainbowkit/assets/6268441/0cbf4068-da56-408a-afc6-94468a570bb8
hi @magiziz thanks for your quick response, I added a video recording, I'm using OKX web3 wallet
@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
@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 👍
@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.