Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with selectedNetworkMiddlware where all domains are added to state regardless of whether they have permissions #3908

Merged
merged 11 commits into from
Feb 22, 2024

Conversation

adonesky1
Copy link
Contributor

@adonesky1 adonesky1 commented Feb 7, 2024

@metamask/selected-network-controller

Changed

  • 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.
  • BREAKING: setNetworkClientIdForDomain now throws an error if passed metamask as its first (domain) argument
  • 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.
  • BREAKING: the domains state now no longer contains a metamask key.
  • BREAKING: getProviderAndBlockTracker now throws an error if called with any domain while the perDomainNetwork flag is false.

(These changes help fix an issue where the SelectedNetworkController adds 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

@adonesky1 adonesky1 force-pushed the ad/fix-selected-network-middleware branch from 1067774 to 10d6e66 Compare February 7, 2024 23:59
@adonesky1 adonesky1 marked this pull request as ready for review February 8, 2024 15:45
@adonesky1 adonesky1 requested a review from a team as a code owner February 8, 2024 15:45
@adonesky1 adonesky1 requested review from mcmire and Gudahtt February 8, 2024 15:45
@adonesky1 adonesky1 marked this pull request as draft February 8, 2024 16:49
@adonesky1 adonesky1 force-pushed the ad/fix-selected-network-middleware branch from 103055a to 99e2006 Compare February 8, 2024 16:54
@adonesky1
Copy link
Contributor Author

@metamaskbot publish-preview

Copy link
Contributor

github-actions bot commented Feb 8, 2024

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "10.0.0-preview.7fd401b",
  "@metamask-previews/address-book-controller": "3.1.7-preview.7fd401b",
  "@metamask-previews/announcement-controller": "5.0.2-preview.7fd401b",
  "@metamask-previews/approval-controller": "5.1.2-preview.7fd401b",
  "@metamask-previews/assets-controllers": "25.0.0-preview.7fd401b",
  "@metamask-previews/base-controller": "4.1.1-preview.7fd401b",
  "@metamask-previews/build-utils": "1.0.2-preview.7fd401b",
  "@metamask-previews/composable-controller": "5.0.1-preview.7fd401b",
  "@metamask-previews/controller-utils": "8.0.2-preview.7fd401b",
  "@metamask-previews/ens-controller": "9.0.0-preview.7fd401b",
  "@metamask-previews/eth-json-rpc-provider": "2.3.2-preview.7fd401b",
  "@metamask-previews/gas-fee-controller": "13.0.0-preview.7fd401b",
  "@metamask-previews/json-rpc-engine": "7.3.2-preview.7fd401b",
  "@metamask-previews/json-rpc-middleware-stream": "6.0.2-preview.7fd401b",
  "@metamask-previews/keyring-controller": "12.2.0-preview.7fd401b",
  "@metamask-previews/logging-controller": "2.0.2-preview.7fd401b",
  "@metamask-previews/message-manager": "7.3.8-preview.7fd401b",
  "@metamask-previews/name-controller": "5.0.0-preview.7fd401b",
  "@metamask-previews/network-controller": "17.2.0-preview.7fd401b",
  "@metamask-previews/notification-controller": "4.0.2-preview.7fd401b",
  "@metamask-previews/permission-controller": "8.0.0-preview.7fd401b",
  "@metamask-previews/permission-log-controller": "0.0.0-preview.7fd401b",
  "@metamask-previews/phishing-controller": "8.0.2-preview.7fd401b",
  "@metamask-previews/polling-controller": "5.0.0-preview.7fd401b",
  "@metamask-previews/preferences-controller": "7.0.0-preview.7fd401b",
  "@metamask-previews/queued-request-controller": "0.4.0-preview.7fd401b",
  "@metamask-previews/rate-limit-controller": "4.0.2-preview.7fd401b",
  "@metamask-previews/selected-network-controller": "7.0.1-preview.7fd401b",
  "@metamask-previews/signature-controller": "12.0.0-preview.7fd401b",
  "@metamask-previews/transaction-controller": "21.2.0-preview.7fd401b",
  "@metamask-previews/user-operation-controller": "3.0.0-preview.7fd401b"
}

@adonesky1 adonesky1 force-pushed the ad/fix-selected-network-middleware branch from f7736f1 to 08978bf Compare February 8, 2024 23:06
@adonesky1
Copy link
Contributor Author

@metamaskbot publish-preview

Copy link
Contributor

github-actions bot commented Feb 8, 2024

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "10.0.0-preview.08978bf",
  "@metamask-previews/address-book-controller": "3.1.7-preview.08978bf",
  "@metamask-previews/announcement-controller": "5.0.2-preview.08978bf",
  "@metamask-previews/approval-controller": "5.1.2-preview.08978bf",
  "@metamask-previews/assets-controllers": "25.0.0-preview.08978bf",
  "@metamask-previews/base-controller": "4.1.1-preview.08978bf",
  "@metamask-previews/build-utils": "1.0.2-preview.08978bf",
  "@metamask-previews/composable-controller": "5.0.1-preview.08978bf",
  "@metamask-previews/controller-utils": "8.0.2-preview.08978bf",
  "@metamask-previews/ens-controller": "9.0.0-preview.08978bf",
  "@metamask-previews/eth-json-rpc-provider": "2.3.2-preview.08978bf",
  "@metamask-previews/gas-fee-controller": "13.0.0-preview.08978bf",
  "@metamask-previews/json-rpc-engine": "7.3.2-preview.08978bf",
  "@metamask-previews/json-rpc-middleware-stream": "6.0.2-preview.08978bf",
  "@metamask-previews/keyring-controller": "12.2.0-preview.08978bf",
  "@metamask-previews/logging-controller": "2.0.2-preview.08978bf",
  "@metamask-previews/message-manager": "7.3.8-preview.08978bf",
  "@metamask-previews/name-controller": "5.0.0-preview.08978bf",
  "@metamask-previews/network-controller": "17.2.0-preview.08978bf",
  "@metamask-previews/notification-controller": "4.0.2-preview.08978bf",
  "@metamask-previews/permission-controller": "8.0.0-preview.08978bf",
  "@metamask-previews/permission-log-controller": "0.0.0-preview.08978bf",
  "@metamask-previews/phishing-controller": "8.0.2-preview.08978bf",
  "@metamask-previews/polling-controller": "5.0.0-preview.08978bf",
  "@metamask-previews/preferences-controller": "7.0.0-preview.08978bf",
  "@metamask-previews/queued-request-controller": "0.4.0-preview.08978bf",
  "@metamask-previews/rate-limit-controller": "4.0.2-preview.08978bf",
  "@metamask-previews/selected-network-controller": "7.0.1-preview.08978bf",
  "@metamask-previews/signature-controller": "12.0.0-preview.08978bf",
  "@metamask-previews/transaction-controller": "21.2.0-preview.08978bf",
  "@metamask-previews/user-operation-controller": "3.0.0-preview.08978bf"
}

@adonesky1
Copy link
Contributor Author

@metamaskbot publish-preview

Copy link
Contributor

github-actions bot commented Feb 9, 2024

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "10.0.0-preview.bc4dd941",
  "@metamask-previews/address-book-controller": "3.1.7-preview.bc4dd941",
  "@metamask-previews/announcement-controller": "5.0.2-preview.bc4dd941",
  "@metamask-previews/approval-controller": "5.1.2-preview.bc4dd941",
  "@metamask-previews/assets-controllers": "25.0.0-preview.bc4dd941",
  "@metamask-previews/base-controller": "4.1.1-preview.bc4dd941",
  "@metamask-previews/build-utils": "1.0.2-preview.bc4dd941",
  "@metamask-previews/composable-controller": "5.0.1-preview.bc4dd941",
  "@metamask-previews/controller-utils": "8.0.2-preview.bc4dd941",
  "@metamask-previews/ens-controller": "9.0.0-preview.bc4dd941",
  "@metamask-previews/eth-json-rpc-provider": "2.3.2-preview.bc4dd941",
  "@metamask-previews/gas-fee-controller": "13.0.0-preview.bc4dd941",
  "@metamask-previews/json-rpc-engine": "7.3.2-preview.bc4dd941",
  "@metamask-previews/json-rpc-middleware-stream": "6.0.2-preview.bc4dd941",
  "@metamask-previews/keyring-controller": "12.2.0-preview.bc4dd941",
  "@metamask-previews/logging-controller": "2.0.2-preview.bc4dd941",
  "@metamask-previews/message-manager": "7.3.8-preview.bc4dd941",
  "@metamask-previews/name-controller": "5.0.0-preview.bc4dd941",
  "@metamask-previews/network-controller": "17.2.0-preview.bc4dd941",
  "@metamask-previews/notification-controller": "4.0.2-preview.bc4dd941",
  "@metamask-previews/permission-controller": "8.0.0-preview.bc4dd941",
  "@metamask-previews/permission-log-controller": "0.0.0-preview.bc4dd941",
  "@metamask-previews/phishing-controller": "8.0.2-preview.bc4dd941",
  "@metamask-previews/polling-controller": "5.0.0-preview.bc4dd941",
  "@metamask-previews/preferences-controller": "7.0.0-preview.bc4dd941",
  "@metamask-previews/queued-request-controller": "0.4.0-preview.bc4dd941",
  "@metamask-previews/rate-limit-controller": "4.0.2-preview.bc4dd941",
  "@metamask-previews/selected-network-controller": "7.0.1-preview.bc4dd941",
  "@metamask-previews/signature-controller": "12.0.0-preview.bc4dd941",
  "@metamask-previews/transaction-controller": "21.2.0-preview.bc4dd941",
  "@metamask-previews/user-operation-controller": "3.0.0-preview.bc4dd941"
}

