diff --git a/packages/accounts-controller/CHANGELOG.md b/packages/accounts-controller/CHANGELOG.md index 00ae70db7f..ca2b8ef0a0 100644 --- a/packages/accounts-controller/CHANGELOG.md +++ b/packages/accounts-controller/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Bump `@metamask/base-controller` from `^7.0.0` to `^7.1.0` ([#5079](https://github.com/MetaMask/core/pull/5079)) +- Rename `AccountsControllerMessenger` to `AccountsMessenger` ([#5090](https://github.com/MetaMask/core/pull/5090)) + - The old name is preserved as an alias, so this is not a breaking change. ## [20.0.2] diff --git a/packages/accounts-controller/src/AccountsController.test.ts b/packages/accounts-controller/src/AccountsController.test.ts index e082ea1c38..2800988f50 100644 --- a/packages/accounts-controller/src/AccountsController.test.ts +++ b/packages/accounts-controller/src/AccountsController.test.ts @@ -1,4 +1,4 @@ -import { ControllerMessenger } from '@metamask/base-controller'; +import { Messenger } from '@metamask/base-controller'; import { BtcAccountType, EthAccountType, @@ -253,12 +253,12 @@ function setLastSelectedAsAny(account: InternalAccount): InternalAccount { } /** - * Builds a new instance of the ControllerMessenger class for the AccountsController. + * Builds a new instance of the Messenger class for the AccountsController. * - * @returns A new instance of the ControllerMessenger class for the AccountsController. + * @returns A new instance of the Messenger class for the AccountsController. */ function buildMessenger() { - return new ControllerMessenger< + return new Messenger< AccountsControllerActions | AllowedActions, AccountsControllerEvents | AllowedEvents >(); @@ -270,7 +270,7 @@ function buildMessenger() { * @param messenger - The messenger to restrict. * @returns The restricted messenger. */ -function buildAccountsControllerMessenger(messenger = buildMessenger()) { +function buildAccountsMessenger(messenger = buildMessenger()) { return messenger.getRestricted({ name: 'AccountsController', allowedEvents: [ @@ -298,22 +298,21 @@ function setupAccountsController({ messenger = buildMessenger(), }: { initialState?: Partial; - messenger?: ControllerMessenger< + messenger?: Messenger< AccountsControllerActions | AllowedActions, AccountsControllerEvents | AllowedEvents >; }): { accountsController: AccountsController; - messenger: ControllerMessenger< + messenger: Messenger< AccountsControllerActions | AllowedActions, AccountsControllerEvents | AllowedEvents >; } { - const accountsControllerMessenger = - buildAccountsControllerMessenger(messenger); + const accountsMessenger = buildAccountsMessenger(messenger); const accountsController = new AccountsController({ - messenger: accountsControllerMessenger, + messenger: accountsMessenger, state: { ...defaultState, ...initialState }, }); return { accountsController, messenger }; diff --git a/packages/accounts-controller/src/AccountsController.ts b/packages/accounts-controller/src/AccountsController.ts index 234d454472..348267782d 100644 --- a/packages/accounts-controller/src/AccountsController.ts +++ b/packages/accounts-controller/src/AccountsController.ts @@ -1,7 +1,7 @@ import type { ControllerGetStateAction, ControllerStateChangeEvent, - RestrictedControllerMessenger, + RestrictedMessenger, } from '@metamask/base-controller'; import { BaseController } from '@metamask/base-controller'; import { SnapKeyring } from '@metamask/eth-snap-keyring'; @@ -170,7 +170,7 @@ export type AccountsControllerEvents = | AccountsControllerAccountRemovedEvent | AccountsControllerAccountRenamedEvent; -export type AccountsControllerMessenger = RestrictedControllerMessenger< +export type AccountsMessenger = RestrictedMessenger< typeof controllerName, AccountsControllerActions | AllowedActions, AccountsControllerEvents | AllowedEvents, @@ -223,7 +223,7 @@ export const EMPTY_ACCOUNT = { export class AccountsController extends BaseController< typeof controllerName, AccountsControllerState, - AccountsControllerMessenger + AccountsMessenger > { /** * Constructor for AccountsController. @@ -236,7 +236,7 @@ export class AccountsController extends BaseController< messenger, state, }: { - messenger: AccountsControllerMessenger; + messenger: AccountsMessenger; state: AccountsControllerState; }) { super({ diff --git a/packages/accounts-controller/src/index.ts b/packages/accounts-controller/src/index.ts index 2ac23b5a25..a87022576b 100644 --- a/packages/accounts-controller/src/index.ts +++ b/packages/accounts-controller/src/index.ts @@ -20,7 +20,8 @@ export type { AccountsControllerAccountRemovedEvent, AccountsControllerAccountRenamedEvent, AccountsControllerEvents, - AccountsControllerMessenger, + AccountsMessenger, + AccountsMessenger as AccountsControllerMessenger, } from './AccountsController'; export { AccountsController } from './AccountsController'; export { keyringTypeToName, getUUIDFromAddressOfNormalAccount } from './utils';