From 5d98d1ac40de27f6a277669fabbad84ab32e5228 Mon Sep 17 00:00:00 2001 From: Darius Costolas <10818970+meltingice1337@users.noreply.github.com> Date: Mon, 2 Nov 2026 12:08:11 +0200 Subject: [PATCH 1/5] feat(ramps-controller): add customer rail abilities Add NeoBankService.getCustomerAbilities, RampsController.refreshCustomerAbilities with a non-persisted vbaCustomerAbilities state, and getMusdAutorampDepositRailReadiness, so clients can check the deposit rail before creating a fiat to mUSD autoramp. MoonPay rejects the create with a 422 when the rail it needs is not Active. --- packages/ramps-controller/CHANGELOG.md | 10 ++ .../src/NeoBankService-method-action-types.ts | 18 +++ .../src/NeoBankService.test.ts | 103 ++++++++++++++++ .../ramps-controller/src/NeoBankService.ts | 112 +++++++++++++++--- .../RampsController-method-action-types.ts | 13 ++ .../src/RampsController.test.ts | 62 ++++++++++ .../ramps-controller/src/RampsController.ts | 41 ++++++- .../src/autorampAccount.test.ts | 70 +++++++++++ .../ramps-controller/src/autorampAccount.ts | 58 +++++++++ packages/ramps-controller/src/index.ts | 7 ++ 10 files changed, 477 insertions(+), 17 deletions(-) diff --git a/packages/ramps-controller/CHANGELOG.md b/packages/ramps-controller/CHANGELOG.md index 711d831a904..a11f74693ed 100644 --- a/packages/ramps-controller/CHANGELOG.md +++ b/packages/ramps-controller/CHANGELOG.md @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add `NeoBankService.getCustomerAbilities`, exposed on the messenger, which returns the customer's rail abilities from neobank-proxy unmodified, and the `NeoBankCustomerAbilities`, `NeoBankFiatAbilities` and `NeoBankAbilityStatus` types ([#TBD](https://github.com/MetaMask/core/pull/TBD)) + - MoonPay rejects an autoramp create with a 422 when the rail it needs is not `Active`, so clients can check the rail first. Any non-2xx response throws an `HttpError`. +- Add `RampsController.refreshCustomerAbilities`, exposed on the messenger, which stores the result in the new `vbaCustomerAbilities` state ([#TBD](https://github.com/MetaMask/core/pull/TBD)) + - The state is not persisted. A failed fetch throws and keeps the stored value. Discarding a VBA session owned by another profile clears it. + - Hosts must now delegate `NeoBankService:getCustomerAbilities` to the `RampsController` messenger. It is included in `RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS`. +- Add `getMusdAutorampDepositRailReadiness` and the `MusdAutorampDepositRailReadiness` type, which read from customer abilities whether the deposit rails a fiat → mUSD autoramp needs are `active`, `pending` or `blocked` ([#TBD](https://github.com/MetaMask/core/pull/TBD)) + - BRL needs `pix` and `pix_thirdparty`, USD needs `ach` and `ach_thirdparty`. Other fiats report `active`. + ## [28.1.0] ### Added diff --git a/packages/ramps-controller/src/NeoBankService-method-action-types.ts b/packages/ramps-controller/src/NeoBankService-method-action-types.ts index 8b6dfdbe9fd..ad1ac0a1415 100644 --- a/packages/ramps-controller/src/NeoBankService-method-action-types.ts +++ b/packages/ramps-controller/src/NeoBankService-method-action-types.ts @@ -191,6 +191,23 @@ export type NeoBankServiceGetMicrodepositsAction = { handler: NeoBankService['getMicrodeposits']; }; +/** + * Reads the customer's rail abilities via neobank-proxy + * `GET /neobank/customers/{customer_id}/abilities` (MoonPay + * `GET /api/customers/{id}/abilities`). + * + * MoonPay rejects an autoramp create with a 422 when the rail it needs is not + * `Active`, even for an `Active` customer. The customer id is resolved the + * same way as in {@link getMicrodeposits}. Any non-2xx response, including a + * 404 when there is no customer yet, throws an {@link HttpError}. + * + * @returns MoonPay customer abilities, unmodified. + */ +export type NeoBankServiceGetCustomerAbilitiesAction = { + type: `NeoBankService:getCustomerAbilities`; + handler: NeoBankService['getCustomerAbilities']; +}; + /** * Checks whether a Monad Money Account address is already registered for the * given Iron customer. @@ -234,5 +251,6 @@ export type NeoBankServiceMethodActions = | NeoBankServiceGetCustomerByExternalIdAction | NeoBankServiceGetMoonpayCustomerIdAction | NeoBankServiceGetMicrodepositsAction + | NeoBankServiceGetCustomerAbilitiesAction | NeoBankServiceGetWalletRegistrationStatusAction | NeoBankServiceRegisterSelfHostedWalletAction; diff --git a/packages/ramps-controller/src/NeoBankService.test.ts b/packages/ramps-controller/src/NeoBankService.test.ts index 6b12a848896..3df73e34417 100644 --- a/packages/ramps-controller/src/NeoBankService.test.ts +++ b/packages/ramps-controller/src/NeoBankService.test.ts @@ -1195,6 +1195,109 @@ describe('NeoBankService', () => { }); }); + describe('getCustomerAbilities', () => { + const CUSTOMER_PATH = '/neobank/customers/canonical-profile-1/external'; + const ABILITIES_PATH = '/neobank/customers/iron-customer-1/abilities'; + + const abilities = { + fiat_deposit: { + brl: { pix: 'Active', pix_thirdparty: 'Active' }, + usd: { ach: 'Pending', ach_thirdparty: 'Unavailable' }, + }, + fiat_payout: { + brl: { pix: 'Active', pix_thirdparty: 'Active' }, + }, + currencies: [], + blocking_abilities: { ach_thirdparty: 'rule engine preflight' }, + }; + + /** + * Stubs the customer lookup that `getCustomerAbilities` performs first. + * + * @returns The nock scope for the lookup. + */ + function mockCustomerLookup(): nock.Scope { + return nock(STAGING_BASE) + .get(CUSTOMER_PATH) + .reply(200, { id: 'iron-customer-1' }); + } + + it('returns the abilities unchanged', async () => { + const customerScope = mockCustomerLookup(); + const scope = nock(STAGING_BASE) + .get(ABILITIES_PATH) + .query({ sdk: /.+/u, controller: /.+/u, context: 'test' }) + .matchHeader('Authorization', 'Bearer test-token') + .reply(200, abilities); + + const service = createService(); + + expect(await service.getCustomerAbilities()).toStrictEqual(abilities); + expect(customerScope.isDone()).toBe(true); + expect(scope.isDone()).toBe(true); + }); + + it('throws an HttpError when the customer does not exist yet (404)', async () => { + nock(STAGING_BASE).get(CUSTOMER_PATH).reply(404, 'customer not found'); + + const service = createService(); + + await expect(service.getCustomerAbilities()).rejects.toMatchObject({ + httpStatus: 404, + }); + }); + + it('throws an HttpError carrying the upstream body on a 5xx', async () => { + mockCustomerLookup(); + nock(STAGING_BASE) + .get(ABILITIES_PATH) + .query(true) + .reply(500, 'upstream exploded'); + + const service = createService(); + + await expect(service.getCustomerAbilities()).rejects.toThrow( + /status '500' - upstream exploded/u, + ); + }); + + it.each([ + ['an array', []], + ['an object without fiat_deposit', { fiat_payout: {} }], + ['a null fiat_deposit', { fiat_deposit: null }], + ])('throws when the body is %s', async (_label, body) => { + mockCustomerLookup(); + nock(STAGING_BASE).get(ABILITIES_PATH).query(true).reply(200, body); + + const service = createService(); + + await expect(service.getCustomerAbilities()).rejects.toThrow( + 'Malformed response received from neo-bank abilities API', + ); + }); + + it('shares the customer id lookup with getMicrodeposits', async () => { + const customerScope = nock(STAGING_BASE) + .get(CUSTOMER_PATH) + .once() + .reply(200, { id: 'iron-customer-1' }); + nock(STAGING_BASE).get(ABILITIES_PATH).query(true).reply(200, abilities); + nock(STAGING_BASE) + .get('/neobank/customers/iron-customer-1/microdeposits') + .query(true) + .reply(200, []); + + const service = createService(); + + await Promise.all([ + service.getCustomerAbilities(), + service.getMicrodeposits(), + ]); + + expect(customerScope.isDone()).toBe(true); + }); + }); + describe('Money Account wallet registration', () => { it('resolves the Iron customer id via neobank customer lookup', async () => { nock(STAGING_BASE) diff --git a/packages/ramps-controller/src/NeoBankService.ts b/packages/ramps-controller/src/NeoBankService.ts index a2a76afdbc3..51cedacb8c0 100644 --- a/packages/ramps-controller/src/NeoBankService.ts +++ b/packages/ramps-controller/src/NeoBankService.ts @@ -108,6 +108,42 @@ export type NeoBankMicrodeposit = { counterparty_name?: string; }; +/** + * Status of one MoonPay rail ability. Only `Active` lets the customer use the + * rail. + */ +export type NeoBankAbilityStatus = + | 'Active' + | 'Pending' + | 'Unavailable' + | 'Blocked' + | 'Maintenance'; + +/** + * Rail statuses keyed by lowercase fiat code, then rail name, e.g. `usd.ach` + * or `brl.pix_thirdparty`. + */ +export type NeoBankFiatAbilities = Record< + string, + Record +>; + +/** + * A MoonPay customer's rail abilities. Shape mirrors MoonPay + * `GET /api/customers/{id}/abilities` and is returned unmodified. + */ +export type NeoBankCustomerAbilities = { + // eslint-disable-next-line @typescript-eslint/naming-convention -- MoonPay API field + fiat_deposit: NeoBankFiatAbilities; + // eslint-disable-next-line @typescript-eslint/naming-convention -- MoonPay API field + fiat_payout: NeoBankFiatAbilities; + /** What the customer can do with each currency it can currently use. */ + currencies: unknown[]; + /** Why a rail is `Unavailable`, keyed by rail name (e.g. `ach`). */ + // eslint-disable-next-line @typescript-eslint/naming-convention -- MoonPay API field + blocking_abilities: Record; +}; + /** * Optional headers for neo-bank mutating requests. */ @@ -155,6 +191,7 @@ const MESSENGER_EXPOSED_METHODS = [ 'getCustomerByExternalId', 'getMoonpayCustomerId', 'getMicrodeposits', + 'getCustomerAbilities', 'getWalletRegistrationStatus', 'registerSelfHostedWallet', 'getPixDepositInstructions', @@ -974,22 +1011,7 @@ export class NeoBankService { async getMicrodeposits(): Promise { let response: unknown; try { - this.#customerIdPromise ??= this.getMoonpayCustomerId().catch( - (error: unknown) => { - this.#customerIdPromise = undefined; - // The lookup runs outside the service policy and throws - // WalletRegistrationError; surface HTTP failures as HttpError like - // every other method. - if (error instanceof WalletRegistrationError && error.httpStatus) { - throw new HttpError( - error.httpStatus, - `Fetching neo-bank customer lookup failed with status '${error.httpStatus}'${error.body ? ` - ${error.body}` : ''}`, - ); - } - throw error; - }, - ); - const customerId = await this.#customerIdPromise; + const customerId = await this.#resolveCustomerId(); response = await this.#getJson( `customers/${encodeURIComponent(customerId)}/microdeposits`, ); @@ -1007,6 +1029,64 @@ export class NeoBankService { return response as NeoBankMicrodeposit[]; } + /** + * Reads the customer's rail abilities via neobank-proxy + * `GET /neobank/customers/{customer_id}/abilities` (MoonPay + * `GET /api/customers/{id}/abilities`). + * + * MoonPay rejects an autoramp create with a 422 when the rail it needs is not + * `Active`, even for an `Active` customer. The customer id is resolved the + * same way as in {@link getMicrodeposits}. Any non-2xx response, including a + * 404 when there is no customer yet, throws an {@link HttpError}. + * + * @returns MoonPay customer abilities, unmodified. + */ + async getCustomerAbilities(): Promise { + const customerId = await this.#resolveCustomerId(); + const response = await this.#getJson( + `customers/${encodeURIComponent(customerId)}/abilities`, + ); + if ( + !response || + typeof response !== 'object' || + !('fiat_deposit' in response) || + !response.fiat_deposit || + typeof response.fiat_deposit !== 'object' + ) { + throw new Error( + 'Malformed response received from neo-bank abilities API', + ); + } + return response as NeoBankCustomerAbilities; + } + + /** + * Resolves the MoonPay customer id through {@link getMoonpayCustomerId} at + * most once per service instance. Concurrent callers share the in-flight + * lookup and a failed lookup is retried by the next call. The lookup is a + * single attempt: it does not go through the retry policy. + * + * @returns Iron's internal customer id. + */ + async #resolveCustomerId(): Promise { + this.#customerIdPromise ??= this.getMoonpayCustomerId().catch( + (error: unknown) => { + this.#customerIdPromise = undefined; + // The lookup runs outside the service policy and throws + // WalletRegistrationError; surface HTTP failures as HttpError like + // every other method. + if (error instanceof WalletRegistrationError && error.httpStatus) { + throw new HttpError( + error.httpStatus, + `Fetching neo-bank customer lookup failed with status '${error.httpStatus}'${error.body ? ` - ${error.body}` : ''}`, + ); + } + throw error; + }, + ); + return await this.#customerIdPromise; + } + /** * Checks whether a Monad Money Account address is already registered for the * given Iron customer. diff --git a/packages/ramps-controller/src/RampsController-method-action-types.ts b/packages/ramps-controller/src/RampsController-method-action-types.ts index 08dba24b5a9..4d2c3b31f93 100644 --- a/packages/ramps-controller/src/RampsController-method-action-types.ts +++ b/packages/ramps-controller/src/RampsController-method-action-types.ts @@ -517,6 +517,18 @@ export type RampsControllerRefreshAutorampAction = { handler: RampsController['refreshAutoramp']; }; +/** + * Fetches the MoonPay customer's rail abilities from the neo-bank proxy and + * stores them in `vbaCustomerAbilities`. A failed fetch throws and leaves the + * stored value unchanged. + * + * @returns The fetched abilities. + */ +export type RampsControllerRefreshCustomerAbilitiesAction = { + type: `RampsController:refreshCustomerAbilities`; + handler: RampsController['refreshCustomerAbilities']; +}; + /** * Refreshes all known local autoramps from MoonPay. * Intended for app resume / unlock catch-up when webhooks were missed. @@ -988,6 +1000,7 @@ export type RampsControllerMethodActions = | RampsControllerMarkAutorampAsNotifiedAction | RampsControllerApplyAutorampStatusFromPushAction | RampsControllerRefreshAutorampAction + | RampsControllerRefreshCustomerAbilitiesAction | RampsControllerRefreshAutorampsAction | RampsControllerRefreshAutorampTransactionsAction | RampsControllerStartOrderPollingAction diff --git a/packages/ramps-controller/src/RampsController.test.ts b/packages/ramps-controller/src/RampsController.test.ts index 7ddc90b7b9f..595b9e26daa 100644 --- a/packages/ramps-controller/src/RampsController.test.ts +++ b/packages/ramps-controller/src/RampsController.test.ts @@ -203,6 +203,7 @@ describe('RampsController', () => { }, "userRegion": null, "vbaAutorampListFetchedAt": null, + "vbaCustomerAbilities": null, } `); }); @@ -283,6 +284,7 @@ describe('RampsController', () => { }, "userRegion": null, "vbaAutorampListFetchedAt": null, + "vbaCustomerAbilities": null, } `); }); @@ -2658,6 +2660,7 @@ describe('RampsController', () => { }, "userRegion": null, "vbaAutorampListFetchedAt": null, + "vbaCustomerAbilities": null, } `); }); @@ -2703,6 +2706,7 @@ describe('RampsController', () => { "selected": null, }, "userRegion": null, + "vbaCustomerAbilities": null, } `); }); @@ -2794,6 +2798,7 @@ describe('RampsController', () => { }, "userRegion": null, "vbaAutorampListFetchedAt": null, + "vbaCustomerAbilities": null, } `); }); @@ -10157,6 +10162,54 @@ describe('RampsController', () => { }); }); + describe('refreshCustomerAbilities', () => { + const abilities = { + fiat_deposit: { + usd: { ach: 'Pending', ach_thirdparty: 'Pending' }, + }, + fiat_payout: {}, + currencies: [], + blocking_abilities: {}, + } as const; + + it('stores and returns the abilities from NeoBankService', async () => { + await withController(async ({ controller, rootMessenger }) => { + const getCustomerAbilities = vi.fn().mockResolvedValue(abilities); + rootMessenger.registerActionHandler( + 'NeoBankService:getCustomerAbilities', + getCustomerAbilities, + ); + + expect(await controller.refreshCustomerAbilities()).toStrictEqual( + abilities, + ); + expect(getCustomerAbilities).toHaveBeenCalledTimes(1); + expect(controller.state.vbaCustomerAbilities).toStrictEqual( + abilities, + ); + }); + }); + + it('keeps the stored abilities when the fetch fails', async () => { + await withController( + { options: { state: { vbaCustomerAbilities: abilities } } }, + async ({ controller, rootMessenger }) => { + rootMessenger.registerActionHandler( + 'NeoBankService:getCustomerAbilities', + vi.fn().mockRejectedValue(new Error('proxy down')), + ); + + await expect(controller.refreshCustomerAbilities()).rejects.toThrow( + 'proxy down', + ); + expect(controller.state.vbaCustomerAbilities).toStrictEqual( + abilities, + ); + }, + ); + }); + }); + it('injects the Profile Sync customer id and applies the created autoramp', async () => { await withController(async ({ controller, rootMessenger }) => { rootMessenger.registerActionHandler( @@ -11272,6 +11325,14 @@ describe('RampsController', () => { }, }, vbaAutorampListFetchedAt: 2, + vbaCustomerAbilities: { + fiat_deposit: { + brl: { pix: 'Active', pix_thirdparty: 'Active' }, + }, + fiat_payout: {}, + currencies: [], + blocking_abilities: {}, + }, }, }, }, @@ -11305,6 +11366,7 @@ describe('RampsController', () => { expect(controller.state.autoramps).toStrictEqual([]); expect(controller.state.autorampTransactionRecords).toStrictEqual({}); expect(controller.state.vbaAutorampListFetchedAt).toBeNull(); + expect(controller.state.vbaCustomerAbilities).toBeNull(); }, ); }); diff --git a/packages/ramps-controller/src/RampsController.ts b/packages/ramps-controller/src/RampsController.ts index ab9f1d8376b..af146e3d14a 100644 --- a/packages/ramps-controller/src/RampsController.ts +++ b/packages/ramps-controller/src/RampsController.ts @@ -42,12 +42,16 @@ import type { NeoBankServiceCreateAutorampAction, NeoBankServiceGetAutorampAction, NeoBankServiceGetAutorampsAction, + NeoBankServiceGetCustomerAbilitiesAction, NeoBankServiceGetCustomerByExternalIdAction, NeoBankServiceListAutorampTransactionsAction, NeoBankServiceGetWalletRegistrationStatusAction, NeoBankServiceRegisterSelfHostedWalletAction, } from './NeoBankService-method-action-types.js'; -import type { NeoBankServiceActions } from './NeoBankService.js'; +import type { + NeoBankCustomerAbilities, + NeoBankServiceActions, +} from './NeoBankService.js'; import { areOrdersEqual, deleteOrderInUserStorage, @@ -234,6 +238,7 @@ export const RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = [ 'NeoBankService:getCustomerByExternalId', 'NeoBankService:getWalletRegistrationStatus', 'NeoBankService:registerSelfHostedWallet', + 'NeoBankService:getCustomerAbilities', ] as const satisfies readonly ( | RampsServiceActions['type'] | TransakServiceActions['type'] @@ -879,6 +884,13 @@ export type RampsControllerState = { * The usable-autoramp short-circuit does not update it. */ vbaAutorampListFetchedAt: number | null; + /** + * Rail abilities of the signed-in profile's MoonPay customer from the last + * {@link RampsController.refreshCustomerAbilities}. MoonPay rejects an + * autoramp create when the rail it needs is not `Active`. Not persisted, + * since a rail can change at any time. + */ + vbaCustomerAbilities: NeoBankCustomerAbilities | null; /** * Whether the currently selected provider was auto-selected by the system * (no order history, no Transak) rather than chosen by the user or derived @@ -964,6 +976,12 @@ const rampsControllerMetadata = { includeInStateLogs: false, usedInUi: true, }, + vbaCustomerAbilities: { + persist: false, + includeInDebugSnapshot: true, + includeInStateLogs: true, + usedInUi: true, + }, providerAutoSelected: { persist: true, includeInDebugSnapshot: true, @@ -1034,6 +1052,7 @@ export function getDefaultRampsControllerState(): RampsControllerState { autorampTransactionRecords: {}, moneyAccountWalletRegistrations: [], vbaAutorampListFetchedAt: null, + vbaCustomerAbilities: null, providerAutoSelected: false, }; } @@ -1166,6 +1185,7 @@ type AllowedActions = | NeoBankServiceGetCustomerByExternalIdAction | NeoBankServiceGetWalletRegistrationStatusAction | NeoBankServiceRegisterSelfHostedWalletAction + | NeoBankServiceGetCustomerAbilitiesAction | AuthenticationController.AuthenticationControllerGetSessionProfileAction | KeyringControllerSignPersonalMessageAction | KycControllerReadSessionStatusAction @@ -1414,6 +1434,7 @@ const MESSENGER_EXPOSED_METHODS = [ 'refreshAutoramp', 'refreshAutoramps', 'refreshAutorampTransactions', + 'refreshCustomerAbilities', 'startOrderPolling', 'stopOrderPolling', 'getBuyWidgetData', @@ -4303,6 +4324,7 @@ export class RampsController extends BaseController< state.autoramps = []; state.autorampTransactionRecords = {}; state.vbaAutorampListFetchedAt = null; + state.vbaCustomerAbilities = null; }); return { ...EMPTY_VBA_ONBOARDING_SNAPSHOT }; } @@ -4584,6 +4606,23 @@ export class RampsController extends BaseController< return this.#applyAutorampRemoteSnapshot(remote, { allowInsert: false }); } + /** + * Fetches the MoonPay customer's rail abilities from the neo-bank proxy and + * stores them in `vbaCustomerAbilities`. A failed fetch throws and leaves the + * stored value unchanged. + * + * @returns The fetched abilities. + */ + async refreshCustomerAbilities(): Promise { + const abilities = await this.messenger.call( + 'NeoBankService:getCustomerAbilities', + ); + this.update((state) => { + state.vbaCustomerAbilities = abilities; + }); + return abilities; + } + /** * Refreshes all known local autoramps from MoonPay. * Intended for app resume / unlock catch-up when webhooks were missed. diff --git a/packages/ramps-controller/src/autorampAccount.test.ts b/packages/ramps-controller/src/autorampAccount.test.ts index c071684567a..61ce585c567 100644 --- a/packages/ramps-controller/src/autorampAccount.test.ts +++ b/packages/ramps-controller/src/autorampAccount.test.ts @@ -11,12 +11,82 @@ import { buildBrazilMusdAutorampRequest, buildMusdAutorampRequest, createAutorampAccount, + getMusdAutorampDepositRailReadiness, isTerminalAutorampStatus, markAutorampNotified, normalizeAutorampStatus, } from './autorampAccount.js'; +import type { + NeoBankAbilityStatus, + NeoBankCustomerAbilities, +} from './NeoBankService.js'; + +const abilitiesWith = ( + fiatDeposit: Record>, +): NeoBankCustomerAbilities => ({ + fiat_deposit: fiatDeposit, + fiat_payout: {}, + currencies: [], + blocking_abilities: {}, +}); describe('autorampAccount', () => { + describe('getMusdAutorampDepositRailReadiness', () => { + it.each([ + ['BRL', { pix: 'Active', pix_thirdparty: 'Active' }], + ['USD', { ach: 'Active', ach_thirdparty: 'Active' }], + ['usd', { ach: 'Active', ach_thirdparty: 'Active' }], + ] as const)('is active when every %s rail is Active', (code, rails) => { + expect( + getMusdAutorampDepositRailReadiness( + abilitiesWith({ [code.toLowerCase()]: rails }), + code, + ), + ).toBe('active'); + }); + + it.each([ + ['BRL', { pix: 'Active', pix_thirdparty: 'Pending' }], + ['BRL', { pix: 'Active' }], + ['USD', { ach: 'Maintenance', ach_thirdparty: 'Active' }], + ['USD', {}], + ] as const)( + 'is pending when a %s rail is not Active yet (%j)', + (code, rails) => { + expect( + getMusdAutorampDepositRailReadiness( + abilitiesWith({ [code.toLowerCase()]: rails }), + code, + ), + ).toBe('pending'); + }, + ); + + it('is pending when the fiat is missing from the abilities', () => { + expect( + getMusdAutorampDepositRailReadiness(abilitiesWith({}), 'BRL'), + ).toBe('pending'); + }); + + it.each(['Unavailable', 'Blocked'] as const)( + 'is blocked when a rail is %s, even if another is pending', + (status) => { + expect( + getMusdAutorampDepositRailReadiness( + abilitiesWith({ usd: { ach: 'Pending', ach_thirdparty: status } }), + 'USD', + ), + ).toBe('blocked'); + }, + ); + + it('is active for a fiat with no required rails', () => { + expect( + getMusdAutorampDepositRailReadiness(abilitiesWith({}), 'EUR'), + ).toBe('active'); + }); + }); + describe('buildMusdAutorampRequest', () => { it('builds a standing USD to mUSD autoramp on Monad', () => { expect(buildMusdAutorampRequest('0xabc', 'USD')).toMatchInlineSnapshot(` diff --git a/packages/ramps-controller/src/autorampAccount.ts b/packages/ramps-controller/src/autorampAccount.ts index 48d079204d0..8cbdd900bdf 100644 --- a/packages/ramps-controller/src/autorampAccount.ts +++ b/packages/ramps-controller/src/autorampAccount.ts @@ -7,6 +7,7 @@ import type { AutorampDepositRailsSummary, AutorampRemoteSnapshot, } from './autoramp-types.js'; +import type { NeoBankCustomerAbilities } from './NeoBankService.js'; export type { AutorampDepositRailsSummary, @@ -111,6 +112,63 @@ export function buildBrazilMusdAutorampRequest( return buildMusdAutorampRequest(walletAddress, 'BRL'); } +/** + * Deposit rails MoonPay needs Active before it accepts a + * {@link buildMusdAutorampRequest} create, keyed by fiat code. neobank-proxy + * sends every create as third-party, so that rail is required too. + */ +const MUSD_AUTORAMP_REQUIRED_DEPOSIT_RAILS: Readonly< + Record +> = { + BRL: ['pix', 'pix_thirdparty'], + USD: ['ach', 'ach_thirdparty'], +}; + +const BLOCKED_ABILITY_STATUSES: ReadonlySet = new Set([ + 'Unavailable', + 'Blocked', +]); + +/** + * Whether the deposit rails a fiat → mUSD autoramp needs are usable. + * + * - `active`: every required rail is Active, or the fiat has none. + * - `pending`: a required rail is not Active yet (Pending, Maintenance or + * missing), so MoonPay would reject the create for now. + * - `blocked`: a required rail is Unavailable or Blocked. + */ +export type MusdAutorampDepositRailReadiness = 'active' | 'pending' | 'blocked'; + +/** + * Reads the deposit rail readiness for a fiat → mUSD autoramp from the + * customer's abilities. + * + * @param abilities - Customer abilities, e.g. `vbaCustomerAbilities`. + * @param sourceCurrencyCode - Fiat code passed to + * {@link buildMusdAutorampRequest}. + * @returns The rail readiness. + */ +export function getMusdAutorampDepositRailReadiness( + abilities: NeoBankCustomerAbilities, + sourceCurrencyCode: string, +): MusdAutorampDepositRailReadiness { + const code = sourceCurrencyCode.toUpperCase(); + const rails = MUSD_AUTORAMP_REQUIRED_DEPOSIT_RAILS[code]; + if (!rails) { + return 'active'; + } + const currencyRails = abilities.fiat_deposit[code.toLowerCase()] ?? {}; + const statuses = rails.map((rail) => currencyRails[rail]); + if ( + statuses.some( + (status) => status !== undefined && BLOCKED_ABILITY_STATUSES.has(status), + ) + ) { + return 'blocked'; + } + return statuses.every((status) => status === 'Active') ? 'active' : 'pending'; +} + /** * Result of applying a remote autoramp snapshot onto local state. */ diff --git a/packages/ramps-controller/src/index.ts b/packages/ramps-controller/src/index.ts index ddf489f5729..773cbb6cc97 100644 --- a/packages/ramps-controller/src/index.ts +++ b/packages/ramps-controller/src/index.ts @@ -51,6 +51,7 @@ export type { RampsControllerRefreshAutorampAction, RampsControllerRefreshAutorampsAction, RampsControllerRefreshAutorampTransactionsAction, + RampsControllerRefreshCustomerAbilitiesAction, RampsControllerStartOrderPollingAction, RampsControllerStopOrderPollingAction, RampsControllerGetBuyWidgetDataAction, @@ -287,6 +288,7 @@ export type { AutorampAccount, ApplyAutorampRemoteStatusResult, CreateAutorampRequest, + MusdAutorampDepositRailReadiness, } from './autorampAccount.js'; export { AutorampStatus, @@ -299,6 +301,7 @@ export { markAutorampNotified, buildMusdAutorampRequest, buildBrazilMusdAutorampRequest, + getMusdAutorampDepositRailReadiness, } from './autorampAccount.js'; export { buildOwnershipMessage } from './ownership-message.js'; export type { @@ -322,6 +325,9 @@ export type { NeoBankServiceMessenger, NeoBankAutorampResponse, NeoBankMicrodeposit, + NeoBankAbilityStatus, + NeoBankCustomerAbilities, + NeoBankFiatAbilities, NeoBankRequestOptions, NeoBankQueryParams, GetWalletRegistrationStatusParams, @@ -341,6 +347,7 @@ export type { NeoBankServiceGetCustomerByExternalIdAction, NeoBankServiceGetMoonpayCustomerIdAction, NeoBankServiceGetMicrodepositsAction, + NeoBankServiceGetCustomerAbilitiesAction, NeoBankServiceGetWalletRegistrationStatusAction, NeoBankServiceRegisterSelfHostedWalletAction, } from './NeoBankService-method-action-types.js'; From 567f24c3e6272a685d5bfdda28733f20825d7953 Mon Sep 17 00:00:00 2001 From: Darius Costolas <10818970+meltingice1337@users.noreply.github.com> Date: Mon, 2 Nov 2026 12:08:42 +0200 Subject: [PATCH 2/5] chore(ramps-controller): link changelog entries to #11225 --- packages/ramps-controller/CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/ramps-controller/CHANGELOG.md b/packages/ramps-controller/CHANGELOG.md index a11f74693ed..707d08d084a 100644 --- a/packages/ramps-controller/CHANGELOG.md +++ b/packages/ramps-controller/CHANGELOG.md @@ -9,12 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Add `NeoBankService.getCustomerAbilities`, exposed on the messenger, which returns the customer's rail abilities from neobank-proxy unmodified, and the `NeoBankCustomerAbilities`, `NeoBankFiatAbilities` and `NeoBankAbilityStatus` types ([#TBD](https://github.com/MetaMask/core/pull/TBD)) +- Add `NeoBankService.getCustomerAbilities`, exposed on the messenger, which returns the customer's rail abilities from neobank-proxy unmodified, and the `NeoBankCustomerAbilities`, `NeoBankFiatAbilities` and `NeoBankAbilityStatus` types ([#11225](https://github.com/MetaMask/core/pull/11225)) - MoonPay rejects an autoramp create with a 422 when the rail it needs is not `Active`, so clients can check the rail first. Any non-2xx response throws an `HttpError`. -- Add `RampsController.refreshCustomerAbilities`, exposed on the messenger, which stores the result in the new `vbaCustomerAbilities` state ([#TBD](https://github.com/MetaMask/core/pull/TBD)) +- Add `RampsController.refreshCustomerAbilities`, exposed on the messenger, which stores the result in the new `vbaCustomerAbilities` state ([#11225](https://github.com/MetaMask/core/pull/11225)) - The state is not persisted. A failed fetch throws and keeps the stored value. Discarding a VBA session owned by another profile clears it. - Hosts must now delegate `NeoBankService:getCustomerAbilities` to the `RampsController` messenger. It is included in `RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS`. -- Add `getMusdAutorampDepositRailReadiness` and the `MusdAutorampDepositRailReadiness` type, which read from customer abilities whether the deposit rails a fiat → mUSD autoramp needs are `active`, `pending` or `blocked` ([#TBD](https://github.com/MetaMask/core/pull/TBD)) +- Add `getMusdAutorampDepositRailReadiness` and the `MusdAutorampDepositRailReadiness` type, which read from customer abilities whether the deposit rails a fiat → mUSD autoramp needs are `active`, `pending` or `blocked` ([#11225](https://github.com/MetaMask/core/pull/11225)) - BRL needs `pix` and `pix_thirdparty`, USD needs `ach` and `ach_thirdparty`. Other fiats report `active`. ## [28.1.0] From 25413d191549c5e193c33da0f0b3ed7dd9ce40e8 Mon Sep 17 00:00:00 2001 From: Darius Costolas <10818970+meltingice1337@users.noreply.github.com> Date: Mon, 2 Nov 2026 12:30:46 +0200 Subject: [PATCH 3/5] fix(ramps-controller): type customer ability currencies from the MoonPay spec currencies was unknown[], which is not Json, so RampsControllerState no longer satisfied StateConstraint. --- packages/ramps-controller/CHANGELOG.md | 2 +- .../ramps-controller/src/NeoBankService.ts | 19 ++++++++++++++++++- .../src/RampsController.test.ts | 13 ++++++++++--- packages/ramps-controller/src/index.ts | 2 ++ 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/packages/ramps-controller/CHANGELOG.md b/packages/ramps-controller/CHANGELOG.md index 707d08d084a..8f8198ddc0d 100644 --- a/packages/ramps-controller/CHANGELOG.md +++ b/packages/ramps-controller/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Add `NeoBankService.getCustomerAbilities`, exposed on the messenger, which returns the customer's rail abilities from neobank-proxy unmodified, and the `NeoBankCustomerAbilities`, `NeoBankFiatAbilities` and `NeoBankAbilityStatus` types ([#11225](https://github.com/MetaMask/core/pull/11225)) +- Add `NeoBankService.getCustomerAbilities`, exposed on the messenger, which returns the customer's rail abilities from neobank-proxy unmodified, and the `NeoBankCustomerAbilities`, `NeoBankFiatAbilities`, `NeoBankAbilityStatus`, `NeoBankCurrencyAbility` and `NeoBankAbilityCurrency` types ([#11225](https://github.com/MetaMask/core/pull/11225)) - MoonPay rejects an autoramp create with a 422 when the rail it needs is not `Active`, so clients can check the rail first. Any non-2xx response throws an `HttpError`. - Add `RampsController.refreshCustomerAbilities`, exposed on the messenger, which stores the result in the new `vbaCustomerAbilities` state ([#11225](https://github.com/MetaMask/core/pull/11225)) - The state is not persisted. A failed fetch throws and keeps the stored value. Discarding a VBA session owned by another profile clears it. diff --git a/packages/ramps-controller/src/NeoBankService.ts b/packages/ramps-controller/src/NeoBankService.ts index 51cedacb8c0..34a46e51100 100644 --- a/packages/ramps-controller/src/NeoBankService.ts +++ b/packages/ramps-controller/src/NeoBankService.ts @@ -128,6 +128,23 @@ export type NeoBankFiatAbilities = Record< Record >; +/** + * A MoonPay currency, as it appears in a customer's currency abilities. + */ +export type NeoBankAbilityCurrency = + | { type: 'Fiat'; code: string } + | { type: 'Crypto'; token: string; blockchain: string }; + +/** + * What a MoonPay customer can do with one currency. + */ +export type NeoBankCurrencyAbility = { + currency: NeoBankAbilityCurrency; + flows: ('Onramp' | 'Offramp' | 'Swap' | 'Mint' | 'Redeem')[]; + /** Mint/redeem counterparts. Empty except for mint-only brand tokens. */ + counterparts: NeoBankAbilityCurrency[]; +}; + /** * A MoonPay customer's rail abilities. Shape mirrors MoonPay * `GET /api/customers/{id}/abilities` and is returned unmodified. @@ -138,7 +155,7 @@ export type NeoBankCustomerAbilities = { // eslint-disable-next-line @typescript-eslint/naming-convention -- MoonPay API field fiat_payout: NeoBankFiatAbilities; /** What the customer can do with each currency it can currently use. */ - currencies: unknown[]; + currencies: NeoBankCurrencyAbility[]; /** Why a rail is `Unavailable`, keyed by rail name (e.g. `ach`). */ // eslint-disable-next-line @typescript-eslint/naming-convention -- MoonPay API field blocking_abilities: Record; diff --git a/packages/ramps-controller/src/RampsController.test.ts b/packages/ramps-controller/src/RampsController.test.ts index 595b9e26daa..853a81bd7d6 100644 --- a/packages/ramps-controller/src/RampsController.test.ts +++ b/packages/ramps-controller/src/RampsController.test.ts @@ -18,6 +18,7 @@ import { buildBrazilMusdAutorampRequest, } from './autorampAccount.js'; import { MONEY_HEADLESS_ALL_PROVIDERS_FLAG_KEY } from './featureFlags.js'; +import type { NeoBankCustomerAbilities } from './NeoBankService.js'; import type { AutorampTransactionStatusChangedPayload, RampsControllerMessenger, @@ -10163,14 +10164,20 @@ describe('RampsController', () => { }); describe('refreshCustomerAbilities', () => { - const abilities = { + const abilities: NeoBankCustomerAbilities = { fiat_deposit: { usd: { ach: 'Pending', ach_thirdparty: 'Pending' }, }, fiat_payout: {}, - currencies: [], + currencies: [ + { + currency: { type: 'Fiat', code: 'USD' }, + flows: ['Onramp', 'Offramp'], + counterparts: [], + }, + ], blocking_abilities: {}, - } as const; + }; it('stores and returns the abilities from NeoBankService', async () => { await withController(async ({ controller, rootMessenger }) => { diff --git a/packages/ramps-controller/src/index.ts b/packages/ramps-controller/src/index.ts index 773cbb6cc97..4a8aa7b70f7 100644 --- a/packages/ramps-controller/src/index.ts +++ b/packages/ramps-controller/src/index.ts @@ -325,7 +325,9 @@ export type { NeoBankServiceMessenger, NeoBankAutorampResponse, NeoBankMicrodeposit, + NeoBankAbilityCurrency, NeoBankAbilityStatus, + NeoBankCurrencyAbility, NeoBankCustomerAbilities, NeoBankFiatAbilities, NeoBankRequestOptions, From 84e0072bfb815f1cd54826afc97068b1dcbf883c Mon Sep 17 00:00:00 2001 From: Darius Costolas <10818970+meltingice1337@users.noreply.github.com> Date: Mon, 2 Nov 2026 14:49:05 +0200 Subject: [PATCH 4/5] fix(ramps-controller): key the cached MoonPay customer id by session profile The customer id was cached for the life of NeoBankService, so after a profile switch getCustomerAbilities and getMicrodeposits kept using the first profile's customer. --- packages/ramps-controller/CHANGELOG.md | 4 ++ .../src/NeoBankService.test.ts | 66 +++++++++++++++++-- .../ramps-controller/src/NeoBankService.ts | 27 +++++--- 3 files changed, 81 insertions(+), 16 deletions(-) diff --git a/packages/ramps-controller/CHANGELOG.md b/packages/ramps-controller/CHANGELOG.md index 8f8198ddc0d..6afcf4bad1a 100644 --- a/packages/ramps-controller/CHANGELOG.md +++ b/packages/ramps-controller/CHANGELOG.md @@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add `getMusdAutorampDepositRailReadiness` and the `MusdAutorampDepositRailReadiness` type, which read from customer abilities whether the deposit rails a fiat → mUSD autoramp needs are `active`, `pending` or `blocked` ([#11225](https://github.com/MetaMask/core/pull/11225)) - BRL needs `pix` and `pix_thirdparty`, USD needs `ach` and `ach_thirdparty`. Other fiats report `active`. +### Fixed + +- `NeoBankService.getMicrodeposits` now looks the MoonPay customer up again when the session profile changes, instead of reusing the first profile's customer id for the life of the service ([#11225](https://github.com/MetaMask/core/pull/11225)) + ## [28.1.0] ### Added diff --git a/packages/ramps-controller/src/NeoBankService.test.ts b/packages/ramps-controller/src/NeoBankService.test.ts index 3df73e34417..9e982e6c818 100644 --- a/packages/ramps-controller/src/NeoBankService.test.ts +++ b/packages/ramps-controller/src/NeoBankService.test.ts @@ -40,6 +40,7 @@ const isAutorampTransactionQuery = ( * `{ maxRetries: 0 }` so tests fail fast unless they opt into retries. * @param options.canonicalProfileId - Canonical profile id returned by the * stubbed `AuthenticationController:getSessionProfile` (wallet registration). + * Pass a function to change it between calls. * @returns Service instance for the test. */ function createService(options?: { @@ -47,7 +48,7 @@ function createService(options?: { baseUrlOverride?: string; omitDefaults?: boolean; policyOptions?: CreateServicePolicyOptions; - canonicalProfileId?: string; + canonicalProfileId?: string | (() => string); }): NeoBankService { const rootMessenger = new Messenger({ namespace: MOCK_ANY_NAMESPACE, @@ -56,17 +57,21 @@ function createService(options?: { 'AuthenticationController:getBearerToken', async () => 'test-token', ); - const canonicalProfileId = - options?.canonicalProfileId ?? 'canonical-profile-1'; + const profileIdOption = options?.canonicalProfileId ?? 'canonical-profile-1'; rootMessenger.registerActionHandler( 'AuthenticationController:getSessionProfile', - async () => - ({ + async () => { + const canonicalProfileId = + typeof profileIdOption === 'function' + ? profileIdOption() + : profileIdOption; + return { identifierId: 'id-1', profileId: canonicalProfileId, canonicalProfileId, metaMetricsId: 'mm-1', - }) as never, + } as never; + }, ); const messenger = new Messenger({ @@ -1296,6 +1301,55 @@ describe('NeoBankService', () => { expect(customerScope.isDone()).toBe(true); }); + + it('looks the customer up again after the session profile changes', async () => { + let profileId = 'canonical-profile-1'; + mockCustomerLookup(); + nock(STAGING_BASE).get(ABILITIES_PATH).query(true).reply(200, abilities); + nock(STAGING_BASE) + .get('/neobank/customers/canonical-profile-2/external') + .reply(200, { id: 'iron-customer-2' }); + const secondProfileScope = nock(STAGING_BASE) + .get('/neobank/customers/iron-customer-2/abilities') + .query(true) + .reply(200, abilities); + + const service = createService({ canonicalProfileId: () => profileId }); + + await service.getCustomerAbilities(); + profileId = 'canonical-profile-2'; + await service.getCustomerAbilities(); + + expect(secondProfileScope.isDone()).toBe(true); + }); + + it('keeps the new profile lookup when the old profile lookup fails late', async () => { + let profileId = 'canonical-profile-1'; + nock(STAGING_BASE) + .get(CUSTOMER_PATH) + .delay(50) + .reply(500, 'old lookup failed'); + const newLookupScope = nock(STAGING_BASE) + .get('/neobank/customers/canonical-profile-2/external') + .once() + .reply(200, { id: 'iron-customer-2' }); + nock(STAGING_BASE) + .get('/neobank/customers/iron-customer-2/abilities') + .query(true) + .times(2) + .reply(200, abilities); + + const service = createService({ canonicalProfileId: () => profileId }); + + const oldProfileCall = service.getCustomerAbilities(); + await new Promise((resolve) => setTimeout(resolve, 0)); + profileId = 'canonical-profile-2'; + await service.getCustomerAbilities(); + await expect(oldProfileCall).rejects.toMatchObject({ httpStatus: 500 }); + + expect(await service.getCustomerAbilities()).toStrictEqual(abilities); + expect(newLookupScope.isDone()).toBe(true); + }); }); describe('Money Account wallet registration', () => { diff --git a/packages/ramps-controller/src/NeoBankService.ts b/packages/ramps-controller/src/NeoBankService.ts index 34a46e51100..98bdfaa69ea 100644 --- a/packages/ramps-controller/src/NeoBankService.ts +++ b/packages/ramps-controller/src/NeoBankService.ts @@ -559,7 +559,9 @@ export class NeoBankService { #walletRegistrationService: WalletRegistrationService | undefined; - #customerIdPromise: Promise | undefined; + #customerIdLookup: + | { externalId: string; customerId: Promise } + | undefined; constructor({ messenger, @@ -1079,16 +1081,20 @@ export class NeoBankService { /** * Resolves the MoonPay customer id through {@link getMoonpayCustomerId} at - * most once per service instance. Concurrent callers share the in-flight - * lookup and a failed lookup is retried by the next call. The lookup is a - * single attempt: it does not go through the retry policy. + * most once per session profile, so a profile switch looks the customer up + * again. Concurrent callers share the in-flight lookup and a failed lookup + * is retried by the next call. The lookup is a single attempt: it does not + * go through the retry policy. * * @returns Iron's internal customer id. */ async #resolveCustomerId(): Promise { - this.#customerIdPromise ??= this.getMoonpayCustomerId().catch( - (error: unknown) => { - this.#customerIdPromise = undefined; + const externalId = await this.#getCanonicalExternalId(); + if (this.#customerIdLookup?.externalId !== externalId) { + const customerId = this.getMoonpayCustomerId().catch((error: unknown) => { + if (this.#customerIdLookup?.externalId === externalId) { + this.#customerIdLookup = undefined; + } // The lookup runs outside the service policy and throws // WalletRegistrationError; surface HTTP failures as HttpError like // every other method. @@ -1099,9 +1105,10 @@ export class NeoBankService { ); } throw error; - }, - ); - return await this.#customerIdPromise; + }); + this.#customerIdLookup = { externalId, customerId }; + } + return await this.#customerIdLookup.customerId; } /** From acf55e6fd57ff970069ed9b69bd50c06dc47bb98 Mon Sep 17 00:00:00 2001 From: Darius Costolas <10818970+meltingice1337@users.noreply.github.com> Date: Mon, 2 Nov 2026 15:56:12 +0200 Subject: [PATCH 5/5] chore(ramps-controller): mark the new required service action as breaking Moves the RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS change to a BREAKING entry under Changed and notes that customer lookups go through AuthenticationController:getSessionProfile. --- packages/ramps-controller/CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/ramps-controller/CHANGELOG.md b/packages/ramps-controller/CHANGELOG.md index 6afcf4bad1a..26121ef229c 100644 --- a/packages/ramps-controller/CHANGELOG.md +++ b/packages/ramps-controller/CHANGELOG.md @@ -11,12 +11,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add `NeoBankService.getCustomerAbilities`, exposed on the messenger, which returns the customer's rail abilities from neobank-proxy unmodified, and the `NeoBankCustomerAbilities`, `NeoBankFiatAbilities`, `NeoBankAbilityStatus`, `NeoBankCurrencyAbility` and `NeoBankAbilityCurrency` types ([#11225](https://github.com/MetaMask/core/pull/11225)) - MoonPay rejects an autoramp create with a 422 when the rail it needs is not `Active`, so clients can check the rail first. Any non-2xx response throws an `HttpError`. + - It resolves the MoonPay customer through `AuthenticationController:getSessionProfile`, so hosts must delegate that action to the `NeoBankService` messenger as well as `AuthenticationController:getBearerToken`. `getMicrodeposits` needs it too. - Add `RampsController.refreshCustomerAbilities`, exposed on the messenger, which stores the result in the new `vbaCustomerAbilities` state ([#11225](https://github.com/MetaMask/core/pull/11225)) - The state is not persisted. A failed fetch throws and keeps the stored value. Discarding a VBA session owned by another profile clears it. - - Hosts must now delegate `NeoBankService:getCustomerAbilities` to the `RampsController` messenger. It is included in `RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS`. - Add `getMusdAutorampDepositRailReadiness` and the `MusdAutorampDepositRailReadiness` type, which read from customer abilities whether the deposit rails a fiat → mUSD autoramp needs are `active`, `pending` or `blocked` ([#11225](https://github.com/MetaMask/core/pull/11225)) - BRL needs `pix` and `pix_thirdparty`, USD needs `ach` and `ach_thirdparty`. Other fiats report `active`. +### Changed + +- **BREAKING:** `RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS` now includes `NeoBankService:getCustomerAbilities`. Hosts must delegate that action to `RampsController` ([#11225](https://github.com/MetaMask/core/pull/11225)) + ### Fixed - `NeoBankService.getMicrodeposits` now looks the MoonPay customer up again when the session profile changes, instead of reusing the first profile's customer id for the life of the service ([#11225](https://github.com/MetaMask/core/pull/11225))