Skip to content

fix: start Ramps V2 init when remote feature flags hydrate cp-7.71.0#27778

Merged
amitabh94 merged 2 commits into
mainfrom
fix/ramps-v2-init-remote-flags-hydrate
Mar 23, 2026
Merged

fix: start Ramps V2 init when remote feature flags hydrate cp-7.71.0#27778
amitabh94 merged 2 commits into
mainfrom
fix/ramps-v2-init-remote-flags-hydrate

Conversation

@amitabh94
Copy link
Copy Markdown
Contributor

@amitabh94 amitabh94 commented Mar 22, 2026

Description

On a fresh install, RemoteFeatureFlagController loads flags asynchronously while Engine builds controllers. rampsControllerInit previously read the unified buy V2 flag only once; if flags were not in state yet, RampsController.init() never ran, so buy token lists stayed empty until a full app restart.

This change subscribes to RemoteFeatureFlagController:stateChange (already delegated on RampsControllerInitMessenger) and re-runs the same V2 startup path when remote flag state updates. Order-status subscriptions are registered at most once. RampsController.init() remains idempotent for repeated calls.

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/TRAM-3350

Manual testing steps

Feature: Unified buy V2 after fresh install

  Scenario: Buy token list loads without restarting the app
    Given a dev build with unified buy V2 enabled via remote flags
    And the app is installed fresh (or remote flag cache cleared)

    When the user completes onboarding and opens Buy / token selection
    Then tokens and providers load without requiring an app restart

Screenshots/Recordings

Before

After

Pre-merge author checklist

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
Adds a new subscription-driven initialization path triggered by RemoteFeatureFlagController:stateChange, which can change startup behavior and potentially cause repeated init/polling if underlying idempotency assumptions are wrong.

Overview
Ensures Unified Buy V2 startup runs even when remote feature flags hydrate after Engine/controller initialization by subscribing to RemoteFeatureFlagController:stateChange and re-checking the V2 flag.

Refactors V2 startup into a helper that conditionally calls RampsController.init()/startOrderPolling() and registers order-status subscriptions only once. Updates tests to cover the “flag off at startup then enabled on stateChange” scenario and to include subscribe in the thrown-state mock.

Written by Cursor Bugbot for commit 78ff800. This will update automatically on new commits. Configure here.

@amitabh94 amitabh94 self-assigned this Mar 22, 2026
@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.

Subscribe to RemoteFeatureFlagController:stateChange and retry unified buy
V2 startup when flags become available after async fetch (e.g. fresh
install). Register order subscriptions once; RampsController.init remains
idempotent for repeated calls.

Add unit test for flag hydration after stateChange.

Made-with: Cursor
@amitabh94 amitabh94 force-pushed the fix/ramps-v2-init-remote-flags-hydrate branch from 7a7a09f to 7df1623 Compare March 22, 2026 04:37
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

⏭️ Smart E2E selection skipped - draft PR

All E2E tests pre-selected.

View GitHub Actions results

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.44%. Comparing base (d86db93) to head (78ff800).
⚠️ Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
...trollers/ramps-controller/ramps-controller-init.ts 83.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #27778      +/-   ##
==========================================
+ Coverage   77.80%   82.44%   +4.63%     
==========================================
  Files        4802     4801       -1     
  Lines      123906   123800     -106     
  Branches    27594    27595       +1     
==========================================
+ Hits        96410   102065    +5655     
+ Misses      20523    14665    -5858     
- Partials     6973     7070      +97     

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

@sonarqubecloud
Copy link
Copy Markdown

@amitabh94 amitabh94 added the team-money-movement issues related to Money Movement features label Mar 22, 2026
@amitabh94 amitabh94 changed the title fix: start Ramps V2 init when remote feature flags hydrate fix: start Ramps V2 init when remote feature flags hydrate cp-7.71.0 Mar 22, 2026
@amitabh94 amitabh94 marked this pull request as ready for review March 22, 2026 05:18
@amitabh94 amitabh94 requested a review from a team as a code owner March 22, 2026 05:18
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 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.

@github-actions
Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
17 value mismatches detected (expected — fixture represents an existing user).
View details

@amitabh94 amitabh94 enabled auto-merge March 22, 2026 05:35
@amitabh94 amitabh94 added this pull request to the merge queue Mar 23, 2026
Merged via the queue into main with commit c6d96b6 Mar 23, 2026
225 of 227 checks passed
@amitabh94 amitabh94 deleted the fix/ramps-v2-init-remote-flags-hydrate branch March 23, 2026 13:56
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 23, 2026
@metamaskbot metamaskbot added the release-7.72.0 Issue or pull request that will be included in release 7.72.0 label Mar 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.72.0 Issue or pull request that will be included in release 7.72.0 size-S team-money-movement issues related to Money Movement features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants