feat: cp-7.81.0 scope QuickBuy networks to user-enabled networks#31092
Conversation
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>
|
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. |
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>
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Changes analyzed:
Tag selection rationale:
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: |
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
NetworkControllerstate.This PR scopes QuickBuy to the networks the user has actually enabled and makes popular network names resolve to a readable label:
useNetworkEnabledPredicatehook returns a(chainId) => booleanpredicate backed byselectEVMEnabledNetworks(hex) andselectNonEVMEnabledNetworks(CAIP), branching onisNonEvmChainId. It's applied at the token-options layer (useSourceTokenOptionsanduseSellDestTokenOptions) so pills, token rows, and default selection all stay consistent — disabled networks can't be implicitly selected.resolveNetworkDisplayNamenow falls back to the curatedNETWORK_TO_NAME_MAPfor EVM hex andeip155CAIP 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
useIsNetworkEnabledper-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
Screenshots/Recordings
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
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
useNetworkEnabledPredicatehook wired intouseSourceTokenOptionsanduseSellDestTokenOptionsso pills, rows, and defaults stay aligned.Network labels:
resolveNetworkDisplayNamefalls back to curatedNETWORK_TO_NAME_MAP(e.g. MegaETH, HyperEVM) when a chain isn’t inNetworkControllerstate, includingeip155CAIP IDs.NETWORK_TO_NAME_MAPbuild is guarded whenNETWORK_CHAIN_IDis 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.