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
4 changes: 4 additions & 0 deletions packages/ramps-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Treat a relay-approved KYC session as approved in `hydrateVbaOnboarding` even when the vendor-side `finalStatus` is still `pending`, so relay-approved users are no longer stranded on the pending screen ([#10497](https://github.com/MetaMask/core/pull/10497))

## [26.0.0]

### Changed
Expand Down
50 changes: 49 additions & 1 deletion packages/ramps-controller/src/RampsController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10444,7 +10444,9 @@ describe('RampsController', () => {
const sessionWithStatus = (finalStatus: string): KycSession => ({
id: 'session-1',
finalStatus,
kycStatus: 'approved',
// Relay and vendor decisions agree in these cases; the relay-approved,
// vendor-pending divergence is covered by its own test below.
kycStatus: finalStatus,
vendorStatus: finalStatus,
externalUserId: CANONICAL_PROFILE_ID,
});
Expand Down Expand Up @@ -10684,6 +10686,52 @@ describe('RampsController', () => {
});
});

it('treats a relay-approved session as approved even while the vendor finalizes', async () => {
await withController(async ({ controller, rootMessenger }) => {
// The relay has approved (`kycStatus: 'approved'`) but the vendor is
// still finalizing (`finalStatus: 'pending'`). Activation must proceed
// rather than stranding the user on a pending screen.
registerKycHandlers(rootMessenger, {
session: {
...approvedSession,
finalStatus: 'pending',
vendorStatus: 'new',
},
});
jest.spyOn(controller, 'registerMoneyAccountWallet').mockResolvedValue({
type: 'registered',
registration: {
id: 'wallet-1',
address: '0xabc',
blockchain: 'Monad',
disabled: false,
isSelf: true,
},
});
const createAutoramp = jest
.spyOn(controller, 'createAutoramp')
.mockImplementation(async () =>
controller.addAutoramp({
id: 'autoramp-1',
customerId: 'customer-1',
walletAddress: '0xabc',
status: AutorampStatus.Created,
}),
);

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

expect(createAutoramp).toHaveBeenCalledWith({});
});
});

it('loads an existing autoramp from the service instead of creating another', async () => {
await withController(async ({ controller, rootMessenger }) => {
const handlers = registerKycHandlers(rootMessenger);
Expand Down
11 changes: 10 additions & 1 deletion packages/ramps-controller/src/RampsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3977,7 +3977,16 @@ export class RampsController extends BaseController<
vendorDisclaimersComplete,
sessionDisclaimersComplete,
providerFlowStatus,
kycStatus: toVbaKycStatus(session.finalStatus),
// The relay approves (`kycStatus: 'approved'`) as soon as the KYC decision
// is made, while the vendor-side `finalStatus` can lag at `'pending'` until
// the vendor record is finalized (and in sandbox may never advance). Treat
// either signal as approval so a relay-approved user is not stranded on the
// pending screen. This mirrors the UKYC backend, whose own "already
// approved" check is `finalStatus === 'approved' || kycStatus === 'approved'`.
kycStatus:
session.finalStatus === 'approved' || session.kycStatus === 'approved'
? 'approved'
: toVbaKycStatus(session.finalStatus),
autorampStatus: 'not_ready',
};

Expand Down
Loading