metamask-mobile
metamask-mobile copied to clipboard
fix: snaps unable to call wallet_switchEthereumChain when they have no accounts permitted
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
- Visit https://metamask.github.io/snaps/test-snaps/latest/
- Connect to Ethereum Provider Snap
- Change the Select Chain Dropdown
- Click Get Chain Id
- Should match each time
Screenshots/Recordings
Before
After
https://github.com/user-attachments/assets/48d65c48-c61c-44dd-8dbd-aa97f4ef9958
Pre-merge author checklist
- [ ] I’ve followed MetaMask Contributor Docs and MetaMask Mobile Coding Standards.
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using JSDoc format if applicable
- [ ] I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
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.