Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 7 additions & 3 deletions packages/keyring-snap-bridge/src/SnapKeyring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import {
KnownCaipNamespace,
toCaipChainId,
} from '@metamask/utils';
import { EventEmitter } from 'events';
import { v4 as uuid } from 'uuid';

import { transformAccount } from './account';
Expand All @@ -74,6 +73,7 @@ import type {
SnapKeyringEvents,
SnapKeyringMessenger,
} from './SnapKeyringMessenger';
import { SNAP_KEYRING_NAME } from './SnapKeyringMessenger';
import type { SnapMessage } from './types';
import { SnapMessageStruct } from './types';
import {
Expand Down Expand Up @@ -154,11 +154,16 @@ function normalizeAccountAddress(account: KeyringAccount): string {
/**
* Keyring bridge implementation to support Snaps.
*/
export class SnapKeyring extends EventEmitter {
Comment thread
Mrtenz marked this conversation as resolved.
export class SnapKeyring {
static type: string = SNAP_KEYRING_TYPE;

type: string;

// Name and state are required for modular initialisation.
name: typeof SNAP_KEYRING_NAME = SNAP_KEYRING_NAME;

state = null;

/**
* Messenger to dispatch requests to the Snaps controller.
*/
Expand Down Expand Up @@ -225,7 +230,6 @@ export class SnapKeyring extends EventEmitter {
callbacks: SnapKeyringCallbacks;
isAnyAccountTypeAllowed?: boolean;
}) {
super();
this.type = SnapKeyring.type;
this.#messenger = messenger;
this.#snapClient = new KeyringInternalSnapClient({ messenger });
Expand Down
4 changes: 3 additions & 1 deletion packages/keyring-snap-bridge/src/SnapKeyringMessenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ export type SnapKeyringAllowedActions =
| SnapControllerGetSnap
| SnapControllerIsMinimumPlatformVersion;

export const SNAP_KEYRING_NAME = 'SnapKeyring';

export type SnapKeyringMessenger = RestrictedMessenger<
'SnapKeyring',
typeof SNAP_KEYRING_NAME,
SnapKeyringAllowedActions,
SnapKeyringEvents,
SnapKeyringAllowedActions['type'],
Expand Down
Loading