rainbowkit icon indicating copy to clipboard operation
rainbowkit copied to clipboard

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

Open futantan opened this issue 1 year ago • 6 comments

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 avatar May 31 '24 08:05 futantan

@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

0xmkh avatar May 31 '24 11:05 0xmkh

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

0xmkh avatar May 31 '24 11:05 0xmkh

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 avatar May 31 '24 12:05 futantan

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

0xmkh avatar May 31 '24 22:05 0xmkh

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 avatar Jun 01 '24 01:06 futantan

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

0xmkh avatar Jun 02 '24 15:06 0xmkh

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

0xmkh avatar Jul 17 '24 09:07 0xmkh