Skip to content
Draft
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 eslint-suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@
},
"packages/core-backend/src/ws/AccountActivityService.test.ts": {
"no-restricted-syntax": {
"count": 2
"count": 1
}
},
"packages/core-backend/src/ws/AccountActivityService.ts": {
Expand Down
16 changes: 15 additions & 1 deletion packages/core-backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add `AccountActivityService.subscribeMany({ addresses: string[] })` and `AccountActivityService.unsubscribeMany({ addresses: string[] })` to subscribe/unsubscribe from account activity for multiple CAIP-10 account addresses in a single call
- `subscribeMany` is idempotent: addresses that already have an active subscription are skipped, so multiple consumers can call it safely.
- The existing single-address `subscribe({ address })` and `unsubscribe({ address })` methods are unchanged (they now delegate to the `*Many` variants).

### Changed

- **BREAKING:** `AccountActivityService` now auto-subscribes based on the selected account group rather than the single selected account
- The service now requires the `AccountTreeController:getAccountsFromSelectedAccountGroup` action and listens to the `AccountTreeController:selectedAccountGroupChange` event instead of the `AccountsController:selectedAccountChange` event and `AccountsController:getSelectedAccount` action. Consumers must delegate these to the `AccountActivityServiceMessenger`, and no longer need to delegate any `AccountsController` actions or events.
- Auto-subscription is currently restricted to EVM (`eip155`) accounts in the group; Solana, Tron and Bitcoin are not yet supported by the backend.
- EVM addresses in auto-subscription channels are now lowercased so they match the channels produced by other consumers (idempotency).
- Bump `@metamask/utils` from `^11.9.0` to `^11.11.0` ([#9074](https://github.com/MetaMask/core/pull/9074))
- Bump `@metamask/controller-utils` from `^12.1.1` to `^12.3.0` ([#9083](https://github.com/MetaMask/core/pull/9083), [#9218](https://github.com/MetaMask/core/pull/9218))
- Bump `@metamask/profile-sync-controller` from `^28.1.1` to `^28.2.0` ([#9119](https://github.com/MetaMask/core/pull/9119))
- Bump `@metamask/keyring-controller` from `^27.0.0` to `^27.1.0` ([#9129](https://github.com/MetaMask/core/pull/9129))
- Bump `@metamask/accounts-controller` from `^39.0.1` to `^39.0.3` ([#9218](https://github.com/MetaMask/core/pull/9218), [#9231](https://github.com/MetaMask/core/pull/9231))

### Removed

- Remove the direct dependency on `@metamask/accounts-controller`
- `AccountActivityService` no longer calls `AccountsController:getSelectedAccount`; it relies solely on `AccountTreeController:getAccountsFromSelectedAccountGroup` for auto-subscription.

## [6.3.3]

Expand Down
2 changes: 1 addition & 1 deletion packages/core-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
},
"dependencies": {
"@metamask/accounts-controller": "^39.0.3",
"@metamask/account-tree-controller": "^7.5.3",
"@metamask/controller-utils": "^12.3.0",
"@metamask/keyring-controller": "^27.1.0",
"@metamask/messenger": "^1.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
import type { AccountActivityService } from './AccountActivityService';

/**
* Subscribe to account activity (transactions and balance updates)
* Address should be in CAIP-10 format (e.g., "eip155:0:0x1234..." or "solana:0:ABC123...")
* Subscribe to account activity (transactions and balance updates) for a single
* account. Address should be in CAIP-10 format (e.g., "eip155:0:0x1234..." or
* "solana:0:ABC123...").
*
* The call is idempotent: if the address already has an active subscription it
* is skipped, so multiple callers can use it safely.
*
* @param subscription - Account subscription configuration with address
*/
Expand All @@ -17,8 +21,25 @@ export type AccountActivityServiceSubscribeAction = {
};

/**
* Unsubscribe from account activity for specified address
* Address should be in CAIP-10 format (e.g., "eip155:0:0x1234..." or "solana:0:ABC123...")
* Subscribe to account activity (transactions and balance updates) for one or
* more accounts. Each address should be in CAIP-10 format (e.g.,
* "eip155:0:0x1234..." or "solana:0:ABC123...").
*
* The call is idempotent: addresses that already have an active subscription are
* skipped, so multiple consumers (e.g. data sources and the auto-subscription)
* can call this safely.
*
* @param subscription - Account subscription configuration with addresses
*/
export type AccountActivityServiceSubscribeManyAction = {
type: `AccountActivityService:subscribeMany`;
handler: AccountActivityService['subscribeMany'];
};

/**
* Unsubscribe from account activity for the specified account.
* Address should be in CAIP-10 format (e.g., "eip155:0:0x1234..." or
* "solana:0:ABC123...").
*
* @param subscription - Account subscription configuration with address to unsubscribe
*/
Expand All @@ -27,9 +48,23 @@ export type AccountActivityServiceUnsubscribeAction = {
handler: AccountActivityService['unsubscribe'];
};

/**
* Unsubscribe from account activity for the specified accounts.
* Each address should be in CAIP-10 format (e.g., "eip155:0:0x1234..." or
* "solana:0:ABC123...").
*
* @param subscription - Account subscription configuration with addresses to unsubscribe
*/
export type AccountActivityServiceUnsubscribeManyAction = {
type: `AccountActivityService:unsubscribeMany`;
handler: AccountActivityService['unsubscribeMany'];
};

/**
* Union of all AccountActivityService action types.
*/
export type AccountActivityServiceMethodActions =
| AccountActivityServiceSubscribeAction
| AccountActivityServiceUnsubscribeAction;
| AccountActivityServiceSubscribeManyAction
| AccountActivityServiceUnsubscribeAction
| AccountActivityServiceUnsubscribeManyAction;
Loading