Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/multichain-account-service/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

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

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,16 @@ describe('MultichainAccountService', () => {
expect(wallet).toBeDefined();
expect(wallet.entropySource).toBe('abc');
});

it('resync accounts with MultichainAccountService:resyncAccounts', async () => {
const { messenger, service } = await setup({
accounts: [MOCK_HD_ACCOUNT_1],
});

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

describe('resyncAccounts', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ export class MultichainAccountService {
'MultichainAccountService:createMultichainAccountWallet',
(...args) => this.createMultichainAccountWallet(...args),
);
this.#messenger.registerActionHandler(
'MultichainAccountService:resyncAccounts',
(...args) => this.resyncAccounts(...args),
);

this.#messenger.subscribe('AccountsController:accountAdded', (account) =>
this.#handleOnAccountAdded(account),
Expand Down
8 changes: 7 additions & 1 deletion packages/multichain-account-service/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ export type MultichainAccountServiceCreateMultichainAccountWalletAction = {
handler: MultichainAccountService['createMultichainAccountWallet'];
};

export type MultichainAccountServiceResyncAccountsAction = {
type: `${typeof serviceName}:resyncAccounts`;
handler: MultichainAccountService['resyncAccounts'];
};

/**
* All actions that {@link MultichainAccountService} registers so that other
* modules can call them.
Expand All @@ -97,7 +102,8 @@ export type MultichainAccountServiceActions =
| MultichainAccountServiceSetBasicFunctionalityAction
| MultichainAccountServiceAlignWalletAction
| MultichainAccountServiceAlignWalletsAction
| MultichainAccountServiceCreateMultichainAccountWalletAction;
| MultichainAccountServiceCreateMultichainAccountWalletAction
| MultichainAccountServiceResyncAccountsAction;

export type MultichainAccountServiceMultichainAccountGroupCreatedEvent = {
type: `${typeof serviceName}:multichainAccountGroupCreated`;
Expand Down
Loading