feat: remove provider ID normalization and update related functionality#9448
Open
meltingice1337 wants to merge 3 commits into
Open
feat: remove provider ID normalization and update related functionality#9448meltingice1337 wants to merge 3 commits into
meltingice1337 wants to merge 3 commits into
Conversation
…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.
1bf463e to
d67a44d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
@metamask/ramps-controllernormalized provider IDs by stripping a/providers/prefix through anormalizeProviderCodehelper. This normalization was applied in two places: across thegetQuotesscope-aware selection logic (matching the providers list, each quote'sprovider, 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
normalizeProviderCodefunction and its public export are removed; the sixnormalizeProviderCode(...)call sites in thegetQuotesselection logic are dropped so the map keys and lookups use the raw provider IDs; and a precreated stub order'sprovider.idis now the canonical provider code passed to the create-order call rather than a/providers/-prefixed value. The dedicatednormalizeProviderCodeunit test is removed and the stub-order test now expects the canonicalpaypalID.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
getQuotestests continue to pass unchanged (308 tests green).This is a breaking change:
normalizeProviderCodeis no longer exported, and the precreated stub order'sprovider.idchanges shape from/providers/<code>to<code>. Consumers must supply non-prefixed (canonical) provider IDs. The mobile consumer PR removes allnormalizeProviderCodeusages and the app-side normalization to adopt this.References
getQuotesnormalization removed here)Checklist
Note
Medium Risk
Breaking public API and order stub shape; quote auto-selection can mis-match if callers still send prefixed IDs, but behavior is aligned with the backend contract.
Overview
Breaking:
@metamask/ramps-controllerstops stripping/providers/from provider IDs. ThenormalizeProviderCodehelper and its package export are removed.getQuotesscope-aware selection (providers list, quoteprovider, custom actions, sort order) now compares IDs as returned by the API.addPrecreatedOrderstores the stub’sprovider.idas the canonical code you pass in (e.g.paypal), not/providers/paypal.Consumers must pass and expect non-prefixed provider IDs everywhere this package matches or persists them. Changelog and JSDoc are updated; tests drop the normalizer suite and assert the new stub shape.
Reviewed by Cursor Bugbot for commit d67a44d. Bugbot is set up for automated code reviews on this repo. Configure here.