Skip to content

Commit

Permalink
chore(accounts): Rename ControllerMessenger to Messenger
Browse files Browse the repository at this point in the history
Rename `ControllerMessenger` to `Messenger` in the
`@metamask/accounts-controller` package. The
`AccountsControllerMessenger` type export was renamed to
`AccountsMessenger`, but the old name is preserved as an alias.

Relates to #4538
  • Loading branch information
Gudahtt committed Dec 20, 2024
1 parent f8e5f2e commit 400548f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
2 changes: 2 additions & 0 deletions packages/accounts-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
19 changes: 9 additions & 10 deletions packages/accounts-controller/src/AccountsController.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ControllerMessenger } from '@metamask/base-controller';
import { Messenger } from '@metamask/base-controller';
import {
BtcAccountType,
EthAccountType,
Expand Down Expand Up @@ -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
>();
Expand All @@ -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: [
Expand Down Expand Up @@ -298,22 +298,21 @@ function setupAccountsController({
messenger = buildMessenger(),
}: {
initialState?: Partial<AccountsControllerState>;
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 };
Expand Down
8 changes: 4 additions & 4 deletions packages/accounts-controller/src/AccountsController.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -170,7 +170,7 @@ export type AccountsControllerEvents =
| AccountsControllerAccountRemovedEvent
| AccountsControllerAccountRenamedEvent;

export type AccountsControllerMessenger = RestrictedControllerMessenger<
export type AccountsMessenger = RestrictedMessenger<
typeof controllerName,
AccountsControllerActions | AllowedActions,
AccountsControllerEvents | AllowedEvents,
Expand Down Expand Up @@ -223,7 +223,7 @@ export const EMPTY_ACCOUNT = {
export class AccountsController extends BaseController<
typeof controllerName,
AccountsControllerState,
AccountsControllerMessenger
AccountsMessenger
> {
/**
* Constructor for AccountsController.
Expand All @@ -236,7 +236,7 @@ export class AccountsController extends BaseController<
messenger,
state,
}: {
messenger: AccountsControllerMessenger;
messenger: AccountsMessenger;
state: AccountsControllerState;
}) {
super({
Expand Down
3 changes: 2 additions & 1 deletion packages/accounts-controller/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

0 comments on commit 400548f

Please sign in to comment.