Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/ramps-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Require provider-side `finalStatus` approval before `hydrateVbaOnboarding` reports KYC as approved; relay `kycStatus` approval alone remains pending and does not start account setup ([#11243](https://github.com/MetaMask/core/pull/11243))
- `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]
Expand Down
31 changes: 24 additions & 7 deletions packages/ramps-controller/src/RampsController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11083,8 +11083,8 @@ describe('RampsController', () => {
const sessionWithStatus = (finalStatus: string): KycSession => ({
id: 'session-1',
finalStatus,
// Relay and vendor decisions agree in these cases; the relay-approved,
// vendor-pending divergence is covered by its own test below.
// Relay and vendor decisions agree in these cases; status divergence is
// covered by dedicated tests below.
kycStatus: finalStatus,
vendorStatus: finalStatus,
externalUserId: CANONICAL_PROFILE_ID,
Expand Down Expand Up @@ -11558,9 +11558,9 @@ describe('RampsController', () => {
});
});

it('treats a relay-approved session as approved without signing or creating', async () => {
it('keeps a relay-approved session pending until the vendor approves it', async () => {
await withController(async ({ controller, rootMessenger }) => {
registerKycHandlers(rootMessenger, {
const handlers = registerKycHandlers(rootMessenger, {
session: {
...approvedSession,
finalStatus: 'pending',
Expand All @@ -11573,6 +11573,26 @@ describe('RampsController', () => {
'registerMoneyAccountWallet',
);

expect(
await controller.hydrateVbaOnboarding({ walletAddress: '0xabc' }),
).toStrictEqual(factsSnapshot({ kycStatus: 'pending' }));

expect(handlers.getCustomerByExternalId).not.toHaveBeenCalled();
expect(handlers.signPersonalMessage).not.toHaveBeenCalled();
expect(createAutoramp).not.toHaveBeenCalled();
expect(registerWallet).not.toHaveBeenCalled();
});
});

it('uses final provider approval when the relay status lags', async () => {
await withController(async ({ controller, rootMessenger }) => {
registerKycHandlers(rootMessenger, {
session: {
...approvedSession,
kycStatus: 'pending',
},
});

expect(
await controller.hydrateVbaOnboarding({ walletAddress: '0xabc' }),
).toStrictEqual(
Expand All @@ -11581,9 +11601,6 @@ describe('RampsController', () => {
autorampStatus: 'needs_wallet_registration',
}),
);

expect(createAutoramp).not.toHaveBeenCalled();
expect(registerWallet).not.toHaveBeenCalled();
});
});

Expand Down
10 changes: 6 additions & 4 deletions packages/ramps-controller/src/RampsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,11 @@ function toVbaKycStatus(value: string | undefined): VbaKycStatus {
/**
* Maps a KYC session onto the snapshot vocabulary.
*
* Relay approval (`kycStatus: 'approved'`) counts even when `finalStatus` is
* still `pending`. A non-approved session whose provider flow was submitted,
* or whose status is pending, is `pending`.
* Only provider approval (`finalStatus: 'approved'`) is final. Relay approval
* (`kycStatus: 'approved'`) can represent completed document review while the
* provider is still deciding, so that state remains `pending`. A non-approved
* session whose provider flow was submitted, or whose status is pending, is
* also `pending`.
*
* @param session - Persisted or freshly fetched KYC session.
* @param providerFlowStatus - Durable provider-flow outcome.
Expand All @@ -510,7 +512,7 @@ function resolveVbaKycStatus(
session: KycControllerSessionStatus,
providerFlowStatus: VbaProviderFlowStatus,
): VbaKycStatus {
if (session.finalStatus === 'approved' || session.kycStatus === 'approved') {
if (session.finalStatus === 'approved') {
return 'approved';
}
const mapped = toVbaKycStatus(session.finalStatus);
Expand Down
Loading