@metamask-previews/keyring-controller 19.0.5-preview-0d0d258d → 19.0.5-preview-aec8dc46

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.
@@ -36,7 +36,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
36
36
  var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
38
  };
39
- var _KeyringController_instances, _KeyringController_controllerOperationMutex, _KeyringController_vaultOperationMutex, _KeyringController_keyringBuilders, _KeyringController_unsupportedKeyrings, _KeyringController_encryptor, _KeyringController_cacheEncryptionKey, _KeyringController_keyrings, _KeyringController_password, _KeyringController_qrKeyringStateListener, _KeyringController_registerMessageHandlers, _KeyringController_getKeyringBuilderForType, _KeyringController_addQRKeyring, _KeyringController_subscribeToQRKeyringEvents, _KeyringController_unsubscribeFromQRKeyringsEvents, _KeyringController_createNewVaultWithKeyring, _KeyringController_verifySeedPhrase, _KeyringController_getUpdatedKeyrings, _KeyringController_getSerializedKeyrings, _KeyringController_restoreSerializedKeyrings, _KeyringController_unlockKeyrings, _KeyringController_updateVault, _KeyringController_getAccountsFromKeyrings, _KeyringController_createKeyringWithFirstAccount, _KeyringController_newKeyring, _KeyringController_clearKeyrings, _KeyringController_restoreKeyring, _KeyringController_destroyKeyring, _KeyringController_removeEmptyKeyrings, _KeyringController_checkForDuplicate, _KeyringController_setUnlocked, _KeyringController_persistOrRollback, _KeyringController_withRollback, _KeyringController_assertControllerMutexIsLocked, _KeyringController_withControllerLock, _KeyringController_withVaultLock;
39
+ var _KeyringController_instances, _KeyringController_controllerOperationMutex, _KeyringController_vaultOperationMutex, _KeyringController_keyringBuilders, _KeyringController_unsupportedKeyrings, _KeyringController_encryptor, _KeyringController_cacheEncryptionKey, _KeyringController_keyrings, _KeyringController_keyringsMetadata, _KeyringController_password, _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;
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,7 +48,10 @@ 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");
51
53
  const constants_1 = require("./constants.cjs");
54
+ const ulid = (0, ulid_1.monotonicFactory)();
52
55
  const name = 'KeyringController';
53
56
  /**
54
57
  * Available keyring types
@@ -115,6 +118,7 @@ const getDefaultKeyringState = () => {
115
118
  return {
116
119
  isUnlocked: false,
117
120
  keyrings: [],
121
+ keyringsMetadata: [],
118
122
  };
119
123
  };
120
124
  exports.getDefaultKeyringState = getDefaultKeyringState;
@@ -246,6 +250,7 @@ class KeyringController extends base_controller_1.BaseController {
246
250
  vault: { persist: true, anonymous: false },
247
251
  isUnlocked: { persist: false, anonymous: true },
248
252
  keyrings: { persist: false, anonymous: false },
253
+ keyringsMetadata: { persist: true, anonymous: false },
249
254
  encryptionKey: { persist: false, anonymous: false },
250
255
  encryptionSalt: { persist: false, anonymous: false },
251
256
  },
@@ -263,6 +268,7 @@ class KeyringController extends base_controller_1.BaseController {
263
268
  _KeyringController_encryptor.set(this, void 0);
264
269
  _KeyringController_cacheEncryptionKey.set(this, void 0);
265
270
  _KeyringController_keyrings.set(this, void 0);
271
+ _KeyringController_keyringsMetadata.set(this, void 0);
266
272
  _KeyringController_password.set(this, void 0);
267
273
  _KeyringController_qrKeyringStateListener.set(this, void 0);
268
274
  __classPrivateFieldSet(this, _KeyringController_keyringBuilders, keyringBuilders
@@ -270,6 +276,7 @@ class KeyringController extends base_controller_1.BaseController {
270
276
  : defaultKeyringBuilders, "f");
271
277
  __classPrivateFieldSet(this, _KeyringController_encryptor, encryptor, "f");
272
278
  __classPrivateFieldSet(this, _KeyringController_keyrings, [], "f");
279
+ __classPrivateFieldSet(this, _KeyringController_keyringsMetadata, state?.keyringsMetadata ?? [], "f");
273
280
  __classPrivateFieldSet(this, _KeyringController_unsupportedKeyrings, [], "f");
274
281
  // This option allows the controller to cache an exported key
275
282
  // for use in decrypting and encrypting data without password
@@ -288,11 +295,11 @@ class KeyringController extends base_controller_1.BaseController {
288
295
  */
289
296
  async addNewAccount(accountCount) {
290
297
  return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_persistOrRollback).call(this, async () => {
291
- const primaryKeyring = this.getKeyringsByType('HD Key Tree')[0];
292
- if (!primaryKeyring) {
298
+ const selectedKeyring = this.getKeyringsByType('HD Key Tree')[0];
299
+ if (!selectedKeyring) {
293
300
  throw new Error('No HD keyring found');
294
301
  }
295
- const oldAccounts = await primaryKeyring.getAccounts();
302
+ const oldAccounts = await selectedKeyring.getAccounts();
296
303
  if (accountCount && oldAccounts.length !== accountCount) {
297
304
  if (accountCount > oldAccounts.length) {
298
305
  throw new Error('Account out of sequence');
@@ -304,7 +311,7 @@ class KeyringController extends base_controller_1.BaseController {
304
311
  }
305
312
  return existingAccount;
306
313
  }
307
- const [addedAccountAddress] = await primaryKeyring.addAccounts(1);
314
+ const [addedAccountAddress] = await selectedKeyring.addAccounts(1);
308
315
  await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_verifySeedPhrase).call(this);
309
316
  return addedAccountAddress;
310
317
  });
@@ -415,12 +422,21 @@ class KeyringController extends base_controller_1.BaseController {
415
422
  * Gets the seed phrase of the HD keyring.
416
423
  *
417
424
  * @param password - Password of the keyring.
425
+ * @param keyringId - The id of the keyring.
418
426
  * @returns Promise resolving to the seed phrase.
419
427
  */
420
- async exportSeedPhrase(password) {
428
+ async exportSeedPhrase(password, keyringId) {
421
429
  await this.verifyPassword(password);
422
- assertHasUint8ArrayMnemonic(__classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0]);
423
- return __classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0].mnemonic;
430
+ if (!keyringId) {
431
+ assertHasUint8ArrayMnemonic(__classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0]);
432
+ return __classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0].mnemonic;
433
+ }
434
+ const selectedKeyring = __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringById).call(this, keyringId);
435
+ if (!selectedKeyring) {
436
+ throw new Error('Keyring not found');
437
+ }
438
+ assertHasUint8ArrayMnemonic(selectedKeyring);
439
+ return selectedKeyring.mnemonic;
424
440
  }
425
441
  /**
426
442
  * Gets the private key from the keyring controlling an address.
@@ -820,10 +836,24 @@ class KeyringController extends base_controller_1.BaseController {
820
836
  /**
821
837
  * Verifies the that the seed phrase restores the current keychain's accounts.
822
838
  *
839
+ * @param keyringId - The id of the keyring to verify.
823
840
  * @returns Promise resolving to the seed phrase as Uint8Array.
824
841
  */
825
- async verifySeedPhrase() {
826
- return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withControllerLock).call(this, async () => __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_verifySeedPhrase).call(this));
842
+ async verifySeedPhrase(keyringId) {
843
+ let keyring;
844
+ if (!keyringId) {
845
+ keyring = __classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0];
846
+ }
847
+ else {
848
+ keyring = __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringById).call(this, keyringId);
849
+ if (keyring.type !== KeyringTypes.hd) {
850
+ throw new Error(constants_1.KeyringControllerError.UnsupportedVerifySeedPhrase);
851
+ }
852
+ }
853
+ if (!keyring) {
854
+ throw new Error(constants_1.KeyringControllerError.NoHdKeyring);
855
+ }
856
+ return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withControllerLock).call(this, async () => __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_verifySeedPhrase).call(this, keyringId));
827
857
  }
828
858
  async withKeyring(selector, operation, options = {
829
859
  createIfMissing: false,
@@ -833,12 +863,15 @@ class KeyringController extends base_controller_1.BaseController {
833
863
  if ('address' in selector) {
834
864
  keyring = (await this.getKeyringForAccount(selector.address));
835
865
  }
836
- else {
866
+ else if ('type' in selector) {
837
867
  keyring = this.getKeyringsByType(selector.type)[selector.index || 0];
838
868
  if (!keyring && options.createIfMissing) {
839
869
  keyring = (await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_newKeyring).call(this, selector.type, options.createWithData));
840
870
  }
841
871
  }
872
+ else if ('id' in selector) {
873
+ keyring = __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringById).call(this, selector.id);
874
+ }
842
875
  if (!keyring) {
843
876
  throw new Error(constants_1.KeyringControllerError.KeyringNotFound);
844
877
  }
@@ -1038,7 +1071,7 @@ class KeyringController extends base_controller_1.BaseController {
1038
1071
  }
1039
1072
  }
1040
1073
  exports.KeyringController = KeyringController;
1041
- _KeyringController_controllerOperationMutex = new WeakMap(), _KeyringController_vaultOperationMutex = new WeakMap(), _KeyringController_keyringBuilders = new WeakMap(), _KeyringController_unsupportedKeyrings = new WeakMap(), _KeyringController_encryptor = new WeakMap(), _KeyringController_cacheEncryptionKey = new WeakMap(), _KeyringController_keyrings = new WeakMap(), _KeyringController_password = new WeakMap(), _KeyringController_qrKeyringStateListener = new WeakMap(), _KeyringController_instances = new WeakSet(), _KeyringController_registerMessageHandlers = function _KeyringController_registerMessageHandlers() {
1074
+ _KeyringController_controllerOperationMutex = new WeakMap(), _KeyringController_vaultOperationMutex = new WeakMap(), _KeyringController_keyringBuilders = new WeakMap(), _KeyringController_unsupportedKeyrings = new WeakMap(), _KeyringController_encryptor = new WeakMap(), _KeyringController_cacheEncryptionKey = new WeakMap(), _KeyringController_keyrings = new WeakMap(), _KeyringController_keyringsMetadata = new WeakMap(), _KeyringController_password = new WeakMap(), _KeyringController_qrKeyringStateListener = new WeakMap(), _KeyringController_instances = new WeakSet(), _KeyringController_registerMessageHandlers = function _KeyringController_registerMessageHandlers() {
1042
1075
  this.messagingSystem.registerActionHandler(`${name}:signMessage`, this.signMessage.bind(this));
1043
1076
  this.messagingSystem.registerActionHandler(`${name}:signPersonalMessage`, this.signPersonalMessage.bind(this));
1044
1077
  this.messagingSystem.registerActionHandler(`${name}:signTypedMessage`, this.signTypedMessage.bind(this));
@@ -1052,6 +1085,9 @@ _KeyringController_controllerOperationMutex = new WeakMap(), _KeyringController_
1052
1085
  this.messagingSystem.registerActionHandler(`${name}:patchUserOperation`, this.patchUserOperation.bind(this));
1053
1086
  this.messagingSystem.registerActionHandler(`${name}:signUserOperation`, this.signUserOperation.bind(this));
1054
1087
  this.messagingSystem.registerActionHandler(`${name}:addNewAccount`, this.addNewAccount.bind(this));
1088
+ }, _KeyringController_getKeyringById = function _KeyringController_getKeyringById(keyringId) {
1089
+ const index = this.state.keyringsMetadata.findIndex((metadata) => metadata.id === keyringId);
1090
+ return __classPrivateFieldGet(this, _KeyringController_keyrings, "f")[index];
1055
1091
  }, _KeyringController_getKeyringBuilderForType = function _KeyringController_getKeyringBuilderForType(type) {
1056
1092
  return __classPrivateFieldGet(this, _KeyringController_keyringBuilders, "f").find((keyringBuilder) => keyringBuilder.type === type);
1057
1093
  }, _KeyringController_addQRKeyring =
@@ -1065,7 +1101,7 @@ _KeyringController_controllerOperationMutex = new WeakMap(), _KeyringController_
1065
1101
  async function _KeyringController_addQRKeyring() {
1066
1102
  __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
1067
1103
  // QRKeyring is not yet compatible with Keyring type from @metamask/utils
1068
- return (await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_newKeyring).call(this, KeyringTypes.qr));
1104
+ return (await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_newKeyring).call(this, KeyringTypes.qr, undefined));
1069
1105
  }, _KeyringController_subscribeToQRKeyringEvents = function _KeyringController_subscribeToQRKeyringEvents(qrKeyring) {
1070
1106
  __classPrivateFieldSet(this, _KeyringController_qrKeyringStateListener, (state) => {
1071
1107
  this.messagingSystem.publish(`${name}:qrKeyringStateChange`, state);
@@ -1110,17 +1146,20 @@ async function _KeyringController_createNewVaultWithKeyring(password, keyring) {
1110
1146
  /**
1111
1147
  * Internal non-exclusive method to verify the seed phrase.
1112
1148
  *
1149
+ * @param keyringId - The id of the keyring to verify the seed phrase for.
1113
1150
  * @returns A promise resolving to the seed phrase as Uint8Array.
1114
1151
  */
1115
- async function _KeyringController_verifySeedPhrase() {
1152
+ async function _KeyringController_verifySeedPhrase(keyringId) {
1116
1153
  __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
1117
- const primaryKeyring = this.getKeyringsByType(KeyringTypes.hd)[0];
1118
- if (!primaryKeyring) {
1154
+ const keyring = keyringId
1155
+ ? __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringById).call(this, keyringId)
1156
+ : this.getKeyringsByType(KeyringTypes.hd)[0];
1157
+ if (!keyring) {
1119
1158
  throw new Error('No HD keyring found.');
1120
1159
  }
1121
- assertHasUint8ArrayMnemonic(primaryKeyring);
1122
- const seedWords = primaryKeyring.mnemonic;
1123
- const accounts = await primaryKeyring.getAccounts();
1160
+ assertHasUint8ArrayMnemonic(keyring);
1161
+ const seedWords = keyring.mnemonic;
1162
+ const accounts = await keyring.getAccounts();
1124
1163
  /* istanbul ignore if */
1125
1164
  if (accounts.length === 0) {
1126
1165
  throw new Error('Cannot verify an empty keyring.');
@@ -1168,7 +1207,7 @@ async function _KeyringController_getUpdatedKeyrings() {
1168
1207
  async function _KeyringController_getSerializedKeyrings({ includeUnsupported } = {
1169
1208
  includeUnsupported: true,
1170
1209
  }) {
1171
- const serializedKeyrings = await Promise.all(__classPrivateFieldGet(this, _KeyringController_keyrings, "f").map(async (keyring) => {
1210
+ const serializedKeyrings = await Promise.all(__classPrivateFieldGet(this, _KeyringController_keyrings, "f").map(async (keyring, index) => {
1172
1211
  const [type, data] = await Promise.all([
1173
1212
  keyring.type,
1174
1213
  keyring.serialize(),
@@ -1190,6 +1229,9 @@ async function _KeyringController_restoreSerializedKeyrings(serializedKeyrings)
1190
1229
  for (const serializedKeyring of serializedKeyrings) {
1191
1230
  await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_restoreKeyring).call(this, serializedKeyring);
1192
1231
  }
1232
+ if (__classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f").length > __classPrivateFieldGet(this, _KeyringController_keyrings, "f").length) {
1233
+ throw new Error(constants_1.KeyringControllerError.KeyringMetadataLengthMismatch);
1234
+ }
1193
1235
  }, _KeyringController_unlockKeyrings =
1194
1236
  /**
1195
1237
  * Unlock Keyrings, decrypting the vault and deserializing all
@@ -1303,10 +1345,14 @@ async function _KeyringController_unlockKeyrings(password, encryptionKey, encryp
1303
1345
  this.update((state) => {
1304
1346
  state.vault = updatedState.vault;
1305
1347
  state.keyrings = updatedKeyrings;
1348
+ state.keyringsMetadata = __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f");
1306
1349
  if (updatedState.encryptionKey) {
1307
1350
  state.encryptionKey = updatedState.encryptionKey;
1308
1351
  state.encryptionSalt = JSON.parse(updatedState.vault).salt;
1309
1352
  }
1353
+ if (updatedKeyrings.length < __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f").length) {
1354
+ throw new Error(constants_1.KeyringControllerError.KeyringMetadataLengthMismatch);
1355
+ }
1310
1356
  });
1311
1357
  return true;
1312
1358
  });
@@ -1342,13 +1388,13 @@ async function _KeyringController_createKeyringWithFirstAccount(type, opts) {
1342
1388
  if (!firstAccount) {
1343
1389
  throw new Error(constants_1.KeyringControllerError.NoFirstAccount);
1344
1390
  }
1391
+ return firstAccount;
1345
1392
  }, _KeyringController_newKeyring =
1346
1393
  /**
1347
1394
  * Instantiate, initialize and return a new keyring of the given `type`,
1348
1395
  * using the given `opts`. The keyring is built using the keyring builder
1349
1396
  * registered for the given `type`.
1350
1397
  *
1351
- *
1352
1398
  * @param type - The type of keyring to add.
1353
1399
  * @param data - The data to restore a previously serialized keyring.
1354
1400
  * @returns The new keyring.
@@ -1356,6 +1402,10 @@ async function _KeyringController_createKeyringWithFirstAccount(type, opts) {
1356
1402
  */
1357
1403
  async function _KeyringController_newKeyring(type, data) {
1358
1404
  __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
1405
+ const newKeyringMetadata = {
1406
+ id: ulid().toString(),
1407
+ name: '',
1408
+ };
1359
1409
  const keyringBuilder = __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringBuilderForType).call(this, type);
1360
1410
  if (!keyringBuilder) {
1361
1411
  throw new Error(`${constants_1.KeyringControllerError.NoKeyringBuilder}. Keyring type: ${type}`);
@@ -1383,6 +1433,10 @@ async function _KeyringController_newKeyring(type, data) {
1383
1433
  __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_subscribeToQRKeyringEvents).call(this, keyring);
1384
1434
  }
1385
1435
  __classPrivateFieldGet(this, _KeyringController_keyrings, "f").push(keyring);
1436
+ if (newKeyringMetadata &&
1437
+ __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f").length < __classPrivateFieldGet(this, _KeyringController_keyrings, "f").length) {
1438
+ __classPrivateFieldSet(this, _KeyringController_keyringsMetadata, [...__classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f"), newKeyringMetadata], "f");
1439
+ }
1386
1440
  return keyring;
1387
1441
  }, _KeyringController_clearKeyrings =
1388
1442
  /**
@@ -1395,6 +1449,10 @@ async function _KeyringController_clearKeyrings() {
1395
1449
  await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_destroyKeyring).call(this, keyring);
1396
1450
  }
1397
1451
  __classPrivateFieldSet(this, _KeyringController_keyrings, [], "f");
1452
+ __classPrivateFieldSet(this, _KeyringController_keyringsMetadata, [], "f");
1453
+ // this.update((state) => {
1454
+ // state.keyringsMetadata = [];
1455
+ // });
1398
1456
  }, _KeyringController_restoreKeyring =
1399
1457
  /**
1400
1458
  * Restore a Keyring from a provided serialized payload.
@@ -1435,19 +1493,22 @@ async function _KeyringController_destroyKeyring(keyring) {
1435
1493
  async function _KeyringController_removeEmptyKeyrings() {
1436
1494
  __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
1437
1495
  const validKeyrings = [];
1496
+ const validKeyringMetadata = [];
1438
1497
  // Since getAccounts returns a Promise
1439
1498
  // We need to wait to hear back form each keyring
1440
1499
  // in order to decide which ones are now valid (accounts.length > 0)
1441
- await Promise.all(__classPrivateFieldGet(this, _KeyringController_keyrings, "f").map(async (keyring) => {
1500
+ await Promise.all(__classPrivateFieldGet(this, _KeyringController_keyrings, "f").map(async (keyring, index) => {
1442
1501
  const accounts = await keyring.getAccounts();
1443
1502
  if (accounts.length > 0) {
1444
1503
  validKeyrings.push(keyring);
1504
+ validKeyringMetadata.push(this.state.keyringsMetadata[index]);
1445
1505
  }
1446
1506
  else {
1447
1507
  await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_destroyKeyring).call(this, keyring);
1448
1508
  }
1449
1509
  }));
1450
1510
  __classPrivateFieldSet(this, _KeyringController_keyrings, validKeyrings, "f");
1511
+ __classPrivateFieldSet(this, _KeyringController_keyringsMetadata, validKeyringMetadata, "f");
1451
1512
  }, _KeyringController_checkForDuplicate =
1452
1513
  /**
1453
1514
  * Checks for duplicate keypairs, using the the first account in the given