@metamask-previews/keyring-controller 8.0.0-preview.1b84247 → 8.0.2-preview.26b130a

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
@@ -6,6 +6,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [8.0.2]
10
+ ### Changed
11
+ - Bump dependency on `@metamask/utils` to ^8.1.0 ([#1639](https://github.com/MetaMask/core/pull/1639))
12
+ - Bump dependency on `@metamask/base-controller` to ^3.2.3
13
+ - Bump dependency on `@metamask/message-manager` to ^7.3.5
14
+
15
+ ### Fixed
16
+ - Update `removeAccount` to remove call to `PreferencesController.removeIdentity` as `PreferencesController` already handles account removal side effects through messenger events ([#1759](https://github.com/MetaMask/core/pull/1759))
17
+
18
+ ## [8.0.1]
19
+ ### Changed
20
+ - Update TypeScript to v4.8.x ([#1718](https://github.com/MetaMask/core/pull/1718))
21
+
22
+ ### Fixed
23
+ - Removed `keyringTypes` from `memStore` ([#1710](https://github.com/MetaMask/core/pull/1710))
24
+ - This property was accidentally getting copied into the memstore from the internal keyring controller. It was causing errors because there is no metadata for this state property.
25
+
9
26
  ## [8.0.0]
10
27
  ### Added
11
28
  - Add `getQRKeyring(): QRKeyring | undefined` method
@@ -196,7 +213,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
196
213
 
197
214
  All changes listed after this point were applied to this package following the monorepo conversion.
198
215
 
199
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@8.0.0...HEAD
216
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@8.0.2...HEAD
217
+ [8.0.2]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@8.0.1...@metamask/keyring-controller@8.0.2
218
+ [8.0.1]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@8.0.0...@metamask/keyring-controller@8.0.1
200
219
  [8.0.0]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@7.5.0...@metamask/keyring-controller@8.0.0
201
220
  [7.5.0]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@7.4.0...@metamask/keyring-controller@7.5.0
202
221
  [7.4.0]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@7.3.0...@metamask/keyring-controller@7.4.0
@@ -1,14 +1,11 @@
1
1
  import type { TxData, TypedTransaction } from '@ethereumjs/tx';
2
- import { MetaMaskKeyring as QRKeyring, type IKeyringState as IQRKeyringState } from '@keystonehq/metamask-airgapped-keyring';
3
- import type Transport from '@ledgerhq/hw-transport';
4
- import LedgerKeyring from '@ledgerhq/metamask-keyring';
2
+ import type { MetaMaskKeyring as QRKeyring, IKeyringState as IQRKeyringState } from '@keystonehq/metamask-airgapped-keyring';
5
3
  import type { RestrictedControllerMessenger } from '@metamask/base-controller';
6
4
  import { BaseControllerV2 } from '@metamask/base-controller';
7
5
  import type { PersonalMessageParams, TypedMessageParams } from '@metamask/message-manager';
8
6
  import type { PreferencesController } from '@metamask/preferences-controller';
9
7
  import type { Eip1024EncryptedData, Hex, Keyring, Json } from '@metamask/utils';
10
8
  import type { Patch } from 'immer';
11
- import type { SerializedLedgerKeyring } from './types/SerializedKeyringTypes';
12
9
  declare const name = "KeyringController";
13
10
  /**
14
11
  * Available keyring types
@@ -16,8 +13,7 @@ declare const name = "KeyringController";
16
13
  export declare enum KeyringTypes {
17
14
  simple = "Simple Key Pair",
18
15
  hd = "HD Key Tree",
19
- qr = "QR Hardware Wallet Device",
20
- ledger = "Ledger"
16
+ qr = "QR Hardware Wallet Device"
21
17
  }
22
18
  /**
23
19
  * @type KeyringControllerState
@@ -98,7 +94,6 @@ export declare type KeyringControllerActions = KeyringControllerGetStateAction |
98
94
  export declare type KeyringControllerEvents = KeyringControllerStateChangeEvent | KeyringControllerLockEvent | KeyringControllerUnlockEvent | KeyringControllerAccountRemovedEvent | KeyringControllerQRKeyringStateChangeEvent;
99
95
  export declare type KeyringControllerMessenger = RestrictedControllerMessenger<typeof name, KeyringControllerActions, KeyringControllerEvents, string, string>;
100
96
  export declare type KeyringControllerOptions = {
101
- removeIdentity: PreferencesController['removeIdentity'];
102
97
  syncIdentities: PreferencesController['syncIdentities'];
103
98
  updateIdentities: PreferencesController['updateIdentities'];
104
99
  setSelectedAddress: PreferencesController['setSelectedAddress'];
@@ -154,7 +149,6 @@ export declare enum SignTypedDataVersion {
154
149
  export declare class KeyringController extends BaseControllerV2<typeof name, KeyringControllerState, KeyringControllerMessenger> {
155
150
  #private;
156
151
  private readonly mutex;
157
- private readonly removeIdentity;
158
152
  private readonly syncIdentities;
159
153
  private readonly updateIdentities;
160
154
  private readonly setSelectedAddress;
@@ -163,7 +157,6 @@ export declare class KeyringController extends BaseControllerV2<typeof name, Key
163
157
  * Creates a KeyringController instance.
164
158
  *
165
159
  * @param opts - Initial options used to configure this controller
166
- * @param opts.removeIdentity - Remove the identity with the given address.
167
160
  * @param opts.syncIdentities - Sync identities with the given list of addresses.
168
161
  * @param opts.updateIdentities - Generate an identity for each address given that doesn't already have an identity.
169
162
  * @param opts.setSelectedAddress - Set the selected address.
@@ -174,7 +167,7 @@ export declare class KeyringController extends BaseControllerV2<typeof name, Key
174
167
  * @param opts.messenger - A restricted controller messenger.
175
168
  * @param opts.state - Initial state to set on this controller.
176
169
  */
177
- constructor({ removeIdentity, syncIdentities, updateIdentities, setSelectedAddress, setAccountLabel, encryptor, keyringBuilders, cacheEncryptionKey, messenger, state, }: KeyringControllerOptions);
170
+ constructor({ syncIdentities, updateIdentities, setSelectedAddress, setAccountLabel, encryptor, keyringBuilders, cacheEncryptionKey, messenger, state, }: KeyringControllerOptions);
178
171
  /**
179
172
  * Adds a new account to the default (first) HD seed phrase keyring.
180
173
  *
@@ -365,9 +358,10 @@ export declare class KeyringController extends BaseControllerV2<typeof name, Key
365
358
  *
366
359
  * @param transaction - Transaction object to sign. Must be a `ethereumjs-tx` transaction instance.
367
360
  * @param from - Address to sign from, should be in keychain.
361
+ * @param opts - An optional options object.
368
362
  * @returns Promise resolving to a signed transaction string.
369
363
  */
370
- signTransaction(transaction: TypedTransaction, from: string): Promise<TxData>;
364
+ signTransaction(transaction: TypedTransaction, from: string, opts?: Record<string, unknown>): Promise<TxData>;
371
365
  /**
372
366
  * Attempts to decrypt the current vault and load its keyrings,
373
367
  * using the given encryption key and salt.
@@ -422,48 +416,6 @@ export declare class KeyringController extends BaseControllerV2<typeof name, Key
422
416
  unlockQRHardwareWalletAccount(index: number): Promise<void>;
423
417
  getAccountKeyringType(account: string): Promise<string>;
424
418
  forgetQRDevice(): Promise<void>;
425
- private addLedgerKeyring;
426
- /**
427
- * Retrieve the existing LedgerKeyring or create a new one.
428
- *
429
- * @returns The stored Ledger Keyring
430
- */
431
- getLedgerKeyring(): Promise<LedgerKeyring>;
432
- /**
433
- * Restores the Ledger Keyring. This is only used at the time the user resets the account's password at the moment.
434
- *
435
- * @param keyringSerialized - The serialized keyring;
436
- */
437
- restoreLedgerKeyring(keyringSerialized: SerializedLedgerKeyring): Promise<void>;
438
- /**
439
- * Connects to the ledger device by requesting some metadata from it.
440
- *
441
- * @param transport - The transport to use to connect to the device
442
- * @param deviceId - The device ID to connect to
443
- * @returns The name of the currently open application on the device
444
- */
445
- connectLedgerHardware(transport: Transport, deviceId: string): Promise<string>;
446
- /**
447
- * Retrieve the first account from the Ledger device.
448
- *
449
- * @returns The default (first) account on the device
450
- */
451
- unlockLedgerDefaultAccount(): Promise<{
452
- address: string;
453
- balance: string;
454
- }>;
455
- /**
456
- * Automatically opens the Ethereum app on the Ledger device.
457
- */
458
- openEthereumAppOnLedger(): Promise<void>;
459
- /**
460
- * Automatically closes the current app on the Ledger device.
461
- */
462
- closeRunningAppOnLedger(): Promise<void>;
463
- /**
464
- * Forgets the ledger keyring's previous device specific state.
465
- */
466
- forgetLedger(): Promise<void>;
467
419
  }
468
420
  export default KeyringController;
469
421
  //# sourceMappingURL=KeyringController.d.ts.map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;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IA2B3D,6BAA6B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuB3D,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIvD,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;CAgJtC;AAED,eAAe,iBAAiB,CAAC"}
@@ -42,17 +42,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
42
42
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
43
43
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
44
44
  };
45
- var __importDefault = (this && this.__importDefault) || function (mod) {
46
- return (mod && mod.__esModule) ? mod : { "default": mod };
47
- };
48
45
  var _KeyringController_instances, _KeyringController_keyring, _KeyringController_qrKeyringStateListener, _KeyringController_registerMessageHandlers, _KeyringController_addQRKeyring, _KeyringController_subscribeToQRKeyringEvents, _KeyringController_unsubscribeFromQRKeyringsEvents, _KeyringController_fullUpdate, _KeyringController_handleLock, _KeyringController_handleUnlock, _KeyringController_getMemState;
49
46
  Object.defineProperty(exports, "__esModule", { value: true });
50
47
  exports.KeyringController = exports.SignTypedDataVersion = exports.AccountImportStrategy = exports.KeyringTypes = void 0;
51
- const metamask_airgapped_keyring_1 = require("@keystonehq/metamask-airgapped-keyring");
52
- const metamask_keyring_1 = __importDefault(require("@ledgerhq/metamask-keyring"));
53
48
  const base_controller_1 = require("@metamask/base-controller");
54
49
  const eth_keyring_controller_1 = require("@metamask/eth-keyring-controller");
55
- const eth_sig_util_1 = require("@metamask/eth-sig-util");
56
50
  const utils_1 = require("@metamask/utils");
57
51
  const async_mutex_1 = require("async-mutex");
58
52
  const ethereumjs_util_1 = require("ethereumjs-util");
@@ -66,7 +60,6 @@ var KeyringTypes;
66
60
  KeyringTypes["simple"] = "Simple Key Pair";
67
61
  KeyringTypes["hd"] = "HD Key Tree";
68
62
  KeyringTypes["qr"] = "QR Hardware Wallet Device";
69
- KeyringTypes["ledger"] = "Ledger";
70
63
  })(KeyringTypes = exports.KeyringTypes || (exports.KeyringTypes = {}));
71
64
  /**
72
65
  * A strategy for importing an account
@@ -117,7 +110,6 @@ class KeyringController extends base_controller_1.BaseControllerV2 {
117
110
  * Creates a KeyringController instance.
118
111
  *
119
112
  * @param opts - Initial options used to configure this controller
120
- * @param opts.removeIdentity - Remove the identity with the given address.
121
113
  * @param opts.syncIdentities - Sync identities with the given list of addresses.
122
114
  * @param opts.updateIdentities - Generate an identity for each address given that doesn't already have an identity.
123
115
  * @param opts.setSelectedAddress - Set the selected address.
@@ -128,7 +120,7 @@ class KeyringController extends base_controller_1.BaseControllerV2 {
128
120
  * @param opts.messenger - A restricted controller messenger.
129
121
  * @param opts.state - Initial state to set on this controller.
130
122
  */
131
- constructor({ removeIdentity, syncIdentities, updateIdentities, setSelectedAddress, setAccountLabel, encryptor, keyringBuilders, cacheEncryptionKey = false, messenger, state, }) {
123
+ constructor({ syncIdentities, updateIdentities, setSelectedAddress, setAccountLabel, encryptor, keyringBuilders, cacheEncryptionKey = false, messenger, state, }) {
132
124
  super({
133
125
  name,
134
126
  metadata: {
@@ -145,25 +137,16 @@ class KeyringController extends base_controller_1.BaseControllerV2 {
145
137
  this.mutex = new async_mutex_1.Mutex();
146
138
  _KeyringController_keyring.set(this, void 0);
147
139
  _KeyringController_qrKeyringStateListener.set(this, void 0);
148
- const additionalKeyringBuilders = [
149
- (0, eth_keyring_controller_1.keyringBuilderFactory)(metamask_airgapped_keyring_1.MetaMaskKeyring),
150
- (0, eth_keyring_controller_1.keyringBuilderFactory)(metamask_keyring_1.default),
151
- ];
152
- __classPrivateFieldSet(this, _KeyringController_keyring, new eth_keyring_controller_1.KeyringController(Object.assign({ initState: state }, {
140
+ __classPrivateFieldSet(this, _KeyringController_keyring, new eth_keyring_controller_1.KeyringController({
141
+ initState: state,
153
142
  encryptor,
143
+ keyringBuilders,
154
144
  cacheEncryptionKey,
155
- keyringBuilders: [
156
- ...(keyringBuilders && Array.isArray(keyringBuilders)
157
- ? keyringBuilders
158
- : []),
159
- ...additionalKeyringBuilders,
160
- ],
161
- })), "f");
145
+ }), "f");
162
146
  __classPrivateFieldGet(this, _KeyringController_keyring, "f").memStore.subscribe(__classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_fullUpdate).bind(this));
163
147
  __classPrivateFieldGet(this, _KeyringController_keyring, "f").store.subscribe(__classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_fullUpdate).bind(this));
164
148
  __classPrivateFieldGet(this, _KeyringController_keyring, "f").on('lock', __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_handleLock).bind(this));
165
149
  __classPrivateFieldGet(this, _KeyringController_keyring, "f").on('unlock', __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_handleUnlock).bind(this));
166
- this.removeIdentity = removeIdentity;
167
150
  this.syncIdentities = syncIdentities;
168
151
  this.updateIdentities = updateIdentities;
169
152
  this.setSelectedAddress = setSelectedAddress;
@@ -501,7 +484,6 @@ class KeyringController extends base_controller_1.BaseControllerV2 {
501
484
  */
502
485
  removeAccount(address) {
503
486
  return __awaiter(this, void 0, void 0, function* () {
504
- this.removeIdentity(address);
505
487
  yield __classPrivateFieldGet(this, _KeyringController_keyring, "f").removeAccount(address);
506
488
  this.messagingSystem.publish(`${name}:accountRemoved`, address);
507
489
  return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getMemState).call(this);
@@ -558,14 +540,6 @@ class KeyringController extends base_controller_1.BaseControllerV2 {
558
540
  ].includes(version)) {
559
541
  throw new Error(`Unexpected signTypedMessage version: '${version}'`);
560
542
  }
561
- const ledgerKeyring = yield this.getLedgerKeyring();
562
- const isLedgerAccount = yield ledgerKeyring.managesAccount((0, eth_sig_util_1.normalize)(messageParams.from || '') || '');
563
- if (isLedgerAccount) {
564
- return yield __classPrivateFieldGet(this, _KeyringController_keyring, "f").signTypedMessage({
565
- from: messageParams.from,
566
- data: messageParams.data,
567
- }, { version });
568
- }
569
543
  return yield __classPrivateFieldGet(this, _KeyringController_keyring, "f").signTypedMessage({
570
544
  from: messageParams.from,
571
545
  data: version !== SignTypedDataVersion.V1 &&
@@ -584,10 +558,11 @@ class KeyringController extends base_controller_1.BaseControllerV2 {
584
558
  *
585
559
  * @param transaction - Transaction object to sign. Must be a `ethereumjs-tx` transaction instance.
586
560
  * @param from - Address to sign from, should be in keychain.
561
+ * @param opts - An optional options object.
587
562
  * @returns Promise resolving to a signed transaction string.
588
563
  */
589
- signTransaction(transaction, from) {
590
- return __classPrivateFieldGet(this, _KeyringController_keyring, "f").signTransaction(transaction, from);
564
+ signTransaction(transaction, from, opts) {
565
+ return __classPrivateFieldGet(this, _KeyringController_keyring, "f").signTransaction(transaction, from, opts);
591
566
  }
592
567
  /**
593
568
  * Attempts to decrypt the current vault and load its keyrings,
@@ -804,118 +779,6 @@ class KeyringController extends base_controller_1.BaseControllerV2 {
804
779
  yield __classPrivateFieldGet(this, _KeyringController_keyring, "f").persistAllKeyrings();
805
780
  });
806
781
  }
807
- // Ledger Related methods
808
- addLedgerKeyring() {
809
- return __awaiter(this, void 0, void 0, function* () {
810
- return (yield __classPrivateFieldGet(this, _KeyringController_keyring, "f").addNewKeyring(KeyringTypes.ledger));
811
- });
812
- }
813
- /**
814
- * Retrieve the existing LedgerKeyring or create a new one.
815
- *
816
- * @returns The stored Ledger Keyring
817
- */
818
- getLedgerKeyring() {
819
- return __awaiter(this, void 0, void 0, function* () {
820
- const keyring = __classPrivateFieldGet(this, _KeyringController_keyring, "f").getKeyringsByType(KeyringTypes.ledger)[0];
821
- if (keyring) {
822
- return keyring;
823
- }
824
- return yield this.addLedgerKeyring();
825
- });
826
- }
827
- /**
828
- * Restores the Ledger Keyring. This is only used at the time the user resets the account's password at the moment.
829
- *
830
- * @param keyringSerialized - The serialized keyring;
831
- */
832
- restoreLedgerKeyring(keyringSerialized) {
833
- return __awaiter(this, void 0, void 0, function* () {
834
- (yield this.getLedgerKeyring()).deserialize(keyringSerialized);
835
- this.updateIdentities(yield __classPrivateFieldGet(this, _KeyringController_keyring, "f").getAccounts());
836
- yield __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_fullUpdate).call(this);
837
- });
838
- }
839
- /**
840
- * Connects to the ledger device by requesting some metadata from it.
841
- *
842
- * @param transport - The transport to use to connect to the device
843
- * @param deviceId - The device ID to connect to
844
- * @returns The name of the currently open application on the device
845
- */
846
- connectLedgerHardware(transport, deviceId) {
847
- return __awaiter(this, void 0, void 0, function* () {
848
- const keyring = yield this.getLedgerKeyring();
849
- keyring.setTransport(transport, deviceId);
850
- const { appName } = yield keyring.getAppAndVersion();
851
- return appName;
852
- });
853
- }
854
- /**
855
- * Retrieve the first account from the Ledger device.
856
- *
857
- * @returns The default (first) account on the device
858
- */
859
- unlockLedgerDefaultAccount() {
860
- return __awaiter(this, void 0, void 0, function* () {
861
- const keyring = yield this.getLedgerKeyring();
862
- const oldAccounts = yield __classPrivateFieldGet(this, _KeyringController_keyring, "f").getAccounts();
863
- yield __classPrivateFieldGet(this, _KeyringController_keyring, "f").addNewAccount(keyring);
864
- const newAccounts = yield __classPrivateFieldGet(this, _KeyringController_keyring, "f").getAccounts();
865
- this.updateIdentities(newAccounts);
866
- newAccounts.forEach((address) => {
867
- if (!oldAccounts.includes(address)) {
868
- if (this.setAccountLabel) {
869
- // The first ledger account is always returned.
870
- this.setAccountLabel(address, `${keyring.getName()} 1`);
871
- }
872
- this.setSelectedAddress(address);
873
- }
874
- });
875
- yield __classPrivateFieldGet(this, _KeyringController_keyring, "f").persistAllKeyrings();
876
- yield __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_fullUpdate).call(this);
877
- const address = yield keyring.getDefaultAccount();
878
- return {
879
- address,
880
- balance: `0x0`,
881
- };
882
- });
883
- }
884
- /**
885
- * Automatically opens the Ethereum app on the Ledger device.
886
- */
887
- openEthereumAppOnLedger() {
888
- return __awaiter(this, void 0, void 0, function* () {
889
- const keyring = yield this.getLedgerKeyring();
890
- yield keyring.openEthApp();
891
- });
892
- }
893
- /**
894
- * Automatically closes the current app on the Ledger device.
895
- */
896
- closeRunningAppOnLedger() {
897
- return __awaiter(this, void 0, void 0, function* () {
898
- const keyring = yield this.getLedgerKeyring();
899
- const { appName } = yield keyring.getAppAndVersion();
900
- // BOLOS means we are on the dashboard we don't need to close anything
901
- if (appName !== 'BOLOS') {
902
- yield keyring.quitApp();
903
- }
904
- });
905
- }
906
- /**
907
- * Forgets the ledger keyring's previous device specific state.
908
- */
909
- forgetLedger() {
910
- return __awaiter(this, void 0, void 0, function* () {
911
- const keyring = yield this.getLedgerKeyring();
912
- keyring.forgetDevice();
913
- const accounts = yield __classPrivateFieldGet(this, _KeyringController_keyring, "f").getAccounts();
914
- this.setSelectedAddress(accounts[0]);
915
- yield __classPrivateFieldGet(this, _KeyringController_keyring, "f").persistAllKeyrings();
916
- yield __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_fullUpdate).call(this);
917
- });
918
- }
919
782
  }
920
783
  exports.KeyringController = KeyringController;
921
784
  _KeyringController_keyring = new WeakMap(), _KeyringController_qrKeyringStateListener = new WeakMap(), _KeyringController_instances = new WeakSet(), _KeyringController_registerMessageHandlers = function _KeyringController_registerMessageHandlers() {
@@ -947,7 +810,15 @@ _KeyringController_keyring = new WeakMap(), _KeyringController_qrKeyringStateLis
947
810
  }
948
811
  });
949
812
  }, _KeyringController_fullUpdate = function _KeyringController_fullUpdate() {
950
- this.update(() => (Object.assign(Object.assign({}, __classPrivateFieldGet(this, _KeyringController_keyring, "f").store.getState()), __classPrivateFieldGet(this, _KeyringController_keyring, "f").memStore.getState())));
813
+ const { vault } = __classPrivateFieldGet(this, _KeyringController_keyring, "f").store.getState();
814
+ const { keyrings, isUnlocked, encryptionKey, encryptionSalt } = __classPrivateFieldGet(this, _KeyringController_keyring, "f").memStore.getState();
815
+ this.update(() => ({
816
+ vault,
817
+ keyrings,
818
+ isUnlocked,
819
+ encryptionKey,
820
+ encryptionSalt,
821
+ }));
951
822
  }, _KeyringController_handleLock = function _KeyringController_handleLock() {
952
823
  this.messagingSystem.publish(`${name}:lock`);
953
824
  }, _KeyringController_handleUnlock = function _KeyringController_handleUnlock() {
@@ -1 +1 @@
1
- {"version":3,"file":"KeyringController.js","sourceRoot":"","sources":["../src/KeyringController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uFAGgD;AAEhD,kFAAuD;AAEvD,+DAA6D;AAC7D,6EAG0C;AAC1C,yDAAuE;AAavE,2CAAuE;AACvE,6CAAoC;AACpC,qDAOyB;AACzB,uEAAoE;AAKpE,MAAM,IAAI,GAAG,mBAAmB,CAAC;AAEjC;;GAEG;AACH,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,0CAA0B,CAAA;IAC1B,kCAAkB,CAAA;IAClB,gDAAgC,CAAA;IAChC,iCAAiB,CAAA;AACnB,CAAC,EALW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAKvB;AAmJD;;GAEG;AACH,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,kDAAyB,CAAA;IACzB,sCAAa,CAAA;AACf,CAAC,EAHW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAGhC;AAED;;;;GAIG;AACH,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC9B,iCAAS,CAAA;IACT,iCAAS,CAAA;IACT,iCAAS,CAAA;AACX,CAAC,EAJW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAI/B;AAED,MAAM,YAAY,GAA2B;IAC3C,UAAU,EAAE,KAAK;IACjB,QAAQ,EAAE,EAAE;CACb,CAAC;AAEF;;;;;;GAMG;AACH,SAAS,2BAA2B,CAClC,OAAsB;IAEtB,IACE,CAAC,CACC,IAAA,mBA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S,CAAC,KAAK,CAAC,QAAQ,EAAE,GAC9B,uBAAA,IAAI,kCAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,EACpC,CAAC,CAAC;AACN,CAAC;IAQC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,CAAC;AAC/C,CAAC;IAQC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,IAAI,SAAS,CAAC,CAAC;AACjD,CAAC;IAGC,OAAO;QACL,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU;QACjC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ;KAC9B,CAAC;AACJ,CAAC;AAiIH,kBAAe,iBAAiB,CAAC","sourcesContent":["import type { TxData, TypedTransaction } from '@ethereumjs/tx';\nimport {\n MetaMaskKeyring as QRKeyring,\n type IKeyringState as IQRKeyringState,\n} from '@keystonehq/metamask-airgapped-keyring';\nimport type Transport from '@ledgerhq/hw-transport';\nimport LedgerKeyring from '@ledgerhq/metamask-keyring';\nimport type { RestrictedControllerMessenger } from '@metamask/base-controller';\nimport { BaseControllerV2 } from '@metamask/base-controller';\nimport {\n KeyringController as EthKeyringController,\n keyringBuilderFactory,\n} from '@metamask/eth-keyring-controller';\nimport { normalize as normalizeAddress } from '@metamask/eth-sig-util';\nimport type {\n PersonalMessageParams,\n TypedMessageParams,\n} from '@metamask/message-manager';\nimport type { PreferencesController } from '@metamask/preferences-controller';\nimport type {\n Eip1024EncryptedData,\n Hex,\n Keyring,\n Json,\n KeyringClass,\n} from '@metamask/utils';\nimport { assertIsStrictHexString, hasProperty } from '@metamask/utils';\nimport { Mutex } from 'async-mutex';\nimport {\n addHexPrefix,\n bufferToHex,\n isValidPrivate,\n toBuffer,\n stripHexPrefix,\n getBinarySize,\n} from 'ethereumjs-util';\nimport Wallet, { thirdparty as importers } from 'ethereumjs-wallet';\nimport type { Patch } from 'immer';\n\nimport type { SerializedLedgerKeyring } from './types/SerializedKeyringTypes';\n\nconst name = 'KeyringController';\n\n/**\n * Available keyring types\n */\nexport enum KeyringTypes {\n simple = 'Simple Key Pair',\n hd = 'HD Key Tree',\n qr = 'QR Hardware Wallet Device',\n ledger = 'Ledger',\n}\n\n/**\n * @type KeyringControllerState\n *\n * Keyring controller state\n * @property vault - Encrypted string representing keyring data\n * @property isUnlocked - Whether vault is unlocked\n * @property keyringTypes - Account types\n * @property keyrings - Group of accounts\n * @property encryptionKey - Keyring encryption key\n * @property encryptionSalt - Keyring encryption salt\n */\nexport type KeyringControllerState = {\n vault?: string;\n isUnlocked: boolean;\n keyrings: KeyringObject[];\n encryptionKey?: string;\n encryptionSalt?: string;\n};\n\nexport type KeyringControllerMemState = Omit<\n KeyringControllerState,\n 'vault' | 'encryptionKey' | 'encryptionSalt'\n>;\n\nexport type KeyringControllerGetStateAction = {\n type: `${typeof name}:getState`;\n handler: () => KeyringControllerState;\n};\n\nexport type KeyringControllerSignMessageAction = {\n type: `${typeof name}:signMessage`;\n handler: KeyringController['signMessage'];\n};\n\nexport type KeyringControllerSignPersonalMessageAction = {\n type: `${typeof name}:signPersonalMessage`;\n handler: KeyringController['signPersonalMessage'];\n};\n\nexport type KeyringControllerSignTypedMessageAction = {\n type: `${typeof name}:signTypedMessage`;\n handler: KeyringController['signTypedMessage'];\n};\n\nexport type KeyringControllerDecryptMessageAction = {\n type: `${typeof name}:decryptMessage`;\n handler: KeyringController['decryptMessage'];\n};\n\nexport type KeyringControllerGetEncryptionPublicKeyAction = {\n type: `${typeof name}:getEncryptionPublicKey`;\n handler: KeyringController['getEncryptionPublicKey'];\n};\n\nexport type KeyringControllerGetKeyringsByTypeAction = {\n type: `${typeof name}:getKeyringsByType`;\n handler: KeyringController['getKeyringsByType'];\n};\n\nexport type KeyringControllerGetKeyringForAccountAction = {\n type: `${typeof name}:getKeyringForAccount`;\n handler: KeyringController['getKeyringForAccount'];\n};\n\nexport type KeyringControllerGetAccountsAction = {\n type: `${typeof name}:getAccounts`;\n handler: KeyringController['getAccounts'];\n};\n\nexport type KeyringControllerStateChangeEvent = {\n type: `${typeof name}:stateChange`;\n payload: [KeyringControllerState, Patch[]];\n};\n\nexport type KeyringControllerAccountRemovedEvent = {\n type: `${typeof name}:accountRemoved`;\n payload: [string];\n};\n\nexport type KeyringControllerLockEvent = {\n type: `${typeof name}:lock`;\n payload: [];\n};\n\nexport type KeyringControllerUnlockEvent = {\n type: `${typeof name}:unlock`;\n payload: [];\n};\n\nexport type KeyringControllerQRKeyringStateChangeEvent = {\n type: `${typeof name}:qrKeyringStateChange`;\n payload: [ReturnType<IQRKeyringState['getState']>];\n};\n\nexport type KeyringControllerActions =\n | KeyringControllerGetStateAction\n | KeyringControllerSignMessageAction\n | KeyringControllerSignPersonalMessageAction\n | KeyringControllerSignTypedMessageAction\n | KeyringControllerDecryptMessageAction\n | KeyringControllerGetEncryptionPublicKeyAction\n | KeyringControllerGetAccountsAction\n | KeyringControllerGetKeyringsByTypeAction\n | KeyringControllerGetKeyringForAccountAction;\n\nexport type KeyringControllerEvents =\n | KeyringControllerStateChangeEvent\n | KeyringControllerLockEvent\n | KeyringControllerUnlockEvent\n | KeyringControllerAccountRemovedEvent\n | KeyringControllerQRKeyringStateChangeEvent;\n\nexport type KeyringControllerMessenger = RestrictedControllerMessenger<\n typeof name,\n KeyringControllerActions,\n KeyringControllerEvents,\n string,\n string\n>;\n\nexport type KeyringControllerOptions = {\n removeIdentity: PreferencesController['removeIdentity'];\n syncIdentities: PreferencesController['syncIdentities'];\n updateIdentities: PreferencesController['updateIdentities'];\n setSelectedAddress: PreferencesController['setSelectedAddress'];\n setAccountLabel?: PreferencesController['setAccountLabel'];\n encryptor?: any;\n keyringBuilders?: { (): Keyring<Json>; type: string }[];\n cacheEncryptionKey?: boolean;\n messenger: KeyringControllerMessenger;\n state?: { vault?: string };\n};\n\n/**\n * @type KeyringObject\n *\n * Keyring object to return in fullUpdate\n * @property type - Keyring type\n * @property accounts - Associated accounts\n */\nexport type KeyringObject = {\n accounts: string[];\n type: string;\n};\n\n/**\n * A strategy for importing an account\n */\nexport enum AccountImportStrategy {\n privateKey = 'privateKey',\n json = 'json',\n}\n\n/**\n * The `signTypedMessage` version\n *\n * @see https://docs.metamask.io/guide/signing-data.html\n */\nexport enum SignTypedDataVersion {\n V1 = 'V1',\n V3 = 'V3',\n V4 = 'V4',\n}\n\nconst defaultState: KeyringControllerState = {\n isUnlocked: false,\n keyrings: [],\n};\n\n/**\n * Assert that the given keyring has an exportable\n * mnemonic.\n *\n * @param keyring - The keyring to check\n * @throws When the keyring does not have a mnemonic\n */\nfunction assertHasUint8ArrayMnemonic(\n keyring: Keyring<Json>,\n): asserts keyring is Keyring<Json> & { mnemonic: Uint8Array } {\n if (\n !(\n hasProperty(keyring, 'mnemonic') && keyring.mnemonic instanceof Uint8Array\n )\n ) {\n throw new Error(\"Can't get mnemonic bytes from keyring\");\n }\n}\n\n/**\n * Controller responsible for establishing and managing user identity.\n *\n * This class is a wrapper around the `eth-keyring-controller` package. The\n * `eth-keyring-controller` manages the \"vault\", which is an encrypted store of private keys, and\n * it manages the wallet \"lock\" state. This wrapper class has convenience methods for interacting\n * with the internal keyring controller and handling certain complex operations that involve the\n * keyrings.\n */\nexport class KeyringController extends BaseControllerV2<\n typeof name,\n KeyringControllerState,\n KeyringControllerMessenger\n> {\n private readonly mutex = new Mutex();\n\n private readonly removeIdentity: PreferencesController['removeIdentity'];\n\n private readonly syncIdentities: PreferencesController['syncIdentities'];\n\n private readonly updateIdentities: PreferencesController['updateIdentities'];\n\n private readonly setSelectedAddress: PreferencesController['setSelectedAddress'];\n\n private readonly setAccountLabel?: PreferencesController['setAccountLabel'];\n\n #keyring: EthKeyringController;\n\n #qrKeyringStateListener?: (\n state: ReturnType<IQRKeyringState['getState']>,\n ) => void;\n\n /**\n * Creates a KeyringController instance.\n *\n * @param opts - Initial options used to configure this controller\n * @param opts.removeIdentity - Remove the identity with the given address.\n * @param opts.syncIdentities - Sync identities with the given list of addresses.\n * @param opts.updateIdentities - Generate an identity for each address given that doesn't already have an identity.\n * @param opts.setSelectedAddress - Set the selected address.\n * @param opts.setAccountLabel - Set a new name for account.\n * @param opts.encryptor - An optional object for defining encryption schemes.\n * @param opts.keyringBuilders - Set a new name for account.\n * @param opts.cacheEncryptionKey - Whether to cache or not encryption key.\n * @param opts.messenger - A restricted controller messenger.\n * @param opts.state - Initial state to set on this controller.\n */\n constructor({\n removeIdentity,\n syncIdentities,\n updateIdentities,\n setSelectedAddress,\n setAccountLabel,\n encryptor,\n keyringBuilders,\n cacheEncryptionKey = false,\n messenger,\n state,\n }: KeyringControllerOptions) {\n super({\n name,\n metadata: {\n vault: { persist: true, anonymous: false },\n isUnlocked: { persist: false, anonymous: true },\n keyrings: { persist: false, anonymous: false },\n encryptionKey: { persist: false, anonymous: false },\n encryptionSalt: { persist: false, anonymous: false },\n },\n messenger,\n state: {\n ...defaultState,\n ...state,\n },\n });\n\n const additionalKeyringBuilders = [\n keyringBuilderFactory(QRKeyring as unknown as KeyringClass<Json>),\n keyringBuilderFactory(LedgerKeyring as unknown as KeyringClass<Json>),\n ];\n\n this.#keyring = new EthKeyringController(\n Object.assign(\n { initState: state },\n {\n encryptor,\n cacheEncryptionKey,\n keyringBuilders: [\n ...(keyringBuilders && Array.isArray(keyringBuilders)\n ? keyringBuilders\n : []),\n ...additionalKeyringBuilders,\n ],\n },\n ),\n );\n this.#keyring.memStore.subscribe(this.#fullUpdate.bind(this));\n this.#keyring.store.subscribe(this.#fullUpdate.bind(this));\n this.#keyring.on('lock', this.#handleLock.bind(this));\n this.#keyring.on('unlock', this.#handleUnlock.bind(this));\n\n this.removeIdentity = removeIdentity;\n this.syncIdentities = syncIdentities;\n this.updateIdentities = updateIdentities;\n this.setSelectedAddress = setSelectedAddress;\n this.setAccountLabel = setAccountLabel;\n\n this.#registerMessageHandlers();\n }\n\n /**\n * Adds a new account to the default (first) HD seed phrase keyring.\n *\n * @param accountCount - Number of accounts before adding a new one, used to\n * make the method idempotent.\n * @returns Promise resolving to keyring current state and added account\n * address.\n */\n async addNewAccount(accountCount?: number): Promise<{\n keyringState: KeyringControllerMemState;\n addedAccountAddress: string;\n }> {\n const primaryKeyring = this.#keyring.getKeyringsByType('HD Key Tree')[0];\n /* istanbul ignore if */\n if (!primaryKeyring) {\n throw new Error('No HD keyring found');\n }\n const oldAccounts = await this.#keyring.getAccounts();\n\n if (accountCount && oldAccounts.length !== accountCount) {\n if (accountCount > oldAccounts.length) {\n throw new Error('Account out of sequence');\n }\n // we return the account already existing at index `accountCount`\n const primaryKeyringAccounts = await primaryKeyring.getAccounts();\n return {\n keyringState: this.#getMemState(),\n addedAccountAddress: primaryKeyringAccounts[accountCount],\n };\n }\n\n await this.#keyring.addNewAccount(primaryKeyring);\n const newAccounts = await this.#keyring.getAccounts();\n\n await this.verifySeedPhrase();\n\n this.updateIdentities(newAccounts);\n const addedAccountAddress = newAccounts.find(\n (selectedAddress: string) => !oldAccounts.includes(selectedAddress),\n );\n\n assertIsStrictHexString(addedAccountAddress);\n return {\n keyringState: this.#getMemState(),\n addedAccountAddress,\n };\n }\n\n /**\n * Adds a new account to the specified keyring.\n *\n * @param keyring - Keyring to add the account to.\n * @param accountCount - Number of accounts before adding a new one, used to make the method idempotent.\n * @returns Promise resolving to keyring current state and added account\n */\n async addNewAccountForKeyring(\n keyring: Keyring<Json>,\n accountCount?: number,\n ): Promise<Hex> {\n const oldAccounts = await this.getAccounts();\n\n if (accountCount && oldAccounts.length !== accountCount) {\n if (accountCount > oldAccounts.length) {\n throw new Error('Account out of sequence');\n }\n\n const existingAccount = oldAccounts[accountCount];\n assertIsStrictHexString(existingAccount);\n\n return existingAccount;\n }\n\n await this.#keyring.addNewAccount(keyring);\n const addedAccountAddress = (await this.getAccounts()).find(\n (selectedAddress) => !oldAccounts.includes(selectedAddress),\n );\n assertIsStrictHexString(addedAccountAddress);\n\n this.updateIdentities(await this.#keyring.getAccounts());\n\n return addedAccountAddress;\n }\n\n /**\n * Adds a new account to the default (first) HD seed phrase keyring without updating identities in preferences.\n *\n * @returns Promise resolving to current state when the account is added.\n */\n async addNewAccountWithoutUpdate(): Promise<KeyringControllerMemState> {\n const primaryKeyring = this.#keyring.getKeyringsByType('HD Key Tree')[0];\n /* istanbul ignore if */\n if (!primaryKeyring) {\n throw new Error('No HD keyring found');\n }\n await this.#keyring.addNewAccount(primaryKeyring);\n await this.verifySeedPhrase();\n return this.#getMemState();\n }\n\n /**\n * Effectively the same as creating a new keychain then populating it\n * using the given seed phrase.\n *\n * @param password - Password to unlock keychain.\n * @param seed - A BIP39-compliant seed phrase as Uint8Array,\n * either as a string or an array of UTF-8 bytes that represent the string.\n * @returns Promise resolving to the restored keychain object.\n */\n async createNewVaultAndRestore(\n password: string,\n seed: Uint8Array,\n ): Promise<KeyringControllerMemState> {\n const releaseLock = await this.mutex.acquire();\n if (!password || !password.length) {\n throw new Error('Invalid password');\n }\n\n try {\n this.updateIdentities([]);\n await this.#keyring.createNewVaultAndRestore(password, seed);\n this.updateIdentities(await this.#keyring.getAccounts());\n return this.#getMemState();\n } finally {\n releaseLock();\n }\n }\n\n /**\n * Create a new primary keychain and wipe any previous keychains.\n *\n * @param password - Password to unlock the new vault.\n * @returns Newly-created keychain object.\n */\n async createNewVaultAndKeychain(password: string) {\n const releaseLock = await this.mutex.acquire();\n try {\n const accounts = await this.getAccounts();\n if (!accounts.length) {\n await this.#keyring.createNewVaultAndKeychain(password);\n this.updateIdentities(await this.getAccounts());\n }\n return this.#getMemState();\n } finally {\n releaseLock();\n }\n }\n\n /**\n * Adds a new keyring of the given `type`.\n *\n * @param type - Keyring type name.\n * @param opts - Keyring options.\n * @throws If a builder for the given `type` does not exist.\n * @returns Promise resolving to the added keyring.\n */\n async addNewKeyring(\n type: KeyringTypes | string,\n opts?: unknown,\n ): Promise<unknown> {\n if (type === KeyringTypes.qr) {\n return this.getOrAddQRKeyring();\n }\n\n return this.#keyring.addNewKeyring(type, opts);\n }\n\n /**\n * Method to verify a given password validity. Throws an\n * error if the password is invalid.\n *\n * @param password - Password of the keyring.\n */\n async verifyPassword(password: string) {\n await this.#keyring.verifyPassword(password);\n }\n\n /**\n * Returns the status of the vault.\n *\n * @returns Boolean returning true if the vault is unlocked.\n */\n isUnlocked(): boolean {\n return this.state.isUnlocked;\n }\n\n /**\n * Gets the seed phrase of the HD keyring.\n *\n * @param password - Password of the keyring.\n * @returns Promise resolving to the seed phrase.\n */\n async exportSeedPhrase(password: string): Promise<Uint8Array> {\n await this.verifyPassword(password);\n assertHasUint8ArrayMnemonic(this.#keyring.keyrings[0]);\n return this.#keyring.keyrings[0].mnemonic;\n }\n\n /**\n * Gets the private key from the keyring controlling an address.\n *\n * @param password - Password of the keyring.\n * @param address - Address to export.\n * @returns Promise resolving to the private key for an address.\n */\n async exportAccount(password: string, address: string): Promise<string> {\n await this.verifyPassword(password);\n return this.#keyring.exportAccount(address);\n }\n\n /**\n * Returns the public addresses of all accounts for the current keyring.\n *\n * @returns A promise resolving to an array of addresses.\n */\n getAccounts(): Promise<string[]> {\n return this.#keyring.getAccounts();\n }\n\n /**\n * Get encryption public key.\n *\n * @param account - An account address.\n * @param opts - Additional encryption options.\n * @throws If the `account` does not exist or does not support the `getEncryptionPublicKey` method\n * @returns Promise resolving to encyption public key of the `account` if one exists.\n */\n async getEncryptionPublicKey(\n account: string,\n opts?: Record<string, unknown>,\n ): Promise<string> {\n return this.#keyring.getEncryptionPublicKey(account, opts);\n }\n\n /**\n * Attempts to decrypt the provided message parameters.\n *\n * @param messageParams - The decryption message parameters.\n * @param messageParams.from - The address of the account you want to use to decrypt the message.\n * @param messageParams.data - The encrypted data that you want to decrypt.\n * @returns The raw decryption result.\n */\n async decryptMessage(messageParams: {\n from: string;\n data: Eip1024EncryptedData;\n }): Promise<string> {\n return this.#keyring.decryptMessage(messageParams);\n }\n\n /**\n * Returns the currently initialized keyring that manages\n * the specified `address` if one exists.\n *\n * @deprecated Use of this method is discouraged as actions executed directly on\n * keyrings are not being reflected in the KeyringController state and not\n * persisted in the vault.\n * @param account - An account address.\n * @returns Promise resolving to keyring of the `account` if one exists.\n */\n async getKeyringForAccount(account: string): Promise<unknown> {\n return this.#keyring.getKeyringForAccount(account);\n }\n\n /**\n * Returns all keyrings of the given type.\n *\n * @deprecated Use of this method is discouraged as actions executed directly on\n * keyrings are not being reflected in the KeyringController state and not\n * persisted in the vault.\n * @param type - Keyring type name.\n * @returns An array of keyrings of the given type.\n */\n getKeyringsByType(type: KeyringTypes | string): unknown[] {\n return this.#keyring.getKeyringsByType(type);\n }\n\n /**\n * Persist all serialized keyrings in the vault.\n *\n * @returns Promise resolving with `true` value when the\n * operation completes.\n */\n async persistAllKeyrings(): Promise<boolean> {\n return this.#keyring.persistAllKeyrings();\n }\n\n /**\n * Imports an account with the specified import strategy.\n *\n * @param strategy - Import strategy name.\n * @param args - Array of arguments to pass to the underlying stategy.\n * @throws Will throw when passed an unrecognized strategy.\n * @returns Promise resolving to keyring current state and imported account\n * address.\n */\n async importAccountWithStrategy(\n strategy: AccountImportStrategy,\n args: any[],\n ): Promise<{\n keyringState: KeyringControllerMemState;\n importedAccountAddress: string;\n }> {\n let privateKey;\n switch (strategy) {\n case 'privateKey':\n const [importedKey] = args;\n if (!importedKey) {\n throw new Error('Cannot import an empty key.');\n }\n const prefixed = addHexPrefix(importedKey);\n\n let bufferedPrivateKey;\n try {\n bufferedPrivateKey = toBuffer(prefixed);\n } catch {\n throw new Error('Cannot import invalid private key.');\n }\n\n /* istanbul ignore if */\n if (\n !isValidPrivate(bufferedPrivateKey) ||\n // ensures that the key is 64 bytes long\n getBinarySize(prefixed) !== 64 + '0x'.length\n ) {\n throw new Error('Cannot import invalid private key.');\n }\n\n privateKey = stripHexPrefix(prefixed);\n break;\n case 'json':\n let wallet;\n const [input, password] = args;\n try {\n wallet = importers.fromEtherWallet(input, password);\n } catch (e) {\n wallet = wallet || (await Wallet.fromV3(input, password, true));\n }\n privateKey = bufferToHex(wallet.getPrivateKey());\n break;\n default:\n throw new Error(`Unexpected import strategy: '${strategy}'`);\n }\n const newKeyring = await this.#keyring.addNewKeyring(KeyringTypes.simple, [\n privateKey,\n ]);\n const accounts = await newKeyring.getAccounts();\n const allAccounts = await this.#keyring.getAccounts();\n this.updateIdentities(allAccounts);\n return {\n keyringState: this.#getMemState(),\n importedAccountAddress: accounts[0],\n };\n }\n\n /**\n * Removes an account from keyring state.\n *\n * @param address - Address of the account to remove.\n * @fires KeyringController:accountRemoved\n * @returns Promise resolving current state when this account removal completes.\n */\n async removeAccount(address: Hex): Promise<KeyringControllerMemState> {\n this.removeIdentity(address);\n await this.#keyring.removeAccount(address);\n this.messagingSystem.publish(`${name}:accountRemoved`, address);\n return this.#getMemState();\n }\n\n /**\n * Deallocates all secrets and locks the wallet.\n *\n * @returns Promise resolving to current state.\n */\n async setLocked(): Promise<KeyringControllerMemState> {\n this.#unsubscribeFromQRKeyringsEvents();\n await this.#keyring.setLocked();\n return this.#getMemState();\n }\n\n /**\n * Signs message by calling down into a specific keyring.\n *\n * @param messageParams - PersonalMessageParams object to sign.\n * @returns Promise resolving to a signed message string.\n */\n signMessage(messageParams: PersonalMessageParams) {\n if (!messageParams.data) {\n throw new Error(\"Can't sign an empty message\");\n }\n return this.#keyring.signMessage(messageParams);\n }\n\n /**\n * Signs personal message by calling down into a specific keyring.\n *\n * @param messageParams - PersonalMessageParams object to sign.\n * @returns Promise resolving to a signed message string.\n */\n signPersonalMessage(messageParams: PersonalMessageParams) {\n return this.#keyring.signPersonalMessage(messageParams);\n }\n\n /**\n * Signs typed message by calling down into a specific keyring.\n *\n * @param messageParams - TypedMessageParams object to sign.\n * @param version - Compatibility version EIP712.\n * @throws Will throw when passed an unrecognized version.\n * @returns Promise resolving to a signed message string or an error if any.\n */\n async signTypedMessage(\n messageParams: TypedMessageParams,\n version: SignTypedDataVersion,\n ): Promise<string> {\n try {\n if (\n ![\n SignTypedDataVersion.V1,\n SignTypedDataVersion.V3,\n SignTypedDataVersion.V4,\n ].includes(version)\n ) {\n throw new Error(`Unexpected signTypedMessage version: '${version}'`);\n }\n\n const ledgerKeyring = await this.getLedgerKeyring();\n const isLedgerAccount = await ledgerKeyring.managesAccount(\n normalizeAddress(messageParams.from || '') || '',\n );\n\n if (isLedgerAccount) {\n return await this.#keyring.signTypedMessage(\n {\n from: messageParams.from,\n data: messageParams.data as\n | Record<string, unknown>\n | Record<string, unknown>[],\n },\n { version },\n );\n }\n\n return await this.#keyring.signTypedMessage(\n {\n from: messageParams.from,\n data:\n version !== SignTypedDataVersion.V1 &&\n typeof messageParams.data === 'string'\n ? JSON.parse(messageParams.data)\n : messageParams.data,\n },\n { version },\n );\n } catch (error) {\n throw new Error(`Keyring Controller signTypedMessage: ${error}`);\n }\n }\n\n /**\n * Signs a transaction by calling down into a specific keyring.\n *\n * @param transaction - Transaction object to sign. Must be a `ethereumjs-tx` transaction instance.\n * @param from - Address to sign from, should be in keychain.\n * @returns Promise resolving to a signed transaction string.\n */\n signTransaction(\n transaction: TypedTransaction,\n from: string,\n ): Promise<TxData> {\n return this.#keyring.signTransaction(transaction, from);\n }\n\n /**\n * Attempts to decrypt the current vault and load its keyrings,\n * using the given encryption key and salt.\n *\n * @param encryptionKey - Key to unlock the keychain.\n * @param encryptionSalt - Salt to unlock the keychain.\n * @returns Promise resolving to the current state.\n */\n async submitEncryptionKey(\n encryptionKey: string,\n encryptionSalt: string,\n ): Promise<KeyringControllerMemState> {\n await this.#keyring.submitEncryptionKey(encryptionKey, encryptionSalt);\n\n const qrKeyring = this.getQRKeyring();\n if (qrKeyring) {\n // if there is a QR keyring, we need to subscribe\n // to its events after unlocking the vault\n this.#subscribeToQRKeyringEvents(qrKeyring);\n }\n\n return this.#getMemState();\n }\n\n /**\n * Attempts to decrypt the current vault and load its keyrings,\n * using the given password.\n *\n * @param password - Password to unlock the keychain.\n * @returns Promise resolving to the current state.\n */\n async submitPassword(password: string): Promise<KeyringControllerMemState> {\n await this.#keyring.submitPassword(password);\n const accounts = await this.#keyring.getAccounts();\n\n const qrKeyring = this.getQRKeyring();\n if (qrKeyring) {\n // if there is a QR keyring, we need to subscribe\n // to its events after unlocking the vault\n this.#subscribeToQRKeyringEvents(qrKeyring);\n }\n\n await this.syncIdentities(accounts);\n return this.#getMemState();\n }\n\n /**\n * Verifies the that the seed phrase restores the current keychain's accounts.\n *\n * @returns Promise resolving to the seed phrase as Uint8Array.\n */\n async verifySeedPhrase(): Promise<Uint8Array> {\n const primaryKeyring = this.#keyring.getKeyringsByType(KeyringTypes.hd)[0];\n /* istanbul ignore if */\n if (!primaryKeyring) {\n throw new Error('No HD keyring found.');\n }\n\n assertHasUint8ArrayMnemonic(primaryKeyring);\n\n const seedWords = primaryKeyring.mnemonic;\n const accounts = await primaryKeyring.getAccounts();\n /* istanbul ignore if */\n if (accounts.length === 0) {\n throw new Error('Cannot verify an empty keyring.');\n }\n\n // The HD Keyring Builder is a default keyring builder\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const hdKeyringBuilder = this.#keyring.getKeyringBuilderForType(\n KeyringTypes.hd,\n )!;\n\n const hdKeyring = hdKeyringBuilder();\n // @ts-expect-error @metamask/eth-hd-keyring correctly handles\n // Uint8Array seed phrases in the `deserialize` method.\n hdKeyring.deserialize({\n mnemonic: seedWords,\n numberOfAccounts: accounts.length,\n });\n const testAccounts = await hdKeyring.getAccounts();\n /* istanbul ignore if */\n if (testAccounts.length !== accounts.length) {\n throw new Error('Seed phrase imported incorrect number of accounts.');\n }\n\n testAccounts.forEach((account: string, i: number) => {\n /* istanbul ignore if */\n if (account.toLowerCase() !== accounts[i].toLowerCase()) {\n throw new Error('Seed phrase imported different accounts.');\n }\n });\n\n return seedWords;\n }\n\n // QR Hardware related methods\n\n /**\n * Get QR Hardware keyring.\n *\n * @returns The QR Keyring if defined, otherwise undefined\n */\n getQRKeyring(): QRKeyring | undefined {\n // QRKeyring is not yet compatible with Keyring type from @metamask/utils\n return this.#keyring.getKeyringsByType(\n KeyringTypes.qr,\n )[0] as unknown as QRKeyring;\n }\n\n /**\n * Get QR hardware keyring. If it doesn't exist, add it.\n *\n * @returns The added keyring\n */\n async getOrAddQRKeyring(): Promise<QRKeyring> {\n return this.getQRKeyring() || (await this.#addQRKeyring());\n }\n\n async restoreQRKeyring(serialized: any): Promise<void> {\n (await this.getOrAddQRKeyring()).deserialize(serialized);\n await this.#keyring.persistAllKeyrings();\n this.updateIdentities(await this.#keyring.getAccounts());\n }\n\n async resetQRKeyringState(): Promise<void> {\n (await this.getOrAddQRKeyring()).resetStore();\n }\n\n async getQRKeyringState(): Promise<IQRKeyringState> {\n return (await this.getOrAddQRKeyring()).getMemStore();\n }\n\n async submitQRCryptoHDKey(cryptoHDKey: string): Promise<void> {\n (await this.getOrAddQRKeyring()).submitCryptoHDKey(cryptoHDKey);\n }\n\n async submitQRCryptoAccount(cryptoAccount: string): Promise<void> {\n (await this.getOrAddQRKeyring()).submitCryptoAccount(cryptoAccount);\n }\n\n async submitQRSignature(\n requestId: string,\n ethSignature: string,\n ): Promise<void> {\n (await this.getOrAddQRKeyring()).submitSignature(requestId, ethSignature);\n }\n\n async cancelQRSignRequest(): Promise<void> {\n (await this.getOrAddQRKeyring()).cancelSignRequest();\n }\n\n /**\n * Cancels qr keyring sync.\n */\n async cancelQRSynchronization(): Promise<void> {\n // eslint-disable-next-line n/no-sync\n (await this.getOrAddQRKeyring()).cancelSync();\n }\n\n async connectQRHardware(\n page: number,\n ): Promise<{ balance: string; address: string; index: number }[]> {\n try {\n const keyring = await this.getOrAddQRKeyring();\n let accounts;\n switch (page) {\n case -1:\n accounts = await keyring.getPreviousPage();\n break;\n case 1:\n accounts = await keyring.getNextPage();\n break;\n default:\n accounts = await keyring.getFirstPage();\n }\n return accounts.map((account: any) => {\n return {\n ...account,\n balance: '0x0',\n };\n });\n } catch (e) {\n // TODO: Add test case for when keyring throws\n /* istanbul ignore next */\n throw new Error(`Unspecified error when connect QR Hardware, ${e}`);\n }\n }\n\n async unlockQRHardwareWalletAccount(index: number): Promise<void> {\n const keyring = await this.getOrAddQRKeyring();\n\n keyring.setAccountToUnlock(index);\n const oldAccounts = await this.#keyring.getAccounts();\n // QRKeyring is not yet compatible with Keyring from\n // @metamask/utils, but we can use the `addNewAccount` method\n // as it internally calls `addAccounts` from on the keyring instance,\n // which is supported by QRKeyring API.\n await this.#keyring.addNewAccount(keyring as unknown as Keyring<Json>);\n const newAccounts = await this.#keyring.getAccounts();\n this.updateIdentities(newAccounts);\n newAccounts.forEach((address: string) => {\n if (!oldAccounts.includes(address)) {\n if (this.setAccountLabel) {\n this.setAccountLabel(address, `${keyring.getName()} ${index}`);\n }\n this.setSelectedAddress(address);\n }\n });\n await this.#keyring.persistAllKeyrings();\n }\n\n async getAccountKeyringType(account: string): Promise<string> {\n return (await this.#keyring.getKeyringForAccount(account)).type;\n }\n\n async forgetQRDevice(): Promise<void> {\n const keyring = await this.getOrAddQRKeyring();\n keyring.forgetDevice();\n const accounts = (await this.#keyring.getAccounts()) as string[];\n accounts.forEach((account) => {\n this.setSelectedAddress(account);\n });\n await this.#keyring.persistAllKeyrings();\n }\n\n /**\n * Constructor helper for registering this controller's messaging system\n * actions.\n */\n #registerMessageHandlers() {\n this.messagingSystem.registerActionHandler(\n `${name}:signMessage`,\n this.signMessage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${name}:signPersonalMessage`,\n this.signPersonalMessage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${name}:signTypedMessage`,\n this.signTypedMessage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${name}:decryptMessage`,\n this.decryptMessage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${name}:getEncryptionPublicKey`,\n this.getEncryptionPublicKey.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${name}:getAccounts`,\n this.getAccounts.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${name}:getKeyringsByType`,\n this.getKeyringsByType.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${name}:getKeyringForAccount`,\n this.getKeyringForAccount.bind(this),\n );\n }\n\n /**\n * Add qr hardware keyring.\n *\n * @returns The added keyring\n * @throws If a QRKeyring builder is not provided\n * when initializing the controller\n */\n async #addQRKeyring(): Promise<QRKeyring> {\n // QRKeyring is not yet compatible with Keyring type from @metamask/utils\n const qrKeyring = (await this.#keyring.addNewKeyring(\n KeyringTypes.qr,\n )) as unknown as QRKeyring;\n\n this.#subscribeToQRKeyringEvents(qrKeyring);\n\n return qrKeyring;\n }\n\n /**\n * Subscribe to a QRKeyring state change events and\n * forward them through the messaging system.\n *\n * @param qrKeyring - The QRKeyring instance to subscribe to\n */\n #subscribeToQRKeyringEvents(qrKeyring: QRKeyring) {\n this.#qrKeyringStateListener = (state) => {\n this.messagingSystem.publish(`${name}:qrKeyringStateChange`, state);\n };\n\n qrKeyring.getMemStore().subscribe(this.#qrKeyringStateListener);\n }\n\n #unsubscribeFromQRKeyringsEvents() {\n const qrKeyrings = this.#keyring.getKeyringsByType(\n KeyringTypes.qr,\n ) as unknown as QRKeyring[];\n\n qrKeyrings.forEach((qrKeyring) => {\n if (this.#qrKeyringStateListener) {\n qrKeyring.getMemStore().unsubscribe(this.#qrKeyringStateListener);\n }\n });\n }\n\n /**\n * Sync controller state with current keyring store\n * and memStore states.\n *\n * @fires KeyringController:stateChange\n */\n #fullUpdate() {\n this.update(() => ({\n ...this.#keyring.store.getState(),\n ...this.#keyring.memStore.getState(),\n }));\n }\n\n /**\n * Handle keyring lock event.\n *\n * @fires KeyringController:lock\n */\n #handleLock() {\n this.messagingSystem.publish(`${name}:lock`);\n }\n\n /**\n * Handle keyring unlock event.\n *\n * @fires KeyringController:unlock\n */\n #handleUnlock() {\n this.messagingSystem.publish(`${name}:unlock`);\n }\n\n #getMemState(): KeyringControllerMemState {\n return {\n isUnlocked: this.state.isUnlocked,\n keyrings: this.state.keyrings,\n };\n }\n\n // Ledger Related methods\n\n private async addLedgerKeyring(): Promise<LedgerKeyring> {\n return (await this.#keyring.addNewKeyring(\n KeyringTypes.ledger,\n )) as unknown as LedgerKeyring;\n }\n\n /**\n * Retrieve the existing LedgerKeyring or create a new one.\n *\n * @returns The stored Ledger Keyring\n */\n async getLedgerKeyring(): Promise<LedgerKeyring> {\n const keyring = this.#keyring.getKeyringsByType(\n KeyringTypes.ledger,\n )[0] as unknown as LedgerKeyring;\n\n if (keyring) {\n return keyring;\n }\n\n return await this.addLedgerKeyring();\n }\n\n /**\n * Restores the Ledger Keyring. This is only used at the time the user resets the account's password at the moment.\n *\n * @param keyringSerialized - The serialized keyring;\n */\n async restoreLedgerKeyring(\n keyringSerialized: SerializedLedgerKeyring,\n ): Promise<void> {\n (await this.getLedgerKeyring()).deserialize(keyringSerialized);\n this.updateIdentities(await this.#keyring.getAccounts());\n await this.#fullUpdate();\n }\n\n /**\n * Connects to the ledger device by requesting some metadata from it.\n *\n * @param transport - The transport to use to connect to the device\n * @param deviceId - The device ID to connect to\n * @returns The name of the currently open application on the device\n */\n async connectLedgerHardware(\n transport: Transport,\n deviceId: string,\n ): Promise<string> {\n const keyring = await this.getLedgerKeyring();\n keyring.setTransport(transport, deviceId);\n\n const { appName } = await keyring.getAppAndVersion();\n\n return appName;\n }\n\n /**\n * Retrieve the first account from the Ledger device.\n *\n * @returns The default (first) account on the device\n */\n async unlockLedgerDefaultAccount(): Promise<{\n address: string;\n balance: string;\n }> {\n const keyring = await this.getLedgerKeyring();\n const oldAccounts = await this.#keyring.getAccounts();\n await this.#keyring.addNewAccount(keyring as unknown as Keyring<Json>);\n const newAccounts = await this.#keyring.getAccounts();\n\n this.updateIdentities(newAccounts);\n newAccounts.forEach((address: string) => {\n if (!oldAccounts.includes(address)) {\n if (this.setAccountLabel) {\n // The first ledger account is always returned.\n this.setAccountLabel(address, `${keyring.getName()} 1`);\n }\n this.setSelectedAddress(address);\n }\n });\n await this.#keyring.persistAllKeyrings();\n await this.#fullUpdate();\n\n const address = await keyring.getDefaultAccount();\n return {\n address,\n balance: `0x0`,\n };\n }\n\n /**\n * Automatically opens the Ethereum app on the Ledger device.\n */\n async openEthereumAppOnLedger(): Promise<void> {\n const keyring = await this.getLedgerKeyring();\n await keyring.openEthApp();\n }\n\n /**\n * Automatically closes the current app on the Ledger device.\n */\n async closeRunningAppOnLedger(): Promise<void> {\n const keyring = await this.getLedgerKeyring();\n const { appName } = await keyring.getAppAndVersion();\n\n // BOLOS means we are on the dashboard we don't need to close anything\n if (appName !== 'BOLOS') {\n await keyring.quitApp();\n }\n }\n\n /**\n * Forgets the ledger keyring's previous device specific state.\n */\n async forgetLedger(): Promise<void> {\n const keyring = await this.getLedgerKeyring();\n keyring.forgetDevice();\n\n const accounts: string[] = await this.#keyring.getAccounts();\n this.setSelectedAddress(accounts[0]);\n\n await this.#keyring.persistAllKeyrings();\n await this.#fullUpdate();\n }\n}\n\nexport default KeyringController;\n"]}
1
+ {"version":3,"file":"KeyringController.js","sourceRoot":"","sources":["../src/KeyringController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,+DAA6D;AAC7D,6EAA6F;AAO7F,2CAAuE;AACvE,6CAAoC;AACpC,qDAOyB;AACzB,uEAAoE;AAGpE,MAAM,IAAI,GAAG,mBAAmB,CAAC;AAEjC;;GAEG;AACH,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,0CAA0B,CAAA;IAC1B,kCAAkB,CAAA;IAClB,gDAAgC,CAAA;AAClC,CAAC,EAJW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAIvB;AAkJD;;GAEG;AACH,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,kDAAyB,CAAA;IACzB,sCAAa,CAAA;AACf,CAAC,EAHW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAGhC;AAED;;;;GAIG;AACH,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC9B,iCAAS,CAAA;IACT,iCAAS,CAAA;IACT,iCAAS,CAAA;AACX,CAAC,EAJW,oBAAoB,GAApB,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O,CAAC,CAAC,SAAS,EAAE,EAAE;QAC/B,IAAI,uBAAA,IAAI,iDAAwB,EAAE;YAChC,SAAS,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC,uBAAA,IAAI,iDAAwB,CAAC,CAAC;SACnE;IACH,CAAC,CAAC,CAAC;AACL,CAAC;IASC,MAAM,EAAE,KAAK,EAAE,GAAG,uBAAA,IAAI,kCAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IACjD,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,GAC3D,uBAAA,IAAI,kCAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAEpC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QACjB,KAAK;QACL,QAAQ;QACR,UAAU;QACV,aAAa;QACb,cAAc;KACf,CAAC,CAAC,CAAC;AACN,CAAC;IAQC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,CAAC;AAC/C,CAAC;IAQC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,IAAI,SAAS,CAAC,CAAC;AACjD,CAAC;IAGC,OAAO;QACL,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU;QACjC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ;KAC9B,CAAC;AACJ,CAAC;AAGH,kBAAe,iBAAiB,CAAC","sourcesContent":["import type { TxData, TypedTransaction } from '@ethereumjs/tx';\nimport type {\n MetaMaskKeyring as QRKeyring,\n IKeyringState as IQRKeyringState,\n} from '@keystonehq/metamask-airgapped-keyring';\nimport type { RestrictedControllerMessenger } from '@metamask/base-controller';\nimport { BaseControllerV2 } from '@metamask/base-controller';\nimport { KeyringController as EthKeyringController } from '@metamask/eth-keyring-controller';\nimport type {\n PersonalMessageParams,\n TypedMessageParams,\n} from '@metamask/message-manager';\nimport type { PreferencesController } from '@metamask/preferences-controller';\nimport type { Eip1024EncryptedData, Hex, Keyring, Json } from '@metamask/utils';\nimport { assertIsStrictHexString, hasProperty } from '@metamask/utils';\nimport { Mutex } from 'async-mutex';\nimport {\n addHexPrefix,\n bufferToHex,\n isValidPrivate,\n toBuffer,\n stripHexPrefix,\n getBinarySize,\n} from 'ethereumjs-util';\nimport Wallet, { thirdparty as importers } from 'ethereumjs-wallet';\nimport type { Patch } from 'immer';\n\nconst name = 'KeyringController';\n\n/**\n * Available keyring types\n */\nexport enum KeyringTypes {\n simple = 'Simple Key Pair',\n hd = 'HD Key Tree',\n qr = 'QR Hardware Wallet Device',\n}\n\n/**\n * @type KeyringControllerState\n *\n * Keyring controller state\n * @property vault - Encrypted string representing keyring data\n * @property isUnlocked - Whether vault is unlocked\n * @property keyringTypes - Account types\n * @property keyrings - Group of accounts\n * @property encryptionKey - Keyring encryption key\n * @property encryptionSalt - Keyring encryption salt\n */\nexport type KeyringControllerState = {\n vault?: string;\n isUnlocked: boolean;\n keyrings: KeyringObject[];\n encryptionKey?: string;\n encryptionSalt?: string;\n};\n\nexport type KeyringControllerMemState = Omit<\n KeyringControllerState,\n 'vault' | 'encryptionKey' | 'encryptionSalt'\n>;\n\nexport type KeyringControllerGetStateAction = {\n type: `${typeof name}:getState`;\n handler: () => KeyringControllerState;\n};\n\nexport type KeyringControllerSignMessageAction = {\n type: `${typeof name}:signMessage`;\n handler: KeyringController['signMessage'];\n};\n\nexport type KeyringControllerSignPersonalMessageAction = {\n type: `${typeof name}:signPersonalMessage`;\n handler: KeyringController['signPersonalMessage'];\n};\n\nexport type KeyringControllerSignTypedMessageAction = {\n type: `${typeof name}:signTypedMessage`;\n handler: KeyringController['signTypedMessage'];\n};\n\nexport type KeyringControllerDecryptMessageAction = {\n type: `${typeof name}:decryptMessage`;\n handler: KeyringController['decryptMessage'];\n};\n\nexport type KeyringControllerGetEncryptionPublicKeyAction = {\n type: `${typeof name}:getEncryptionPublicKey`;\n handler: KeyringController['getEncryptionPublicKey'];\n};\n\nexport type KeyringControllerGetKeyringsByTypeAction = {\n type: `${typeof name}:getKeyringsByType`;\n handler: KeyringController['getKeyringsByType'];\n};\n\nexport type KeyringControllerGetKeyringForAccountAction = {\n type: `${typeof name}:getKeyringForAccount`;\n handler: KeyringController['getKeyringForAccount'];\n};\n\nexport type KeyringControllerGetAccountsAction = {\n type: `${typeof name}:getAccounts`;\n handler: KeyringController['getAccounts'];\n};\n\nexport type KeyringControllerStateChangeEvent = {\n type: `${typeof name}:stateChange`;\n payload: [KeyringControllerState, Patch[]];\n};\n\nexport type KeyringControllerAccountRemovedEvent = {\n type: `${typeof name}:accountRemoved`;\n payload: [string];\n};\n\nexport type KeyringControllerLockEvent = {\n type: `${typeof name}:lock`;\n payload: [];\n};\n\nexport type KeyringControllerUnlockEvent = {\n type: `${typeof name}:unlock`;\n payload: [];\n};\n\nexport type KeyringControllerQRKeyringStateChangeEvent = {\n type: `${typeof name}:qrKeyringStateChange`;\n payload: [ReturnType<IQRKeyringState['getState']>];\n};\n\nexport type KeyringControllerActions =\n | KeyringControllerGetStateAction\n | KeyringControllerSignMessageAction\n | KeyringControllerSignPersonalMessageAction\n | KeyringControllerSignTypedMessageAction\n | KeyringControllerDecryptMessageAction\n | KeyringControllerGetEncryptionPublicKeyAction\n | KeyringControllerGetAccountsAction\n | KeyringControllerGetKeyringsByTypeAction\n | KeyringControllerGetKeyringForAccountAction;\n\nexport type KeyringControllerEvents =\n | KeyringControllerStateChangeEvent\n | KeyringControllerLockEvent\n | KeyringControllerUnlockEvent\n | KeyringControllerAccountRemovedEvent\n | KeyringControllerQRKeyringStateChangeEvent;\n\nexport type KeyringControllerMessenger = RestrictedControllerMessenger<\n typeof name,\n KeyringControllerActions,\n KeyringControllerEvents,\n string,\n string\n>;\n\nexport type KeyringControllerOptions = {\n syncIdentities: PreferencesController['syncIdentities'];\n updateIdentities: PreferencesController['updateIdentities'];\n setSelectedAddress: PreferencesController['setSelectedAddress'];\n setAccountLabel?: PreferencesController['setAccountLabel'];\n encryptor?: any;\n keyringBuilders?: { (): Keyring<Json>; type: string }[];\n cacheEncryptionKey?: boolean;\n messenger: KeyringControllerMessenger;\n state?: { vault?: string };\n};\n\n/**\n * @type KeyringObject\n *\n * Keyring object to return in fullUpdate\n * @property type - Keyring type\n * @property accounts - Associated accounts\n */\nexport type KeyringObject = {\n accounts: string[];\n type: string;\n};\n\n/**\n * A strategy for importing an account\n */\nexport enum AccountImportStrategy {\n privateKey = 'privateKey',\n json = 'json',\n}\n\n/**\n * The `signTypedMessage` version\n *\n * @see https://docs.metamask.io/guide/signing-data.html\n */\nexport enum SignTypedDataVersion {\n V1 = 'V1',\n V3 = 'V3',\n V4 = 'V4',\n}\n\nconst defaultState: KeyringControllerState = {\n isUnlocked: false,\n keyrings: [],\n};\n\n/**\n * Assert that the given keyring has an exportable\n * mnemonic.\n *\n * @param keyring - The keyring to check\n * @throws When the keyring does not have a mnemonic\n */\nfunction assertHasUint8ArrayMnemonic(\n keyring: Keyring<Json>,\n): asserts keyring is Keyring<Json> & { mnemonic: Uint8Array } {\n if (\n !(\n hasProperty(keyring, 'mnemonic') && keyring.mnemonic instanceof Uint8Array\n )\n ) {\n throw new Error(\"Can't get mnemonic bytes from keyring\");\n }\n}\n\n/**\n * Controller responsible for establishing and managing user identity.\n *\n * This class is a wrapper around the `eth-keyring-controller` package. The\n * `eth-keyring-controller` manages the \"vault\", which is an encrypted store of private keys, and\n * it manages the wallet \"lock\" state. This wrapper class has convenience methods for interacting\n * with the internal keyring controller and handling certain complex operations that involve the\n * keyrings.\n */\nexport class KeyringController extends BaseControllerV2<\n typeof name,\n KeyringControllerState,\n KeyringControllerMessenger\n> {\n private readonly mutex = new Mutex();\n\n private readonly syncIdentities: PreferencesController['syncIdentities'];\n\n private readonly updateIdentities: PreferencesController['updateIdentities'];\n\n private readonly setSelectedAddress: PreferencesController['setSelectedAddress'];\n\n private readonly setAccountLabel?: PreferencesController['setAccountLabel'];\n\n #keyring: EthKeyringController;\n\n #qrKeyringStateListener?: (\n state: ReturnType<IQRKeyringState['getState']>,\n ) => void;\n\n /**\n * Creates a KeyringController instance.\n *\n * @param opts - Initial options used to configure this controller\n * @param opts.syncIdentities - Sync identities with the given list of addresses.\n * @param opts.updateIdentities - Generate an identity for each address given that doesn't already have an identity.\n * @param opts.setSelectedAddress - Set the selected address.\n * @param opts.setAccountLabel - Set a new name for account.\n * @param opts.encryptor - An optional object for defining encryption schemes.\n * @param opts.keyringBuilders - Set a new name for account.\n * @param opts.cacheEncryptionKey - Whether to cache or not encryption key.\n * @param opts.messenger - A restricted controller messenger.\n * @param opts.state - Initial state to set on this controller.\n */\n constructor({\n syncIdentities,\n updateIdentities,\n setSelectedAddress,\n setAccountLabel,\n encryptor,\n keyringBuilders,\n cacheEncryptionKey = false,\n messenger,\n state,\n }: KeyringControllerOptions) {\n super({\n name,\n metadata: {\n vault: { persist: true, anonymous: false },\n isUnlocked: { persist: false, anonymous: true },\n keyrings: { persist: false, anonymous: false },\n encryptionKey: { persist: false, anonymous: false },\n encryptionSalt: { persist: false, anonymous: false },\n },\n messenger,\n state: {\n ...defaultState,\n ...state,\n },\n });\n\n this.#keyring = new EthKeyringController({\n initState: state,\n encryptor,\n keyringBuilders,\n cacheEncryptionKey,\n });\n this.#keyring.memStore.subscribe(this.#fullUpdate.bind(this));\n this.#keyring.store.subscribe(this.#fullUpdate.bind(this));\n this.#keyring.on('lock', this.#handleLock.bind(this));\n this.#keyring.on('unlock', this.#handleUnlock.bind(this));\n\n this.syncIdentities = syncIdentities;\n this.updateIdentities = updateIdentities;\n this.setSelectedAddress = setSelectedAddress;\n this.setAccountLabel = setAccountLabel;\n\n this.#registerMessageHandlers();\n }\n\n /**\n * Adds a new account to the default (first) HD seed phrase keyring.\n *\n * @param accountCount - Number of accounts before adding a new one, used to\n * make the method idempotent.\n * @returns Promise resolving to keyring current state and added account\n * address.\n */\n async addNewAccount(accountCount?: number): Promise<{\n keyringState: KeyringControllerMemState;\n addedAccountAddress: string;\n }> {\n const primaryKeyring = this.#keyring.getKeyringsByType('HD Key Tree')[0];\n /* istanbul ignore if */\n if (!primaryKeyring) {\n throw new Error('No HD keyring found');\n }\n const oldAccounts = await this.#keyring.getAccounts();\n\n if (accountCount && oldAccounts.length !== accountCount) {\n if (accountCount > oldAccounts.length) {\n throw new Error('Account out of sequence');\n }\n // we return the account already existing at index `accountCount`\n const primaryKeyringAccounts = await primaryKeyring.getAccounts();\n return {\n keyringState: this.#getMemState(),\n addedAccountAddress: primaryKeyringAccounts[accountCount],\n };\n }\n\n await this.#keyring.addNewAccount(primaryKeyring);\n const newAccounts = await this.#keyring.getAccounts();\n\n await this.verifySeedPhrase();\n\n this.updateIdentities(newAccounts);\n const addedAccountAddress = newAccounts.find(\n (selectedAddress: string) => !oldAccounts.includes(selectedAddress),\n );\n\n assertIsStrictHexString(addedAccountAddress);\n return {\n keyringState: this.#getMemState(),\n addedAccountAddress,\n };\n }\n\n /**\n * Adds a new account to the specified keyring.\n *\n * @param keyring - Keyring to add the account to.\n * @param accountCount - Number of accounts before adding a new one, used to make the method idempotent.\n * @returns Promise resolving to keyring current state and added account\n */\n async addNewAccountForKeyring(\n keyring: Keyring<Json>,\n accountCount?: number,\n ): Promise<Hex> {\n const oldAccounts = await this.getAccounts();\n\n if (accountCount && oldAccounts.length !== accountCount) {\n if (accountCount > oldAccounts.length) {\n throw new Error('Account out of sequence');\n }\n\n const existingAccount = oldAccounts[accountCount];\n assertIsStrictHexString(existingAccount);\n\n return existingAccount;\n }\n\n await this.#keyring.addNewAccount(keyring);\n const addedAccountAddress = (await this.getAccounts()).find(\n (selectedAddress) => !oldAccounts.includes(selectedAddress),\n );\n assertIsStrictHexString(addedAccountAddress);\n\n this.updateIdentities(await this.#keyring.getAccounts());\n\n return addedAccountAddress;\n }\n\n /**\n * Adds a new account to the default (first) HD seed phrase keyring without updating identities in preferences.\n *\n * @returns Promise resolving to current state when the account is added.\n */\n async addNewAccountWithoutUpdate(): Promise<KeyringControllerMemState> {\n const primaryKeyring = this.#keyring.getKeyringsByType('HD Key Tree')[0];\n /* istanbul ignore if */\n if (!primaryKeyring) {\n throw new Error('No HD keyring found');\n }\n await this.#keyring.addNewAccount(primaryKeyring);\n await this.verifySeedPhrase();\n return this.#getMemState();\n }\n\n /**\n * Effectively the same as creating a new keychain then populating it\n * using the given seed phrase.\n *\n * @param password - Password to unlock keychain.\n * @param seed - A BIP39-compliant seed phrase as Uint8Array,\n * either as a string or an array of UTF-8 bytes that represent the string.\n * @returns Promise resolving to the restored keychain object.\n */\n async createNewVaultAndRestore(\n password: string,\n seed: Uint8Array,\n ): Promise<KeyringControllerMemState> {\n const releaseLock = await this.mutex.acquire();\n if (!password || !password.length) {\n throw new Error('Invalid password');\n }\n\n try {\n this.updateIdentities([]);\n await this.#keyring.createNewVaultAndRestore(password, seed);\n this.updateIdentities(await this.#keyring.getAccounts());\n return this.#getMemState();\n } finally {\n releaseLock();\n }\n }\n\n /**\n * Create a new primary keychain and wipe any previous keychains.\n *\n * @param password - Password to unlock the new vault.\n * @returns Newly-created keychain object.\n */\n async createNewVaultAndKeychain(password: string) {\n const releaseLock = await this.mutex.acquire();\n try {\n const accounts = await this.getAccounts();\n if (!accounts.length) {\n await this.#keyring.createNewVaultAndKeychain(password);\n this.updateIdentities(await this.getAccounts());\n }\n return this.#getMemState();\n } finally {\n releaseLock();\n }\n }\n\n /**\n * Adds a new keyring of the given `type`.\n *\n * @param type - Keyring type name.\n * @param opts - Keyring options.\n * @throws If a builder for the given `type` does not exist.\n * @returns Promise resolving to the added keyring.\n */\n async addNewKeyring(\n type: KeyringTypes | string,\n opts?: unknown,\n ): Promise<unknown> {\n if (type === KeyringTypes.qr) {\n return this.getOrAddQRKeyring();\n }\n\n return this.#keyring.addNewKeyring(type, opts);\n }\n\n /**\n * Method to verify a given password validity. Throws an\n * error if the password is invalid.\n *\n * @param password - Password of the keyring.\n */\n async verifyPassword(password: string) {\n await this.#keyring.verifyPassword(password);\n }\n\n /**\n * Returns the status of the vault.\n *\n * @returns Boolean returning true if the vault is unlocked.\n */\n isUnlocked(): boolean {\n return this.state.isUnlocked;\n }\n\n /**\n * Gets the seed phrase of the HD keyring.\n *\n * @param password - Password of the keyring.\n * @returns Promise resolving to the seed phrase.\n */\n async exportSeedPhrase(password: string): Promise<Uint8Array> {\n await this.verifyPassword(password);\n assertHasUint8ArrayMnemonic(this.#keyring.keyrings[0]);\n return this.#keyring.keyrings[0].mnemonic;\n }\n\n /**\n * Gets the private key from the keyring controlling an address.\n *\n * @param password - Password of the keyring.\n * @param address - Address to export.\n * @returns Promise resolving to the private key for an address.\n */\n async exportAccount(password: string, address: string): Promise<string> {\n await this.verifyPassword(password);\n return this.#keyring.exportAccount(address);\n }\n\n /**\n * Returns the public addresses of all accounts for the current keyring.\n *\n * @returns A promise resolving to an array of addresses.\n */\n getAccounts(): Promise<string[]> {\n return this.#keyring.getAccounts();\n }\n\n /**\n * Get encryption public key.\n *\n * @param account - An account address.\n * @param opts - Additional encryption options.\n * @throws If the `account` does not exist or does not support the `getEncryptionPublicKey` method\n * @returns Promise resolving to encyption public key of the `account` if one exists.\n */\n async getEncryptionPublicKey(\n account: string,\n opts?: Record<string, unknown>,\n ): Promise<string> {\n return this.#keyring.getEncryptionPublicKey(account, opts);\n }\n\n /**\n * Attempts to decrypt the provided message parameters.\n *\n * @param messageParams - The decryption message parameters.\n * @param messageParams.from - The address of the account you want to use to decrypt the message.\n * @param messageParams.data - The encrypted data that you want to decrypt.\n * @returns The raw decryption result.\n */\n async decryptMessage(messageParams: {\n from: string;\n data: Eip1024EncryptedData;\n }): Promise<string> {\n return this.#keyring.decryptMessage(messageParams);\n }\n\n /**\n * Returns the currently initialized keyring that manages\n * the specified `address` if one exists.\n *\n * @deprecated Use of this method is discouraged as actions executed directly on\n * keyrings are not being reflected in the KeyringController state and not\n * persisted in the vault.\n * @param account - An account address.\n * @returns Promise resolving to keyring of the `account` if one exists.\n */\n async getKeyringForAccount(account: string): Promise<unknown> {\n return this.#keyring.getKeyringForAccount(account);\n }\n\n /**\n * Returns all keyrings of the given type.\n *\n * @deprecated Use of this method is discouraged as actions executed directly on\n * keyrings are not being reflected in the KeyringController state and not\n * persisted in the vault.\n * @param type - Keyring type name.\n * @returns An array of keyrings of the given type.\n */\n getKeyringsByType(type: KeyringTypes | string): unknown[] {\n return this.#keyring.getKeyringsByType(type);\n }\n\n /**\n * Persist all serialized keyrings in the vault.\n *\n * @returns Promise resolving with `true` value when the\n * operation completes.\n */\n async persistAllKeyrings(): Promise<boolean> {\n return this.#keyring.persistAllKeyrings();\n }\n\n /**\n * Imports an account with the specified import strategy.\n *\n * @param strategy - Import strategy name.\n * @param args - Array of arguments to pass to the underlying stategy.\n * @throws Will throw when passed an unrecognized strategy.\n * @returns Promise resolving to keyring current state and imported account\n * address.\n */\n async importAccountWithStrategy(\n strategy: AccountImportStrategy,\n args: any[],\n ): Promise<{\n keyringState: KeyringControllerMemState;\n importedAccountAddress: string;\n }> {\n let privateKey;\n switch (strategy) {\n case 'privateKey':\n const [importedKey] = args;\n if (!importedKey) {\n throw new Error('Cannot import an empty key.');\n }\n const prefixed = addHexPrefix(importedKey);\n\n let bufferedPrivateKey;\n try {\n bufferedPrivateKey = toBuffer(prefixed);\n } catch {\n throw new Error('Cannot import invalid private key.');\n }\n\n /* istanbul ignore if */\n if (\n !isValidPrivate(bufferedPrivateKey) ||\n // ensures that the key is 64 bytes long\n getBinarySize(prefixed) !== 64 + '0x'.length\n ) {\n throw new Error('Cannot import invalid private key.');\n }\n\n privateKey = stripHexPrefix(prefixed);\n break;\n case 'json':\n let wallet;\n const [input, password] = args;\n try {\n wallet = importers.fromEtherWallet(input, password);\n } catch (e) {\n wallet = wallet || (await Wallet.fromV3(input, password, true));\n }\n privateKey = bufferToHex(wallet.getPrivateKey());\n break;\n default:\n throw new Error(`Unexpected import strategy: '${strategy}'`);\n }\n const newKeyring = await this.#keyring.addNewKeyring(KeyringTypes.simple, [\n privateKey,\n ]);\n const accounts = await newKeyring.getAccounts();\n const allAccounts = await this.#keyring.getAccounts();\n this.updateIdentities(allAccounts);\n return {\n keyringState: this.#getMemState(),\n importedAccountAddress: accounts[0],\n };\n }\n\n /**\n * Removes an account from keyring state.\n *\n * @param address - Address of the account to remove.\n * @fires KeyringController:accountRemoved\n * @returns Promise resolving current state when this account removal completes.\n */\n async removeAccount(address: Hex): Promise<KeyringControllerMemState> {\n await this.#keyring.removeAccount(address);\n this.messagingSystem.publish(`${name}:accountRemoved`, address);\n return this.#getMemState();\n }\n\n /**\n * Deallocates all secrets and locks the wallet.\n *\n * @returns Promise resolving to current state.\n */\n async setLocked(): Promise<KeyringControllerMemState> {\n this.#unsubscribeFromQRKeyringsEvents();\n await this.#keyring.setLocked();\n return this.#getMemState();\n }\n\n /**\n * Signs message by calling down into a specific keyring.\n *\n * @param messageParams - PersonalMessageParams object to sign.\n * @returns Promise resolving to a signed message string.\n */\n signMessage(messageParams: PersonalMessageParams) {\n if (!messageParams.data) {\n throw new Error(\"Can't sign an empty message\");\n }\n return this.#keyring.signMessage(messageParams);\n }\n\n /**\n * Signs personal message by calling down into a specific keyring.\n *\n * @param messageParams - PersonalMessageParams object to sign.\n * @returns Promise resolving to a signed message string.\n */\n signPersonalMessage(messageParams: PersonalMessageParams) {\n return this.#keyring.signPersonalMessage(messageParams);\n }\n\n /**\n * Signs typed message by calling down into a specific keyring.\n *\n * @param messageParams - TypedMessageParams object to sign.\n * @param version - Compatibility version EIP712.\n * @throws Will throw when passed an unrecognized version.\n * @returns Promise resolving to a signed message string or an error if any.\n */\n async signTypedMessage(\n messageParams: TypedMessageParams,\n version: SignTypedDataVersion,\n ): Promise<string> {\n try {\n if (\n ![\n SignTypedDataVersion.V1,\n SignTypedDataVersion.V3,\n SignTypedDataVersion.V4,\n ].includes(version)\n ) {\n throw new Error(`Unexpected signTypedMessage version: '${version}'`);\n }\n\n return await this.#keyring.signTypedMessage(\n {\n from: messageParams.from,\n data:\n version !== SignTypedDataVersion.V1 &&\n typeof messageParams.data === 'string'\n ? JSON.parse(messageParams.data)\n : messageParams.data,\n },\n { version },\n );\n } catch (error) {\n throw new Error(`Keyring Controller signTypedMessage: ${error}`);\n }\n }\n\n /**\n * Signs a transaction by calling down into a specific keyring.\n *\n * @param transaction - Transaction object to sign. Must be a `ethereumjs-tx` transaction instance.\n * @param from - Address to sign from, should be in keychain.\n * @param opts - An optional options object.\n * @returns Promise resolving to a signed transaction string.\n */\n signTransaction(\n transaction: TypedTransaction,\n from: string,\n opts?: Record<string, unknown>,\n ): Promise<TxData> {\n return this.#keyring.signTransaction(transaction, from, opts);\n }\n\n /**\n * Attempts to decrypt the current vault and load its keyrings,\n * using the given encryption key and salt.\n *\n * @param encryptionKey - Key to unlock the keychain.\n * @param encryptionSalt - Salt to unlock the keychain.\n * @returns Promise resolving to the current state.\n */\n async submitEncryptionKey(\n encryptionKey: string,\n encryptionSalt: string,\n ): Promise<KeyringControllerMemState> {\n await this.#keyring.submitEncryptionKey(encryptionKey, encryptionSalt);\n\n const qrKeyring = this.getQRKeyring();\n if (qrKeyring) {\n // if there is a QR keyring, we need to subscribe\n // to its events after unlocking the vault\n this.#subscribeToQRKeyringEvents(qrKeyring);\n }\n\n return this.#getMemState();\n }\n\n /**\n * Attempts to decrypt the current vault and load its keyrings,\n * using the given password.\n *\n * @param password - Password to unlock the keychain.\n * @returns Promise resolving to the current state.\n */\n async submitPassword(password: string): Promise<KeyringControllerMemState> {\n await this.#keyring.submitPassword(password);\n const accounts = await this.#keyring.getAccounts();\n\n const qrKeyring = this.getQRKeyring();\n if (qrKeyring) {\n // if there is a QR keyring, we need to subscribe\n // to its events after unlocking the vault\n this.#subscribeToQRKeyringEvents(qrKeyring);\n }\n\n await this.syncIdentities(accounts);\n return this.#getMemState();\n }\n\n /**\n * Verifies the that the seed phrase restores the current keychain's accounts.\n *\n * @returns Promise resolving to the seed phrase as Uint8Array.\n */\n async verifySeedPhrase(): Promise<Uint8Array> {\n const primaryKeyring = this.#keyring.getKeyringsByType(KeyringTypes.hd)[0];\n /* istanbul ignore if */\n if (!primaryKeyring) {\n throw new Error('No HD keyring found.');\n }\n\n assertHasUint8ArrayMnemonic(primaryKeyring);\n\n const seedWords = primaryKeyring.mnemonic;\n const accounts = await primaryKeyring.getAccounts();\n /* istanbul ignore if */\n if (accounts.length === 0) {\n throw new Error('Cannot verify an empty keyring.');\n }\n\n // The HD Keyring Builder is a default keyring builder\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const hdKeyringBuilder = this.#keyring.getKeyringBuilderForType(\n KeyringTypes.hd,\n )!;\n\n const hdKeyring = hdKeyringBuilder();\n // @ts-expect-error @metamask/eth-hd-keyring correctly handles\n // Uint8Array seed phrases in the `deserialize` method.\n hdKeyring.deserialize({\n mnemonic: seedWords,\n numberOfAccounts: accounts.length,\n });\n const testAccounts = await hdKeyring.getAccounts();\n /* istanbul ignore if */\n if (testAccounts.length !== accounts.length) {\n throw new Error('Seed phrase imported incorrect number of accounts.');\n }\n\n testAccounts.forEach((account: string, i: number) => {\n /* istanbul ignore if */\n if (account.toLowerCase() !== accounts[i].toLowerCase()) {\n throw new Error('Seed phrase imported different accounts.');\n }\n });\n\n return seedWords;\n }\n\n // QR Hardware related methods\n\n /**\n * Get QR Hardware keyring.\n *\n * @returns The QR Keyring if defined, otherwise undefined\n */\n getQRKeyring(): QRKeyring | undefined {\n // QRKeyring is not yet compatible with Keyring type from @metamask/utils\n return this.#keyring.getKeyringsByType(\n KeyringTypes.qr,\n )[0] as unknown as QRKeyring;\n }\n\n /**\n * Get QR hardware keyring. If it doesn't exist, add it.\n *\n * @returns The added keyring\n */\n async getOrAddQRKeyring(): Promise<QRKeyring> {\n return this.getQRKeyring() || (await this.#addQRKeyring());\n }\n\n async restoreQRKeyring(serialized: any): Promise<void> {\n (await this.getOrAddQRKeyring()).deserialize(serialized);\n await this.#keyring.persistAllKeyrings();\n this.updateIdentities(await this.#keyring.getAccounts());\n }\n\n async resetQRKeyringState(): Promise<void> {\n (await this.getOrAddQRKeyring()).resetStore();\n }\n\n async getQRKeyringState(): Promise<IQRKeyringState> {\n return (await this.getOrAddQRKeyring()).getMemStore();\n }\n\n async submitQRCryptoHDKey(cryptoHDKey: string): Promise<void> {\n (await this.getOrAddQRKeyring()).submitCryptoHDKey(cryptoHDKey);\n }\n\n async submitQRCryptoAccount(cryptoAccount: string): Promise<void> {\n (await this.getOrAddQRKeyring()).submitCryptoAccount(cryptoAccount);\n }\n\n async submitQRSignature(\n requestId: string,\n ethSignature: string,\n ): Promise<void> {\n (await this.getOrAddQRKeyring()).submitSignature(requestId, ethSignature);\n }\n\n async cancelQRSignRequest(): Promise<void> {\n (await this.getOrAddQRKeyring()).cancelSignRequest();\n }\n\n /**\n * Cancels qr keyring sync.\n */\n async cancelQRSynchronization(): Promise<void> {\n // eslint-disable-next-line n/no-sync\n (await this.getOrAddQRKeyring()).cancelSync();\n }\n\n async connectQRHardware(\n page: number,\n ): Promise<{ balance: string; address: string; index: number }[]> {\n try {\n const keyring = await this.getOrAddQRKeyring();\n let accounts;\n switch (page) {\n case -1:\n accounts = await keyring.getPreviousPage();\n break;\n case 1:\n accounts = await keyring.getNextPage();\n break;\n default:\n accounts = await keyring.getFirstPage();\n }\n return accounts.map((account: any) => {\n return {\n ...account,\n balance: '0x0',\n };\n });\n } catch (e) {\n // TODO: Add test case for when keyring throws\n /* istanbul ignore next */\n throw new Error(`Unspecified error when connect QR Hardware, ${e}`);\n }\n }\n\n async unlockQRHardwareWalletAccount(index: number): Promise<void> {\n const keyring = await this.getOrAddQRKeyring();\n\n keyring.setAccountToUnlock(index);\n const oldAccounts = await this.#keyring.getAccounts();\n // QRKeyring is not yet compatible with Keyring from\n // @metamask/utils, but we can use the `addNewAccount` method\n // as it internally calls `addAccounts` from on the keyring instance,\n // which is supported by QRKeyring API.\n await this.#keyring.addNewAccount(keyring as unknown as Keyring<Json>);\n const newAccounts = await this.#keyring.getAccounts();\n this.updateIdentities(newAccounts);\n newAccounts.forEach((address: string) => {\n if (!oldAccounts.includes(address)) {\n if (this.setAccountLabel) {\n this.setAccountLabel(address, `${keyring.getName()} ${index}`);\n }\n this.setSelectedAddress(address);\n }\n });\n await this.#keyring.persistAllKeyrings();\n }\n\n async getAccountKeyringType(account: string): Promise<string> {\n return (await this.#keyring.getKeyringForAccount(account)).type;\n }\n\n async forgetQRDevice(): Promise<void> {\n const keyring = await this.getOrAddQRKeyring();\n keyring.forgetDevice();\n const accounts = (await this.#keyring.getAccounts()) as string[];\n accounts.forEach((account) => {\n this.setSelectedAddress(account);\n });\n await this.#keyring.persistAllKeyrings();\n }\n\n /**\n * Constructor helper for registering this controller's messaging system\n * actions.\n */\n #registerMessageHandlers() {\n this.messagingSystem.registerActionHandler(\n `${name}:signMessage`,\n this.signMessage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${name}:signPersonalMessage`,\n this.signPersonalMessage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${name}:signTypedMessage`,\n this.signTypedMessage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${name}:decryptMessage`,\n this.decryptMessage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${name}:getEncryptionPublicKey`,\n this.getEncryptionPublicKey.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${name}:getAccounts`,\n this.getAccounts.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${name}:getKeyringsByType`,\n this.getKeyringsByType.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${name}:getKeyringForAccount`,\n this.getKeyringForAccount.bind(this),\n );\n }\n\n /**\n * Add qr hardware keyring.\n *\n * @returns The added keyring\n * @throws If a QRKeyring builder is not provided\n * when initializing the controller\n */\n async #addQRKeyring(): Promise<QRKeyring> {\n // QRKeyring is not yet compatible with Keyring type from @metamask/utils\n const qrKeyring = (await this.#keyring.addNewKeyring(\n KeyringTypes.qr,\n )) as unknown as QRKeyring;\n\n this.#subscribeToQRKeyringEvents(qrKeyring);\n\n return qrKeyring;\n }\n\n /**\n * Subscribe to a QRKeyring state change events and\n * forward them through the messaging system.\n *\n * @param qrKeyring - The QRKeyring instance to subscribe to\n */\n #subscribeToQRKeyringEvents(qrKeyring: QRKeyring) {\n this.#qrKeyringStateListener = (state) => {\n this.messagingSystem.publish(`${name}:qrKeyringStateChange`, state);\n };\n\n qrKeyring.getMemStore().subscribe(this.#qrKeyringStateListener);\n }\n\n #unsubscribeFromQRKeyringsEvents() {\n const qrKeyrings = this.#keyring.getKeyringsByType(\n KeyringTypes.qr,\n ) as unknown as QRKeyring[];\n\n qrKeyrings.forEach((qrKeyring) => {\n if (this.#qrKeyringStateListener) {\n qrKeyring.getMemStore().unsubscribe(this.#qrKeyringStateListener);\n }\n });\n }\n\n /**\n * Sync controller state with current keyring store\n * and memStore states.\n *\n * @fires KeyringController:stateChange\n */\n #fullUpdate() {\n const { vault } = this.#keyring.store.getState();\n const { keyrings, isUnlocked, encryptionKey, encryptionSalt } =\n this.#keyring.memStore.getState();\n\n this.update(() => ({\n vault,\n keyrings,\n isUnlocked,\n encryptionKey,\n encryptionSalt,\n }));\n }\n\n /**\n * Handle keyring lock event.\n *\n * @fires KeyringController:lock\n */\n #handleLock() {\n this.messagingSystem.publish(`${name}:lock`);\n }\n\n /**\n * Handle keyring unlock event.\n *\n * @fires KeyringController:unlock\n */\n #handleUnlock() {\n this.messagingSystem.publish(`${name}:unlock`);\n }\n\n #getMemState(): KeyringControllerMemState {\n return {\n isUnlocked: this.state.isUnlocked,\n keyrings: this.state.keyrings,\n };\n }\n}\n\nexport default KeyringController;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/keyring-controller",
3
- "version": "8.0.0-preview.1b84247",
3
+ "version": "8.0.2-preview.26b130a",
4
4
  "description": "Stores identities seen in the wallet and manages interactions such as signing",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -25,18 +25,16 @@
25
25
  "changelog:validate": "../../scripts/validate-changelog.sh @metamask/keyring-controller",
26
26
  "publish:preview": "yarn npm publish --tag preview",
27
27
  "test": "jest",
28
+ "test:clean": "jest --clearCache",
28
29
  "test:watch": "jest --watch"
29
30
  },
30
31
  "dependencies": {
31
32
  "@keystonehq/metamask-airgapped-keyring": "^0.13.1",
32
- "@ledgerhq/hw-transport": "6.24.1",
33
- "@ledgerhq/metamask-keyring": "0.3.3",
34
- "@metamask/base-controller": "^3.2.1",
33
+ "@metamask/base-controller": "^3.2.3",
35
34
  "@metamask/eth-keyring-controller": "^13.0.1",
36
- "@metamask/eth-sig-util": "^7.0.0",
37
- "@metamask/message-manager": "^7.3.3",
38
- "@metamask/preferences-controller": "^4.4.1",
39
- "@metamask/utils": "^6.2.0",
35
+ "@metamask/message-manager": "^7.3.5",
36
+ "@metamask/preferences-controller": "^4.4.2",
37
+ "@metamask/utils": "^8.1.0",
40
38
  "async-mutex": "^0.2.6",
41
39
  "ethereumjs-util": "^7.0.10",
42
40
  "ethereumjs-wallet": "^1.0.1",
@@ -47,19 +45,20 @@
47
45
  "@ethereumjs/tx": "^4.2.0",
48
46
  "@keystonehq/bc-ur-registry-eth": "^0.9.0",
49
47
  "@metamask/auto-changelog": "^3.1.0",
48
+ "@metamask/eth-sig-util": "^7.0.0",
50
49
  "@metamask/scure-bip39": "^2.1.0",
51
50
  "@types/jest": "^27.4.1",
52
51
  "deepmerge": "^4.2.2",
53
52
  "jest": "^27.5.1",
54
53
  "sinon": "^9.2.4",
55
54
  "ts-jest": "^27.1.4",
56
- "typedoc": "^0.23.15",
57
- "typedoc-plugin-missing-exports": "^0.23.0",
58
- "typescript": "~4.6.3",
55
+ "typedoc": "^0.24.8",
56
+ "typedoc-plugin-missing-exports": "^2.0.0",
57
+ "typescript": "~4.8.4",
59
58
  "uuid": "^8.3.2"
60
59
  },
61
60
  "peerDependencies": {
62
- "@metamask/preferences-controller": "^4.4.1"
61
+ "@metamask/preferences-controller": "^4.4.2"
63
62
  },
64
63
  "engines": {
65
64
  "node": ">=16.0.0"
@@ -1,9 +0,0 @@
1
- export interface SerializedLedgerKeyring {
2
- accounts: {
3
- address: string;
4
- hdPath: string;
5
- }[];
6
- deviceId: string;
7
- hdPath: string;
8
- }
9
- //# sourceMappingURL=SerializedKeyringTypes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SerializedKeyringTypes.d.ts","sourceRoot":"","sources":["../../src/types/SerializedKeyringTypes.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=SerializedKeyringTypes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SerializedKeyringTypes.js","sourceRoot":"","sources":["../../src/types/SerializedKeyringTypes.ts"],"names":[],"mappings":"","sourcesContent":["export interface SerializedLedgerKeyring {\n accounts: { address: string; hdPath: string }[];\n deviceId: string;\n hdPath: string;\n}\n"]}