Skip to content

fix(ramps-controller): scope getAutoramps to the current customer - #10507

Closed
georgeweiler wants to merge 2 commits into
mainfrom
fix/vba-hydrate-autoramp-by-customer
Closed

georgeweiler wants to merge 2 commits into
mainfrom
fix/vba-hydrate-autoramp-by-customer

Conversation

@georgeweiler

@georgeweiler georgeweiler commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Explanation

NeoBankService.getAutoramps called GET /neobank/autoramps with no query filter. Two problems:

  1. The neobank-proxy only exposed autoramps by id (no unfiltered collection route), so GET /neobank/autoramps returned 404 "Cannot GET /neobank/autoramps".
  2. MoonPay's underlying GET /api/autoramps treats customer_id as optional and, when omitted, returns every partner customer's autoramps — never what a single-user client wants, and served under the shared partner token.

Because of this, hydrateVbaOnboarding could not discover a customer's existing autoramp: after KYC it fell through to a create attempt that MoonPay rejects with 400 "Customer already has a Pix onramp", dead-ending account provisioning ("couldn't create your account") — reproducible after clearing app state or restoring an SRP on a new device.

This resolves the current customer from the signed-in profile (reusing the existing getMoonpayCustomerId() — canonical MetaMask profile id → Iron customer id) and passes it as customer_id, then parses MoonPay's paginated { items } envelope. Discovery is now keyed on identity, not local state, so an existing autoramp is found on a fresh install.

Non-breaking: the public getAutoramps() signature is unchanged — the customer is resolved internally — so RampsController.hydrateVbaOnboarding and hosts (mobile) need no changes.

Depends on consensys-vertical-apps/va-mmcx-onramp-api#1290, which adds the GET /neobank/autoramps passthrough to the proxy. Merge/deploy that first.

References

Changelog

@metamask/ramps-controller

  • FIXED: NeoBankService.getAutoramps scopes the query to the current customer (customer_id, resolved from the signed-in profile) and parses MoonPay's paginated response, so hydrateVbaOnboarding rediscovers an existing autoramp after reinstall/SRP restore instead of failing provisioning. Public getAutoramps() signature unchanged.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated the changelog
  • I've applied the right labels on the PR. Not required for external contributors.

🤖 Generated with Claude Code


Note

Medium Risk
Changes neo-bank autoramp discovery used in VBA onboarding and relies on a matching neobank-proxy list route deploy; mis-scoping or response parsing would break account provisioning for returning users.

Overview
NeoBankService.getAutoramps no longer calls an unfiltered GET /neobank/autoramps (which 404'd on the proxy and would have been unsafe on MoonPay anyway). It now resolves the MoonPay customer id from the signed-in profile via getMoonpayCustomerId(), requests GET /neobank/autoramps?customer_id=…, and maps results from MoonPay's paginated { items, cursor, prev_cursor } envelope instead of a bare array.

The public getAutoramps() signature is unchanged, so hydrateVbaOnboarding and hosts can rediscover an existing autoramp after reinstall or SRP restore without attempting a duplicate create. Tests and action-type docs were updated to match the scoped query and paginated response shape.

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

`NeoBankService.getAutoramps` called `GET /neobank/autoramps` with no filter.
That route is unsupported unfiltered (it 404'd), and MoonPay's `GET /api/autoramps`
returns every partner customer's autoramps when `customer_id` is omitted — never
what a single-user client wants. As a result `hydrateVbaOnboarding` could not
discover a customer's existing autoramp and account provisioning failed.

Resolve the current customer from the signed-in profile (via the existing
`getMoonpayCustomerId`) and pass it as `customer_id`, and parse MoonPay's
paginated `{ items }` envelope. This rediscovers an existing autoramp after a
reinstall or SRP restore on a new device, keyed on identity rather than local
state. The public `getAutoramps()` signature is unchanged, so callers
(RampsController, hosts) are unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant