[pull] main from MetaMask:main#658
Merged
Merged
Conversation
…sing (#9159) ## Summary Fixes duplicate fiat-on-ramp Activity rows (TRAM-3539) when redirect providers (Moonpay, PayPal, Coinbase, etc.) return a provider-native id in `providerOrderId` while the precreated stub used MetaMask's internal order code (`c-{guid}`). **Root cause:** `RampsController` merged orders on `providerOrderId`. After precreate, stub and API/callback updates often disagree on that field even though they represent the same buy. **Fix:** Introduce `getInternalOrderCode()` to derive the canonical code from `order.id` (`/providers/{provider}/orders/{code}`), then merge/heal in `addOrder`, `getOrder`, and `addPrecreatedOrder` on that key. Stored `providerOrderId` is normalized to the internal code so polling continues to use `c-{guid}` (supported by on-ramp-api → Moonpay `/v1/transactions/ext/{code}`). ## Changes - Export `getInternalOrderCode()` from `@metamask/ramps-controller` - Merge orders by internal order code, not provider-native `providerOrderId` - Regression test: precreated stub + API order with mismatched `providerOrderId` → single merged row - Changelog entry under `[Unreleased]` → Fixed ## Preview build `@metamask-previews/ramps-controller@14.2.0-preview-589a499` ## Related PRs - Mobile QA (preview): MetaMask/metamask-mobile#31837 ## Out of scope - No on-ramp-api changes (BE already resolves Moonpay orders by internal `c-` code) - Mobile follow-up after merge: bump to released `@metamask/ramps-controller` (drop preview) ## Test plan - [x] `yarn workspace @metamask/ramps-controller run jest packages/ramps-controller/src/RampsController.test.ts` (285 tests) - [ ] Moonpay redirect buy on mobile preview PR: single Activity row after completion Fixes TRAM-3539
…9135) ## Explanation Unified Buy v2 (and other `@metamask/ramps-controller` consumers) need to detect specific Transak API failures from `TransakApiError` — for example error code `2020` when a phone number is already registered to a different email. Today, mobile duplicated string literals and ad-hoc `instanceof` / Axios-shaped parsing because ramps-controller only exported `TransakApiError` itself, not reusable helpers or known codes. This PR adds shared Transak error codes and small type guards/helpers so consumers can branch on `errorCode` and read `apiMessage` consistently: - `TRANSAK_ERROR_CODES` (`ORDER_EXISTS: '4005'`, `PHONE_ALREADY_REGISTERED: '2020'`) and `TransakErrorCode` - `isTransakApiError`, `getTransakErrorCode`, `getTransakApiMessage`, `isTransakErrorCode`, `isTransakPhoneRegisteredError` `TransakService` now uses `TRANSAK_ERROR_CODES.ORDER_EXISTS` instead of a private `'4005'` constant so order-exists retry logic and public exports stay aligned. No breaking changes. Changelog updated under `@metamask/ramps-controller` Unreleased. ## References - [TRAM-3654](https://consensyssoftware.atlassian.net/browse/TRAM-3654) — Unified Buy v2: show login-with-email action for Transak phone-already-registered error - Mobile consumer: [MetaMask/metamask-mobile#31580](MetaMask/metamask-mobile#31580) — depends on this release before dropping local error parsing ## 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 _(N/A — additive exports only)_ [TRAM-3654]: https://consensyssoftware.atlassian.net/browse/TRAM-3654?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: Cursor <cursoragent@cursor.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )