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
- Connect to the application with MetaMask on a supported chain.
- Change the network in MetaMask to another supported chain.
- Observe the ConnectButton showing "Wrong network."
- Reload the page.
- 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.
@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 👍
@QalbeHabib This seems to be a MetaMask issue. Wagmi is also impacted by this wevm/wagmi#3998
Closing this issue since this is a MetaMask specific issue which is impacted by all dApps.