@metamask-previews/keyring-controller 19.0.6-preview-224dff25 → 19.0.7-preview-1a21f764

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [19.0.7]
11
+
12
+ ### Changed
13
+
14
+ - Bump `@metamask/base-controller` from `^7.1.1` to `^8.0.0` ([#5305](https://github.com/MetaMask/core/pull/5305))
15
+ - Bump `@metamask/message-manager` from `^12.0.0` to `^12.0.1` ([#5305](https://github.com/MetaMask/core/pull/5305))
16
+
10
17
  ## [19.0.6]
11
18
 
12
19
  ### Changed
@@ -653,7 +660,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
653
660
 
654
661
  All changes listed after this point were applied to this package following the monorepo conversion.
655
662
 
656
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@19.0.6...HEAD
663
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@19.0.7...HEAD
664
+ [19.0.7]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@19.0.6...@metamask/keyring-controller@19.0.7
657
665
  [19.0.6]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@19.0.5...@metamask/keyring-controller@19.0.6
658
666
  [19.0.5]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@19.0.4...@metamask/keyring-controller@19.0.5
659
667
  [19.0.4]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@19.0.3...@metamask/keyring-controller@19.0.4
@@ -36,7 +36,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
36
36
  var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
38
  };
39
- var _KeyringController_instances, _KeyringController_controllerOperationMutex, _KeyringController_vaultOperationMutex, _KeyringController_keyringBuilders, _KeyringController_unsupportedKeyrings, _KeyringController_encryptor, _KeyringController_cacheEncryptionKey, _KeyringController_keyrings, _KeyringController_password, _KeyringController_qrKeyringStateListener, _KeyringController_registerMessageHandlers, _KeyringController_getKeyringBuilderForType, _KeyringController_addQRKeyring, _KeyringController_subscribeToQRKeyringEvents, _KeyringController_unsubscribeFromQRKeyringsEvents, _KeyringController_createNewVaultWithKeyring, _KeyringController_verifySeedPhrase, _KeyringController_getUpdatedKeyrings, _KeyringController_getSerializedKeyrings, _KeyringController_restoreSerializedKeyrings, _KeyringController_unlockKeyrings, _KeyringController_updateVault, _KeyringController_getAccountsFromKeyrings, _KeyringController_createKeyringWithFirstAccount, _KeyringController_newKeyring, _KeyringController_clearKeyrings, _KeyringController_restoreKeyring, _KeyringController_destroyKeyring, _KeyringController_removeEmptyKeyrings, _KeyringController_checkForDuplicate, _KeyringController_setUnlocked, _KeyringController_persistOrRollback, _KeyringController_withRollback, _KeyringController_assertControllerMutexIsLocked, _KeyringController_withControllerLock, _KeyringController_withVaultLock;
39
+ var _KeyringController_instances, _KeyringController_controllerOperationMutex, _KeyringController_vaultOperationMutex, _KeyringController_keyringBuilders, _KeyringController_unsupportedKeyrings, _KeyringController_encryptor, _KeyringController_cacheEncryptionKey, _KeyringController_keyrings, _KeyringController_password, _KeyringController_qrKeyringStateListener, _KeyringController_registerMessageHandlers, _KeyringController_getKeyringBuilderForType, _KeyringController_addQRKeyring, _KeyringController_subscribeToQRKeyringEvents, _KeyringController_unsubscribeFromQRKeyringsEvents, _KeyringController_createNewVaultWithKeyring, _KeyringController_verifySeedPhrase, _KeyringController_getUpdatedKeyrings, _KeyringController_getSerializedKeyrings, _KeyringController_restoreSerializedKeyrings, _KeyringController_unlockKeyrings, _KeyringController_updateVault, _KeyringController_getAccountsFromKeyrings, _KeyringController_createKeyringWithFirstAccount, _KeyringController_newKeyring, _KeyringController_clearKeyrings, _KeyringController_restoreKeyring, _KeyringController_destroyKeyring, _KeyringController_removeEmptyKeyrings, _KeyringController_checkForDuplicate, _KeyringController_setUnlocked, _KeyringController_assertIsUnlocked, _KeyringController_persistOrRollback, _KeyringController_withRollback, _KeyringController_assertControllerMutexIsLocked, _KeyringController_withControllerLock, _KeyringController_withVaultLock;
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.KeyringController = exports.getDefaultKeyringState = exports.keyringBuilderFactory = exports.SignTypedDataVersion = exports.AccountImportStrategy = exports.isCustodyKeyring = exports.KeyringTypes = void 0;
42
42
  const util_1 = require("@ethereumjs/util");
@@ -287,6 +287,7 @@ class KeyringController extends base_controller_1.BaseController {
287
287
  * @returns Promise resolving to the added account address.
288
288
  */
289
289
  async addNewAccount(accountCount) {
290
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
290
291
  return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_persistOrRollback).call(this, async () => {
291
292
  const primaryKeyring = this.getKeyringsByType('HD Key Tree')[0];
292
293
  if (!primaryKeyring) {
@@ -321,6 +322,7 @@ class KeyringController extends base_controller_1.BaseController {
321
322
  // We still uses `Hex` here, since we are not using this method when creating
322
323
  // and account using a "Snap Keyring". This function assume the `keyring` is
323
324
  // ethereum compatible, but "Snap Keyring" might not be.
325
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
324
326
  return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_persistOrRollback).call(this, async () => {
325
327
  const oldAccounts = await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getAccountsFromKeyrings).call(this);
326
328
  if (accountCount && oldAccounts.length !== accountCount) {
@@ -386,6 +388,7 @@ class KeyringController extends base_controller_1.BaseController {
386
388
  * @returns Promise resolving to the added keyring.
387
389
  */
388
390
  async addNewKeyring(type, opts) {
391
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
389
392
  if (type === KeyringTypes.qr) {
390
393
  return this.getOrAddQRKeyring();
391
394
  }
@@ -418,6 +421,7 @@ class KeyringController extends base_controller_1.BaseController {
418
421
  * @returns Promise resolving to the seed phrase.
419
422
  */
420
423
  async exportSeedPhrase(password) {
424
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
421
425
  await this.verifyPassword(password);
422
426
  assertHasUint8ArrayMnemonic(__classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0]);
423
427
  return __classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0].mnemonic;
@@ -443,6 +447,7 @@ class KeyringController extends base_controller_1.BaseController {
443
447
  * @returns A promise resolving to an array of addresses.
444
448
  */
445
449
  async getAccounts() {
450
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
446
451
  return this.state.keyrings.reduce((accounts, keyring) => accounts.concat(keyring.accounts), []);
447
452
  }
448
453
  /**
@@ -454,6 +459,7 @@ class KeyringController extends base_controller_1.BaseController {
454
459
  * @returns Promise resolving to encyption public key of the `account` if one exists.
455
460
  */
456
461
  async getEncryptionPublicKey(account, opts) {
462
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
457
463
  const address = (0, eth_sig_util_1.normalize)(account);
458
464
  const keyring = (await this.getKeyringForAccount(account));
459
465
  if (!keyring.getEncryptionPublicKey) {
@@ -470,6 +476,7 @@ class KeyringController extends base_controller_1.BaseController {
470
476
  * @returns The raw decryption result.
471
477
  */
472
478
  async decryptMessage(messageParams) {
479
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
473
480
  const address = (0, eth_sig_util_1.normalize)(messageParams.from);
474
481
  const keyring = (await this.getKeyringForAccount(address));
475
482
  if (!keyring.decryptMessage) {
@@ -488,6 +495,7 @@ class KeyringController extends base_controller_1.BaseController {
488
495
  * @returns Promise resolving to keyring of the `account` if one exists.
489
496
  */
490
497
  async getKeyringForAccount(account) {
498
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
491
499
  const address = normalize(account);
492
500
  const candidates = await Promise.all(__classPrivateFieldGet(this, _KeyringController_keyrings, "f").map(async (keyring) => {
493
501
  return Promise.all([keyring, keyring.getAccounts()]);
@@ -519,6 +527,7 @@ class KeyringController extends base_controller_1.BaseController {
519
527
  * @returns An array of keyrings of the given type.
520
528
  */
521
529
  getKeyringsByType(type) {
530
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
522
531
  return __classPrivateFieldGet(this, _KeyringController_keyrings, "f").filter((keyring) => keyring.type === type);
523
532
  }
524
533
  /**
@@ -529,6 +538,7 @@ class KeyringController extends base_controller_1.BaseController {
529
538
  * operation completes.
530
539
  */
531
540
  async persistAllKeyrings() {
541
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
532
542
  return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_persistOrRollback).call(this, async () => true);
533
543
  }
534
544
  /**
@@ -543,6 +553,7 @@ class KeyringController extends base_controller_1.BaseController {
543
553
  // TODO: Replace `any` with type
544
554
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
545
555
  args) {
556
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
546
557
  return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_persistOrRollback).call(this, async () => {
547
558
  let privateKey;
548
559
  switch (strategy) {
@@ -595,6 +606,7 @@ class KeyringController extends base_controller_1.BaseController {
595
606
  * @returns Promise resolving when the account is removed.
596
607
  */
597
608
  async removeAccount(address) {
609
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
598
610
  await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_persistOrRollback).call(this, async () => {
599
611
  const keyring = (await this.getKeyringForAccount(address));
600
612
  // Not all the keyrings support this, so we have to check
@@ -621,6 +633,7 @@ class KeyringController extends base_controller_1.BaseController {
621
633
  * @returns Promise resolving when the operation completes.
622
634
  */
623
635
  async setLocked() {
636
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
624
637
  return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withRollback).call(this, async () => {
625
638
  __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_unsubscribeFromQRKeyringsEvents).call(this);
626
639
  __classPrivateFieldSet(this, _KeyringController_password, undefined, "f");
@@ -641,6 +654,7 @@ class KeyringController extends base_controller_1.BaseController {
641
654
  * @returns Promise resolving to a signed message string.
642
655
  */
643
656
  async signMessage(messageParams) {
657
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
644
658
  if (!messageParams.data) {
645
659
  throw new Error("Can't sign an empty message");
646
660
  }
@@ -658,6 +672,7 @@ class KeyringController extends base_controller_1.BaseController {
658
672
  * @returns Promise resolving to a signed message string.
659
673
  */
660
674
  async signPersonalMessage(messageParams) {
675
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
661
676
  const address = (0, eth_sig_util_1.normalize)(messageParams.from);
662
677
  const keyring = (await this.getKeyringForAccount(address));
663
678
  if (!keyring.signPersonalMessage) {
@@ -675,6 +690,7 @@ class KeyringController extends base_controller_1.BaseController {
675
690
  * @returns Promise resolving to a signed message string or an error if any.
676
691
  */
677
692
  async signTypedMessage(messageParams, version) {
693
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
678
694
  try {
679
695
  if (![
680
696
  SignTypedDataVersion.V1,
@@ -710,6 +726,7 @@ class KeyringController extends base_controller_1.BaseController {
710
726
  * @returns Promise resolving to a signed transaction string.
711
727
  */
712
728
  async signTransaction(transaction, from, opts) {
729
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
713
730
  const address = (0, eth_sig_util_1.normalize)(from);
714
731
  const keyring = (await this.getKeyringForAccount(address));
715
732
  if (!keyring.signTransaction) {
@@ -726,6 +743,7 @@ class KeyringController extends base_controller_1.BaseController {
726
743
  * @returns A pseudo-UserOperation that can be used to construct a real.
727
744
  */
728
745
  async prepareUserOperation(from, transactions, executionContext) {
746
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
729
747
  const address = (0, eth_sig_util_1.normalize)(from);
730
748
  const keyring = (await this.getKeyringForAccount(address));
731
749
  if (!keyring.prepareUserOperation) {
@@ -743,6 +761,7 @@ class KeyringController extends base_controller_1.BaseController {
743
761
  * @returns A patch to apply to the UserOperation.
744
762
  */
745
763
  async patchUserOperation(from, userOp, executionContext) {
764
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
746
765
  const address = (0, eth_sig_util_1.normalize)(from);
747
766
  const keyring = (await this.getKeyringForAccount(address));
748
767
  if (!keyring.patchUserOperation) {
@@ -759,6 +778,7 @@ class KeyringController extends base_controller_1.BaseController {
759
778
  * @returns The signature of the UserOperation.
760
779
  */
761
780
  async signUserOperation(from, userOp, executionContext) {
781
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
762
782
  const address = (0, eth_sig_util_1.normalize)(from);
763
783
  const keyring = (await this.getKeyringForAccount(address));
764
784
  if (!keyring.signUserOperation) {
@@ -773,10 +793,8 @@ class KeyringController extends base_controller_1.BaseController {
773
793
  * @returns Promise resolving when the operation completes.
774
794
  */
775
795
  changePassword(password) {
796
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
776
797
  return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_persistOrRollback).call(this, async () => {
777
- if (!this.state.isUnlocked) {
778
- throw new Error(constants_1.KeyringControllerError.MissingCredentials);
779
- }
780
798
  assertIsValidPassword(password);
781
799
  __classPrivateFieldSet(this, _KeyringController_password, password, "f");
782
800
  // We need to clear encryption key and salt from state
@@ -823,11 +841,13 @@ class KeyringController extends base_controller_1.BaseController {
823
841
  * @returns Promise resolving to the seed phrase as Uint8Array.
824
842
  */
825
843
  async verifySeedPhrase() {
844
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
826
845
  return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withControllerLock).call(this, async () => __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_verifySeedPhrase).call(this));
827
846
  }
828
847
  async withKeyring(selector, operation, options = {
829
848
  createIfMissing: false,
830
849
  }) {
850
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
831
851
  return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_persistOrRollback).call(this, async () => {
832
852
  let keyring;
833
853
  if ('address' in selector) {
@@ -861,6 +881,7 @@ class KeyringController extends base_controller_1.BaseController {
861
881
  * @deprecated Use `withKeyring` instead.
862
882
  */
863
883
  getQRKeyring() {
884
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
864
885
  // QRKeyring is not yet compatible with Keyring type from @metamask/utils
865
886
  return this.getKeyringsByType(KeyringTypes.qr)[0];
866
887
  }
@@ -871,6 +892,7 @@ class KeyringController extends base_controller_1.BaseController {
871
892
  * @deprecated Use `addNewKeyring` and `withKeyring` instead.
872
893
  */
873
894
  async getOrAddQRKeyring() {
895
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
874
896
  return (this.getQRKeyring() ||
875
897
  (await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_persistOrRollback).call(this, async () => __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_addQRKeyring).call(this))));
876
898
  }
@@ -884,6 +906,7 @@ class KeyringController extends base_controller_1.BaseController {
884
906
  // TODO: Replace `any` with type
885
907
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
886
908
  async restoreQRKeyring(serialized) {
909
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
887
910
  return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_persistOrRollback).call(this, async () => {
888
911
  const keyring = this.getQRKeyring() || (await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_addQRKeyring).call(this));
889
912
  keyring.deserialize(serialized);
@@ -896,6 +919,7 @@ class KeyringController extends base_controller_1.BaseController {
896
919
  * @deprecated Use `withKeyring` instead.
897
920
  */
898
921
  async resetQRKeyringState() {
922
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
899
923
  (await this.getOrAddQRKeyring()).resetStore();
900
924
  }
901
925
  /**
@@ -906,6 +930,7 @@ class KeyringController extends base_controller_1.BaseController {
906
930
  * instead.
907
931
  */
908
932
  async getQRKeyringState() {
933
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
909
934
  return (await this.getOrAddQRKeyring()).getMemStore();
910
935
  }
911
936
  /**
@@ -916,6 +941,7 @@ class KeyringController extends base_controller_1.BaseController {
916
941
  * @deprecated Use `withKeyring` instead.
917
942
  */
918
943
  async submitQRCryptoHDKey(cryptoHDKey) {
944
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
919
945
  (await this.getOrAddQRKeyring()).submitCryptoHDKey(cryptoHDKey);
920
946
  }
921
947
  /**
@@ -926,6 +952,7 @@ class KeyringController extends base_controller_1.BaseController {
926
952
  * @deprecated Use `withKeyring` instead.
927
953
  */
928
954
  async submitQRCryptoAccount(cryptoAccount) {
955
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
929
956
  (await this.getOrAddQRKeyring()).submitCryptoAccount(cryptoAccount);
930
957
  }
931
958
  /**
@@ -937,6 +964,7 @@ class KeyringController extends base_controller_1.BaseController {
937
964
  * @deprecated Use `withKeyring` instead.
938
965
  */
939
966
  async submitQRSignature(requestId, ethSignature) {
967
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
940
968
  (await this.getOrAddQRKeyring()).submitSignature(requestId, ethSignature);
941
969
  }
942
970
  /**
@@ -946,6 +974,7 @@ class KeyringController extends base_controller_1.BaseController {
946
974
  * @deprecated Use `withKeyring` instead.
947
975
  */
948
976
  async cancelQRSignRequest() {
977
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
949
978
  (await this.getOrAddQRKeyring()).cancelSignRequest();
950
979
  }
951
980
  /**
@@ -955,6 +984,7 @@ class KeyringController extends base_controller_1.BaseController {
955
984
  * @deprecated Use `withKeyring` instead.
956
985
  */
957
986
  async cancelQRSynchronization() {
987
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
958
988
  (await this.getOrAddQRKeyring()).cancelSync();
959
989
  }
960
990
  /**
@@ -967,6 +997,7 @@ class KeyringController extends base_controller_1.BaseController {
967
997
  * `withKeyring` instead.
968
998
  */
969
999
  async connectQRHardware(page) {
1000
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
970
1001
  return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_persistOrRollback).call(this, async () => {
971
1002
  try {
972
1003
  const keyring = this.getQRKeyring() || (await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_addQRKeyring).call(this));
@@ -1007,6 +1038,7 @@ class KeyringController extends base_controller_1.BaseController {
1007
1038
  * @deprecated Use `withKeyring` instead.
1008
1039
  */
1009
1040
  async unlockQRHardwareWalletAccount(index) {
1041
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
1010
1042
  return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_persistOrRollback).call(this, async () => {
1011
1043
  const keyring = this.getQRKeyring() || (await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_addQRKeyring).call(this));
1012
1044
  keyring.setAccountToUnlock(index);
@@ -1014,6 +1046,7 @@ class KeyringController extends base_controller_1.BaseController {
1014
1046
  });
1015
1047
  }
1016
1048
  async getAccountKeyringType(account) {
1049
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
1017
1050
  const keyring = (await this.getKeyringForAccount(account));
1018
1051
  return keyring.type;
1019
1052
  }
@@ -1024,6 +1057,7 @@ class KeyringController extends base_controller_1.BaseController {
1024
1057
  * @deprecated Use `withKeyring` instead.
1025
1058
  */
1026
1059
  async forgetQRDevice() {
1060
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
1027
1061
  return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_persistOrRollback).call(this, async () => {
1028
1062
  const keyring = this.getQRKeyring();
1029
1063
  if (!keyring) {
@@ -1481,6 +1515,10 @@ async function _KeyringController_checkForDuplicate(type, newAccountArray) {
1481
1515
  state.isUnlocked = true;
1482
1516
  });
1483
1517
  this.messagingSystem.publish(`${name}:unlock`);
1518
+ }, _KeyringController_assertIsUnlocked = function _KeyringController_assertIsUnlocked() {
1519
+ if (!this.state.isUnlocked) {
1520
+ throw new Error(constants_1.KeyringControllerError.ControllerLocked);
1521
+ }
1484
1522
  }, _KeyringController_persistOrRollback =
1485
1523
  /**
1486
1524
  * Execute the given function after acquiring the controller lock