Skip to content

chore(stellar): stellar preparation PR - 3 - #34527

Open
khanti42 wants to merge 10 commits into
mainfrom
chore/stellar/preparation-3
Open

chore(stellar): stellar preparation PR - 3#34527
khanti42 wants to merge 10 commits into
mainfrom
chore/stellar/preparation-3

Conversation

@khanti42

@khanti42 khanti42 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Description

Stellar is not live yet, it should have no impact to UX

Adds Stellar (pubnet) plumbing ahead of full Stellar accounts UI, following the same patterns as Bitcoin and Tron.

Wires selectIsStellarAccountsEnabled (existing stellarAccounts remote flag, prod default off) into selectNonEvmNetworkConfigurationsByChainId so Stellar pubnet is only included when the flag is on. Adds Stellar network metadata (decimals, ticker, image) and account-scope handling for XlmScope.Pubnet, plus selector/test coverage.

Updates useNetworksToUse so Stellar networks are only mixed into network pickers when a Stellar account exists in the selected group (same account-gated pattern as Solana/BTC/Tron). Adds XlmScope.Pubnet to popular-network classification sets — these only classify already-configured networks, so with the flag off Stellar still does not appear in Network Manager.

Wires Stellar into Bridge source-network fiat sorting (useSortedSourceNetworks) for when pubnet is already an enabled source chain. Extends Social QuickBuy hooks to resolve Stellar account/balances by scope (no-ops without a Stellar account). Updates related NetworkMultiSelector / CustomNetworkSelector tests.

Intentionally omitted from this PR: Trending / Hot Tokens (trendingNetworksList, useTrendingRequest) — Stellar is already in the trending API, and token details Receive currently falls back to the selected EVM address when no Stellar account exists. We’ll enable Explore/Trending together with accounts at launch.

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Stellar is not live yet, it should have no impact to UX

Screen.Recording.2026-08-10.at.12.26.56.mov

Before

After

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.

Note

Medium Risk
Touches network configuration, token lists, Bridge sorting, and Trending API chain sets, but Stellar paths are gated by a remote flag defaulting off; main risk is accidental exposure or API calls if gating is wrong.

Overview
Adds Stellar pubnet support across multichain networking, Bridge, Quick Buy, and Trending, following the same patterns as Tron/Bitcoin and keeping behavior off until selectIsStellarAccountsEnabled is true.

Networks & selectors: selectNonEvmNetworkConfigurationsByChainId only exposes pubnet when the flag is on (metadata + getActiveNetworksByScopes for XlmScope.Pubnet). useNetworksToUse loads the Stellar namespace and merges Stellar networks only when a Stellar account exists in the selected group. XlmScope.Pubnet is added to popular-network chain ID sets; non-EVM token merging is limited to pubnet for stellar: chains.

Bridge & Quick Buy: Bridge source-network sorting includes Stellar fiat totals via XlmScope.Pubnet. Quick Buy balance/receive/pay hooks resolve a Stellar account and include pubnet in stablecoin receive candidates.

Trending: New useTrendingChainIds centralizes default chain IDs and drops Stellar when accounts are disabled; useTrendingRequest, useSearchRequest, and TrendingTokensFullView use it so Explore network filters and API calls stay aligned with the flag.

Test mocks are updated for the expanded useNetworksToUse return shape and Stellar scenarios.

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

@github-actions

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.

@metamask-ci metamask-ci Bot added the team-networks Networks team label Aug 10, 2026
@metamask-ci

metamask-ci Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

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

Warnings — informational, address before merging:

  • Description section is empty. Describe what changed and why.
  • Related issues section is empty. Add Fixes: #123 / Closes: <URL> / Refs: <Jira key>, or write a short rationale after the colon.
  • Manual testing steps still contain template content (the Gherkin example title or a [...] placeholder). Replace with real steps, or write N/A — <reason>.
  • 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 followed MetaMask Contributor Docs and MetaMask Mobile Coding Standards."). 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.

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

🧪 Flaky unit test detection

Run history flaky detection

View recent run history

Historical failure rate is a hint, not proof — review each suggestion in context. See the flaky-test-detection skill for the full pattern reference and manual audit workflow.

Failures / runs sampled per window:

File 7d 15d 30d
app/components/UI/NetworkMultiSelector/NetworkMultiSelector.test.tsx 0/85 0/196 0/359

AI-detected flaky patterns

app/components/UI/NetworkMultiSelector/NetworkMultiSelector.test.tsx

  • J1 — Missing act() around async state updates (critical)
    • This test extracts an async onSelectNetwork handler from the mocked component props and awaits it directly. Per the mms-flaky-test-detection skill (J1), any async callback that may trigger Redux dispatches or setState (common in network selection) must be wrapped in act() to avoid race conditions with React's update batching. This exact pattern is called out in the skill as occurring in NetworkMultiSelector.test.tsx. The PR changes only extended mock data for Stellar networks in other parts of the file; this pre-existing code was not modified but still carries the risk. No other J1-J10 patterns matched with exact verifiable snippets in any of the four files (e.g. beforeEach uses clearAllMocks(), no waitFor/timers/sleeps/spyOn without restore, no module-level lets, complete enough mock setups given the jest.mocked useSelectors). Historical data showed zero failures.
    • Suggested fix in app/components/UI/NetworkMultiSelector/NetworkMultiSelector.test.tsx:
      -      const networkList = getByTestId('mock-network-multi-selector-list');
      -      const { onSelectNetwork } = networkList.props;
      -      await onSelectNetwork('eip155:1');
      -      expect(mockSelectPopularNetwork).toHaveBeenCalledWith(
      -        'eip155:1',
      -        mockDismissModal,
      -      );
      +      const networkList = getByTestId('mock-network-multi-selector-list');
      +      const { onSelectNetwork } = networkList.props;
      +      await act(async () => {
      +        await onSelectNetwork('eip155:1');
      +      });
      +      expect(mockSelectPopularNetwork).toHaveBeenCalledWith(
      +        'eip155:1',
      +        mockDismissModal,
      +      );

This check is informational only and does not block merging.

allNetworkConfigs?: Record<string, { nativeCurrency?: string } | undefined>;
solanaAccount?: { id: string };
tronAccount?: { id: string };
stellarAccount?: { id: string };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is for quick buy and sell, safe for added when only activate if stellar account exist + bridge FF activate

@@ -82,6 +83,7 @@ export const usePayWithTokens = (): {
allNetworkConfigs,
solanaAccount: solanaAccount ?? undefined,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is for quick buy and sell, safe for added when only activate if stellar account exist + bridge FF activate

@@ -170,6 +173,7 @@ export const usePositionTokenBalance = (
allNetworkConfigs,
solanaAccount: solanaAccount ?? undefined,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is for quick buy and sell, safe for added when only activate if stellar account exist + bridge FF activate

@@ -137,6 +138,7 @@ export const useReceiveTokens = (
);
const solanaAccount = selectAccountByScope(SolScope.Mainnet);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is for quick buy and sell, safe for added when only activate if stellar account exist + bridge FF activate

continue;
}
// We just need stellar pubnet, at least for now
if (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no where is consuming buy only earn screen, stellar does not have token to EARN as for now, we add it just to align with other non-evm

@stanleyyconsensys stanleyyconsensys added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Aug 10, 2026
@khanti42
khanti42 marked this pull request as ready for review August 10, 2026 11:53
@khanti42
khanti42 requested review from a team as code owners August 10, 2026 11:53
@github-actions github-actions Bot added the risk:medium AI analysis: medium risk label Aug 10, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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 cd875bc. Configure here.


if (hasSelectedAccounts.stellar) {
accountSelectionFlags.push(areAllStellarNetworksSelected);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Select-all breaks with Stellar kill switch

Medium Severity

areAllNetworksSelectedCombined treats a present Stellar account as requiring all Stellar networks selected, but Stellar network configs are removed when selectIsStellarAccountsEnabled is off. After a remote kill switch, stellarNetworks is empty so areAllStellarNetworksSelected stays false, and the Network Manager “All popular networks” control stays unselected even when every visible network is selected.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit cd875bc. Configure here.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.75000% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.11%. Comparing base (cbe5e23) to head (bfcc7de).
⚠️ Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
...ponents/hooks/useNetworksToUse/useNetworksToUse.ts 28.57% 3 Missing and 2 partials ⚠️
...useSortedSourceNetworks/useSortedSourceNetworks.ts 40.00% 2 Missing and 1 partial ⚠️
app/selectors/multichain/multichain.ts 0.00% 1 Missing and 2 partials ⚠️
app/selectors/multichainNetworkController/index.ts 50.00% 0 Missing and 3 partials ⚠️
...ew/components/QuickBuy/hooks/enrichTokenBalance.ts 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #34527      +/-   ##
==========================================
- Coverage   85.12%   85.11%   -0.02%     
==========================================
  Files        6350     6369      +19     
  Lines      173080   173715     +635     
  Branches    42804    42983     +179     
==========================================
+ Hits       147333   147852     +519     
- Misses      15708    15777      +69     
- Partials    10039    10086      +47     

☔ 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.

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
Hard rule (global-infrastructure-change): Global infrastructure changed: app/components/hooks/useNetworksToUse/useNetworksToUse.test.ts, app/components/hooks/useNetworksToUse/useNetworksToUse.ts. Running all tests.

Performance Test Selection:
The changes add Stellar network support gated behind a feature flag. While there are new selector computations and hook logic, these are additive changes that don't fundamentally alter rendering performance, asset loading patterns, or app launch behavior. The Trending hook changes refactor existing logic (replacing inline useMemo with a new hook) without adding significant computation. No performance spec files were changed. The changes are unlikely to measurably impact any of the defined performance scenarios (launch, login, onboarding, swaps, asset loading, account list, predict, perps).

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
77.6% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

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

Labels

no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed risk:medium AI analysis: medium risk size-M team-networks Networks team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants