Skip to content

fix(ramps): Prevent wallet=undefined param and heal walletAddress in order refresh#8251

Merged
imyugioh merged 3 commits into
mainfrom
fix/TRAM-3349-api-400-wallet-undefined
Mar 19, 2026
Merged

fix(ramps): Prevent wallet=undefined param and heal walletAddress in order refresh#8251
imyugioh merged 3 commits into
mainfrom
fix/TRAM-3349-api-400-wallet-undefined

Conversation

@imyugioh

@imyugioh imyugioh commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Explanation

Fixes a bug where tapping a Transak Native order in "Processing" status in the Activity tab shows "Something went wrong" (HTTP 400).

Root cause: RampsService.getOrder was unconditionally appending the wallet query param to the order URL. When order.walletAddress is undefined in Redux state (which can happen for Transak Native fiat→crypto orders), URLSearchParams.set('wallet', undefined) coerces undefined to the string "undefined". The on-ramp API rejects wallet=undefined with a 400 validation error.

Changes:

  1. RampsService — Only append the wallet query param when it has a real value. This is the primary fix: prevents the 400 error when walletAddress is absent from the stored order.

  2. RampsController — When storing a refreshed order, use order.walletAddress || wallet so that if the API response returns the wallet address (e.g. after the provider maps it correctly), it heals the previously missing value in Redux state. Falls back to the wallet param if the API response omits it.

Link to metamask-mobile

link to: MetaMask/metamask-mobile/pull/27709

References

TRAM-3349

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

Metamask Mobile

No need to change in mobile code.

Before

Screenshot 2026-03-18 234503

After

Screen.Recording.2026-03-19.003710.mp4
Screenshot 2026-03-19 003734

Note

Medium Risk
Changes how order refresh requests are built and how refreshed orders are persisted/returned; mistakes could break order polling or state consistency for on-ramp flows.

Overview
Fixes getOrder wallet handling to prevent invalid order refreshes and keep controller state consistent.

RampsService.getOrder now only appends the wallet query param when it’s non-empty, avoiding wallet=undefined/empty-string requests that can yield 400s. RampsController.getOrder now “heals” refreshed orders by ensuring walletAddress (fallback to the passed wallet) and providerOrderId are persisted and returned, so callers and RampsController:orderStatusChanged listeners see consistent data.

Tests were updated/added to cover missing/empty walletAddress scenarios, to assert the wallet query param is omitted when empty, and to normalize test mocks via a createMockProvider helper; changelog updated accordingly.

Written by Cursor Bugbot for commit 434bd0c. This will update automatically on new commits. Configure here.

@imyugioh imyugioh self-assigned this Mar 19, 2026
@imyugioh imyugioh requested review from a team as code owners March 19, 2026 17:37
@imyugioh

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-previews

@github-actions

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/account-tree-controller@5.0.1-preview-434bd0c
@metamask-previews/accounts-controller@37.0.0-preview-434bd0c
@metamask-previews/address-book-controller@7.1.0-preview-434bd0c
@metamask-previews/ai-controllers@0.4.0-preview-434bd0c
@metamask-previews/analytics-controller@1.0.0-preview-434bd0c
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-434bd0c
@metamask-previews/announcement-controller@8.0.0-preview-434bd0c
@metamask-previews/app-metadata-controller@2.0.0-preview-434bd0c
@metamask-previews/approval-controller@9.0.0-preview-434bd0c
@metamask-previews/assets-controller@3.0.0-preview-434bd0c
@metamask-previews/assets-controllers@101.0.1-preview-434bd0c
@metamask-previews/base-controller@9.0.0-preview-434bd0c
@metamask-previews/base-data-service@0.0.0-preview-434bd0c
@metamask-previews/bridge-controller@69.1.1-preview-434bd0c
@metamask-previews/bridge-status-controller@69.0.0-preview-434bd0c
@metamask-previews/build-utils@3.0.4-preview-434bd0c
@metamask-previews/chain-agnostic-permission@1.4.0-preview-434bd0c
@metamask-previews/claims-controller@0.4.3-preview-434bd0c
@metamask-previews/client-controller@1.0.0-preview-434bd0c
@metamask-previews/compliance-controller@1.0.1-preview-434bd0c
@metamask-previews/composable-controller@12.0.0-preview-434bd0c
@metamask-previews/config-registry-controller@0.1.1-preview-434bd0c
@metamask-previews/connectivity-controller@0.1.0-preview-434bd0c
@metamask-previews/controller-utils@11.19.0-preview-434bd0c
@metamask-previews/core-backend@6.2.0-preview-434bd0c
@metamask-previews/delegation-controller@2.0.2-preview-434bd0c
@metamask-previews/earn-controller@11.1.2-preview-434bd0c
@metamask-previews/eip-5792-middleware@3.0.1-preview-434bd0c
@metamask-previews/eip-7702-internal-rpc-middleware@0.1.0-preview-434bd0c
@metamask-previews/eip1193-permission-middleware@1.0.3-preview-434bd0c
@metamask-previews/ens-controller@19.1.0-preview-434bd0c
@metamask-previews/error-reporting-service@3.0.1-preview-434bd0c
@metamask-previews/eth-block-tracker@15.0.1-preview-434bd0c
@metamask-previews/eth-json-rpc-middleware@23.1.0-preview-434bd0c
@metamask-previews/eth-json-rpc-provider@6.0.0-preview-434bd0c
@metamask-previews/foundryup@1.0.1-preview-434bd0c
@metamask-previews/gas-fee-controller@26.1.0-preview-434bd0c
@metamask-previews/gator-permissions-controller@2.1.1-preview-434bd0c
@metamask-previews/geolocation-controller@0.1.1-preview-434bd0c
@metamask-previews/json-rpc-engine@10.2.3-preview-434bd0c
@metamask-previews/json-rpc-middleware-stream@8.0.8-preview-434bd0c
@metamask-previews/keyring-controller@25.1.0-preview-434bd0c
@metamask-previews/logging-controller@8.0.0-preview-434bd0c
@metamask-previews/message-manager@14.1.0-preview-434bd0c
@metamask-previews/messenger@0.3.0-preview-434bd0c
@metamask-previews/multichain-account-service@7.1.0-preview-434bd0c
@metamask-previews/multichain-api-middleware@1.2.7-preview-434bd0c
@metamask-previews/multichain-network-controller@3.0.5-preview-434bd0c
@metamask-previews/multichain-transactions-controller@7.0.2-preview-434bd0c
@metamask-previews/name-controller@9.1.0-preview-434bd0c
@metamask-previews/network-controller@30.0.0-preview-434bd0c
@metamask-previews/network-enablement-controller@5.0.0-preview-434bd0c
@metamask-previews/notification-services-controller@23.0.0-preview-434bd0c
@metamask-previews/permission-controller@12.2.1-preview-434bd0c
@metamask-previews/permission-log-controller@5.0.0-preview-434bd0c
@metamask-previews/perps-controller@1.3.0-preview-434bd0c
@metamask-previews/phishing-controller@17.0.0-preview-434bd0c
@metamask-previews/polling-controller@16.0.3-preview-434bd0c
@metamask-previews/preferences-controller@23.0.0-preview-434bd0c
@metamask-previews/profile-metrics-controller@3.1.1-preview-434bd0c
@metamask-previews/profile-sync-controller@28.0.0-preview-434bd0c
@metamask-previews/ramps-controller@12.0.0-preview-434bd0c
@metamask-previews/rate-limit-controller@7.0.0-preview-434bd0c
@metamask-previews/react-data-query@0.0.0-preview-434bd0c
@metamask-previews/remote-feature-flag-controller@4.1.0-preview-434bd0c
@metamask-previews/sample-controllers@4.0.3-preview-434bd0c
@metamask-previews/seedless-onboarding-controller@9.0.0-preview-434bd0c
@metamask-previews/selected-network-controller@26.0.3-preview-434bd0c
@metamask-previews/shield-controller@5.0.2-preview-434bd0c
@metamask-previews/signature-controller@39.1.0-preview-434bd0c
@metamask-previews/storage-service@1.0.0-preview-434bd0c
@metamask-previews/subscription-controller@6.0.2-preview-434bd0c
@metamask-previews/transaction-controller@63.0.0-preview-434bd0c
@metamask-previews/transaction-pay-controller@17.1.0-preview-434bd0c
@metamask-previews/user-operation-controller@41.1.0-preview-434bd0c

@imyugioh

Copy link
Copy Markdown
Contributor Author

I tested again - that works!

@imyugioh imyugioh added this pull request to the merge queue Mar 19, 2026
Merged via the queue into main with commit e5e6aea Mar 19, 2026
328 checks passed
@imyugioh imyugioh deleted the fix/TRAM-3349-api-400-wallet-undefined branch March 19, 2026 20:43
@imyugioh imyugioh mentioned this pull request Mar 20, 2026
4 tasks
github-merge-queue Bot pushed a commit that referenced this pull request Mar 20, 2026
## Explanation

This PR cuts **monorepo release `875.0.0`** and publishes a new
**`@metamask/ramps-controller`** version so consumers can pick up ramps
work that is already on `main` but was **not** included in the previous
npm publish train.

**Current state**

- `main` includes ramps updates (notably messenger exposure and
`getOrder` wallet/query handling), documented under **Unreleased** in
`packages/ramps-controller/CHANGELOG.md`.
- Without a release, clients stay on the last published
`@metamask/ramps-controller` and do not get those fixes/features from
the registry.

**What this change does**

- Bumps the monorepo root version to **`875.0.0`** (release branch
convention).
- Releases **`@metamask/ramps-controller@12.0.1`**, with changelog
entries moved from **Unreleased** into **`[12.0.1]`** per [Keep a
Changelog](https://keepachangelog.com/).
- **Added:** public `RampsController` methods exposed via the messenger
([#8221](#8221)).
- **Fixed:** `getOrder` wallet handling so requests and
`orderStatusChanged` payloads stay consistent
([#8251](#8251)).

**Note for reviewers**

- If this branch also bumps **other** workspace packages (lockfile /
dependents), that is to satisfy release tooling and dependency
constraints for anything else selected for **875**—not arbitrary scope
creep.

---

## References

- Ramps fixes / API surface:
[#8221](#8221),
[#8251](#8251)
- Internal tracking (if applicable): **TRAM-3349**
- Changelog guidelines: [updating
changelogs](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- Consumer follow-up: bump `@metamask/ramps-controller` in **MetaMask
mobile/extension** (and any other consumers) after this version is on
npm

---

## Checklist

- [ ] I've updated the test suite for new or updated code as appropriate
_(N/A — release-only if no code changes on this branch)_
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate _(N/A unless this PR adds docs)_
- [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 _(unchecked — **patch** release; no
breaking changes expected)_

---


<!-- CURSOR_SUMMARY -->
> [!NOTE]
> **Low Risk**
> Low risk release-only change: version bumps and changelog/link updates
with no functional code modifications.
> 
> **Overview**
> Cuts the monorepo release by bumping the root version to `875.0.0`.
> 
> Publishes a patch release of `@metamask/ramps-controller` (`12.0.1`)
by bumping its package version and moving the existing *Unreleased*
changelog entries into a new `12.0.1` section, updating the compare
links accordingly.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
5b33da9. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
imyugioh added a commit to MetaMask/metamask-mobile that referenced this pull request Mar 23, 2026
github-merge-queue Bot pushed a commit to MetaMask/metamask-mobile that referenced this pull request Mar 23, 2026
…71.0 (#27709)

## **Description**

Integration PR to validate **MetaMask/core** changes in mobile CI/E2E by
resolving `@metamask/ramps-controller` from a **preview** npm package
(`previewBuilds` in `package.json` + updated `yarn.lock`). No
application code changes.

**Core PR:** MetaMask/core#8251

After core merges and a **released** version is published, this PR
should be updated to remove `previewBuilds` and bump `dependencies` to
the real version before merge.

## **Changelog**

CHANGELOG entry: null

## **Related issues**

Fixes: N/A (validation / dependency preview only)

## **Manual testing steps**

```gherkin
Feature: ramps-controller preview validation

  Scenario: app resolves preview package
    Given a clean install from this branch
    When the app bundles and runs
    Then @metamask/ramps-controller resolves to the preview version from previewBuilds

  Scenario: ramps flows still work
    Given the app is built from this branch
    When user exercises on-ramp flows that use ramps-controller
    Then no regressions vs main (same UX; underlying package is preview)
```

## **Screenshots/Recordings**

N/A — dependency-only change.

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [ ] I've included tests if applicable
- [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.

---

<!-- Optional: paste below into GitHub if you use Cursor Bugbot summary
-->

> [!NOTE]
> **Low Risk**
> Low risk because this is a dependency source/version switch for
`@metamask/ramps-controller` with no application code changes; main risk
is behavior changes introduced by the preview package at runtime.
>
> **Overview**
> Switches `@metamask/ramps-controller` to a **preview build** via
`previewBuilds` in `package.json` and `yarn.lock` (e.g.
`@metamask-previews/ramps-controller@12.0.0-preview-434bd0c`). Update
the preview version string if the bot publishes a newer build for
core#8251.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Low risk patch-level dependency update; main risk is any runtime
behavior changes in `@metamask/ramps-controller` affecting ramp flows,
plus potential test fixture mismatches if state shape changes again.
> 
> **Overview**
> Updates `@metamask/ramps-controller` from `12.0.0` to `12.0.1`
(including lockfile resolution changes).
> 
> Aligns the default E2E/unit fixture (`default-fixture.json`) with the
newer `RampsController` state shape by adding persisted sub-state for
countries, providers/payment methods/tokens, native provider (Transak)
auth/kyc/user details, requests, and orders.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
0b2fc2f. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
runway-github Bot pushed a commit to MetaMask/metamask-mobile that referenced this pull request Mar 23, 2026
…etaMask/core#8251 -> cp-7.71.0 (#27709)

## **Description**

Integration PR to validate **MetaMask/core** changes in mobile CI/E2E by
resolving `@metamask/ramps-controller` from a **preview** npm package
(`previewBuilds` in `package.json` + updated `yarn.lock`). No
application code changes.

**Core PR:** MetaMask/core#8251

After core merges and a **released** version is published, this PR
should be updated to remove `previewBuilds` and bump `dependencies` to
the real version before merge.

## **Changelog**

CHANGELOG entry: null

## **Related issues**

Fixes: N/A (validation / dependency preview only)

## **Manual testing steps**

```gherkin
Feature: ramps-controller preview validation

  Scenario: app resolves preview package
    Given a clean install from this branch
    When the app bundles and runs
    Then @metamask/ramps-controller resolves to the preview version from previewBuilds

  Scenario: ramps flows still work
    Given the app is built from this branch
    When user exercises on-ramp flows that use ramps-controller
    Then no regressions vs main (same UX; underlying package is preview)
```

## **Screenshots/Recordings**

N/A — dependency-only change.

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [ ] I've included tests if applicable
- [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.

---

<!-- Optional: paste below into GitHub if you use Cursor Bugbot summary
-->

> [!NOTE]
> **Low Risk**
> Low risk because this is a dependency source/version switch for
`@metamask/ramps-controller` with no application code changes; main risk
is behavior changes introduced by the preview package at runtime.
>
> **Overview**
> Switches `@metamask/ramps-controller` to a **preview build** via
`previewBuilds` in `package.json` and `yarn.lock` (e.g.
`@metamask-previews/ramps-controller@12.0.0-preview-434bd0c`). Update
the preview version string if the bot publishes a newer build for
core#8251.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Low risk patch-level dependency update; main risk is any runtime
behavior changes in `@metamask/ramps-controller` affecting ramp flows,
plus potential test fixture mismatches if state shape changes again.
> 
> **Overview**
> Updates `@metamask/ramps-controller` from `12.0.0` to `12.0.1`
(including lockfile resolution changes).
> 
> Aligns the default E2E/unit fixture (`default-fixture.json`) with the
newer `RampsController` state shape by adding persisted sub-state for
countries, providers/payment methods/tokens, native provider (Transak)
auth/kyc/user details, requests, and orders.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
0b2fc2f. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
imyugioh added a commit to MetaMask/metamask-mobile that referenced this pull request Mar 23, 2026
…etaMask/core#8251 -> cp-7.71.0 (#27823)

- chore(deps): ramps-controller preview for MetaMask/core#8251 ->
cp-7.71.0 (#27709)

## **Description**

Integration PR to validate **MetaMask/core** changes in mobile CI/E2E by
resolving `@metamask/ramps-controller` from a **preview** npm package
(`previewBuilds` in `package.json` + updated `yarn.lock`). No
application code changes.

**Core PR:** MetaMask/core#8251

After core merges and a **released** version is published, this PR
should be updated to remove `previewBuilds` and bump `dependencies` to
the real version before merge.

## **Changelog**

CHANGELOG entry: null

## **Related issues**

Fixes: N/A (validation / dependency preview only)

## **Manual testing steps**

```gherkin
Feature: ramps-controller preview validation

  Scenario: app resolves preview package
    Given a clean install from this branch
    When the app bundles and runs
    Then @metamask/ramps-controller resolves to the preview version from previewBuilds

  Scenario: ramps flows still work
    Given the app is built from this branch
    When user exercises on-ramp flows that use ramps-controller
    Then no regressions vs main (same UX; underlying package is preview)
```

## **Screenshots/Recordings**

N/A — dependency-only change.

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding

Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [ ] I've included tests if applicable
- [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling

guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.

---

<!-- Optional: paste below into GitHub if you use Cursor Bugbot summary
-->

> [!NOTE]
> **Low Risk**
> Low risk because this is a dependency source/version switch for
`@metamask/ramps-controller` with no application code changes; main risk
is behavior changes introduced by the preview package at runtime.
>
> **Overview**
> Switches `@metamask/ramps-controller` to a **preview build** via
`previewBuilds` in `package.json` and `yarn.lock` (e.g.
`@metamask-previews/ramps-controller@12.0.0-preview-434bd0c`). Update
the preview version string if the bot publishes a newer build for
core#8251.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Low risk patch-level dependency update; main risk is any runtime
behavior changes in `@metamask/ramps-controller` affecting ramp flows,
plus potential test fixture mismatches if state shape changes again.
> 
> **Overview**
> Updates `@metamask/ramps-controller` from `12.0.0` to `12.0.1`
(including lockfile resolution changes).
> 
> Aligns the default E2E/unit fixture (`default-fixture.json`) with the
newer `RampsController` state shape by adding persisted sub-state for
countries, providers/payment methods/tokens, native provider (Transak)
auth/kyc/user details, requests, and orders.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
0b2fc2f. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
[4a4f0ae](4a4f0ae)

Co-authored-by: Yu-Gi-Oh! <54774811+imyugioh@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants