feat: add @metamask/network-connection-banner-controller#9041
Open
cryptodev-2s wants to merge 20 commits into
Open
feat: add @metamask/network-connection-banner-controller#9041cryptodev-2s wants to merge 20 commits into
cryptodev-2s wants to merge 20 commits into
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
9111156 to
d1fa945
Compare
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
cb4b1af to
ab5cc87
Compare
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
This comment was marked as outdated.
This comment was marked as outdated.
6d2ab14 to
2fc626b
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
…riod in changelog
Mirrors connectivity-controller: a `networkConnectionBannerControllerSelectors` object with `selectNetworkConnectionBannerStatus`, `selectNetworkConnectionBannerNetwork`, and a derived `selectIsNetworkConnectionBannerVisible`.
cabd378 to
ba2e209
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ba2e209. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Explanation
The RPC connection banner ("Still connecting" / "Unable to connect") is currently rendered by both
metamask-extensionandmetamask-mobilebased on duplicated logic in each repo:pslso a single provider's wide outage doesn't pop the banner.{ chainId, networkName, rpcUrl, isInfuraEndpoint, infuraNetworkClientId }payload shape.This PR introduces
@metamask/network-connection-banner-controllerso there's a single source of truth. The controller:NetworkController:stateChanged,NetworkEnablementController:stateChanged, andConnectivityController:stateChangedvia the messenger.{ status: 'available' | 'degraded' | 'unavailable', network: FailedNetwork | null }that clients subscribe to.dismissBanner()andswitchToDefaultInfuraRpc({ chainId })— the latter looks up the chain's first Infura endpoint and callsNetworkController:updateNetworkwithreplacementSelectedRpcEndpointIndex.psl1.15 ships itstypesfield outside itsexportsmap so TypeScript'snode16module resolution can't find it; a small ambientsrc/psl.d.tsshim mirrors the workaround already in use in extension and mobile.ip-regexis pinned to^4.3.0(last CJS release) because the monorepo's Jest config doesn't transform ESM-only deps.References
Checklist
Note
Medium Risk
New package only, but it mutates default RPC via NetworkController and defines user-visible connectivity signaling; incorrect rules or timer edge cases could affect all adopting clients.
Overview
Adds
@metamask/network-connection-banner-controller, a new core package that centralizes RPC connection banner behavior previously duplicated in extension and mobile.NetworkConnectionBannerControllerlistens to network, enablement, and connectivity state (via messenger), but only runs its logic afterinit(). It exposes ephemeral UI state{ status: 'available' | 'degraded' | 'unavailable', network }, applies the shared show/hide rules (custom-RPC failures, multi-domain failures, all-enabled-failed escape hatch, eTLD+1 grouping viaurl-utils), and drives 5s → 30s escalation timers. Messenger actions includedismissBannerandswitchToDefaultInfuraRpc, which updates the chain default RPC throughNetworkController:updateNetwork. Reselect selectors and broad Jest coverage are included.Monorepo wiring updates CODEOWNERS, README (package list + dependency graph), teams.json, root tsconfig references, and yarn.lock (
psl,ip-regex).Reviewed by Cursor Bugbot for commit d4f5ab6. Bugbot is set up for automated code reviews on this repo. Configure here.