…ty (MetaMask#9448)
## Explanation
`@metamask/ramps-controller` normalized provider IDs by stripping a
`/providers/` prefix through a `normalizeProviderCode` helper. This
normalization was applied in two places: across the `getQuotes`
scope-aware selection logic (matching the providers list, each quote's
`provider`, custom-action provider IDs, and the sort-order IDs) and when
building a precreated stub order, where the provider code was re-wrapped
as `/providers/<code>`. The Ramps backend now returns canonical,
non-prefixed provider IDs, so this normalization is unnecessary and
inconsistent with the new contract.
This PR removes provider-ID normalization entirely so IDs are compared
and stored as-is (canonical). Concretely: the `normalizeProviderCode`
function and its public export are removed; the six
`normalizeProviderCode(...)` call sites in the `getQuotes` selection
logic are dropped so the map keys and lookups use the raw provider IDs;
and a precreated stub order's `provider.id` is now the canonical
provider code passed to the create-order call rather than a
`/providers/`-prefixed value. The dedicated `normalizeProviderCode` unit
test is removed and the stub-order test now expects the canonical
`paypal` ID.
One detail worth calling out for reviewers: the six removed call sites
were added recently in MetaMask#9353 (scope-aware in-app provider widening).
Because normalization is removed uniformly from both sides of every map
key and lookup, matching behavior is preserved for
consistently-formatted IDs, and the existing `getQuotes` tests continue
to pass unchanged (308 tests green).
This is a breaking change: `normalizeProviderCode` is no longer
exported, and the precreated stub order's `provider.id` changes shape
from `/providers/<code>` to `<code>`. Consumers must supply non-prefixed
(canonical) provider IDs. The mobile consumer PR removes all
`normalizeProviderCode` usages and the app-side normalization to adopt
this.
## References
* Fixes: https://consensyssoftware.atlassian.net/browse/TRAM-3560
* Consumer PR (mobile):
MetaMask/metamask-mobile#32819
* Related to MetaMask#9353 (introduced the `getQuotes` normalization removed
here)
## 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)
- [x] 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]
> **Medium Risk**
> Breaking API and state shape changes for buy/quote flows; wrong IDs
from consumers that still pass `/providers/`-prefixed values could break
quote selection or order polling until clients migrate.
>
> **Overview**
> **Breaking change:** `@metamask/ramps-controller` drops `/providers/`
prefix normalization so provider IDs are compared and stored as
canonical codes (e.g. `paypal`, `transak`).
>
> The **`normalizeProviderCode` helper and its public export are
removed**. In **`getQuotes`** scope-aware selection, maps and lookups
now use raw `provider.id`, quote `provider`, custom-action `providerId`,
and sort-order IDs with no stripping. **`addPrecreatedOrder`** sets stub
`provider.id` to the passed `providerCode` instead of
`/providers/<code>`.
>
> JSDoc and the changelog document the contract. Tests drop the
normalizer suite, expect canonical `paypal` on stubs, and add coverage
for plain-ID matching in scoped quote selection.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
e352e4f. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Darius Costolas <10818970+meltingice1337@users.noreply.github.com>
Description
Backend ramps entity ids (providers, payment methods, currencies, regions) are migrating from the legacy path form (e.g.
/providers/transak) to the canonical, non-prefixed form (e.g.transak). The client had accumulated defensive normalization to strip the legacy prefix, and one comparison that keyed directly off the legacy prefix. Now that provider ids arrive canonical, the normalization is redundant and the prefix-based comparison no longer matches. This PR aligns the ramps client with canonical (non-prefixed) provider ids.Two mechanical changes:
normalizeProviderCode(id)from@metamask/ramps-controlleris justid.replace(/^\/providers\//, ''). With canonical ids it is a no-op, so the wrapping calls are removed and the raw id/code is used directly. Affected call sites:BuildQuote.tsx(matching the selected provider against a quote'sprovider),Checkout.tsx(addPrecreatedOrderprovider code),BankDetails.tsx/OrderDetails.tsx/useTransakRouting.ts(therefreshOrderprovider code, including thetransak-nativedeposit fallback),useContinueWithQuote.ts(widget provider code), andunifiedOrderProcessor.ts(order provider code).SettingsModal.tsx).isTransakNativeProvidermatched on the legacy path prefix'/providers/transak-native', which never matches a canonicaltransak-nativeid, so the "Log out of Transak" option would silently disappear once ids went non-prefixed. It now matches the canonical code'transak-native', still covering thetransak-native-stagingvariant viastartsWith.Tests are updated accordingly: cases that asserted the prefix-stripping behavior are removed, and the Settings modal test now exercises the canonical
transak-nativecode.Changelog
CHANGELOG entry: Fixed the ramps Settings "Log out of Transak" option and provider-code handling so they keep working after backend provider ids move to the non-prefixed format.
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/TRAM-3560
Manual testing steps
Screenshots/Recordings
N/A — no new UI. The only user-visible effect is that the existing "Log out of Transak" option keeps rendering when the provider id arrives in the non-prefixed form; the remaining changes are internal provider-code plumbing. Behavior is covered by unit tests.
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Medium Risk
Touches buy/checkout/order-refresh paths across ramps; a mismatch between API ids and client assumptions could break quote selection or order polling, though scope is mostly mechanical id plumbing plus one user-visible Settings fix.
Overview
Aligns the ramps UI with canonical, non-prefixed provider ids (e.g.
transakinstead of/providers/transak) after the backend migration, by bumping@metamask/ramps-controllerto ^16.0.0 and stopping client-side prefix stripping.Provider codes are passed through unchanged everywhere
normalizeProviderCodewas used: quote matching in Build Quote, Checkout precreated orders, order refresh in Order Details / Bank Details / Transak routing / unified order processor, and continue-with-quote widget flows. Comparisons now use strict equality on the raw id.Settings modal Transak logout detection no longer keys off the legacy path prefix
'/providers/transak-native'(which would never match canonical ids). It now matches the canonical codetransak-native, still coveringtransak-native-stagingviastartsWith.Tests drop prefix-normalization scenarios and use canonical mock provider ids.
Reviewed by Cursor Bugbot for commit a8e08f0. Bugbot is set up for automated code reviews on this repo. Configure here.