Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c4b5d5a
fix(snap-account-service)!: prevent double-lock when handling Keyring…
ccharly May 20, 2026
340122b
chore: lint
ccharly May 20, 2026
7af6eb4
test: add tests
ccharly May 20, 2026
8ceff62
chore: changelog
ccharly May 20, 2026
bfa94c0
chore: changelog
ccharly May 20, 2026
e7c25d6
fix: faster snap-account-service init
ccharly May 20, 2026
9c8d42a
chore: changelog
ccharly May 20, 2026
cf72603
refactor(snap-account-service)!: make init sync + use it in ctor
ccharly May 21, 2026
9fb8d00
chore: changelog
ccharly May 21, 2026
3b99fcf
feat(snap-account-service): always forward non-keyring events in :han…
ccharly May 27, 2026
bd96402
Merge branch 'main' into cc/feat/snap-account-service-sync-init
ccharly Jun 2, 2026
b034cd2
chore: changelog
ccharly Jun 2, 2026
4ab5cf4
Merge branch 'cc/feat/snap-account-service-sync-init' into cc/feat/sn…
ccharly Jun 2, 2026
d2cf5f3
Merge branch 'main' into cc/feat/snap-account-service-forward-non-key…
ccharly Jun 2, 2026
4258151
refactor: wording
ccharly Jun 2, 2026
ab40ded
chore: jsdocs
ccharly Jun 2, 2026
b08e13e
chore: revert accounts-controller changes (will be split in its own PR)
ccharly Jun 2, 2026
e33e897
Revert "chore: revert accounts-controller changes (will be split in i…
ccharly Jun 2, 2026
d4ab067
Merge branch 'main' into cc/feat/use-new-snap-account-service-events
ccharly Jun 2, 2026
b04be5d
refactor: remove SnapKering:* events
ccharly Jun 2, 2026
7e64dc0
chore: fix changelog
ccharly Jun 3, 2026
4bcc1c6
fix: do not export SnapAccountService* + move them to types.ts
ccharly Jun 3, 2026
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
6 changes: 6 additions & 0 deletions packages/accounts-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- **BREAKING:** Re-publish `SnapAccountService:account{AssetList,Balances,Transactions}Updated` events as `AccountsController:account{AssetList,Balances,Transactions}Updated` events ([#8978](https://github.com/MetaMask/core/pull/8978))
- Now requires `SnapAccountService:account{AssetList,Balances,Transactions}Updated` events to be registered on the messenger.
- No longer requires `SnapKeyring:account{AssetList,Balances,Transactions}Updated` events to be registered on the messenger.

## [38.1.2]

### Changed
Expand Down
21 changes: 12 additions & 9 deletions packages/accounts-controller/src/AccountsController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ function buildAccountsControllerMessenger(
],
events: [
'KeyringController:stateChange',
'SnapKeyring:accountAssetListUpdated',
'SnapKeyring:accountBalancesUpdated',
'SnapKeyring:accountTransactionsUpdated',
'SnapAccountService:accountAssetListUpdated',
'SnapAccountService:accountBalancesUpdated',
'SnapAccountService:accountTransactionsUpdated',
'MultichainNetworkController:networkDidChange',
],
});
Expand Down Expand Up @@ -2144,7 +2144,7 @@ describe('AccountsController', () => {
return { messenger, account, accountsController };
};

it('re-publishes keyring events: SnapKeyring:accountBalancesUpdated', () => {
it('re-publishes keyring events: SnapAccountService:accountBalancesUpdated', () => {
const { account, messenger } = setupTest();

const payload: AccountBalancesUpdatedEventPayload = {
Expand All @@ -2163,11 +2163,11 @@ describe('AccountsController', () => {
'AccountsController:accountBalancesUpdated',
mockRePublishedCallback,
);
messenger.publish('SnapKeyring:accountBalancesUpdated', payload);
messenger.publish('SnapAccountService:accountBalancesUpdated', payload);
expect(mockRePublishedCallback).toHaveBeenCalledWith(payload);
});

it('re-publishes keyring events: SnapKeyring:accountAssetListUpdated', () => {
it('re-publishes keyring events: SnapAccountService:accountAssetListUpdated', () => {
const { account, messenger } = setupTest();

const payload: AccountAssetListUpdatedEventPayload = {
Expand All @@ -2184,11 +2184,11 @@ describe('AccountsController', () => {
'AccountsController:accountAssetListUpdated',
mockRePublishedCallback,
);
messenger.publish('SnapKeyring:accountAssetListUpdated', payload);
messenger.publish('SnapAccountService:accountAssetListUpdated', payload);
expect(mockRePublishedCallback).toHaveBeenCalledWith(payload);
});

it('re-publishes keyring events: SnapKeyring:accountTransactionsUpdated', () => {
it('re-publishes keyring events: SnapAccountService:accountTransactionsUpdated', () => {
const { account, messenger } = setupTest();

const payload: AccountTransactionsUpdatedEventPayload = {
Expand Down Expand Up @@ -2225,7 +2225,10 @@ describe('AccountsController', () => {
'AccountsController:accountTransactionsUpdated',
mockRePublishedCallback,
);
messenger.publish('SnapKeyring:accountTransactionsUpdated', payload);
messenger.publish(
'SnapAccountService:accountTransactionsUpdated',
payload,
);
expect(mockRePublishedCallback).toHaveBeenCalledWith(payload);
});
});
Expand Down
19 changes: 12 additions & 7 deletions packages/accounts-controller/src/AccountsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ import { cloneDeep } from 'lodash';

import { AccountsControllerMethodActions } from './AccountsController-method-action-types';
import { projectLogger as log } from './logger';
import type { MultichainNetworkControllerNetworkDidChangeEvent } from './types';
import type {
MultichainNetworkControllerNetworkDidChangeEvent,
SnapAccountServiceAccountAssetListUpdatedEvent,
SnapAccountServiceAccountBalancesUpdatedEvent,
SnapAccountServiceAccountTransactionsUpdatedEvent,
} from './types';
import type { AccountsControllerStrictState } from './typing';
import type { HdSnapKeyringAccount } from './utils';
import {
Expand Down Expand Up @@ -212,9 +217,9 @@ export type AccountsControllerAccountAssetListUpdatedEvent = {
*/
export type AllowedEvents =
| KeyringControllerStateChangeEvent
| SnapKeyringAccountAssetListUpdatedEvent
| SnapKeyringAccountBalancesUpdatedEvent
| SnapKeyringAccountTransactionsUpdatedEvent
| SnapAccountServiceAccountAssetListUpdatedEvent
| SnapAccountServiceAccountBalancesUpdatedEvent
| SnapAccountServiceAccountTransactionsUpdatedEvent
| MultichainNetworkControllerNetworkDidChangeEvent;

/**
Expand Down Expand Up @@ -1279,7 +1284,7 @@ export class AccountsController extends BaseController<
);

this.messenger.subscribe(
'SnapKeyring:accountAssetListUpdated',
'SnapAccountService:accountAssetListUpdated',
(snapAccountEvent) =>
this.#handleOnSnapKeyringAccountEvent(
'AccountsController:accountAssetListUpdated',
Expand All @@ -1288,7 +1293,7 @@ export class AccountsController extends BaseController<
);

this.messenger.subscribe(
'SnapKeyring:accountBalancesUpdated',
'SnapAccountService:accountBalancesUpdated',
(snapAccountEvent) =>
this.#handleOnSnapKeyringAccountEvent(
'AccountsController:accountBalancesUpdated',
Expand All @@ -1297,7 +1302,7 @@ export class AccountsController extends BaseController<
);

this.messenger.subscribe(
'SnapKeyring:accountTransactionsUpdated',
'SnapAccountService:accountTransactionsUpdated',
(snapAccountEvent) =>
this.#handleOnSnapKeyringAccountEvent(
'AccountsController:accountTransactionsUpdated',
Expand Down
20 changes: 20 additions & 0 deletions packages/accounts-controller/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
// This file contains duplicate code from MultichainNetworkController.ts to avoid circular dependencies
// It should be refactored to avoid duplication

import {
SnapKeyringAccountAssetListUpdatedEvent,
SnapKeyringAccountBalancesUpdatedEvent,
SnapKeyringAccountTransactionsUpdatedEvent,
} from '@metamask/eth-snap-keyring';
import type { CaipChainId } from '@metamask/keyring-api';
import type { NetworkClientId } from '@metamask/network-controller';

export type MultichainNetworkControllerNetworkDidChangeEvent = {
type: `MultichainNetworkController:networkDidChange`;
payload: [NetworkClientId | CaipChainId];
};

export type SnapAccountServiceAccountBalancesUpdatedEvent = {
type: `SnapAccountService:accountBalancesUpdated`;
payload: SnapKeyringAccountBalancesUpdatedEvent['payload'];
};

export type SnapAccountServiceAccountTransactionsUpdatedEvent = {
type: `SnapAccountService:accountTransactionsUpdated`;
payload: SnapKeyringAccountTransactionsUpdatedEvent['payload'];
};

export type SnapAccountServiceAccountAssetListUpdatedEvent = {
type: `SnapAccountService:accountAssetListUpdated`;
payload: SnapKeyringAccountAssetListUpdatedEvent['payload'];
};
Comment on lines +17 to +30
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We put them here to avoid having a cycle:

snap-account-service -> account-tree-controller -> accounts-controller

Loading