Skip to content

feat(ramps): wait for the deposit rail before creating the VBA autoramp - #38651

Merged
meltingice1337 merged 6 commits into
mainfrom
feat/vba-rail-abilities-check
Nov 3, 2026
Merged

meltingice1337 merged 6 commits into
mainfrom
feat/vba-rail-abilities-check

Conversation

@meltingice1337

@meltingice1337 meltingice1337 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

MoonPay rejects an autoramp create with a 422 ("Customer is unable to complete the action. Consult the customer abilities API") when the customer is Active but the deposit rail the autoramp needs is not. Today that sends the user to the account-create error screen with "Contact support", even though the rail usually turns Active on its own shortly after.

ensureMusdAutoramp now reads the customer's rail abilities (RampsController.refreshCustomerAbilities and getMusdAutorampDepositRailReadiness from MetaMask/core#11225) right before it creates the autoramp, both for the first fiat and for an additional fiat:

  • active: creates the autoramp as before.
  • pending: returns awaiting_provider, so VbaDetails keeps the existing "Waiting for MoonPay to approve your account" screen and re-checks on its poll. The autoramp is created once the rail turns Active.
  • blocked: throws the same account-create error a MoonPay 422 produces, without sending the create.
  • Abilities fetch fails: logs the error and creates as before, so a proxy or MoonPay outage never blocks onboarding.

The NeoBankService messenger now also delegates AuthenticationController:getSessionProfile. NeoBankService needs it to resolve the MoonPay customer id for the abilities URL. Without it the abilities call throws inside the app and the check silently falls back to creating.

Blocked by MetaMask/core#11225. @metamask/ramps-controller points at the preview build @metamask-previews/ramps-controller@28.1.0-preview-acf55e6fd until core releases the change. That release is a major (29.0.0) because RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS gains NeoBankService:getCustomerAbilities, which mobile already picks up by spreading the constant. This PR stays a draft until the dependency is switched to ^29.0.0.

Tested on an iOS device against dev with a local neobank-proxy and a temporary stub for the abilities response (fresh SRP, Brazil KYC): with the rail Pending the app polled for about 1.5 minutes and never sent a create; with Pending twice, then Active, it created the BRL autoramp on the next poll.

Changelog

CHANGELOG entry: Fixed Money Account bank account setup showing an error while MoonPay was still enabling the deposit method; the app now waits and finishes setup once it is ready

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/TRAM-4391

Refs: https://consensyssoftware.atlassian.net/browse/TRAM-4364, MetaMask/core#11225

Manual testing steps

Feature: Wait for the deposit rail before creating the virtual bank account

  Scenario: deposit rail is still pending
    Given a user with approved KYC and an Active MoonPay customer
    And the deposit rail for their fiat is Pending in the customer abilities
    When the user opens bank transfer from Money and reaches account creation
    Then the screen shows "Waiting for MoonPay to approve your account"
    And no autoramp create request is sent while the rail stays Pending

  Scenario: deposit rail turns active while the user waits
    Given the user is on "Waiting for MoonPay to approve your account" because the rail is Pending
    When the deposit rail becomes Active
    Then the autoramp is created on the next poll
    And the bank account details are shown

  Scenario: deposit rail is blocked
    Given the deposit rail for the user's fiat is Unavailable or Blocked
    When the user reaches account creation
    Then the account-create error screen is shown
    And no autoramp create request is sent

Screenshots/Recordings

Before

N/A

After

ScreenRecording_11-02-2026.15-47-54_1.compressed.mp4

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • 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.

Note

Medium Risk
Changes Money VBA autoramp creation timing and external abilities API usage; fail-open on fetch errors could still allow a 422 from MoonPay if abilities are wrong.

Overview
ensureMusdAutoramp no longer calls create as soon as KYC/hydrate says ready. It refreshes customer abilities (RampsController.refreshCustomerAbilities) and uses getMusdAutorampDepositRailReadiness from @metamask/ramps-controller 29 before every create (first fiat and additional fiat).

Pending rails return awaiting_provider so VbaDetails keeps the existing “waiting for MoonPay” poll without hitting create (avoids MoonPay 422 when the customer is Active but the deposit method is not). Blocked rails fail like a 422 with analytics, without sending create. If abilities refresh fails, behavior fails open (log + create as before).

Tests add rail-readiness coverage and mock refreshCustomerAbilities in VbaDetails / ensureMusdAutoramp tests; test initial-background-state adds vbaCustomerAbilities.

Dependency bump: @metamask/ramps-controller ^28 → ^29.

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

MoonPay rejects an autoramp create with a 422 while the deposit rail is
not Active, even for an Active customer. ensureMusdAutoramp now reads the
customer's rail abilities first: a pending rail keeps the user waiting and
re-checks on the next poll, a blocked rail surfaces the account-create
error without sending the create, and a failed abilities fetch falls back
to creating as before.

The NeoBankService messenger now also delegates
AuthenticationController:getSessionProfile, which NeoBankService needs to
resolve the MoonPay customer id for the abilities call.

Uses the ramps-controller preview build from MetaMask/core#11225 until it
is released.

TRAM-4391
@meltingice1337 meltingice1337 self-assigned this Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

…es-check

# Conflicts:
#	app/components/UI/Ramp/Views/VirtualBankAccount/ensureMusdAutoramp.test.ts
#	yarn.lock
A blocked rail now reports Money VBA Autoramp Create Updated with status failed and failure_reason vba_create_failed before surfacing the 422 error, the same as the create would have reported.

TRAM-4391
@github-actions github-actions Bot added the size-M label Nov 2, 2026
@socket-security

socket-security Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​metamask/​ramps-controller@​29.0.010010080100100

View full report

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Smart E2E Test Selection

Selected E2E tags: ALL

AI Confidence: 100

E2E reasoning

Expand to read

Hard rule seed (controller-version-update) mandates ALL tags due to @metamask/ramps-controller being bumped from v28 to v29 in package.json.

Beyond the hard rule, the changes include:

  1. @metamask/ramps-controller v28→v29: A major version bump of a controller that powers the Money/Ramps flows. New API surface (getMusdAutorampDepositRailReadiness, MusdAutorampDepositRailReadiness type) is consumed in the app. Controller version bumps can introduce breaking changes in state shape, API contracts, or behavior.

  2. ensureMusdAutoramp.ts functional change: New deposit rail readiness check logic (getRailReadiness, createAutorampWhenRailActive) that gates autoramp creation on rail status. This changes the VBA autoramp flow behavior — previously it would always attempt to create, now it checks rail readiness first and may return 'awaiting_provider' instead.

  3. initial-background-state.json: Added vbaCustomerAbilities: null to RampsController initial state. This JSON file is used as the base fixture for E2E tests. Adding a new field to the controller state could affect any E2E test that validates or depends on the RampsController state shape.

  4. VbaDetails.test.tsx: Added refreshCustomerAbilities mock — indicates a new Engine method is being called in the VBA flow, which could affect E2E tests that exercise the VBA/Money flow.

Primary affected E2E tags: SmokeMoney (ramps, card flows). Secondary risk: any test using the initial-background-state fixture. The controller version bump warrants running ALL smoke tags to ensure no regressions across the full test suite.

View run

@meltingice1337
meltingice1337 marked this pull request as ready for review November 3, 2026 12:27
@meltingice1337
meltingice1337 requested review from a team as code owners November 3, 2026 12:27
…es-check

# Conflicts:
#	app/core/Engine/messengers/neo-bank-service-messenger/neo-bank-service-messenger.test.ts
#	app/core/Engine/messengers/neo-bank-service-messenger/neo-bank-service-messenger.ts
@meltingice1337 meltingice1337 added the team-money-movement issues related to Money Movement features label Nov 3, 2026
@sonarqubecloud

sonarqubecloud Bot commented Nov 3, 2026

Copy link
Copy Markdown

@meltingice1337
meltingice1337 added this pull request to the merge queue Nov 3, 2026
Merged via the queue into main with commit 4c58e5e Nov 3, 2026
198 of 200 checks passed
@meltingice1337
meltingice1337 deleted the feat/vba-rail-abilities-check branch November 3, 2026 18:21
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 3, 2026
@metamask-ci metamask-ci Bot added the release-8.20.0 Issue or pull request that will be included in release 8.20.0 label Nov 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-8.20.0 Issue or pull request that will be included in release 8.20.0 size-M team-money-movement issues related to Money Movement features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants