rainbow-me / rainbowkit

The best way to connect a wallet 🌈 🧰
https://rainbowkit.com
MIT License
2.45k stars 667 forks source link

[bug] WalletConnect connector creates multiple instances and gets unsynced from the app #2232

Open iceanddust opened 1 month ago

iceanddust commented 1 month ago

Is there an existing issue for this?

RainbowKit Version

2.2.0

wagmi Version

2.12.25

Current Behavior

After connecting to the WalletConnect connector and reloading the app, a second instance of the connected connector is created, which prevents the wallet from notifying the app about changes, and eventually throwing a Error: No matching key. history: <number> error.

I double checked and this is not an issue if I directly connect through Wagmi's WalletConnect connector. I also tried connecting through WC with a Safe Wallet and a Metamask wallet and could reproduce the problem in both cases.

Expected Behavior

The WalletConnect connection should keep working between reloads of the app, or worst case scenario, it should automatically disconnect on reloads to prevent the bad UX for the user using the app

Steps To Reproduce

This error seems to affect all messages sent from the wallet to the app, I've also experienced it with transaction statuses on a larger app, where the wallet never notifies the app about confirmed, successful or transactions with errors

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

https://stackblitz.com/edit/new-wagmi-bfc6lr?file=src%2Fwagmi.ts%3AL7

Anything else?

No response

generatorpoint commented 3 weeks ago

@DanielSinclair can you have a look at this issue? It's preventing Rainbow users from connecting with Safe and WalletConnect