-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
Describe the bug
When the "Selected networks for each site" toggle is enabled, the wallet API should use an origin-specific chain for all interactions. However this doesn't work correctly if the connection status has changed since the last refresh. If you grant permissions to a site or revoke them (i.e. connect to or disconnect from a site), the site does not work as expected until after the site is refreshed.
Expected behavior
The wallet API should always use the dapp-selected chain for sites with permissions, and should use the globally-selected chain for sites without permissions. This should apply even if the permissions have changed since the page loaded.
Screenshots/Recordings
This recording shows both reproduction use cases (granting permissions, then revoking)
queue-selected-chain-bug-2024-03-14_19.49.19.webm
Steps to reproduce
The problem presents itself in two scenarios: when granting site permissions, and when revoking all site permissions.
When granting permissions:
- Enable the "Selected networks for each site" toggle
- Open a site with no permissions in one tab, and the fullscreen wallet UI in another
- If the site was open already, hard-refresh before proceeding
- Call
eth_requestAccountson the site, asking for theeth_accountspermissions - Approve the request
- Call
eth_chainIdfrom the site, and see that it matches the wallet selected chain - Switch the selected chain in the fullscreen UI
- Call
eth_chainIdfrom the site, and see that it matches the wallet selected chain- It is not supposed to change. The expected behavior is for it to return the same answer as the first time. It should reflect the dapp-selected chain, not the globally selected chain.
When revoking permissions:
- Enable the "Selected networks for each site" toggle
- Open a site with permissions in one tab, and the fullscreen wallet UI in another
- If the site was open already, hard-refresh before proceeding
- Call
eth_chainIdfrom the site. If it matches the selected chain in the fullscreen wallet UI, switch the chain in the fullscreen wallet UI before proceeding. Calleth_chainIdagain to verify that it's different before proceeding. - Open the browser-action popup, click on the three-vertical-dots menu, click "Connected sites", then disconnect from the site
- Call
eth_chainIdfrom the site. See that it's still different from the selected chain in the fullscreen UI.- It is supposed to change. The expected behavior is for it to reflect the globally selected chain after permissions have been revoked.
Error messages or log output
No response
Version
develop
Build type
None
Browser
Chrome
Operating system
Linux
Hardware wallet
No response
Additional context
No response
Severity
No response