metamask-mobile icon indicating copy to clipboard operation
metamask-mobile copied to clipboard

fix: snaps unable to call wallet_switchEthereumChain when they have no accounts permitted

Open jiexi opened this issue 4 months ago • 2 comments

Description

A helper function used for facilitating chain switching and permissions related to it incorrectly requires accounts to permitted before setting the per dapp selected network for that dapp. This seems to be a scenario that is possible in Snaps specifically making it so that Snaps are unable to switch their selected network.

The fix is to remove this requirement for accounts as it isn't truly needed in the first place.

Related issues

Fixes:

Manual testing steps

  1. Visit https://metamask.github.io/snaps/test-snaps/latest/
  2. Connect to Ethereum Provider Snap
  3. Change the Select Chain Dropdown
  4. Click Get Chain Id
  5. Should match each time

Screenshots/Recordings

Before

After

https://github.com/user-attachments/assets/48d65c48-c61c-44dd-8dbd-aa97f4ef9958

Pre-merge author checklist

Pre-merge reviewer checklist

  • [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

jiexi avatar Jun 13 '25 18:06 jiexi