@adonesky1 adonesky1 force-pushed the ad/fix-selected-network-middleware branch from 067fd49 to 3905f51 Compare February 9, 2024 19:19
@adonesky1
Copy link
Contributor Author

@metamaskbot publish-preview

Copy link
Contributor

github-actions bot commented Feb 9, 2024

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "10.0.0-preview.3905f51",
  "@metamask-previews/address-book-controller": "3.1.7-preview.3905f51",
  "@metamask-previews/announcement-controller": "5.0.2-preview.3905f51",
  "@metamask-previews/approval-controller": "5.1.2-preview.3905f51",
  "@metamask-previews/assets-controllers": "25.0.0-preview.3905f51",
  "@metamask-previews/base-controller": "4.1.1-preview.3905f51",
  "@metamask-previews/build-utils": "1.0.2-preview.3905f51",
  "@metamask-previews/composable-controller": "5.0.1-preview.3905f51",
  "@metamask-previews/controller-utils": "8.0.2-preview.3905f51",
  "@metamask-previews/ens-controller": "9.0.0-preview.3905f51",
  "@metamask-previews/eth-json-rpc-provider": "2.3.2-preview.3905f51",
  "@metamask-previews/gas-fee-controller": "13.0.0-preview.3905f51",
  "@metamask-previews/json-rpc-engine": "7.3.2-preview.3905f51",
  "@metamask-previews/json-rpc-middleware-stream": "6.0.2-preview.3905f51",
  "@metamask-previews/keyring-controller": "12.2.0-preview.3905f51",
  "@metamask-previews/logging-controller": "2.0.2-preview.3905f51",
  "@metamask-previews/message-manager": "7.3.8-preview.3905f51",
  "@metamask-previews/name-controller": "5.0.0-preview.3905f51",
  "@metamask-previews/network-controller": "17.2.0-preview.3905f51",
  "@metamask-previews/notification-controller": "4.0.2-preview.3905f51",
  "@metamask-previews/permission-controller": "8.0.0-preview.3905f51",
  "@metamask-previews/permission-log-controller": "0.0.0-preview.3905f51",
  "@metamask-previews/phishing-controller": "8.0.2-preview.3905f51",
  "@metamask-previews/polling-controller": "5.0.0-preview.3905f51",
  "@metamask-previews/preferences-controller": "7.0.0-preview.3905f51",
  "@metamask-previews/queued-request-controller": "0.4.0-preview.3905f51",
  "@metamask-previews/rate-limit-controller": "4.0.2-preview.3905f51",
  "@metamask-previews/selected-network-controller": "7.0.1-preview.3905f51",
  "@metamask-previews/signature-controller": "12.0.0-preview.3905f51",
  "@metamask-previews/transaction-controller": "21.2.0-preview.3905f51",
  "@metamask-previews/user-operation-controller": "3.0.0-preview.3905f51"
}

@adonesky1
Copy link
Contributor Author

@metamaskbot publish-preview

Copy link
Contributor

