Skip to content

refactor(kyc-controller): move Moonpay frame handling out of KycController - #10082

Merged
Akaryatrh merged 7 commits into
mainfrom
jl/kyc-controller-refactor-moonpay-specific-flow
Sep 3, 2026
Merged

refactor(kyc-controller): move Moonpay frame handling out of KycController#10082
Akaryatrh merged 7 commits into
mainfrom
jl/kyc-controller-refactor-moonpay-specific-flow

Conversation

@jiexi

@jiexi jiexi commented Sep 3, 2026

Copy link
Copy Markdown
Member

Explanation

Starting the pattern of abstracting vendor specific flows out of the KycController

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Behavior is largely a move of authentication-critical frame/crypto logic; regressions would affect MoonPay login and token handling, though the refactor is covered by relocated unit tests and unchanged public controller APIs.

Overview
Extracts MoonPay Check/Auth frame logic from KycController into vendors/MoonPayFrameHandler, as the first step toward isolating vendor-specific flows.

KycController still exposes the same frame APIs (handleFrameMessage, buildCheckFrameUrl, buildAuthFrameUrl, buildResetFrameUrl) but delegates to a composed MoonPayFrameHandler wired with callbacks (getState, update, fail, onAuthenticated, requireTermsReacceptance). Frame keypairs, auth client tokens, message parsing, credential decryption, URL construction, and phase transitions for Check/Auth now live in the handler; clearMoonPaySession is shared from that module for state teardown on vendor switch, session recreate, and reset.

Tests move detailed frame-protocol coverage to MoonPayFrameHandler.test.ts; KycController.test.ts mocks the handler and asserts delegation, lifecycle hooks (startFlow, ensureKeypair, clear, clearAuthentication), and controller callback wiring. ARCHITECTURE.md documents the new file in the appendix.

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

@jiexi
jiexi requested a review from a team as a code owner September 3, 2026 00:34
jiexi and others added 3 commits September 2, 2026 17:45
Signed-off-by: Sébastien Van Eyck <sebastien.vaneyck@consensys.net>
Akaryatrh
Akaryatrh previously approved these changes Sep 3, 2026
@Akaryatrh
Akaryatrh enabled auto-merge September 3, 2026 13:55

@Akaryatrh Akaryatrh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Akaryatrh
Akaryatrh added this pull request to the merge queue Sep 3, 2026
Merged via the queue into main with commit 08c137e Sep 3, 2026
46 checks passed
@Akaryatrh
Akaryatrh deleted the jl/kyc-controller-refactor-moonpay-specific-flow branch September 3, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants