Skip to content

feat: remove provider ID normalization and update related functionality#9448

Merged
meltingice1337 merged 6 commits into
mainfrom
feat/TRAM-3560-non-prefix-providers
Jul 10, 2026
Merged

feat: remove provider ID normalization and update related functionality#9448
meltingice1337 merged 6 commits into
mainfrom
feat/TRAM-3560-non-prefix-providers

Conversation

@meltingice1337

@meltingice1337 meltingice1337 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

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 #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

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

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.

Reviewed by Cursor Bugbot for commit e352e4f. Bugbot is set up for automated code reviews on this repo. Configure here.

@meltingice1337 meltingice1337 requested review from a team as code owners July 9, 2026 13:47
…ion and removal of normalizeProviderCode export
The messenger-action-types:check CI step failed because RampsController-method-action-types.ts embeds the getBuyWidgetData method JSDoc, which changed when the providerCode param doc was updated to describe canonical (non-prefixed) provider codes. Regenerated via messenger-action-types --generate.
@meltingice1337 meltingice1337 force-pushed the feat/TRAM-3560-non-prefix-providers branch from 1bf463e to d67a44d Compare July 9, 2026 15:06
wenfix
wenfix previously approved these changes Jul 10, 2026
wenfix
wenfix previously approved these changes Jul 10, 2026
…efix-providers

# Conflicts:
#	packages/ramps-controller/CHANGELOG.md
@meltingice1337 meltingice1337 added this pull request to the merge queue Jul 10, 2026
Merged via the queue into main with commit aae70c3 Jul 10, 2026
421 checks passed
@meltingice1337 meltingice1337 deleted the feat/TRAM-3560-non-prefix-providers branch July 10, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants