@metamask-previews/keyring-controller 19.0.3-preview-4c4eb52a → 19.0.4-preview-5f45f70f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [19.0.4]
11
+
12
+ ### Changed
13
+
14
+ - Bump `@metamask/keyring-api` from `^13.0.0` to `^14.0.0` ([#5177](https://github.com/MetaMask/core/pull/5177))
15
+ - Bump `@metamask/keyring-internal-api` from `^2.0.0` to `^2.0.1` ([#5177](https://github.com/MetaMask/core/pull/5177))
16
+ - Bump `@metamask/message-manager` from `^12.0.0` to `^11.0.3` ([#5169](https://github.com/MetaMask/core/pull/5169))
17
+
10
18
  ## [19.0.3]
11
19
 
12
20
  ### Changed
@@ -632,7 +640,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
632
640
 
633
641
  All changes listed after this point were applied to this package following the monorepo conversion.
634
642
 
635
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@19.0.3...HEAD
643
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@19.0.4...HEAD
644
+ [19.0.4]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@19.0.3...@metamask/keyring-controller@19.0.4
636
645
  [19.0.3]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@19.0.2...@metamask/keyring-controller@19.0.3
637
646
  [19.0.2]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@19.0.1...@metamask/keyring-controller@19.0.2
638
647
  [19.0.1]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@19.0.0...@metamask/keyring-controller@19.0.1
@@ -36,7 +36,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
36
36
  var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
38
  };
39
- var _KeyringController_instances, _KeyringController_controllerOperationMutex, _KeyringController_vaultOperationMutex, _KeyringController_keyringBuilders, _KeyringController_keyrings, _KeyringController_keyringsMetadata, _KeyringController_unsupportedKeyrings, _KeyringController_password, _KeyringController_encryptor, _KeyringController_cacheEncryptionKey, _KeyringController_qrKeyringStateListener, _KeyringController_registerMessageHandlers, _KeyringController_getKeyringById, _KeyringController_getKeyringBuilderForType, _KeyringController_addQRKeyring, _KeyringController_subscribeToQRKeyringEvents, _KeyringController_unsubscribeFromQRKeyringsEvents, _KeyringController_createNewVaultWithKeyring, _KeyringController_verifySeedPhrase, _KeyringController_getUpdatedKeyrings, _KeyringController_getSerializedKeyrings, _KeyringController_restoreSerializedKeyrings, _KeyringController_unlockKeyrings, _KeyringController_updateVault, _KeyringController_getAccountsFromKeyrings, _KeyringController_createKeyringWithFirstAccount, _KeyringController_newKeyring, _KeyringController_clearKeyrings, _KeyringController_restoreKeyring, _KeyringController_destroyKeyring, _KeyringController_removeEmptyKeyrings, _KeyringController_checkForDuplicate, _KeyringController_setUnlocked, _KeyringController_persistOrRollback, _KeyringController_withRollback, _KeyringController_assertControllerMutexIsLocked, _KeyringController_withControllerLock, _KeyringController_withVaultLock;
39
+ var _KeyringController_instances, _KeyringController_controllerOperationMutex, _KeyringController_vaultOperationMutex, _KeyringController_keyringBuilders, _KeyringController_keyrings, _KeyringController_unsupportedKeyrings, _KeyringController_password, _KeyringController_encryptor, _KeyringController_cacheEncryptionKey, _KeyringController_qrKeyringStateListener, _KeyringController_registerMessageHandlers, _KeyringController_getKeyringBuilderForType, _KeyringController_addQRKeyring, _KeyringController_subscribeToQRKeyringEvents, _KeyringController_unsubscribeFromQRKeyringsEvents, _KeyringController_createNewVaultWithKeyring, _KeyringController_verifySeedPhrase, _KeyringController_getUpdatedKeyrings, _KeyringController_getSerializedKeyrings, _KeyringController_restoreSerializedKeyrings, _KeyringController_unlockKeyrings, _KeyringController_updateVault, _KeyringController_getAccountsFromKeyrings, _KeyringController_createKeyringWithFirstAccount, _KeyringController_newKeyring, _KeyringController_clearKeyrings, _KeyringController_restoreKeyring, _KeyringController_destroyKeyring, _KeyringController_removeEmptyKeyrings, _KeyringController_checkForDuplicate, _KeyringController_setUnlocked, _KeyringController_persistOrRollback, _KeyringController_withRollback, _KeyringController_assertControllerMutexIsLocked, _KeyringController_withControllerLock, _KeyringController_withVaultLock;
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.KeyringController = exports.getDefaultKeyringState = exports.keyringBuilderFactory = exports.SignTypedDataVersion = exports.AccountImportStrategy = exports.isCustodyKeyring = exports.KeyringTypes = void 0;
42
42
  const util_1 = require("@ethereumjs/util");
@@ -48,10 +48,7 @@ const eth_simple_keyring_1 = __importDefault(require("@metamask/eth-simple-keyri
48
48
  const utils_1 = require("@metamask/utils");
49
49
  const async_mutex_1 = require("async-mutex");
50
50
  const ethereumjs_wallet_1 = __importStar(require("ethereumjs-wallet"));
51
- // When generating a ULID within the same millisecond, monotonicFactory provides some guarantees regarding sort order.
52
- const ulid_1 = require("ulid");
53
51
  const constants_1 = require("./constants.cjs");
54
- const ulid = (0, ulid_1.monotonicFactory)();
55
52
  const name = 'KeyringController';
56
53
  /**
57
54
  * Available keyring types
@@ -135,7 +132,6 @@ const getDefaultKeyringState = () => {
135
132
  return {
136
133
  isUnlocked: false,
137
134
  keyrings: [],
138
- keyringsMetadata: [],
139
135
  };
140
136
  };
141
137
  exports.getDefaultKeyringState = getDefaultKeyringState;
@@ -267,7 +263,6 @@ class KeyringController extends base_controller_1.BaseController {
267
263
  vault: { persist: true, anonymous: false },
268
264
  isUnlocked: { persist: false, anonymous: true },
269
265
  keyrings: { persist: false, anonymous: false },
270
- keyringsMetadata: { persist: true, anonymous: false },
271
266
  encryptionKey: { persist: false, anonymous: false },
272
267
  encryptionSalt: { persist: false, anonymous: false },
273
268
  },
@@ -282,7 +277,6 @@ class KeyringController extends base_controller_1.BaseController {
282
277
  _KeyringController_vaultOperationMutex.set(this, new async_mutex_1.Mutex());
283
278
  _KeyringController_keyringBuilders.set(this, void 0);
284
279
  _KeyringController_keyrings.set(this, void 0);
285
- _KeyringController_keyringsMetadata.set(this, void 0);
286
280
  _KeyringController_unsupportedKeyrings.set(this, void 0);
287
281
  _KeyringController_password.set(this, void 0);
288
282
  _KeyringController_encryptor.set(this, void 0);
@@ -293,7 +287,6 @@ class KeyringController extends base_controller_1.BaseController {
293
287
  : defaultKeyringBuilders, "f");
294
288
  __classPrivateFieldSet(this, _KeyringController_encryptor, encryptor, "f");
295
289
  __classPrivateFieldSet(this, _KeyringController_keyrings, [], "f");
296
- __classPrivateFieldSet(this, _KeyringController_keyringsMetadata, state?.keyringsMetadata ?? [], "f");
297
290
  __classPrivateFieldSet(this, _KeyringController_unsupportedKeyrings, [], "f");
298
291
  // This option allows the controller to cache an exported key
299
292
  // for use in decrypting and encrypting data without password
@@ -312,11 +305,11 @@ class KeyringController extends base_controller_1.BaseController {
312
305
  */
313
306
  async addNewAccount(accountCount) {
314
307
  return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_persistOrRollback).call(this, async () => {
315
- const selectedKeyring = this.getKeyringsByType('HD Key Tree')[0];
316
- if (!selectedKeyring) {
308
+ const primaryKeyring = this.getKeyringsByType('HD Key Tree')[0];
309
+ if (!primaryKeyring) {
317
310
  throw new Error('No HD keyring found');
318
311
  }
319
- const oldAccounts = await selectedKeyring.getAccounts();
312
+ const oldAccounts = await primaryKeyring.getAccounts();
320
313
  if (accountCount && oldAccounts.length !== accountCount) {
321
314
  if (accountCount > oldAccounts.length) {
322
315
  throw new Error('Account out of sequence');
@@ -328,7 +321,7 @@ class KeyringController extends base_controller_1.BaseController {
328
321
  }
329
322
  return existingAccount;
330
323
  }
331
- const [addedAccountAddress] = await selectedKeyring.addAccounts(1);
324
+ const [addedAccountAddress] = await primaryKeyring.addAccounts(1);
332
325
  await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_verifySeedPhrase).call(this);
333
326
  return addedAccountAddress;
334
327
  });
@@ -438,21 +431,12 @@ class KeyringController extends base_controller_1.BaseController {
438
431
  * Gets the seed phrase of the HD keyring.
439
432
  *
440
433
  * @param password - Password of the keyring.
441
- * @param keyringId - The id of the keyring.
442
434
  * @returns Promise resolving to the seed phrase.
443
435
  */
444
- async exportSeedPhrase(password, keyringId) {
436
+ async exportSeedPhrase(password) {
445
437
  await this.verifyPassword(password);
446
- if (!keyringId) {
447
- assertHasUint8ArrayMnemonic(__classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0]);
448
- return __classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0].mnemonic;
449
- }
450
- const selectedKeyring = __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringById).call(this, keyringId);
451
- if (!selectedKeyring) {
452
- throw new Error('Keyring not found');
453
- }
454
- assertHasUint8ArrayMnemonic(selectedKeyring);
455
- return selectedKeyring.mnemonic;
438
+ assertHasUint8ArrayMnemonic(__classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0]);
439
+ return __classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0].mnemonic;
456
440
  }
457
441
  /**
458
442
  * Gets the private key from the keyring controlling an address.
@@ -853,24 +837,10 @@ class KeyringController extends base_controller_1.BaseController {
853
837
  /**
854
838
  * Verifies the that the seed phrase restores the current keychain's accounts.
855
839
  *
856
- * @param keyringId - The id of the keyring to verify.
857
840
  * @returns Promise resolving to the seed phrase as Uint8Array.
858
841
  */
859
- async verifySeedPhrase(keyringId) {
860
- let keyring;
861
- if (!keyringId) {
862
- keyring = __classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0];
863
- }
864
- else {
865
- keyring = __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringById).call(this, keyringId);
866
- if (keyring.type !== KeyringTypes.hd) {
867
- throw new Error(constants_1.KeyringControllerError.UnsupportedVerifySeedPhrase);
868
- }
869
- }
870
- if (!keyring) {
871
- throw new Error(constants_1.KeyringControllerError.NoHdKeyring);
872
- }
873
- return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withControllerLock).call(this, async () => __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_verifySeedPhrase).call(this, keyringId));
842
+ async verifySeedPhrase() {
843
+ return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withControllerLock).call(this, async () => __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_verifySeedPhrase).call(this));
874
844
  }
875
845
  async withKeyring(selector, operation, options = {
876
846
  createIfMissing: false,
@@ -880,15 +850,12 @@ class KeyringController extends base_controller_1.BaseController {
880
850
  if ('address' in selector) {
881
851
  keyring = (await this.getKeyringForAccount(selector.address));
882
852
  }
883
- else if ('type' in selector) {
853
+ else {
884
854
  keyring = this.getKeyringsByType(selector.type)[selector.index || 0];
885
855
  if (!keyring && options.createIfMissing) {
886
856
  keyring = (await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_newKeyring).call(this, selector.type, options.createWithData));
887
857
  }
888
858
  }
889
- else if ('id' in selector) {
890
- keyring = __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringById).call(this, selector.id);
891
- }
892
859
  if (!keyring) {
893
860
  throw new Error(constants_1.KeyringControllerError.KeyringNotFound);
894
861
  }
@@ -1088,7 +1055,7 @@ class KeyringController extends base_controller_1.BaseController {
1088
1055
  }
1089
1056
  }
1090
1057
  exports.KeyringController = KeyringController;
1091
- _KeyringController_controllerOperationMutex = new WeakMap(), _KeyringController_vaultOperationMutex = new WeakMap(), _KeyringController_keyringBuilders = new WeakMap(), _KeyringController_keyrings = new WeakMap(), _KeyringController_keyringsMetadata = new WeakMap(), _KeyringController_unsupportedKeyrings = new WeakMap(), _KeyringController_password = new WeakMap(), _KeyringController_encryptor = new WeakMap(), _KeyringController_cacheEncryptionKey = new WeakMap(), _KeyringController_qrKeyringStateListener = new WeakMap(), _KeyringController_instances = new WeakSet(), _KeyringController_registerMessageHandlers = function _KeyringController_registerMessageHandlers() {
1058
+ _KeyringController_controllerOperationMutex = new WeakMap(), _KeyringController_vaultOperationMutex = new WeakMap(), _KeyringController_keyringBuilders = new WeakMap(), _KeyringController_keyrings = new WeakMap(), _KeyringController_unsupportedKeyrings = new WeakMap(), _KeyringController_password = new WeakMap(), _KeyringController_encryptor = new WeakMap(), _KeyringController_cacheEncryptionKey = new WeakMap(), _KeyringController_qrKeyringStateListener = new WeakMap(), _KeyringController_instances = new WeakSet(), _KeyringController_registerMessageHandlers = function _KeyringController_registerMessageHandlers() {
1092
1059
  this.messagingSystem.registerActionHandler(`${name}:signMessage`, this.signMessage.bind(this));
1093
1060
  this.messagingSystem.registerActionHandler(`${name}:signPersonalMessage`, this.signPersonalMessage.bind(this));
1094
1061
  this.messagingSystem.registerActionHandler(`${name}:signTypedMessage`, this.signTypedMessage.bind(this));
@@ -1102,9 +1069,6 @@ _KeyringController_controllerOperationMutex = new WeakMap(), _KeyringController_
1102
1069
  this.messagingSystem.registerActionHandler(`${name}:patchUserOperation`, this.patchUserOperation.bind(this));
1103
1070
  this.messagingSystem.registerActionHandler(`${name}:signUserOperation`, this.signUserOperation.bind(this));
1104
1071
  this.messagingSystem.registerActionHandler(`${name}:addNewAccount`, this.addNewAccount.bind(this));
1105
- }, _KeyringController_getKeyringById = function _KeyringController_getKeyringById(keyringId) {
1106
- const index = this.state.keyringsMetadata.findIndex((metadata) => metadata.id === keyringId);
1107
- return __classPrivateFieldGet(this, _KeyringController_keyrings, "f")[index];
1108
1072
  }, _KeyringController_getKeyringBuilderForType = function _KeyringController_getKeyringBuilderForType(type) {
1109
1073
  return __classPrivateFieldGet(this, _KeyringController_keyringBuilders, "f").find((keyringBuilder) => keyringBuilder.type === type);
1110
1074
  }, _KeyringController_addQRKeyring =
@@ -1118,7 +1082,7 @@ _KeyringController_controllerOperationMutex = new WeakMap(), _KeyringController_
1118
1082
  async function _KeyringController_addQRKeyring() {
1119
1083
  __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
1120
1084
  // QRKeyring is not yet compatible with Keyring type from @metamask/utils
1121
- return (await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_newKeyring).call(this, KeyringTypes.qr, undefined));
1085
+ return (await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_newKeyring).call(this, KeyringTypes.qr));
1122
1086
  }, _KeyringController_subscribeToQRKeyringEvents = function _KeyringController_subscribeToQRKeyringEvents(qrKeyring) {
1123
1087
  __classPrivateFieldSet(this, _KeyringController_qrKeyringStateListener, (state) => {
1124
1088
  this.messagingSystem.publish(`${name}:qrKeyringStateChange`, state);
@@ -1163,20 +1127,17 @@ async function _KeyringController_createNewVaultWithKeyring(password, keyring) {
1163
1127
  /**
1164
1128
  * Internal non-exclusive method to verify the seed phrase.
1165
1129
  *
1166
- * @param keyringId - The id of the keyring to verify the seed phrase for.
1167
1130
  * @returns A promise resolving to the seed phrase as Uint8Array.
1168
1131
  */
1169
- async function _KeyringController_verifySeedPhrase(keyringId) {
1132
+ async function _KeyringController_verifySeedPhrase() {
1170
1133
  __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
1171
- const keyring = keyringId
1172
- ? __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringById).call(this, keyringId)
1173
- : this.getKeyringsByType(KeyringTypes.hd)[0];
1174
- if (!keyring) {
1134
+ const primaryKeyring = this.getKeyringsByType(KeyringTypes.hd)[0];
1135
+ if (!primaryKeyring) {
1175
1136
  throw new Error('No HD keyring found.');
1176
1137
  }
1177
- assertHasUint8ArrayMnemonic(keyring);
1178
- const seedWords = keyring.mnemonic;
1179
- const accounts = await keyring.getAccounts();
1138
+ assertHasUint8ArrayMnemonic(primaryKeyring);
1139
+ const seedWords = primaryKeyring.mnemonic;
1140
+ const accounts = await primaryKeyring.getAccounts();
1180
1141
  /* istanbul ignore if */
1181
1142
  if (accounts.length === 0) {
1182
1143
  throw new Error('Cannot verify an empty keyring.');
@@ -1224,7 +1185,7 @@ async function _KeyringController_getUpdatedKeyrings() {
1224
1185
  async function _KeyringController_getSerializedKeyrings({ includeUnsupported } = {
1225
1186
  includeUnsupported: true,
1226
1187
  }) {
1227
- const serializedKeyrings = await Promise.all(__classPrivateFieldGet(this, _KeyringController_keyrings, "f").map(async (keyring, index) => {
1188
+ const serializedKeyrings = await Promise.all(__classPrivateFieldGet(this, _KeyringController_keyrings, "f").map(async (keyring) => {
1228
1189
  const [type, data] = await Promise.all([
1229
1190
  keyring.type,
1230
1191
  keyring.serialize(),
@@ -1246,9 +1207,6 @@ async function _KeyringController_restoreSerializedKeyrings(serializedKeyrings)
1246
1207
  for (const serializedKeyring of serializedKeyrings) {
1247
1208
  await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_restoreKeyring).call(this, serializedKeyring);
1248
1209
  }
1249
- if (__classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f").length > __classPrivateFieldGet(this, _KeyringController_keyrings, "f").length) {
1250
- throw new Error(constants_1.KeyringControllerError.KeyringMetadataLengthMismatch);
1251
- }
1252
1210
  }, _KeyringController_unlockKeyrings =
1253
1211
  /**
1254
1212
  * Unlock Keyrings, decrypting the vault and deserializing all
@@ -1362,14 +1320,10 @@ async function _KeyringController_unlockKeyrings(password, encryptionKey, encryp
1362
1320
  this.update((state) => {
1363
1321
  state.vault = updatedState.vault;
1364
1322
  state.keyrings = updatedKeyrings;
1365
- state.keyringsMetadata = __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f");
1366
1323
  if (updatedState.encryptionKey) {
1367
1324
  state.encryptionKey = updatedState.encryptionKey;
1368
1325
  state.encryptionSalt = JSON.parse(updatedState.vault).salt;
1369
1326
  }
1370
- if (updatedKeyrings.length < __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f").length) {
1371
- throw new Error(constants_1.KeyringControllerError.KeyringMetadataLengthMismatch);
1372
- }
1373
1327
  });
1374
1328
  return true;
1375
1329
  });
@@ -1405,13 +1359,13 @@ async function _KeyringController_createKeyringWithFirstAccount(type, opts) {
1405
1359
  if (!firstAccount) {
1406
1360
  throw new Error(constants_1.KeyringControllerError.NoFirstAccount);
1407
1361
  }
1408
- return firstAccount;
1409
1362
  }, _KeyringController_newKeyring =
1410
1363
  /**
1411
1364
  * Instantiate, initialize and return a new keyring of the given `type`,
1412
1365
  * using the given `opts`. The keyring is built using the keyring builder
1413
1366
  * registered for the given `type`.
1414
1367
  *
1368
+ *
1415
1369
  * @param type - The type of keyring to add.
1416
1370
  * @param data - The data to restore a previously serialized keyring.
1417
1371
  * @returns The new keyring.
@@ -1419,10 +1373,6 @@ async function _KeyringController_createKeyringWithFirstAccount(type, opts) {
1419
1373
  */
1420
1374
  async function _KeyringController_newKeyring(type, data) {
1421
1375
  __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
1422
- const newKeyringMetadata = {
1423
- id: ulid().toString(),
1424
- name: '',
1425
- };
1426
1376
  const keyringBuilder = __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringBuilderForType).call(this, type);
1427
1377
  if (!keyringBuilder) {
1428
1378
  throw new Error(`${constants_1.KeyringControllerError.NoKeyringBuilder}. Keyring type: ${type}`);
@@ -1453,10 +1403,6 @@ async function _KeyringController_newKeyring(type, data) {
1453
1403
  __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_subscribeToQRKeyringEvents).call(this, keyring);
1454
1404
  }
1455
1405
  __classPrivateFieldGet(this, _KeyringController_keyrings, "f").push(keyring);
1456
- if (newKeyringMetadata &&
1457
- __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f").length < __classPrivateFieldGet(this, _KeyringController_keyrings, "f").length) {
1458
- __classPrivateFieldSet(this, _KeyringController_keyringsMetadata, [...__classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f"), newKeyringMetadata], "f");
1459
- }
1460
1406
  return keyring;
1461
1407
  }, _KeyringController_clearKeyrings =
1462
1408
  /**
@@ -1469,10 +1415,6 @@ async function _KeyringController_clearKeyrings() {
1469
1415
  await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_destroyKeyring).call(this, keyring);
1470
1416
  }
1471
1417
  __classPrivateFieldSet(this, _KeyringController_keyrings, [], "f");
1472
- __classPrivateFieldSet(this, _KeyringController_keyringsMetadata, [], "f");
1473
- // this.update((state) => {
1474
- // state.keyringsMetadata = [];
1475
- // });
1476
1418
  }, _KeyringController_restoreKeyring =
1477
1419
  /**
1478
1420
  * Restore a Keyring from a provided serialized payload.
@@ -1513,22 +1455,19 @@ async function _KeyringController_destroyKeyring(keyring) {
1513
1455
  async function _KeyringController_removeEmptyKeyrings() {
1514
1456
  __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
1515
1457
  const validKeyrings = [];
1516
- const validKeyringMetadata = [];
1517
1458
  // Since getAccounts returns a Promise
1518
1459
  // We need to wait to hear back form each keyring
1519
1460
  // in order to decide which ones are now valid (accounts.length > 0)
1520
- await Promise.all(__classPrivateFieldGet(this, _KeyringController_keyrings, "f").map(async (keyring, index) => {
1461
+ await Promise.all(__classPrivateFieldGet(this, _KeyringController_keyrings, "f").map(async (keyring) => {
1521
1462
  const accounts = await keyring.getAccounts();
1522
1463
  if (accounts.length > 0) {
1523
1464
  validKeyrings.push(keyring);
1524
- validKeyringMetadata.push(this.state.keyringsMetadata[index]);
1525
1465
  }
1526
1466
  else {
1527
1467
  await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_destroyKeyring).call(this, keyring);
1528
1468
  }
1529
1469
  }));
1530
1470
  __classPrivateFieldSet(this, _KeyringController_keyrings, validKeyrings, "f");
1531
- __classPrivateFieldSet(this, _KeyringController_keyringsMetadata, validKeyringMetadata, "f");
1532
1471
  }, _KeyringController_checkForDuplicate =
1533
1472
  /**
1534
1473
  * Checks for duplicate keypairs, using the the first account in the given