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

ConnectButton Displays Wallet Connected to Last Stored Chain, Not Current Chain in MetaMask

QalbeHabib opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

RainbowKit Version

2.0.5

wagmi Version

2.5.20

Current Behavior

I encountered an issue when using RainbowKit with MetaMask in my application as well as in some of the popular application like

https://www.rainbowkit.com/docs/connect-button
https://app.cabana.fi/
https://www.base.org/ecosystem
https://swap.defillama.com/
https://pro.opensea.io/

. The problem arises when the user changes the network in MetaMask after initially connecting to the application. Here are the steps to reproduce the issue:

Connect to the application using MetaMask.
Ensure MetaMask is connected to a supported chain.
Change the network in MetaMask to the unsupported chain.
Reload the browser tab.
It shows the connected button with the last chain instead of showing "Wrong wallet" as the chain is not supported in Metamask.

Expected Behavior

  • The ConnectButton in the application should reflect the current network selected in MetaMask.
  • If the network is not supported, the button should display "Wrong network." instead it connects to the last chain Id.

Steps To Reproduce

  1. Connect to the application with MetaMask on a supported chain.
  2. Change the network in MetaMask to another supported chain.
  3. Observe the ConnectButton showing "Wrong network."
  4. Reload the page.
  5. Observe the ConnectButton displaying the wallet connected to the last stored chain, not the current chain in MetaMask.

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

No response

Anything else?

I have attached a reference video showcasing the issue for better understanding: Watch Video

The video demonstrates the problem where the ConnectButton displays the wallet connected to the last stored chain instead of the current chain in MetaMask after a network change. This issue is reproducible and affects user experience, especially in scenarios where network changes are frequent.

Your attention to this matter and feedback on resolving this issue would be highly appreciated.

commented

@QalbeHabib Thanks for spotting the bug, i'm able to reproduce this as well. We've had a few unusual behaviors from MetaMask lately and i'll report this to the Wagmi team 👍

commented

@QalbeHabib This seems to be a MetaMask issue. Wagmi is also impacted by this wevm/wagmi#3998

commented

Closing this issue since this is a MetaMask specific issue which is impacted by all dApps.