github-actions bot commented Feb 9, 2024

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "10.0.0-preview.a3a3121",
  "@metamask-previews/address-book-controller": "3.1.7-preview.a3a3121",
  "@metamask-previews/announcement-controller": "5.0.2-preview.a3a3121",
  "@metamask-previews/approval-controller": "5.1.2-preview.a3a3121",
  "@metamask-previews/assets-controllers": "25.0.0-preview.a3a3121",
  "@metamask-previews/base-controller": "4.1.1-preview.a3a3121",
  "@metamask-previews/build-utils": "1.0.2-preview.a3a3121",
  "@metamask-previews/composable-controller": "5.0.1-preview.a3a3121",
  "@metamask-previews/controller-utils": "8.0.2-preview.a3a3121",
  "@metamask-previews/ens-controller": "9.0.0-preview.a3a3121",
  "@metamask-previews/eth-json-rpc-provider": "2.3.2-preview.a3a3121",
  "@metamask-previews/gas-fee-controller": "13.0.0-preview.a3a3121",
  "@metamask-previews/json-rpc-engine": "7.3.2-preview.a3a3121",
  "@metamask-previews/json-rpc-middleware-stream": "6.0.2-preview.a3a3121",
  "@metamask-previews/keyring-controller": "12.2.0-preview.a3a3121",
  "@metamask-previews/logging-controller": "2.0.2-preview.a3a3121",
  "@metamask-previews/message-manager": "7.3.8-preview.a3a3121",
  "@metamask-previews/name-controller": "5.0.0-preview.a3a3121",
  "@metamask-previews/network-controller": "17.2.0-preview.a3a3121",
  "@metamask-previews/notification-controller": "4.0.2-preview.a3a3121",
  "@metamask-previews/permission-controller": "8.0.0-preview.a3a3121",
  "@metamask-previews/permission-log-controller": "0.0.0-preview.a3a3121",
  "@metamask-previews/phishing-controller": "8.0.2-preview.a3a3121",
  "@metamask-previews/polling-controller": "5.0.0-preview.a3a3121",
  "@metamask-previews/preferences-controller": "7.0.0-preview.a3a3121",
  "@metamask-previews/queued-request-controller": "0.4.0-preview.a3a3121",
  "@metamask-previews/rate-limit-controller": "4.0.2-preview.a3a3121",
  "@metamask-previews/selected-network-controller": "7.0.1-preview.a3a3121",
  "@metamask-previews/signature-controller": "12.0.0-preview.a3a3121",
  "@metamask-previews/transaction-controller": "21.2.0-preview.a3a3121",
  "@metamask-previews/user-operation-controller": "3.0.0-preview.a3a3121"
}

@adonesky1
Copy link
Contributor Author

@metamaskbot publish-preview

Copy link
Contributor

github-actions bot commented Feb 9, 2024

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "10.0.0-preview.91dd28a",
  "@metamask-previews/address-book-controller": "3.1.7-preview.91dd28a",
  "@metamask-previews/announcement-controller": "5.0.2-preview.91dd28a",
  "@metamask-previews/approval-controller": "5.1.2-preview.91dd28a",
  "@metamask-previews/assets-controllers": "25.0.0-preview.91dd28a",
  "@metamask-previews/base-controller": "4.1.1-preview.91dd28a",
  "@metamask-previews/build-utils": "1.0.2-preview.91dd28a",
  "@metamask-previews/composable-controller": "5.0.1-preview.91dd28a",
  "@metamask-previews/controller-utils": "8.0.2-preview.91dd28a",
  "@metamask-previews/ens-controller": "9.0.0-preview.91dd28a",
  "@metamask-previews/eth-json-rpc-provider": "2.3.2-preview.91dd28a",
  "@metamask-previews/gas-fee-controller": "13.0.0-preview.91dd28a",
  "@metamask-previews/json-rpc-engine": "7.3.2-preview.91dd28a",
  "@metamask-previews/json-rpc-middleware-stream": "6.0.2-preview.91dd28a",
  "@metamask-previews/keyring-controller": "12.2.0-preview.91dd28a",
  "@metamask-previews/logging-controller": "2.0.2-preview.91dd28a",
  "@metamask-previews/message-manager": "7.3.8-preview.91dd28a",
  "@metamask-previews/name-controller": "5.0.0-preview.91dd28a",
  "@metamask-previews/network-controller": "17.2.0-preview.91dd28a",
  "@metamask-previews/notification-controller": "4.0.2-preview.91dd28a",
  "@metamask-previews/permission-controller": "8.0.0-preview.91dd28a",
  "@metamask-previews/permission-log-controller": "0.0.0-preview.91dd28a",
  "@metamask-previews/phishing-controller": "8.0.2-preview.91dd28a",
  "@metamask-previews/polling-controller": "5.0.0-preview.91dd28a",
  "@metamask-previews/preferences-controller": "7.0.0-preview.91dd28a",
  "@metamask-previews/queued-request-controller": "0.4.0-preview.91dd28a",
  "@metamask-previews/rate-limit-controller": "4.0.2-preview.91dd28a",
  "@metamask-previews/selected-network-controller": "7.0.1-preview.91dd28a",
  "@metamask-previews/signature-controller": "12.0.0-preview.91dd28a",
  "@metamask-previews/transaction-controller": "21.2.0-preview.91dd28a",
  "@metamask-previews/user-operation-controller": "3.0.0-preview.91dd28a"
}

@adonesky1
Copy link
Contributor Author

@metamaskbot publish-preview

Copy link
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "10.0.0-preview.1a0f3934",
  "@metamask-previews/address-book-controller": "3.1.7-preview.1a0f3934",
  "@metamask-previews/announcement-controller": "5.0.2-preview.1a0f3934",
  "@metamask-previews/approval-controller": "5.1.2-preview.1a0f3934",
  "@metamask-previews/assets-controllers": "25.0.0-preview.1a0f3934",
  "@metamask-previews/base-controller": "4.1.1-preview.1a0f3934",
  "@metamask-previews/build-utils": "1.0.2-preview.1a0f3934",
  "@metamask-previews/composable-controller": "5.0.1-preview.1a0f3934",
  "@metamask-previews/controller-utils": "8.0.2-preview.1a0f3934",
  "@metamask-previews/ens-controller": "9.0.0-preview.1a0f3934",
  "@metamask-previews/eth-json-rpc-provider": "2.3.2-preview.1a0f3934",
  "@metamask-previews/gas-fee-controller": "13.0.0-preview.1a0f3934",
  "@metamask-previews/json-rpc-engine": "7.3.2-preview.1a0f3934",
  "@metamask-previews/json-rpc-middleware-stream": "6.0.2-preview.1a0f3934",
  "@metamask-previews/keyring-controller": "12.2.0-preview.1a0f3934",
  "@metamask-previews/logging-controller": "2.0.2-preview.1a0f3934",
  "@metamask-previews/message-manager": "7.3.8-preview.1a0f3934",
  "@metamask-previews/name-controller": "5.0.0-preview.1a0f3934",
  "@metamask-previews/network-controller": "17.2.0-preview.1a0f3934",
  "@metamask-previews/notification-controller": "4.0.2-preview.1a0f3934",
  "@metamask-previews/permission-controller": "8.0.0-preview.1a0f3934",
  "@metamask-previews/permission-log-controller": "0.0.0-preview.1a0f3934",
  "@metamask-previews/phishing-controller": "8.0.2-preview.1a0f3934",
  "@metamask-previews/polling-controller": "5.0.0-preview.1a0f3934",
  "@metamask-previews/preferences-controller": "7.0.0-preview.1a0f3934",
  "@metamask-previews/queued-request-controller": "0.4.0-preview.1a0f3934",
  "@metamask-previews/rate-limit-controller": "4.0.2-preview.1a0f3934",
  "@metamask-previews/selected-network-controller": "7.0.1-preview.1a0f3934",
  "@metamask-previews/signature-controller": "12.0.0-preview.1a0f3934",
  "@metamask-previews/transaction-controller": "21.2.0-preview.1a0f3934",
  "@metamask-previews/user-operation-controller": "3.0.0-preview.1a0f3934"
}

@adonesky1 adonesky1 force-pushed the ad/fix-selected-network-middleware branch from 1a0f393 to 3b3808f Compare February 15, 2024 21:52
@adonesky1 adonesky1 force-pushed the ad/fix-selected-network-middleware branch from 88b679e to ecb5e72 Compare February 19, 2024 22:54
@adonesky1 adonesky1 force-pushed the ad/fix-selected-network-middleware branch from a209931 to a71ecdd Compare February 20, 2024 19:29
Comment on lines -232 to -238
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),
);
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

@mcmire
Copy link
Contributor

mcmire commented Feb 21, 2024

Changes make sense.

@adonesky1 adonesky1 requested a review from mcmire February 21, 2024 19:08
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Oops, didn't realize I didn't approve 😅

@adonesky1 adonesky1 merged commit 65f1bba into main Feb 22, 2024
136 checks passed
@adonesky1 adonesky1 deleted the ad/fix-selected-network-middleware branch February 22, 2024 00:14
@adonesky1 adonesky1 mentioned this pull request Feb 22, 2024
adonesky1 added a commit that referenced this pull request Feb 22, 2024
# @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>
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.

6 participants