Conversation
1067774 to
10d6e66
Compare
103055a to
99e2006
Compare
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
f7736f1 to
08978bf
Compare
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
067fd49 to
3905f51
Compare
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
packages/selected-network-controller/tests/SelectedNetworkMiddleware.test.ts
Show resolved
Hide resolved
57aad5e to
b790270
Compare
packages/selected-network-controller/src/SelectedNetworkController.ts
Outdated
Show resolved
Hide resolved
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
1a0f393 to
3b3808f
Compare
packages/selected-network-controller/src/SelectedNetworkController.ts
Outdated
Show resolved
Hide resolved
88b679e to
ecb5e72
Compare
…electedNetworkMiddleware. Fallback to metamask domain networkClientId to add to the req object.
Cleans up and simplifies
a209931 to
a71ecdd
Compare
| Object.keys(this.state.domains).forEach((domain) => { | ||
| // when perDomainNetwork is false, getNetworkClientIdForDomain always returns the networkClientId for the domain 'metamask' | ||
| this.setNetworkClientIdForDomain( | ||
| domain, | ||
| this.getNetworkClientIdForDomain(domain), | ||
| ); | ||
| }); |
There was a problem hiding this comment.
No need to update the domain state when the perDomainNetwork flag is toggled on or off, we can just reference this flag in the relevant methods to determine which networkClient to access in either case.
packages/selected-network-controller/src/SelectedNetworkController.ts
Outdated
Show resolved
Hide resolved
|
Changes make sense. |
mcmire
left a comment
There was a problem hiding this comment.
Oops, didn't realize I didn't approve 😅
# @metamask/selected-network-controller ## [8.0.0] ### Changed - **BREAKING:** `setNetworkClientIdForDomain` now throws an error if passed `metamask` as its first (`domain`) argument ([#3908](#3908)). - **BREAKING:** `setNetworkClientIdForDomain` now includes a check that the requesting `domain` has already been granted permissions in the `PermissionsController` before adding it to `domains` state and throws an error if the domain does not have permissions ([#3908](#3908)). - **BREAKING:** the `domains` state now no longer contains a `metamask` domain key Consumers should instead use the `selectedNetworkClientId` from the `NetworkController` to get the selected network for the `metamask` domain ([#3908](#3908)). - **BREAKING:** `getProviderAndBlockTracker` now throws an error if called with any domain while the `perDomainNetwork` flag is false. Consumers should instead use the `provider` and `blockTracker` from the `NetworkController` when the `perDomainNetwork` flag is false ([#3908](#3908)). - **BREAKING:** `getProviderAndBlockTracker` now throws an error if called with a domain that is not in domains state ([#3908](#3908)). - **BREAKING:** `getNetworkClientIdForDomain` now returns the `selectedNetworkClientId` for the globally selected network if the `perDomainNetwork` flag is false and if the domain is not in the `domains` state ([#3908](#3908)). ### Removed - **BREAKING:** Remove logic in `selectedNetworkMiddleware` to set a default `networkClientId` for the requesting origin when not already set. Now if no `networkClientId` is already set for the requesting origin, the middleware will not add the origin to `domains` state but will add the `networkClientId` currently set for the `selectedNetworkClient` from the `NetworkController` to the request object ([#3908](#3908)). ### Fixed - The `SelectedNetworkController` now listens for `networkConfiguration` removal events on the `NetworkController` and if a removed `networkClientId` matches the set `networkClientId` for any domains in its state, it updates them to the globally selected `networkClientId` and repoints the proxies accordingly. ([#3926](#3926)) --------- Co-authored-by: jiexi <jiexiluan@gmail.com> Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
@metamask/selected-network-controller
Changed
selectedNetworkMiddlewareto set a defaultnetworkClientIdfor the requesting origin when not already set. Now if nonetworkClientIdis already set for the requesting origin, the middleware will not add the origin todomainsstate but will add thenetworkClientIdcurrently set for theselectedNetworkClientfrom theNetworkControllerto the request object.setNetworkClientIdForDomainnow throws an error if passedmetamaskas its first (domain) argumentsetNetworkClientIdForDomainnow includes a check that the requestingdomainhas already been granted permissions in thePermissionsControllerbefore adding it todomainsstate and throws an error if the domain does not have permissions.domainsstate now no longer contains ametamaskkey.getProviderAndBlockTrackernow throws an error if called with any domain while theperDomainNetworkflag is false.(These changes help fix an issue where the
SelectedNetworkControlleradds any and all domains the user visits to its domains state whether or not the user has connected to these sites.)Currently can be e2e tested on this WIP integration branch: MetaMask/metamask-extension#22860