Skip to content

Exclude Snaps from SelectedNetworkController domains state#4258

Merged
adonesky1 merged 2 commits intomainfrom
ad/fix/exclude-snaps-from-selectedNetworkController-domains-state
May 6, 2024
Merged

Exclude Snaps from SelectedNetworkController domains state#4258
adonesky1 merged 2 commits intomainfrom
ad/fix/exclude-snaps-from-selectedNetworkController-domains-state

Conversation

@adonesky1
Copy link
Contributor

Explanation

Currently Snaps should not be included in the SelectedNetworkController's domains state since they have no way of changing their network (they cannot call wallet_switchEthereumChain and have no UI exposed to manually switch their connected chain). This means that with the useRequestQueue toggle on they are stuck permanently connected to whatever chain is selected when they are installed.

References

Changelog

@metamask/selected-network-controller

  • FIX: Adds logic to exclude connecting Snaps from setting selected network state and proxies in the SelectedNetworkController

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@adonesky1 adonesky1 requested review from a team, FrederikBolding, Gudahtt, mcmire and shanejonas May 6, 2024 14:28
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Gudahtt
Copy link
Member

Gudahtt commented May 6, 2024

Hmm, I think this is better categorized as a change, and we should document that it requires a migration as well (i.e. that it's breaking).

The previous behavior wasn't really broken, at least not at the controller API level.

@adonesky1 adonesky1 merged commit 9687bfc into main May 6, 2024
@adonesky1 adonesky1 deleted the ad/fix/exclude-snaps-from-selectedNetworkController-domains-state branch May 6, 2024 15:46
@adonesky1 adonesky1 mentioned this pull request May 6, 2024
adonesky1 added a commit that referenced this pull request May 6, 2024
# @metamask/selected-network-controller

## [13.0.0]

### Changed

- `getProviderAndBlockTracker` now returns the `NetworkController`'s
globally selected network client proxy if the `domain` arg is either
`metamask` or a snap (identified as starting with `npm:` or `local:`)
([#4259](#4259))
- **BREAKING:** Now when `setNetworkClientIdForDomain` is called with a
snap's domain (identified as starting with `npm:` or `local:`), the
`domain` will not be added to state and no proxy will be created for
this domain in the `domainProxyMap`
([#4258](#4258))
- In order to remove snaps that made it into `domains` state prior to
this change, consumers will need to run a migration.

---------

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants