Skip to content

feat: record Money Account previous address retirements - #11879

Merged
shane-t merged 5 commits into
mainfrom
feat/malc-address-retirements
Dec 4, 2026
Merged

shane-t merged 5 commits into
mainfrom
feat/malc-address-retirements

Conversation

@shane-t

@shane-t shane-t commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Explanation

When a Money Account migrates from SFA to MFA, CHOMP keeps monitoring the old (SFA) address for a while: funds that arrive there before the retention window ends are still moved to the new address. CHOMP now reports this window per address on GET /v1/money-account/identities/address/:address, as address.retirement. Clients need it so MFA users can keep seeing their SFA activity and know how long the old address is still monitored. Until now, nothing in core exposed it.

This PR makes the following changes:

  • @metamask/chomp-api-service
    • getDerivedIdentityByAddress now parses address.retirement. It has a state (SCHEDULED, RETIRED or RESTORED) plus the migratedAt, retiresAt, retiredAt and restoredAt timestamps.
    • A missing field, or a state this version doesn't know, parses as null. The service therefore still works against a CHOMP that doesn't send the field yet, and won't fail when CHOMP adds a new state later.
  • @metamask/money-account-lifecycle-controller
    • Each time the controller fetches the identity, it records the retirement of every previous address of the Money Account identity in a new persisted, UI-visible addressRetirements state, keyed by lowercased address.
    • It looks up each address once with ChompApiService:getDerivedIdentityByAddress, and takes both the registration status and the retirement from that response. Before, it called MoneyAccountUpgradeController:getRegistrationStatus, which wraps the same endpoint. In the common case the money account is itself the previous address, so a separate retirement lookup would have hit the same URL twice. It was only deduplicated if the two requests happened to overlap in flight.
    • The lookups keep the existing behaviour:
      • when a newer lookup starts for the same address, the older response is dropped
      • clearState discards lookups still in flight
      • failures are reported via captureException and keep the last recorded values
    • The state is only updated when a registration status or retirement actually changed.
    • getMoneyAccountIdentity() now returns retirements: the recorded retirement of each previous address.
  • @metamask/money-account-upgrade-controller
    • Test fixtures only. AddressIdentityResponse now requires retirement.

These changes are breaking at the type level. Under the breaking changes guidelines, adding a required property to an object type is breaking, and that applies to AddressIdentityResponse['address'], MoneyAccountIdentity and MoneyAccountLifecycleControllerState. MoneyAccountLifecycleControllerMessenger also no longer allows MoneyAccountUpgradeController:getRegistrationStatus, so clients must stop delegating it. At runtime nothing breaks: persisted state without addressRetirements is merged over the defaults. If reviewers would rather avoid the major bump, the new properties could be made optional instead.

References

  • MUSD-1602: expose the migration timestamps from the CHOMP identity endpoint in MALC (parent: MUSD-1445)
  • Mobile consumer: MUSD-1603 adds a selectMoneyAccountIdentity selector. It is implemented locally and will follow once this is released.
  • Depends on the CHOMP API change that adds retirement to the identity response. It is merged and deployed to dev.

Manual testing

I linked this build into MetaMask Mobile (iOS simulator, dev CHOMP) on an account that has migrated to MFA:

  • Before dev CHOMP sent retirement, getMoneyAccountIdentity() returned the identity with retirements: {}, which confirms the field being absent is handled.
  • With the CHOMP change deployed, the old SFA address is recorded in addressRetirements as SCHEDULED, with retiresAt 90 days after migratedAt. getMoneyAccountIdentity().retirements returns the same value, as does the mobile selector built on it.
  • After moving to one lookup per address, the results are the same, and addressRegistrations is unchanged. Counting the service's queries during one refresh() shows one getDerivedIdentityByAddress per address: two in total, down from three.

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

🤖 Generated with Claude Code


Note

Medium Risk
Type-level breaking changes and new persisted Money Account lifecycle state, though parsing is defensive and old persisted state merges safely.

Overview
This PR wires CHOMP's address.retirement field through core so clients can see how long migrated (predecessor) addresses stay monitored for incoming funds.

In @metamask/chomp-api-service, getDerivedIdentityByAddress now parses a required retirement on AddressIdentityResponse.address (SCHEDULED / RETIRED / RESTORED plus timestamps). Missing retirement, omitted field, or unknown state become null instead of failing the whole response; malformed known retirements (e.g. missing retiresAt) still throw.

In @metamask/money-account-lifecycle-controller, each identity sync looks up every previous address and stores results in persisted, UI-visible addressRetirements, with the same in-flight / stale-response / error-handling pattern as registration lookups. getMoneyAccountIdentity() now returns retirements keyed by lowercased previous address. clearState clears retirement lookups too.

Breaking (types only): required retirement on address identity responses, addressRetirements on controller state, and retirements on MoneyAccountIdentity; test fixtures in upgrade packages were updated accordingly.

Reviewed by Cursor Bugbot for commit 366d4b2. Configure here.

shane-t and others added 2 commits December 2, 2026 12:41
…irements

Expose CHOMP's monitoring retirement of each previous Money Account
address, so clients can show when an SFA address migrated and when
monitoring of it retires (MUSD-1602).

- chomp-api-service: parse `address.retirement` from the identity by
  address endpoint (null when absent or of an unknown state)
- money-account-lifecycle-controller: record retirements per previous
  address in persisted `addressRetirements` state, refreshed on every
  identity fetch, and include them in `getMoneyAccountIdentity`
- money-account-upgrade-controller: set `retirement` in test fixtures

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

🛑 Files requiring codeowner review

To merge this PR, you'll need to get approvals from the following owner groups.

(Note: For files with multiple owners, approval from one owner is sufficient.)

@MetaMask/delegation or @MetaMask/earn (8 files)
  • packages/chomp-api-service/CHANGELOG.md
  • packages/chomp-api-service/src/chomp-api-service.test.ts
  • packages/chomp-api-service/src/chomp-api-service.ts
  • packages/chomp-api-service/src/index.ts
  • packages/chomp-api-service/src/types.ts
  • packages/money-account-upgrade-controller/src/MoneyAccountUpgradeController.test.ts
  • packages/money-account-upgrade-controller/src/steps/associate-address.test.ts
  • packages/money-account-upgrade-controller/src/steps/register-migration-intents.test.ts
@MetaMask/earn (9 files)
  • packages/money-account-lifecycle-controller/CHANGELOG.md
  • packages/money-account-lifecycle-controller/src/money-account-lifecycle-controller-method-action-types.ts
  • packages/money-account-lifecycle-controller/src/money-account-lifecycle-controller.binding-migration.test.ts
  • packages/money-account-lifecycle-controller/src/money-account-lifecycle-controller.lifecycle.test.ts
  • packages/money-account-lifecycle-controller/src/money-account-lifecycle-controller.registration.test.ts
  • packages/money-account-lifecycle-controller/src/money-account-lifecycle-controller.start-migration.test.ts
  • packages/money-account-lifecycle-controller/src/money-account-lifecycle-controller.test.ts
  • packages/money-account-lifecycle-controller/src/money-account-lifecycle-controller.ts
  • packages/money-account-lifecycle-controller/tests/helpers.ts

ℹ️ Files co-owned by @MetaMask/core-platform

For convenience in maintaining this repo, this team co-owns the following files and thus may approve changes to them.

Note

You do not need to get approval from @MetaMask/core-platform to merge this PR.

(Expand to view list of files)
  • packages/chomp-api-service/CHANGELOG.md
  • packages/money-account-lifecycle-controller/CHANGELOG.md

@shane-t
shane-t marked this pull request as ready for review December 2, 2026 14:36
@shane-t
shane-t requested review from a team as code owners December 2, 2026 14:36
Take both the registration status and the retirement of each address
from a single ChompApiService:getDerivedIdentityByAddress call, instead
of calling MoneyAccountUpgradeController:getRegistrationStatus and then
looking up previous addresses again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ffmcgee725
ffmcgee725 previously approved these changes Dec 2, 2026

@ffmcgee725 ffmcgee725 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No major blockers, LGTM

MoMannn
MoMannn previously approved these changes Dec 3, 2026
if (retirement) {
state.addressRetirements[addressKey] = retirement;
} else {
delete state.addressRetirements[addressKey];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This deletes from state only if something changes via API call.

Is there a scenario that an address can get "stuck" so never deleted because of a specific scenario? 🤔

…ses no longer previous

An address that stops being a previous address of the Money Account
identity is never looked up again, so its recorded retirement would
stay in state. Remove it on the next lookup, and discard any lookup
still in flight for an address that is no longer looked up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@shane-t
shane-t dismissed stale reviews from MoMannn and ffmcgee725 via 9613045 December 3, 2026 09:18
MoMannn
MoMannn previously approved these changes Dec 3, 2026
@shane-t
shane-t requested a review from ffmcgee725 December 3, 2026 11:45
@shane-t
shane-t added this pull request to the merge queue Dec 3, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 3, 2026
Resolve conflicts with the binding migrations (#11782): keep both the
addressRetirements and bindingMigrations state, and both changelog sets.

The address lookups now also go through getDerivedIdentityByAddress, which
the migration polls, so the binding migration tests count the checks made
while waiting from the point the migration starts waiting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@shane-t
shane-t added this pull request to the merge queue Dec 4, 2026
Merged via the queue into main with commit ce69141 Dec 4, 2026
49 checks passed
@shane-t
shane-t deleted the feat/malc-address-retirements branch December 4, 2026 11:21
@shane-t shane-t mentioned this pull request Dec 4, 2026
1 of 4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants