Skip to content

Commit 956e281

Browse files
committed
Add name and state properties to SnapKeyring to support modular initialisation
1 parent 03d8fd0 commit 956e281

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

packages/keyring-snap-bridge/src/SnapKeyring.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ import {
5151
KnownCaipNamespace,
5252
toCaipChainId,
5353
} from '@metamask/utils';
54-
import { EventEmitter } from 'events';
5554
import { v4 as uuid } from 'uuid';
5655

5756
import { transformAccount } from './account';
@@ -74,6 +73,7 @@ import type {
7473
SnapKeyringEvents,
7574
SnapKeyringMessenger,
7675
} from './SnapKeyringMessenger';
76+
import { SNAP_KEYRING_NAME } from './SnapKeyringMessenger';
7777
import type { SnapMessage } from './types';
7878
import { SnapMessageStruct } from './types';
7979
import {
@@ -154,11 +154,16 @@ function normalizeAccountAddress(account: KeyringAccount): string {
154154
/**
155155
* Keyring bridge implementation to support Snaps.
156156
*/
157-
export class SnapKeyring extends EventEmitter {
157+
export class SnapKeyring {
158158
static type: string = SNAP_KEYRING_TYPE;
159159

160160
type: string;
161161

162+
// Name and state are required for modular initialisation.
163+
name: typeof SNAP_KEYRING_NAME = SNAP_KEYRING_NAME;
164+
165+
state = null;
166+
162167
/**
163168
* Messenger to dispatch requests to the Snaps controller.
164169
*/
@@ -225,7 +230,6 @@ export class SnapKeyring extends EventEmitter {
225230
callbacks: SnapKeyringCallbacks;
226231
isAnyAccountTypeAllowed?: boolean;
227232
}) {
228-
super();
229233
this.type = SnapKeyring.type;
230234
this.#messenger = messenger;
231235
this.#snapClient = new KeyringInternalSnapClient({ messenger });

packages/keyring-snap-bridge/src/SnapKeyringMessenger.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ export type SnapKeyringAllowedActions =
4040
| SnapControllerGetSnap
4141
| SnapControllerIsMinimumPlatformVersion;
4242

43+
export const SNAP_KEYRING_NAME = 'SnapKeyring';
44+
4345
export type SnapKeyringMessenger = RestrictedMessenger<
44-
'SnapKeyring',
46+
typeof SNAP_KEYRING_NAME,
4547
SnapKeyringAllowedActions,
4648
SnapKeyringEvents,
4749
SnapKeyringAllowedActions['type'],

0 commit comments

Comments
 (0)