Commit 889b955
authored
fix(ramps): Fix addPrecreatedOrder's provider id format for legacy prefixed provider ids (#8289)
## Explanation
Fixes `addPrecreatedOrder` to always store `provider.id` in the
canonical `/providers/{code}` format, matching the shape returned by API
responses.
The previous commit
([#8278](#8278)) moved provider ID
normalization into `RampsService` at URL construction time and stopped
normalizing in `addPrecreatedOrder`. However, this caused the stub
order's `provider.id` to be stored as whatever format the caller passed
(e.g. `"paypal"` instead of `"/providers/paypal"`). This mismatch breaks
downstream equality checks — `getOrdersProviders`,
`determinePreferredProvider`, and `useSortedQuotes` all compare
`provider.id` against API-sourced provider lists which use the
`/providers/` prefix.
Changes:
1. **`RampsController.ts`** — Restore `normalizeProviderCode()` call in
`addPrecreatedOrder` to strip any incoming prefix, then rebuild in
canonical `/providers/{normalizedCode}` format. This ensures stub orders
match the shape of API-fetched orders.
2. **`RampsController.test.ts`** — Update `addPrecreatedOrder` test
expectation back to `/providers/paypal`.
3. **`CHANGELOG.md`** — Add Fixed entry for the id format correction.
## Link to mobile PR
link to:
[MetaMask/metamask-mobile#27893](MetaMask/metamask-mobile#27893)
## References
[TRAM-3244](https://consensyssoftware.atlassian.net/browse/TRAM-3244)
Follows:
[#8278](#8278)
## Checklist
- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Low risk: small, localized change to how `addPrecreatedOrder` formats
`provider.id`, plus corresponding test and changelog updates.
>
> **Overview**
> Ensures `RampsController.addPrecreatedOrder` always stores stub orders
with a canonical `provider.id` of `/providers/{code}` by normalizing any
incoming `providerCode` (with or without the `/providers/` prefix).
>
> Updates the related unit test expectation and adds a changelog *Fixed*
entry documenting the provider id normalization for precreated order
stubs.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
934834c. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 38cd6a5 commit 889b955
3 files changed
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5466 | 5466 | | |
5467 | 5467 | | |
5468 | 5468 | | |
5469 | | - | |
| 5469 | + | |
5470 | 5470 | | |
5471 | 5471 | | |
5472 | 5472 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1965 | 1965 | | |
1966 | 1966 | | |
1967 | 1967 | | |
| 1968 | + | |
| 1969 | + | |
1968 | 1970 | | |
1969 | 1971 | | |
1970 | 1972 | | |
1971 | | - | |
| 1973 | + | |
1972 | 1974 | | |
1973 | 1975 | | |
1974 | 1976 | | |
| |||
0 commit comments