Skip to content

feat: drive RPC connection banner from NetworkConnectionBannerController (WPC-1014)#31225

Draft
cryptodev-2s wants to merge 7 commits into
mainfrom
wpc-1014-use-banner-controller
Draft

feat: drive RPC connection banner from NetworkConnectionBannerController (WPC-1014)#31225
cryptodev-2s wants to merge 7 commits into
mainfrom
wpc-1014-use-banner-controller

Conversation

@cryptodev-2s

@cryptodev-2s cryptodev-2s commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Description

Replaces the in-app duplicate of the RPC connection banner rule + 5s/30s timer escalation with the new @metamask/network-connection-banner-controller, registered in mobile's Engine.

Wiring

  • package.json declares the controller as @metamask/network-connection-banner-controller with a Yarn resolutions alias to the preview tarball (@metamask-previews/network-connection-banner-controller@0.1.0-preview-7507a11). When the package ships under its real name, only the resolution line gets removed — no code changes.
  • New init + restricted-messenger files under app/core/Engine/; registered in Engine.ts, messengers/index.ts, and types.ts.
  • The preview package transitively resolves newer peer controllers than mobile installs (network-controller@^32 vs @31, connectivity-controller@^0.2 vs @0.1). Runtime shapes match (same event names + state fields); the type-only mismatch at the messenger boundary is bridged with one as unknown as cast in the messenger factory — removable once mobile bumps versions.

Cleanup

  • Deletes app/reducers/networkConnectionBanner/ and app/actions/networkConnectionBanner/.
  • Selector now reads from engine.backgroundState.NetworkConnectionBannerController and adapts to the existing UI's { visible: boolean } shape, so the banner component is untouched.
  • useNetworkConnectionBanner hook drops the inline checkNetworkStatus, the two setTimeouts, the rpcEndpointChainAvailable subscription, and all showNetworkConnectionBanner/hideNetworkConnectionBanner dispatches. switchToInfura now calls NetworkConnectionBannerController:switchToDefaultInfuraRpc. Analytics + navigation unchanged.

Net diff: −2,310 LOC. No user-visible behavior change.

Core PR: MetaMask/core#9041

Changelog

CHANGELOG entry: null

Related issues

Fixes: WPC-1014

Manual testing steps

Feature: Banner driven by NetworkConnectionBannerController

  Scenario: single Infura blip during a wide outage
    Given all *.infura.io endpoints are unreachable
    When 30s elapse
    Then no banner appears (single registrable domain, suppressed)

  Scenario: custom RPC alone fails
    Given a custom RPC is configured and unreachable
    When 5s elapse
    Then the degraded banner appears for that custom network
    And tapping "Switch to MetaMask default RPC" switches to the chain's Infura endpoint and shows the success toast

  Scenario: two providers fail at once
    Given both an Infura network and an Alchemy network are unreachable
    When 5s elapse
    Then the degraded banner appears, escalating to unavailable at 30s

  Scenario: device offline
    Given the device is offline
    When any RPC times out
    Then no banner appears (existing offline short-circuit honored)

Screenshots/Recordings

Before

After

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
  • I've tested with a power user scenario
  • I've instrumented key operations with Sentry traces for production performance metrics

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.

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@mm-token-exchange-service mm-token-exchange-service Bot added team-core-platform Core Platform team INVALID-PR-TEMPLATE PR's body doesn't match template labels Jun 8, 2026
@mm-token-exchange-service

Copy link
Copy Markdown

PR template — items to address before "Ready for review"

This check is informational while the PR is in draft. It will start blocking once you mark the PR as Ready for review.

  • Screenshots/Recordings section is empty. Add an image/video for user-facing changes, logs/console output for non-user-facing changes, or write N/A if no evidence is applicable.
  • Pre-merge author checklist has unchecked items (e.g. "I've applied the right labels on the PR (see labeling guidelines). Not required for external contributors."). Every box must be consciously checked — see docs/readme/ready-for-review.md.

See docs/readme/ready-for-review.md for the full Definition of Ready for Review.

@socket-security

socket-security Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​metamask/​network-connection-banner-controller@​0.1.0-preview-69c25f14200000

View full report

@cryptodev-2s cryptodev-2s changed the title feat: register NetworkConnectionBannerController in Engine (WPC-1014) feat: drive RPC connection banner from NetworkConnectionBannerController (WPC-1014) Jun 8, 2026
@cryptodev-2s cryptodev-2s force-pushed the wpc-1014-use-banner-controller branch 2 times, most recently from 53f5fc2 to 2abcc76 Compare June 10, 2026 10:46
Wires the new core package into mobile via the standard messenger-client
init pattern. The controller is alongside the existing useNetworkConnectionBanner
hook — clients can now subscribe to its state-change events, and a follow-up
PR will migrate the hook to read from the controller's state instead of the
local Redux reducer.

Mobile's installed controller versions are older than the preview package's
resolved peer ranges (network-controller@31 vs ^32, connectivity-controller@0.1
vs ^0.2). Runtime shapes are compatible — all event names and state field
names align — so the type-level mismatch at the messenger boundary is bridged
with a single cast in the messenger factory. The cast can be dropped once
mobile bumps its controller versions to match.
…Controller

The new controller registered in the previous commit owns the show/hide
rule, 5s/30s timer escalation, and the switch-to-Infura action. With it
in place, the in-app duplicates are dead code:

- delete app/reducers/networkConnectionBanner and app/actions/networkConnectionBanner
- selector now reads from engine.backgroundState.NetworkConnectionBannerController
  and adapts to the existing UI shape (visible: boolean + flat fields)
- useNetworkConnectionBanner hook drops the inline checkNetworkStatus
  function, the two timers, the rpcEndpointChainAvailable subscription,
  and the dispatch calls; switchToInfura now calls the controller via
  NetworkConnectionBannerController:switchToDefaultInfuraRpc
- UI component and analytics events are unchanged
After the connectivity-controller bump to ^0.2.0 the version-skew at
the messenger boundary narrows to event-name aliases: the preview
package's messenger expects each peer's `:stateChanged` event while
mobile's GlobalEvents union still registers the legacy `:stateChange`
flavor. BaseController publishes both at runtime, so wiring works.
@cryptodev-2s cryptodev-2s force-pushed the wpc-1014-use-banner-controller branch from 2abcc76 to 8f62d2b Compare June 10, 2026 22:01
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeConfirmations, SmokeIdentity, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeSwap, SmokeStake, SmokeWalletPlatform, SmokeMoney, SmokePerps, SmokeMultiChainAPI, SmokePredictions, SmokeSeedlessOnboarding, SmokeBrowser, SmokeSnaps
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: high
  • AI Confidence: 100%
click to see 🤖 AI reasoning details

E2E Test Selection:
Hard rule (controller-version-update): @MetaMask controller package version updated in package.json: @metamask/network-connection-banner-controller. Running all tests.

Performance Test Selection:
The changes are a refactoring of the NetworkConnectionBanner from Redux to a controller-based architecture. This does not affect any performance-sensitive flows like app launch, login, onboarding, swaps, asset loading, or account list rendering. No performance test tags are warranted.

View GitHub Actions results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template size-XL team-core-platform Core Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant