Skip to content

[Bug]: Wallet API uses wrong chain after permissions added/removed until refresh (when per-dapp selected network enabled) #23509

@Gudahtt

Description

@Gudahtt

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_requestAccounts on the site, asking for the eth_accounts permissions
  • Approve the request
  • Call eth_chainId from the site, and see that it matches the wallet selected chain
  • Switch the selected chain in the fullscreen UI
  • Call eth_chainId from 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_chainId from the site. If it matches the selected chain in the fullscreen wallet UI, switch the chain in the fullscreen wallet UI before proceeding. Call eth_chainId again 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_chainId from 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

Metadata

Metadata

Assignees

Labels

Sev2-normalNormal severity; minor loss of service or inconvenience.amon-hen-v1Represents blocking issues for the release of Amon Henregression-mainRegression bug that was found on main branch, but not yet present in productionrelease-11.16.0Issue or pull request that will be included in release 11.16.0team-wallet-api-platform-deprecatedDEPRECATED: please use "team-wallet-integrations" insteadtype-bugSomething isn't working

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions