Skip to content

Comments

feat!: Expose Accounts-owned controller/service methods through messenger#7976

Open
GuillaumeRx wants to merge 25 commits intomainfrom
gr/expose-accounts-methods-messenger
Open

feat!: Expose Accounts-owned controller/service methods through messenger#7976
GuillaumeRx wants to merge 25 commits intomainfrom
gr/expose-accounts-methods-messenger

Conversation

@GuillaumeRx
Copy link
Contributor

@GuillaumeRx GuillaumeRx commented Feb 18, 2026

Explanation

Exposes all the public methods other than init or any internally used methods of the accounts-owned controllers/services throught the messenger.

This also refactors how actions are defined and bound to the messenger using registerMethodActionHandlers and MESSENGER_EXPOSED_METHODS.

The generate-method-action-type script was used to generate the action types.

This is a breaking change in the profile-sync-controller package as some of the action type names changed but none of the underlying signatures changed.

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
Medium risk because it changes messenger exposure and public TypeScript action types across multiple packages, which can break downstream compilation or runtime wiring if action lists/types drift, though underlying method implementations are largely unchanged.

Overview
Exposes previously unexposed public methods via messenger for AccountsController, AccountTreeController, MultichainAccountService, AuthenticationController, and UserStorageController by standardizing on MESSENGER_EXPOSED_METHODS + messenger.registerMethodActionHandlers and adding auto-generated *-method-action-types.ts unions/types exported from package index.ts.

Breaking API surface cleanup/standardization: internal-only helpers are made private (e.g. AccountsController#getAccountExpect, AccountTreeController#resolveNameConflict), and profile-sync-controller action type names are standardized to end in Action, requiring downstream TypeScript import updates (action strings/signatures unchanged). Tests and downstream AllowedActions typings are updated accordingly, and packages add a generate-method-action-types script/dependency (tsx) plus changelog entries documenting the new actions and removals.

Written by Cursor Bugbot for commit 92a2528. This will update automatically on new commits. Configure here.

@GuillaumeRx GuillaumeRx requested a review from a team as a code owner February 18, 2026 11:14
@GuillaumeRx GuillaumeRx force-pushed the gr/expose-accounts-methods-messenger branch from 7de355d to 0e42ff2 Compare February 18, 2026 11:15
Comment on lines +4578 to +4589
controller.setAccountGroupName(groupId, 'Suffix Test', true);

// Test with no conflicts: should return "Unique Name (2)"
const uniqueName = controller.resolveNameConflict(
wallet,
groupId,
'Unique Name',
);
expect(uniqueName).toBe('Unique Name (2)');
const collidingGroupObject = controller.getAccountGroupObject(groupId);

expect(collidingGroupObject?.metadata.name).toBe('Suffix Test (3)');

// Test with no conflicts: should return "Unique Name"
controller.setAccountGroupName(groupId, 'Unique Name', true);

const uniqueGroupObject = controller.getAccountGroupObject(groupId);

expect(uniqueGroupObject?.metadata.name).toBe('Unique Name');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolveNameConflict is only internally used. It doesn't make sense to have it publicly only to test its behavior in unit tests. We can do that via the public methods that uses it

Copy link
Contributor

Choose a reason for hiding this comment

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

I can confirm this is not used in either extension and mobile.

Comment on lines +4578 to +4589
controller.setAccountGroupName(groupId, 'Suffix Test', true);

// Test with no conflicts: should return "Unique Name (2)"
const uniqueName = controller.resolveNameConflict(
wallet,
groupId,
'Unique Name',
);
expect(uniqueName).toBe('Unique Name (2)');
const collidingGroupObject = controller.getAccountGroupObject(groupId);

expect(collidingGroupObject?.metadata.name).toBe('Suffix Test (3)');

// Test with no conflicts: should return "Unique Name"
controller.setAccountGroupName(groupId, 'Unique Name', true);

const uniqueGroupObject = controller.getAccountGroupObject(groupId);

expect(uniqueGroupObject?.metadata.name).toBe('Unique Name');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This assertion was very misleading by the way. If there's no conflict the method shouldn't be called therefore no suffix should be added.

* @throws An error if the account ID is not found.
*/
getAccountExpect(accountId: string): InternalAccount {
#getAccountExpect(accountId: string): InternalAccount {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't need this method to be public, it's only used internally.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense!

@GuillaumeRx GuillaumeRx force-pushed the gr/expose-accounts-methods-messenger branch from 0e42ff2 to 6ea2c28 Compare February 19, 2026 15:10
@GuillaumeRx GuillaumeRx requested review from a team as code owners February 19, 2026 15:10
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know what's going on here with the imports, I just made sure that the original export behavior was respected.

Copy link
Contributor

Choose a reason for hiding this comment

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

This certainly seems cleaner :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know what's going on here with the imports, I just made sure that the original export behavior was respected.

@GuillaumeRx GuillaumeRx requested review from a team as code owners February 19, 2026 15:30
@GuillaumeRx GuillaumeRx changed the title chore: Expose Accounts-owned controller/service methods through messenger feat!: Expose Accounts-owned controller/service methods through messenger Feb 20, 2026
@GuillaumeRx GuillaumeRx requested a review from a team as a code owner February 20, 2026 10:44
@GuillaumeRx GuillaumeRx force-pushed the gr/expose-accounts-methods-messenger branch 2 times, most recently from be1d092 to 405c239 Compare February 20, 2026 11:19
Comment on lines +850 to +857
const { messenger, mocks } = await setup({
accounts: [MOCK_HD_ACCOUNT_1],
});

const resyncAccountsSpy = jest.spyOn(service, 'resyncAccounts');
await messenger.call('MultichainAccountService:resyncAccounts');
expect(resyncAccountsSpy).toHaveBeenCalled();

expect(mocks.EvmAccountProvider.resyncAccounts).toHaveBeenCalled();
expect(mocks.SolAccountProvider.resyncAccounts).toHaveBeenCalled();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can't spy resyncAccounts at this step since registeMethodActionHandlers will register the original method not the spied one

Comment on lines -882 to -887
const ensureCanUseSnapPlatformSpy = jest.spyOn(
service,
'ensureCanUseSnapPlatform',
await rootMessenger.call(
'MultichainAccountService:ensureCanUseSnapPlatform',
);
await messenger.call('MultichainAccountService:ensureCanUseSnapPlatform');
expect(ensureCanUseSnapPlatformSpy).toHaveBeenCalled();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can't spy ensureCanUseSnapPlatform at this step since registeMethodActionHandlers will register the original method not the spied one

@GuillaumeRx GuillaumeRx force-pushed the gr/expose-accounts-methods-messenger branch from 31e2baa to 6867941 Compare February 20, 2026 13:04
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Nice! The code changes themselves look good, but I had some suggestions on changelogs. (You may need to add the no-changelog label to this PR to suppress the changelog checker.)

Comment on lines +4578 to +4589
controller.setAccountGroupName(groupId, 'Suffix Test', true);

// Test with no conflicts: should return "Unique Name (2)"
const uniqueName = controller.resolveNameConflict(
wallet,
groupId,
'Unique Name',
);
expect(uniqueName).toBe('Unique Name (2)');
const collidingGroupObject = controller.getAccountGroupObject(groupId);

expect(collidingGroupObject?.metadata.name).toBe('Suffix Test (3)');

// Test with no conflicts: should return "Unique Name"
controller.setAccountGroupName(groupId, 'Unique Name', true);

const uniqueGroupObject = controller.getAccountGroupObject(groupId);

expect(uniqueGroupObject?.metadata.name).toBe('Unique Name');
Copy link
Contributor

Choose a reason for hiding this comment

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

I can confirm this is not used in either extension and mobile.

* @throws An error if the account ID is not found.
*/
getAccountExpect(accountId: string): InternalAccount {
#getAccountExpect(accountId: string): InternalAccount {
Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense!

@GuillaumeRx GuillaumeRx force-pushed the gr/expose-accounts-methods-messenger branch from 5f0e503 to 2aa9997 Compare February 23, 2026 11:13
@GuillaumeRx GuillaumeRx requested a review from mcmire February 23, 2026 11:33
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

LGTM!

@GuillaumeRx GuillaumeRx force-pushed the gr/expose-accounts-methods-messenger branch from 170f273 to 92a2528 Compare February 23, 2026 17:53
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.

4 participants