Skip to content

[pull] main from MetaMask:main#658

Merged
pull[bot] merged 2 commits into
Reality2byte:mainfrom
MetaMask:main
Jun 17, 2026
Merged

[pull] main from MetaMask:main#658
pull[bot] merged 2 commits into
Reality2byte:mainfrom
MetaMask:main

Conversation

@pull

@pull pull Bot commented Jun 17, 2026

Copy link
Copy Markdown

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 : )

amitabh94 and others added 2 commits June 16, 2026 21:44
…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>
@pull pull Bot locked and limited conversation to collaborators Jun 17, 2026
@pull pull Bot added the ⤵️ pull label Jun 17, 2026
@pull pull Bot merged commit 4126310 into Reality2byte:main Jun 17, 2026
0 of 4 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant