-
-
Notifications
You must be signed in to change notification settings - Fork 252
refactor: migrate AccountTreeController to @metamask/messenger
#6380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: migrate AccountTreeController to @metamask/messenger
#6380
Conversation
5562ae3 to
cf24808
Compare
AccountTreeController to @metamask/messengerAccountTreeController to @metamask/messenger
packages/account-tree-controller/src/AccountTreeController.test.ts
Outdated
Show resolved
Hide resolved
packages/account-tree-controller/src/AccountTreeController.test.ts
Outdated
Show resolved
Hide resolved
packages/account-tree-controller/src/AccountTreeController.test.ts
Outdated
Show resolved
Hide resolved
cf772f1 to
da25c0e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
| AccountTreeControllerActions | AllowedActions, | ||
| AccountTreeControllerEvents | AllowedEvents | ||
| >; | ||
| messenger?: ReturnType<typeof getRootMessenger>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Do we want to export a RootMessenger type from mockMessenger.ts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
| () => EMPTY_ACCOUNT_MOCK, | ||
| // Mock getSelectedAccount to return EMPTY_ACCOUNT_MOCK (id is '') BEFORE init | ||
| mockGetSelectedMultichainAccountActionHandler.mockReturnValue( | ||
| EMPTY_ACCOUNT_MOCK, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Mock Handler Not Registered
The mockGetSelectedMultichainAccountActionHandler is defined but not registered as the handler for AccountsController:getSelectedMultichainAccount. Tests attempt to configure its return value, but the action is actually handled by mocks.AccountsController.getSelectedMultichainAccount. This means the test mocks have no effect, leading to unexpected test behavior.
Explanation
This PR migrates the
AccountTreeControllerclass to the new@metamask/messengercomm system, as opposed to the one exported from@metamask/base-controller.References
Checklist
Note
Migrates AccountTreeController and tests to the new @metamask/messenger API, updates state metadata and base-controller/next usage, and adds the messenger dependency.
@metamask/messenger(replacemessagingSystem/restricted messenger withmessenger; updatesubscribe/publish/calland action handler registration).@metamask/base-controller/next; change state metadata key fromanonymoustoincludeInDebugSnapshot.messengerthrough backup/sync context; construct rules (EntropyRule,SnapRule,KeyringRule) withmessenger.tests/mockMessengerto provide root and controller messengers; refactor all tests to use it; remove inline Messenger scaffolding and update spies/handlers accordingly.@metamask/messengerand reference it intsconfigfiles; update README dependency graph to includeaccount-tree-controller --> messenger.Messengerfrom@metamask/messengerinstead ofRestrictedMessengerfrom@metamask/base-controller.Written by Cursor Bugbot for commit a185851. This will update automatically on new commits. Configure here.