Skip to content

chore: align data fetch on stocks#29795

Merged
juanmigdr merged 4 commits into
mainfrom
chore/align-data-fetch-on-stocks
May 7, 2026
Merged

chore: align data fetch on stocks#29795
juanmigdr merged 4 commits into
mainfrom
chore/align-data-fetch-on-stocks

Conversation

@juanmigdr
Copy link
Copy Markdown
Member

@juanmigdr juanmigdr commented May 6, 2026

Description

The useStocksFeed hook was passing chainIds: ['eip155:1'] to useRwaTokens when no search query was active, restricting the API fetch to Ethereum mainnet only. The RWATokensFullView (full-screen Stocks view) fetches from all RWA-supported chains (Ethereum + BNB Chain) by default.

This mismatch caused the two views to operate on different datasets, leading to inconsistent sort order: tokens available on BNB Chain (e.g. Cipher Mining Ondo Tokenized) appeared at the top of the full-screen view due to a higher 24h price change, but were completely absent from the section widget, making a lower-ranked Ethereum token incorrectly appear first there.

The fix removes the chainIds override from useStocksFeed so it fetches the same combined dataset as the full-screen view. A client-side filter is then applied to return only Ethereum mainnet tokens to the section, preserving the intended display scope while correctly reflecting the global sort order.

Changelog

CHANGELOG entry: align data fetch on stocks

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-3149 & https://consensyssoftware.atlassian.net/browse/ASSETS-3155 & https://consensyssoftware.atlassian.net/browse/ASSETS-3154

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

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
Moderate UI/data behavior change: alters what assets appear in Trending sections by shifting RWA chain filtering client-side and optionally hiding risky tokens, which could affect ordering/visibility but not security-critical flows.

Overview
Aligns the Trending Stocks section with the full RWA dataset by removing the chainIds constraint from the useRwaTokens request and instead filtering to Ethereum mainnet locally (by assetId CAIP prefix) to avoid cache divergence and inconsistent sorting.

Adds an optional hideRiskyTokens flag to useTokensFeed to filter out tokens marked Warning, Spam, or Malicious (keeping Verified, Benign, and unscanned), enables it for the Crypto movers pills in NowTab, and extends unit tests to cover the new filtering behavior.

Updates English strings so the RWA perps section/pill labels display "Perps" instead of "Markets"/"Stocks & commodities".

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

@github-actions github-actions Bot added 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 May 6, 2026
@github-actions github-actions Bot added the size-S label May 6, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

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 2 potential issues.

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 7402fc8. Configure here.

Comment thread app/components/Views/TrendingView/feeds/stocks/useStocksFeed.ts
Comment thread app/components/Views/TrendingView/feeds/stocks/useStocksFeed.ts
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.49%. Comparing base (8208502) to head (768df8f).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #29795      +/-   ##
==========================================
+ Coverage   81.44%   81.49%   +0.04%     
==========================================
  Files        5318     5319       +1     
  Lines      140909   140914       +5     
  Branches    32109    32108       -1     
==========================================
+ Hits       114767   114839      +72     
+ Misses      18263    18229      -34     
+ Partials     7879     7846      -33     

☔ View full report in Codecov by Sentry.
📢 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 github-actions Bot added size-M and removed size-S labels May 7, 2026
@juanmigdr juanmigdr enabled auto-merge May 7, 2026 11:17
@juanmigdr juanmigdr 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 May 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeWalletPlatform, SmokePerps
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
All 5 changed files are scoped to the TrendingView feature area:

  1. useStocksFeed.ts: Changed from server-side chain filtering (chainIds param) to client-side filtering via useMemo, filtering RWA tokens to Ethereum mainnet only. This affects the Stocks section in the Trending tab.

  2. useTokensFeed.ts: Added hideRiskyTokens option that filters out Warning/Spam/Malicious tokens when enabled. This is a new filtering capability for the tokens feed.

  3. NowTab.tsx: Applies hideRiskyTokens: true to the crypto movers section in the Trending Now tab, so risky tokens are hidden from users in that surface.

  4. useTokensFeed.test.ts: Unit tests for the new hideRiskyTokens functionality - no E2E impact.

  5. locales/languages/en.json: Changed rwa_perps_section from "Markets" to "Perps" and macro_stocks_commodity_perps from "Stocks & commodities" to "Perps" - these are UI labels in the Perps section within Trending.

Tag selection rationale:

  • SmokeWalletPlatform: Directly covers the Trending discovery tab including Tokens views, Perps section, and browser navigation integration. The NowTab crypto movers filtering change and stocks feed change are core to this tag.
  • SmokePerps: The locale string changes affect Perps section labels within Trending (rwa_perps_section, macro_stocks_commodity_perps). Per tag description, Perps is a section inside Trending (SmokeWalletPlatform), and when selecting SmokePerps, also select SmokeWalletPlatform.

No other flows (confirmations, accounts, network, swap, identity, browser, snaps) are affected by these changes.

Performance Test Selection:
The changes involve client-side filtering with useMemo (minimal overhead) and locale string updates. No significant performance impact is expected - the filtering is lightweight and the useMemo dependency arrays are properly managed. No performance tests are warranted.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 7, 2026

@juanmigdr juanmigdr added this pull request to the merge queue May 7, 2026
Merged via the queue into main with commit ec11b69 May 7, 2026
134 of 137 checks passed
@juanmigdr juanmigdr deleted the chore/align-data-fetch-on-stocks branch May 7, 2026 13:32
@github-actions github-actions Bot locked and limited conversation to collaborators May 7, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.77.0 Issue or pull request that will be included in release 7.77.0 label May 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.77.0 Issue or pull request that will be included in release 7.77.0 size-M team-assets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants