Skip to content

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

Merged
Mrtenz merged 27 commits intomainfrom
gr/expose-accounts-methods-messenger
Feb 24, 2026
Merged

feat!: Expose Accounts-owned controller/service methods through messenger#7976
Mrtenz merged 27 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
Expands messenger-exposed surface area and refactors action handler registration across multiple controllers/services; while behavior should be equivalent, consumers may break due to renamed action types (not strings) and removed internal-only methods.

Overview
Exposes additional public methods on AccountTreeController, AccountsController, MultichainAccountService, AuthenticationController, and UserStorageController through their messengers by switching to registerMethodActionHandlers with a centralized MESSENGER_EXPOSED_METHODS list.

Introduces auto-generated *-method-action-types.ts files (and package scripts/dependency on tsx) and updates exports/changelogs accordingly; internal-only helpers are made private/removed from the public API (e.g., AccountsController#getAccountExpect, AccountTreeController#resolveNameConflict) and tests are updated to use the remaining public methods.

Standardizes profile-sync-controller messenger action type names to end in Action and updates downstream AllowedActions type references across other packages (bridge, assets, notifications, subscription, etc.).

Written by Cursor Bugbot for commit 5705479. 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
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
mcmire
mcmire previously approved these changes Feb 23, 2026
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!

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.

@Mrtenz Mrtenz disabled auto-merge February 24, 2026 14:43
@Mrtenz Mrtenz merged commit 05f02f9 into main Feb 24, 2026
310 checks passed
@Mrtenz Mrtenz deleted the gr/expose-accounts-methods-messenger branch February 24, 2026 14:48
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.

8 participants