Commit 3bb1ee9
committed
chore(runway): cherry-pick fix: start Ramps V2 init when remote feature flags hydrate cp-7.71.0 (#27778)
## **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**
```gherkin
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**
<div>
<a href="https://www.loom.com/share/e80a3794612d4030aa963834e5a8d7bf">
<p>Fix Ramps controller not initializing on fresh install - Watch
Video</p>
</a>
<a href="https://www.loom.com/share/e80a3794612d4030aa963834e5a8d7bf">
<img style="max-width:300px;"
src="https://cdn.loom.com/sessions/thumbnails/e80a3794612d4030aa963834e5a8d7bf-13202ae1a2494608-full-play.gif#t=0.1">
</a>
</div>
### **Before**
### **After**
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **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.
<!-- CURSOR_SUMMARY -->
---
> [!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.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
78ff800. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 445b430 commit 3bb1ee9
2 files changed
Lines changed: 62 additions & 8 deletions
File tree
- app/core/Engine/controllers/ramps-controller
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
210 | 244 | | |
211 | 245 | | |
212 | 246 | | |
| |||
253 | 287 | | |
254 | 288 | | |
255 | 289 | | |
| 290 | + | |
256 | 291 | | |
257 | 292 | | |
258 | 293 | | |
| |||
Lines changed: 27 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
| 14 | + | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
| |||
54 | 53 | | |
55 | 54 | | |
56 | 55 | | |
57 | | - | |
| 56 | + | |
58 | 57 | | |
59 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
60 | 63 | | |
61 | 64 | | |
62 | 65 | | |
63 | 66 | | |
64 | | - | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
| 71 | + | |
69 | 72 | | |
70 | | - | |
71 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
72 | 78 | | |
73 | 79 | | |
74 | 80 | | |
| |||
77 | 83 | | |
78 | 84 | | |
79 | 85 | | |
80 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
81 | 100 | | |
82 | 101 | | |
83 | 102 | | |
| |||
0 commit comments