Skip to content

feat: cp-7.81.0 scope QuickBuy networks to user-enabled networks#31092

Merged
xavier-brochard merged 5 commits into
mainfrom
feat/quickbuy-enabled-network-pills
Jun 5, 2026
Merged

feat: cp-7.81.0 scope QuickBuy networks to user-enabled networks#31092
xavier-brochard merged 5 commits into
mainfrom
feat/quickbuy-enabled-network-pills

Conversation

@xavier-brochard

@xavier-brochard xavier-brochard commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Description

QuickBuy's "Pay with" / "Receive" screen was showing network pills (and token rows) for every candidate network, including ones the user never enabled (e.g. HyperEVM, Sei, Tempo). Some of those also rendered as "Unknown network" because they aren't present in the user's NetworkController state.

This PR scopes QuickBuy to the networks the user has actually enabled and makes popular network names resolve to a readable label:

  1. Filter by enabled networks. A new self-contained useNetworkEnabledPredicate hook returns a (chainId) => boolean predicate backed by selectEVMEnabledNetworks (hex) and selectNonEVMEnabledNetworks (CAIP), branching on isNonEvmChainId. It's applied at the token-options layer (useSourceTokenOptions and useSellDestTokenOptions) so pills, token rows, and default selection all stay consistent — disabled networks can't be implicitly selected.
  2. Readable fallback names. resolveNetworkDisplayName now falls back to the curated NETWORK_TO_NAME_MAP for EVM hex and eip155 CAIP chain IDs, so known popular networks (MegaETH, HyperEVM, …) show their real name instead of "Unknown network".

The filtering lives in the hooks rather than the UI component, keeping the existing useIsNetworkEnabled per-chain hook untouched.

Changelog

CHANGELOG entry: Fixed QuickBuy showing networks the user hasn't enabled and labeling some networks as "Unknown network".

Related issues

Fixes: TSA-617 and TSA-620

Manual testing steps

Feature: QuickBuy network scoping

  Scenario: Receive screen hides disabled networks
    Given a network such as Sei is not enabled
    When the user opens QuickBuy and views the "Receive" screen
    Then no pill or token row is shown for Sei

  Scenario: Enabling a network reveals it in QuickBuy
    Given the user enables Sei via the network selector
    When the user re-opens the QuickBuy "Receive" screen
    Then a pill and token rows for Sei are shown

  Scenario: Popular networks show a readable name
    Given MegaETH/HyperEVM are not configured in NetworkController
    When their pill is rendered
    Then the curated network name is shown instead of "Unknown network"

Screenshots/Recordings

Before

image

After

image

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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.
    Made with Cursor

Note

Low Risk
UI filtering and display-name fallbacks only; no auth, transactions, or persistence changes beyond existing enablement selectors.

Overview
QuickBuy Pay with / Receive lists now only include tokens on networks the user has enabled, via a new useNetworkEnabledPredicate hook wired into useSourceTokenOptions and useSellDestTokenOptions so pills, rows, and defaults stay aligned.

Network labels: resolveNetworkDisplayName falls back to curated NETWORK_TO_NAME_MAP (e.g. MegaETH, HyperEVM) when a chain isn’t in NetworkController state, including eip155 CAIP IDs. NETWORK_TO_NAME_MAP build is guarded when NETWORK_CHAIN_ID is undefined in tests so UI imports don’t throw at module load.

Reviewed by Cursor Bugbot for commit ba0104a. Bugbot is set up for automated code reviews on this repo. Configure here.

Filter QuickBuy "Pay with" / "Receive" token options to networks the
user has enabled via NetworkEnablementController, hiding pills for
disabled networks (e.g. HyperEVM, Sei, Tempo). Also fall back to the
curated NETWORK_TO_NAME_MAP so popular networks render a readable name
instead of "Unknown network".

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

github-actions Bot commented Jun 4, 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 the team-social-ai Social & AI team label Jun 4, 2026
@github-actions github-actions Bot added pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. size-M labels Jun 4, 2026
@xavier-brochard xavier-brochard removed the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label Jun 4, 2026
@xavier-brochard xavier-brochard marked this pull request as ready for review June 4, 2026 16:50
@github-actions github-actions Bot added the risk:high AI analysis: high risk label Jun 4, 2026
@xavier-brochard xavier-brochard enabled auto-merge June 4, 2026 17:01
Importing NETWORK_TO_NAME_MAP from core/Engine/constants made
NetworkMultiSelectorUtils crash in suites that mock customNetworks
(NETWORK_CHAIN_ID is undefined, so the eager map build throws at import
time). Replace it with a self-contained local fallback map, decoupling
the UI util from the Engine layer.

Co-authored-by: Cursor <cursoragent@cursor.com>
@xavier-brochard xavier-brochard disabled auto-merge June 4, 2026 17:28
Instead of redefining popular network names in the UI util, reuse the
canonical NETWORK_TO_NAME_MAP and guard its construction in
core/Engine/constants against an undefined NETWORK_CHAIN_ID, so the
module stays importable in suites that mock customNetworks.

Co-authored-by: Cursor <cursoragent@cursor.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.00%. Comparing base (000d79f) to head (3104e52).
⚠️ Report is 92 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #31092      +/-   ##
==========================================
+ Coverage   82.86%   83.00%   +0.14%     
==========================================
  Files        5582     5606      +24     
  Lines      144198   144368     +170     
  Branches    33521    33537      +16     
==========================================
+ Hits       119483   119830     +347     
+ Misses      16682    16466     -216     
- Partials     8033     8072      +39     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@xavier-brochard xavier-brochard enabled auto-merge June 5, 2026 10:00
@mm-token-exchange-service mm-token-exchange-service Bot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Jun 5, 2026
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeNetworkAbstractions, SmokeWalletPlatform, SmokePredictions, SmokePerps, SmokeConfirmations
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 82%
click to see 🤖 AI reasoning details

E2E Test Selection:

Changes analyzed:

  1. app/core/Engine/constants.ts (CRITICAL): Defensive guard for NETWORK_CHAIN_ID being undefined when test suites mock customNetworks to a partial object. The NETWORK_TO_NAME_MAP now uses a safe CHAIN_ID alias (CHAIN_ID = NETWORK_CHAIN_ID ?? {}). This is a runtime safety fix that prevents module-eval-time throws. No behavioral change in production, but it's a critical file that warrants validation.

  2. app/components/UI/NetworkMultiSelector/NetworkMultiSelectorUtils.ts: Enhanced resolveNetworkDisplayName to fall back to NETWORK_TO_NAME_MAP for known networks (MegaETH, HyperEVM) not yet in the user's NetworkController state. This is used by NetworkMultiSelector.tsx which is directly imported by tests/page-objects/wallet/NetworkManager.ts and tests/smoke/networks/network-manager.spec.ts (tagged SmokeNetworkAbstractions) and tests/smoke/networks/homepage-sections-network-filter.spec.ts (tagged SmokeWalletPlatform).

  3. useNetworkEnabledPredicate.ts (NEW) + useSourceTokenOptions.ts (updated): New hook filters QuickBuy source/sell-dest token candidates by user-enabled networks. QuickBuy is used in Predictions (SmokePredictions) and Perps (SmokePerps) flows. This is a behavioral change — tokens on disabled networks will no longer appear in QuickBuy.

Tag selection rationale:

  • SmokeNetworkAbstractions: NetworkMultiSelectorUtils is directly used in Network Manager tests; the fallback name resolution change needs validation.
  • SmokeWalletPlatform: homepage-sections-network-filter.spec.ts imports NetworkMultiSelector and is tagged SmokeWalletPlatform; also required by SmokePerps and SmokePredictions per their tag descriptions.
  • SmokePredictions: QuickBuy token filtering by enabled networks directly affects Predictions flows (open/close positions use QuickBuy).
  • SmokePerps: QuickBuy token filtering by enabled networks directly affects Perps Add Funds flow.
  • SmokeConfirmations: Required by both SmokePerps and SmokePredictions per their tag descriptions (on-chain transactions go through confirmations).

Performance tests: No performance-sensitive changes — the modifications are defensive guards and filtering logic, not rendering or data-loading changes that would affect measured performance metrics.

Performance Test Selection:
The changes are defensive guards (Engine constants null-safety) and filtering logic (useNetworkEnabledPredicate). No UI rendering performance, list rendering, data loading, or app startup changes that would affect measured performance metrics. No changes to performance-sensitive components like AccountSelector, NetworkSelector, or critical user flow timing.

View GitHub Actions results

@mm-token-exchange-service mm-token-exchange-service Bot removed the INVALID-PR-TEMPLATE PR's body doesn't match template label Jun 5, 2026
@xavier-brochard xavier-brochard added this pull request to the merge queue Jun 5, 2026
@xavier-brochard xavier-brochard changed the title feat: scope QuickBuy networks to user-enabled networks feat: cp-7.81.0 scope QuickBuy networks to user-enabled networks Jun 5, 2026
Merged via the queue into main with commit ec2914b Jun 5, 2026
248 of 264 checks passed
@xavier-brochard xavier-brochard deleted the feat/quickbuy-enabled-network-pills branch June 5, 2026 14:45
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 5, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.82.0 Issue or pull request that will be included in release 7.82.0 label Jun 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.82.0 Issue or pull request that will be included in release 7.82.0 risk:high AI analysis: high risk size-M team-social-ai Social & AI team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants