-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connector fails to update chain after wallet chain switch and page refresh #3998
Comments
Looks like a MetaMask Chrome extension issue. You can reproduce by running RPC requests in the browser console directly. // start with extension on mainnet, then request accounts:
> await window.ethereum.request({ method: 'eth_requestAccounts' })
[...]
> await window.ethereum.request({ method: 'eth_chainId' })
'0x1'
> await window.ethereum.request({ method: 'wallet_switchEthereumChain', params: [{ chainId: '0x89' }] })
> await window.ethereum.request({ method: 'eth_chainId' })
'0x89'
// switch in mm extension ui, then run the following:
> await window.ethereum.request({ method: 'eth_chainId' })
'0x89' // should be 0x1 In the video, you can see that the listener is fired for when the chain switches back to Mainnet via the MetaMask extension UI, but when you call 'eth_chainId' again, the response is not updated. 000930_Google.Chrome_2024-06-06-16.48.44.mp4Confirmed that this is not an issue with the MetaMask Firefox Add-on or Rainbow Chrome extension. |
Linking up MetaMask/metamask-extension#25097 |
Small patch if anyone wants to apply while MM fixes the issue |
@tmm thank you for taking a look! I'll track MM issue 🙂 |
This issue has been locked since it has been closed for more than 14 days. If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Wagmi version. If you have any questions or comments you can create a new discussion thread. |
Check existing issues
Describe the bug
After establishing the connection and changing the chain in the wallet, the new chain doesn't get picked up after the page refresh, and the connector shows the initially connected chain.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/vitejs-vite-wdirrm
Steps To Reproduce
What Wagmi package(s) are you using?
wagmi, @wagmi/connectors
Wagmi Version
2.9.6
Viem Version
2.12.1
TypeScript Version
No response
Anything else?
This also affects all hooks returning current chain information like
useAccount
The text was updated successfully, but these errors were encountered: