Skip to content

Commit d2ed48e

Browse files
authored
fix(multichain-account-service): add missing MultichainAccountService:resyncActions action (#7093)
## Explanation Add this missing action. ## References - #7087 ## 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](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs), highlighting breaking changes as necessary - [ ] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Registers the `MultichainAccountService:resyncAccounts` action, adds its types, updates tests, and amends the changelog. > > - **Service** > - Register action handler `MultichainAccountService:resyncAccounts` to invoke `resyncAccounts()` in `src/MultichainAccountService.ts`. > - **Types** > - Add `MultichainAccountServiceResyncAccountsAction` and include it in `MultichainAccountServiceActions` in `src/types.ts`. > - **Tests** > - Add test to verify calling `MultichainAccountService:resyncAccounts` triggers `service.resyncAccounts()` in `MultichainAccountService.test.ts`. > - **Changelog** > - Update entry to note `resyncAccounts` method and action with PR references. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 0a600fa. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 5ffc19a commit d2ed48e

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

packages/multichain-account-service/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- **BREAKING:** Added error reporting around account creation with the `ErrorReportingService` ([#7044](https://github.com/MetaMask/core/pull/7044))
1313
- The `@metamask/error-reporting-service` is now a peer dependency.
14-
- Add `MultichainAccountService.resyncAccounts` method and action ([#7087](https://github.com/MetaMask/core/pull/7087))
14+
- Add `MultichainAccountService.resyncAccounts` method and action ([#7087](https://github.com/MetaMask/core/pull/7087)), ([#7093](https://github.com/MetaMask/core/pull/7093))
1515
- Add `*AccountProvider.resyncAccounts` method ([#7087](https://github.com/MetaMask/core/pull/7087))
1616

1717
### Changed

packages/multichain-account-service/src/MultichainAccountService.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,16 @@ describe('MultichainAccountService', () => {
996996
expect(wallet).toBeDefined();
997997
expect(wallet.entropySource).toBe('abc');
998998
});
999+
1000+
it('resync accounts with MultichainAccountService:resyncAccounts', async () => {
1001+
const { messenger, service } = await setup({
1002+
accounts: [MOCK_HD_ACCOUNT_1],
1003+
});
1004+
1005+
const resyncAccountsSpy = jest.spyOn(service, 'resyncAccounts');
1006+
await messenger.call('MultichainAccountService:resyncAccounts');
1007+
expect(resyncAccountsSpy).toHaveBeenCalled();
1008+
});
9991009
});
10001010

10011011
describe('resyncAccounts', () => {

packages/multichain-account-service/src/MultichainAccountService.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ export class MultichainAccountService {
162162
'MultichainAccountService:createMultichainAccountWallet',
163163
(...args) => this.createMultichainAccountWallet(...args),
164164
);
165+
this.#messenger.registerActionHandler(
166+
'MultichainAccountService:resyncAccounts',
167+
(...args) => this.resyncAccounts(...args),
168+
);
165169

166170
this.#messenger.subscribe('AccountsController:accountAdded', (account) =>
167171
this.#handleOnAccountAdded(account),

packages/multichain-account-service/src/types.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ export type MultichainAccountServiceCreateMultichainAccountWalletAction = {
8383
handler: MultichainAccountService['createMultichainAccountWallet'];
8484
};
8585

86+
export type MultichainAccountServiceResyncAccountsAction = {
87+
type: `${typeof serviceName}:resyncAccounts`;
88+
handler: MultichainAccountService['resyncAccounts'];
89+
};
90+
8691
/**
8792
* All actions that {@link MultichainAccountService} registers so that other
8893
* modules can call them.
@@ -97,7 +102,8 @@ export type MultichainAccountServiceActions =
97102
| MultichainAccountServiceSetBasicFunctionalityAction
98103
| MultichainAccountServiceAlignWalletAction
99104
| MultichainAccountServiceAlignWalletsAction
100-
| MultichainAccountServiceCreateMultichainAccountWalletAction;
105+
| MultichainAccountServiceCreateMultichainAccountWalletAction
106+
| MultichainAccountServiceResyncAccountsAction;
101107

102108
export type MultichainAccountServiceMultichainAccountGroupCreatedEvent = {
103109
type: `${typeof serviceName}:multichainAccountGroupCreated`;

0 commit comments

Comments
 (0)