@@ -13,7 +13,6 @@ import type {
1313 KeyringControllerWithControllerAction ,
1414 KeyringControllerWithKeyringV2Action ,
1515 KeyringControllerWithKeyringV2UnsafeAction ,
16- KeyringEntry ,
1716} from '@metamask/keyring-controller' ;
1817import {
1918 isKeyringNotFoundError ,
@@ -40,7 +39,6 @@ import type { Json } from '@metamask/utils';
4039import { projectLogger as log } from './logger' ;
4140import type {
4241 SnapAccountServiceEnsureReadyAction ,
43- SnapAccountServiceGetLegacySnapKeyringAction ,
4442 SnapAccountServiceGetSnapsAction ,
4543 SnapAccountServiceHandleKeyringSnapMessageAction ,
4644 SnapAccountServiceMigrateAction ,
@@ -71,7 +69,6 @@ export const serviceName = 'SnapAccountService';
7169const MESSENGER_EXPOSED_METHODS = [
7270 'ensureReady' ,
7371 'getSnaps' ,
74- 'getLegacySnapKeyring' ,
7572 'handleKeyringSnapMessage' ,
7673 'migrate' ,
7774] as const ;
@@ -82,7 +79,6 @@ const MESSENGER_EXPOSED_METHODS = [
8279export type SnapAccountServiceActions =
8380 | SnapAccountServiceEnsureReadyAction
8481 | SnapAccountServiceGetSnapsAction
85- | SnapAccountServiceGetLegacySnapKeyringAction
8682 | SnapAccountServiceHandleKeyringSnapMessageAction
8783 | SnapAccountServiceMigrateAction ;
8884
@@ -535,53 +531,6 @@ export class SnapAccountService {
535531 ) ;
536532 }
537533
538- /**
539- * Atomically gets-or-creates the legacy (v1) Snap keyring — the keyring
540- * associated with {@link KeyringTypes.snap}.
541- *
542- * @returns The existing or newly-created Snap keyring instance.
543- */
544- async getLegacySnapKeyring ( ) : Promise < LegacySnapKeyring > {
545- type Result = {
546- snapKeyring : LegacySnapKeyring ;
547- } ;
548-
549- // `KeyringController:withController` forbids returning a direct keyring
550- // reference (it checks the result via `Object.is`), so we smuggle the
551- // instance out wrapped in an object and unwrap it after the call.
552- // NOTE: This violates the abstraction of `KeyringController:withController`, but this
553- // is how we currently interact with the legacy Snap keyring. Once we migrate it to
554- // the Snap keyring v2, we won't be using the same pattern.
555- const result = await this . #messenger. call (
556- 'KeyringController:withController' ,
557- async ( controller ) : Promise < Result > => {
558- let snapKeyring : KeyringEntry [ 'keyring' ] | undefined ;
559-
560- const found = controller . keyrings . find ( ( { keyring } ) =>
561- isLegacySnapKeyring ( keyring ) ,
562- ) ;
563- if ( found ) {
564- snapKeyring = found . keyring ;
565- }
566-
567- if ( ! snapKeyring ) {
568- const {
569- keyring : newSnapKeyring ,
570- metadata : { id } ,
571- } = await controller . addNewKeyring ( KeyringTypes . snap ) ;
572- snapKeyring = newSnapKeyring ;
573-
574- log ( `Legacy Snap keyring created. ("${ id } ")` ) ;
575- }
576-
577- // The legacy Snap keyring is not compatible with `EthKeyring`, so we need to cast here.
578- return { snapKeyring } as unknown as Result ;
579- } ,
580- ) ;
581-
582- return ( result as Result ) . snapKeyring ;
583- }
584-
585534 /**
586535 * Handle a message from a Snap.
587536 *
0 commit comments