Skip to content
Merged
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
1 change: 1 addition & 0 deletions packages/base-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Update `BaseController` type and constructor to require new `Messenger` from `@metamask/messenger` rather than `RestrictedMessenger` ([#6318](https://github.com/MetaMask/core/pull/6318))
- Rename `ListenerV2` type export to `StateChangeListener` ([#6339](https://github.com/MetaMask/core/pull/6339))
- Rename `messagingSystem` protected instance variable to `messenger` ([#6337](https://github.com/MetaMask/core/pull/6337))
- Remove `isBaseController` ([#6341](https://github.com/MetaMask/core/pull/6341))

### Changed

Expand Down
20 changes: 0 additions & 20 deletions packages/base-controller/src/next/BaseController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import {
BaseController,
getAnonymizedState,
getPersistentState,
isBaseController,
} from './BaseController';
import { JsonRpcEngine } from '../../../json-rpc-engine/src';

export const countControllerName = 'CountController';

Expand Down Expand Up @@ -153,24 +151,6 @@ class MessagesController extends BaseController<
}
}

describe('isBaseController', () => {
it('should return true if passed a V2 controller', () => {
const messenger = getCountMessenger();
const controller = new CountController({
messenger,
name: countControllerName,
state: { count: 0 },
metadata: countControllerStateMetadata,
});
expect(isBaseController(controller)).toBe(true);
});

it('should return false if passed a non-controller', () => {
const notController = new JsonRpcEngine();
expect(isBaseController(notController)).toBe(false);
});
});

describe('BaseController', () => {
afterEach(() => {
sinon.restore();
Expand Down
21 changes: 0 additions & 21 deletions packages/base-controller/src/next/BaseController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,6 @@ import type { Draft, Patch } from 'immer';

enablePatches();

/**
* Determines if the given controller is an instance of `BaseController`
*
* @param controller - Controller instance to check
* @returns True if the controller is an instance of `BaseController`
*/
export function isBaseController(
controller: unknown,
): controller is BaseControllerInstance {
return (
typeof controller === 'object' &&
controller !== null &&
'name' in controller &&
typeof controller.name === 'string' &&
'state' in controller &&
typeof controller.state === 'object' &&
'metadata' in controller &&
typeof controller.metadata === 'object'
);
}

/**
* A type that constrains the state of all controllers.
*
Expand Down
1 change: 0 additions & 1 deletion packages/base-controller/src/next/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ export {
BaseController,
getAnonymizedState,
getPersistentState,
isBaseController,
} from './BaseController';
Loading