Commit bcdaa5c
authored
fix: buy flow quote loading and provider selection (#28373)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
**Quotes felt slow to load** on Buy (Continue / amount screen loading,
modals sluggish) partly because every quote path passed **`forceRefresh:
true`** and React Query used **`staleTime: 0`**, so **`getQuotes` almost
always bypassed the ramps controller cache** (15s TTL) even when token,
amount, provider, and payment method were unchanged.
This PR sets **`RAMPS_QUOTES_STALE_TIME_MS` (15s)** on the quotes
query—aligned with **`RampsController` `DEFAULT_QUOTES_TTL`**—and
**stops passing `forceRefresh`** from Build Quote, provider selection,
and payment selection so controller + React Query can reuse responses
within that window.
**Provider list correctness:** The provider selection modal filtered the
visible list using only the route **`assetId`**. When that param was
absent but **`selectedToken`** was set, the UI could still show every
provider while **`getQuotes`** used the token from **`selectedToken`**,
inflating quote work and mismatching the list vs quotes.
This change uses the same **effective asset id** as quote fetching
(`paramAssetId ?? selectedToken?.assetId`) to derive
**`displayProviders`** from **`supportedCryptoCurrencies`**, so only
providers that support the current asset appear and are included in
quote params.
## **Changelog**
CHANGELOG entry: Fixed buy flow provider selection so only providers
that support the selected asset are shown; improved quote responsiveness
by aligning React Query cache with the ramps quotes TTL (15s) and
avoiding unnecessary `forceRefresh` on each fetch.
## **Related issues**
Fixes:
[TRAM-3425](https://consensyssoftware.atlassian.net/browse/TRAM-3425)
## **Manual testing steps**
```gherkin
Feature: Ramp buy flow quotes and provider selection
Scenario: Provider list matches token support without route asset id
Given user is in the MetaMask buy flow with a token selected
When user opens the provider selection screen
Then only providers that declare support for that token asset id are listed
Scenario: Quotes reuse cache within a short window when inputs unchanged
Given user is on Build Quote with token, provider, payment method, and amount set
When user navigates away and back to the same screen without changing those inputs
Then quote loading should not repeatedly pay full cold-fetch latency where the 15s cache applies
```
## **Screenshots/Recordings**
<div>
<a href="https://www.loom.com/share/4884506a4acd4ff2a20454dc62490b09">
<p>Simulator - Money Movement Sim - 3 April 2026 - Watch Video</p>
</a>
<a href="https://www.loom.com/share/4884506a4acd4ff2a20454dc62490b09">
<img style="max-width:300px;"
src="https://cdn.loom.com/sessions/thumbnails/4884506a4acd4ff2a20454dc62490b09-ebf6caaf52f2a4f2-full-play.gif#t=0.1">
</a>
</div>
## **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**
- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] 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.1 parent 9e56b9f commit bcdaa5c
8 files changed
Lines changed: 65 additions & 15 deletions
File tree
- app/components/UI/Ramp
- Views
- BuildQuote
- Modals
- PaymentSelectionModal
- ProviderSelectionModal
- __snapshots__
- queries
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
434 | | - | |
435 | 434 | | |
436 | 435 | | |
437 | 436 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
361 | | - | |
362 | 361 | | |
363 | 362 | | |
364 | 363 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
99 | 98 | | |
100 | 99 | | |
101 | 100 | | |
| |||
Lines changed: 39 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
| |||
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
| 82 | + | |
80 | 83 | | |
81 | 84 | | |
82 | 85 | | |
| |||
91 | 94 | | |
92 | 95 | | |
93 | 96 | | |
| 97 | + | |
94 | 98 | | |
95 | 99 | | |
96 | 100 | | |
| |||
212 | 216 | | |
213 | 217 | | |
214 | 218 | | |
215 | | - | |
216 | 219 | | |
217 | 220 | | |
218 | 221 | | |
| |||
246 | 249 | | |
247 | 250 | | |
248 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
249 | 275 | | |
250 | 276 | | |
251 | 277 | | |
| |||
254 | 280 | | |
255 | 281 | | |
256 | 282 | | |
257 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
258 | 287 | | |
259 | 288 | | |
260 | 289 | | |
261 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
262 | 294 | | |
263 | 295 | | |
264 | 296 | | |
265 | 297 | | |
266 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
267 | 302 | | |
268 | 303 | | |
269 | 304 | | |
| |||
Lines changed: 10 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
85 | 90 | | |
86 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
87 | 94 | | |
88 | | - | |
| 95 | + | |
89 | 96 | | |
90 | | - | |
| 97 | + | |
91 | 98 | | |
92 | 99 | | |
93 | 100 | | |
| |||
107 | 114 | | |
108 | 115 | | |
109 | 116 | | |
110 | | - | |
111 | 117 | | |
112 | 118 | | |
113 | 119 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
516 | 516 | | |
517 | 517 | | |
518 | 518 | | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
519 | 522 | | |
520 | 523 | | |
521 | 524 | | |
| |||
533 | 536 | | |
534 | 537 | | |
535 | 538 | | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
536 | 542 | | |
537 | 543 | | |
538 | 544 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
2 | 6 | | |
3 | 7 | | |
4 | 8 | | |
| |||
28 | 32 | | |
29 | 33 | | |
30 | 34 | | |
31 | | - | |
32 | 35 | | |
33 | 36 | | |
34 | 37 | | |
| |||
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
44 | | - | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
| |||
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
45 | | - | |
| 48 | + | |
46 | 49 | | |
0 commit comments