rainbow-me / rainbowkit

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

[bug] Website auto-connecting to MM extension wallet even after disconnecting #2021

Open futantan opened 1 month ago

futantan commented 1 month ago

Is there an existing issue for this?

RainbowKit Version

2.1.1

wagmi Version

2.9.8

Current Behavior

When disconnect, the website will connect to previous wallet

Expected Behavior

Disconnect from all wallets

Steps To Reproduce

https://github.com/rainbow-me/rainbowkit/assets/6268441/0497a6dd-fc2c-45c7-84f7-97ebf4cea158

  1. Visit https://www.rainbowkit.com/docs/introduction
  2. Connect MetaMask extension wallet
  3. Disconnect MetaMask extension wallet and connect OKX wallet with WalletConnect
  4. Click Disconnect button

It will disconnect the OKX wallet, and connect to MetaMask wallet immediately

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

No response

Anything else?

No response

magiziz commented 1 month ago

Wagmi supports multiple wallet connections at once by default.

It will also reconnect on mount to multiple wallets which you've connected before. You can set reconnectOnMount to false in <WagmiProvider>. Check out the docs for reference here https://wagmi.sh/react/api/WagmiProvider#reconnectonmount

futantan commented 1 month ago

hi @magiziz thanks for your suggestion, but this won't fix the issue, and this is not the expected behavior. because once we add reconnectOnMount to false, when we connect to Metamask and refresh the page, the connect will lost.

We found this issue when upgrading from 1.x to 2.x

DanielSinclair commented 1 month ago

@futantan I see! Wagmi has a feature called "shim disconnects" that will remember which connector has been disconnected, and avoid reconnecting that connector on the next mount. There is an outstanding issue that seems to exist inside of Wagmi that we are currently investigating with the Wagmi team. We hope this will be resolved soon. https://github.com/wevm/wagmi/issues/3606

futantan commented 1 month ago

thank you @DanielSinclair how about we reopen this issue to track how it goes?