Skip to content

fix: gate asset polling on unified assets flag without violating hooks#30381

Merged
salimtb merged 4 commits into
mainfrom
feat/asset-polling-unified-state-gate
May 20, 2026
Merged

fix: gate asset polling on unified assets flag without violating hooks#30381
salimtb merged 4 commits into
mainfrom
feat/asset-polling-unified-state-gate

Conversation

@salimtb

@salimtb salimtb commented May 19, 2026

Copy link
Copy Markdown
Contributor

Mount polling hooks only when unified assets state is enabled, using a split provider so hook order stays stable. Update tests to mock selectors and cover the disabled path.

Description

Changelog

CHANGELOG entry: gate asset polling on unified assets flag without violating 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 polling hooks are mounted based on a feature flag, which can affect token/rate refresh behavior if the flag value or selector wiring is incorrect. Scope is contained to the polling provider and its unit tests.

Overview
Gates asset polling behind the unified assets feature flag. AssetPollingProvider now checks selectIsAssetsUnifyStateEnabled and returns null when disabled.

To avoid conditional hook invocation, polling hooks were moved into a separate AssetPollingEnabledContent component that only renders when the flag is enabled. Tests were updated to mock the new selector and to assert hooks are not mounted when the flag is off, while keeping existing parameter assertions when enabled.

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

Mount polling hooks only when unified assets state is enabled, using a
split provider so hook order stays stable. Update tests to mock selectors
and cover the disabled path.
@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 19, 2026 13:49
@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 May 19, 2026
@salimtb salimtb 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 19, 2026
@salimtb salimtb enabled auto-merge May 19, 2026 16:42
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.02%. Comparing base (4805c34) to head (48781f7).

Files with missing lines Patch % Lines
...onents/hooks/AssetPolling/AssetPollingProvider.tsx 95.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #30381      +/-   ##
==========================================
- Coverage   82.02%   82.02%   -0.01%     
==========================================
  Files        5451     5451              
  Lines      145587   145595       +8     
  Branches    33322    33323       +1     
==========================================
+ Hits       119422   119425       +3     
- Misses      18005    18010       +5     
  Partials     8160     8160              

☔ 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

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The changes refactor AssetPollingProvider to gate all asset polling hooks behind the selectIsAssetsUnifyStateEnabled feature flag. When the flag is disabled, no polling hooks run (returns null); when enabled, polling proceeds as before via a new inner component.

Key impact areas:

  1. SmokeWalletPlatform: AssetPollingProvider is mounted in the main Wallet view (app/components/Views/Wallet/index.tsx). Asset polling drives token balances, currency rates, token detection, and multichain asset rates displayed on the wallet home screen. If the feature flag behavior is incorrect, balances and token data may not load.

  2. SmokeConfirmations: The confirmation-asset-polling-provider component wraps AssetPollingProvider for use during transaction confirmations. Asset data (token rates, balances) is needed for accurate fee/value display in confirmations.

  3. SmokeNetworkAbstractions: Multi-chain token filtering and network-specific token display depend on asset polling (useTokenBalancesPolling, useTokenDetectionPolling with chainIds). The TokensFullView also uses this provider.

The change is a refactor with a feature flag guard - relatively low risk since existing behavior is preserved when the flag is enabled. However, the flag-gating logic is new and could introduce regressions if the flag state is not correctly read or if the conditional rendering causes hook ordering issues (React rules of hooks). The test file confirms the new behavior is tested at unit level, but E2E validation is warranted for the affected user flows.

Performance Test Selection:
AssetPollingProvider directly controls when token balances, currency rates, token rates, and multichain asset rates are polled. The refactor adds a feature flag check that conditionally mounts/unmounts the polling hooks. This could affect asset loading performance - if the flag check adds overhead or if the conditional mounting changes the timing of when assets start loading. @PerformanceAssetLoading covers token list rendering, balance fetching, and portfolio value calculation which are all driven by the polling hooks in this component.

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 62dca2a May 20, 2026
190 of 237 checks passed
@salimtb salimtb deleted the feat/asset-polling-unified-state-gate branch May 20, 2026 11:15
@github-actions github-actions Bot locked and limited conversation to collaborators May 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants