Skip to content

feat: gate asset controller polling on unified assets in hooks#30477

Merged
salimtb merged 3 commits into
mainfrom
feat/asset-polling-unified-state-in-hooks
May 20, 2026
Merged

feat: gate asset controller polling on unified assets in hooks#30477
salimtb merged 3 commits into
mainfrom
feat/asset-polling-unified-state-in-hooks

Conversation

@salimtb

@salimtb salimtb commented May 20, 2026

Copy link
Copy Markdown
Contributor

Move the feature-flag check from AssetPollingProvider into each polling hook so polling no-ops with empty input when unified assets state is off, while keeping hook call order stable for the provider.

Description

Changelog

CHANGELOG entry: gate asset controller polling on unified assets in hooks

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

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
Changes when asset-related controllers start/stop polling by moving unified-assets feature-flag gating into each polling hook; risk is moderate because it affects background polling behavior and could change network/load characteristics if the flag state is misinterpreted.

Overview
Moves unified-assets feature-flag gating from AssetPollingProvider into each asset polling hook (useCurrencyRatePolling, useTokenRatesPolling, useTokenDetectionPolling, useTokenBalancesPolling, useMultichainAssetsRatePolling) by resolving normal inputs and then passing an empty input to usePolling when the flag is enabled.

Updates AssetPollingProvider to always mount all polling hooks (stable call order) and adjusts/adds tests to assert that polling does not start when unified assets state is enabled, while provider tests no longer cover the provider-level feature-flag branch.

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

Move the feature-flag check from AssetPollingProvider into each polling
hook so polling no-ops with empty input when unified assets state is off,
while keeping hook call order stable for the provider.
@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.

@salimtb salimtb marked this pull request as ready for review May 20, 2026 19:16
@salimtb salimtb enabled auto-merge May 20, 2026 19:17

@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 dc10eb8. Configure here.

Comment thread app/components/hooks/AssetPolling/useCurrencyRatePolling.ts
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeWalletPlatform, SmokeConfirmations, SmokeSwap, SmokeStake, SmokeNetworkAbstractions, SmokeNetworkExpansion
  • Selected Performance tags: @PerformanceAssetLoading, @PerformanceAccountList
  • Risk Level: medium
  • AI Confidence: 78%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes refactor the asset polling architecture by moving the selectIsAssetsUnifyStateEnabled feature flag check from the AssetPollingProvider level down into each individual polling hook (useCurrencyRatePolling, useTokenBalancesPolling, useTokenDetectionPolling, useTokenRatesPolling, useMultichainAssetsRatePolling).

Key behavioral change: Previously, AssetPollingProvider returned null (skipping all hooks) when the flag was disabled. Now the provider always renders, but each hook individually no-ops (passes [] as input) when the flag is enabled. This is a logic inversion - the flag now controls polling at the hook level rather than the component level.

Impact areas:

  1. Wallet home screen (SmokeWalletPlatform): AssetPollingProvider is mounted in Wallet/index.tsx. Token balances, currency rates, and token detection directly affect what users see on the wallet home screen.
  2. Confirmations (SmokeConfirmations): confirmation-asset-polling-provider uses AssetPollingProvider. Currency rates and token rates are needed for transaction value display.
  3. Swap flows (SmokeSwap): Token rates polling is critical for swap quote accuracy and display.
  4. Stake flows (SmokeStake): Asset rates affect staking value display.
  5. Network/multichain (SmokeNetworkAbstractions, SmokeNetworkExpansion): useMultichainAssetsRatePolling and useTokenBalancesPolling handle multi-chain scenarios including Solana.

The risk is medium because: (a) the logic is equivalent in both flag states (just moved), (b) tests were updated to cover both flag states, but (c) any regression in the flag check logic could cause polling to run when it shouldn't (or not run when it should), breaking asset display across the app.

Performance Test Selection:
The polling hooks directly affect asset and balance loading performance. The refactoring changes when polling starts/stops - if there's a regression where polling runs more frequently than intended (e.g., flag check logic error), it could degrade performance. @PerformanceAssetLoading covers token list rendering and balance fetching which depend on these polling hooks. @PerformanceAccountList is relevant because token balances affect account list display. These tests will catch any performance regressions from the polling behavior change.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@salimtb salimtb added this pull request to the merge queue May 20, 2026
Merged via the queue into main with commit b6dc8ea May 20, 2026
200 of 209 checks passed
@salimtb salimtb deleted the feat/asset-polling-unified-state-in-hooks branch May 20, 2026 21:00
@github-actions github-actions Bot locked and limited conversation to collaborators May 20, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.79.0 Issue or pull request that will be included in release 7.79.0 label May 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants