From fe8ba53852c399b6e2f0ed06ae8b35002433b37b Mon Sep 17 00:00:00 2001 From: mikesposito Date: Mon, 7 Sep 2026 12:40:14 +0200 Subject: [PATCH] chore: break AuthenticationController constructor dependency on KeyringController --- packages/profile-sync-controller/CHANGELOG.md | 3 ++- .../AuthenticationController.ts | 24 +++---------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/packages/profile-sync-controller/CHANGELOG.md b/packages/profile-sync-controller/CHANGELOG.md index 48b54489ee5..0cf6182bfaa 100644 --- a/packages/profile-sync-controller/CHANGELOG.md +++ b/packages/profile-sync-controller/CHANGELOG.md @@ -14,7 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Resolve HD entropy source IDs from `KeyringController` instead of the message-signing snap (`getBearerToken` primary ID, `performSignIn` SRP enumeration) ([#9794](https://github.com/MetaMask/core/pull/9794)) - Bump `@metamask/keyring-controller` from `^27.1.0` to `^27.1.1` ([#9791](https://github.com/MetaMask/core/pull/9791)) - Add `@metamask/key-tree` and `@noble/curves`; remove unused `@metamask/snaps-controllers`, `@metamask/snaps-sdk`, and `@metamask/snaps-utils` dependencies ([#9824](https://github.com/MetaMask/core/pull/9824)) -- Bump `@metamask/utils` from `^11.11.0` to `^11.12.0` ([#10076](https://github.com/MetaMask/core/pull/10076)) +- Bump `@metamask/utils` from `^11.11.0` to `^11.12.0` ([#10076](10076)) +- `AuthenticationControllerMessenger` does not require `KeyringController:unlock` or `KeyringController:lock` events anymore ([#0000](https://github.com/MetaMask/core/pull/0000)) ## [29.0.0] diff --git a/packages/profile-sync-controller/src/controllers/authentication/AuthenticationController.ts b/packages/profile-sync-controller/src/controllers/authentication/AuthenticationController.ts index 1a9eb824b5e..65f7fb3378e 100644 --- a/packages/profile-sync-controller/src/controllers/authentication/AuthenticationController.ts +++ b/packages/profile-sync-controller/src/controllers/authentication/AuthenticationController.ts @@ -159,7 +159,7 @@ type AllowedActions = | KeyringControllerWithKeyringV2UnsafeAction | SeedlessOnboardingControllerGetStateAction; -type AllowedEvents = KeyringControllerLockEvent | KeyringControllerUnlockEvent; +type AllowedEvents = never; // Messenger export type AuthenticationControllerMessenger = Messenger< @@ -185,28 +185,11 @@ export class AuthenticationController extends BaseController< env: Env.PRD, }; - #isUnlocked = false; - // Bumped by `requestProfilePairing`. `performSignIn` snapshots this // before its first await; if it changes mid-flight we must NOT clear // `needsProfilePairing` (the rearm signal wins). #profilePairingRequestEpoch = 0; - readonly #keyringController = { - setupLockedStateSubscriptions: () => { - const { isUnlocked } = this.messenger.call('KeyringController:getState'); - this.#isUnlocked = isUnlocked; - - this.messenger.subscribe('KeyringController:unlock', () => { - this.#isUnlocked = true; - }); - - this.messenger.subscribe('KeyringController:lock', () => { - this.#isUnlocked = false; - }); - }, - }; - constructor({ messenger, state, @@ -261,8 +244,6 @@ export class AuthenticationController extends BaseController< }, ); - this.#keyringController.setupLockedStateSubscriptions(); - this.messenger.registerMethodActionHandlers( this, MESSENGER_EXPOSED_METHODS, @@ -301,7 +282,8 @@ export class AuthenticationController extends BaseController< } #assertIsUnlocked(methodName: string): void { - if (!this.#isUnlocked) { + const { isUnlocked } = this.messenger.call('KeyringController:getState'); + if (!isUnlocked) { throw new Error(`${methodName} - unable to proceed, wallet is locked`); } }