@metamask-previews/keyring-controller 19.0.5-preview-958adf52 → 19.0.5-preview-553ac792

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,10 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ### Changed
11
-
12
- - Bump `@metamask/keyring-api"` from `^16.1.0` to `^17.0.0` ([#5280](https://github.com/MetaMask/core/pull/5280))
13
-
14
10
  ## [19.0.5]
15
11
 
16
12
  ### Changed
@@ -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,6 +48,8 @@ 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");
52
54
  const name = 'KeyringController';
53
55
  /**
@@ -115,6 +117,7 @@ const getDefaultKeyringState = () => {
115
117
  return {
116
118
  isUnlocked: false,
117
119
  keyrings: [],
120
+ keyringsMetadata: [],
118
121
  };
119
122
  };
120
123
  exports.getDefaultKeyringState = getDefaultKeyringState;
@@ -246,6 +249,7 @@ class KeyringController extends base_controller_1.BaseController {
246
249
  vault: { persist: true, anonymous: false },
247
250
  isUnlocked: { persist: false, anonymous: true },
248
251
  keyrings: { persist: false, anonymous: false },
252
+ keyringsMetadata: { persist: true, anonymous: false },
249
253
  encryptionKey: { persist: false, anonymous: false },
250
254
  encryptionSalt: { persist: false, anonymous: false },
251
255
  },
@@ -263,6 +267,7 @@ class KeyringController extends base_controller_1.BaseController {
263
267
  _KeyringController_encryptor.set(this, void 0);
264
268
  _KeyringController_cacheEncryptionKey.set(this, void 0);
265
269
  _KeyringController_keyrings.set(this, void 0);
270
+ _KeyringController_keyringsMetadata.set(this, void 0);
266
271
  _KeyringController_password.set(this, void 0);
267
272
  _KeyringController_qrKeyringStateListener.set(this, void 0);
268
273
  __classPrivateFieldSet(this, _KeyringController_keyringBuilders, keyringBuilders
@@ -270,6 +275,7 @@ class KeyringController extends base_controller_1.BaseController {
270
275
  : defaultKeyringBuilders, "f");
271
276
  __classPrivateFieldSet(this, _KeyringController_encryptor, encryptor, "f");
272
277
  __classPrivateFieldSet(this, _KeyringController_keyrings, [], "f");
278
+ __classPrivateFieldSet(this, _KeyringController_keyringsMetadata, state?.keyringsMetadata ?? [], "f");
273
279
  __classPrivateFieldSet(this, _KeyringController_unsupportedKeyrings, [], "f");
274
280
  // This option allows the controller to cache an exported key
275
281
  // for use in decrypting and encrypting data without password
@@ -288,11 +294,11 @@ class KeyringController extends base_controller_1.BaseController {
288
294
  */
289
295
  async addNewAccount(accountCount) {
290
296
  return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_persistOrRollback).call(this, async () => {
291
- const primaryKeyring = this.getKeyringsByType('HD Key Tree')[0];
292
- if (!primaryKeyring) {
297
+ const selectedKeyring = this.getKeyringsByType('HD Key Tree')[0];
298
+ if (!selectedKeyring) {
293
299
  throw new Error('No HD keyring found');
294
300
  }
295
- const oldAccounts = await primaryKeyring.getAccounts();
301
+ const oldAccounts = await selectedKeyring.getAccounts();
296
302
  if (accountCount && oldAccounts.length !== accountCount) {
297
303
  if (accountCount > oldAccounts.length) {
298
304
  throw new Error('Account out of sequence');
@@ -304,7 +310,7 @@ class KeyringController extends base_controller_1.BaseController {
304
310
  }
305
311
  return existingAccount;
306
312
  }
307
- const [addedAccountAddress] = await primaryKeyring.addAccounts(1);
313
+ const [addedAccountAddress] = await selectedKeyring.addAccounts(1);
308
314
  await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_verifySeedPhrase).call(this);
309
315
  return addedAccountAddress;
310
316
  });
@@ -415,12 +421,21 @@ class KeyringController extends base_controller_1.BaseController {
415
421
  * Gets the seed phrase of the HD keyring.
416
422
  *
417
423
  * @param password - Password of the keyring.
424
+ * @param keyringId - The id of the keyring.
418
425
  * @returns Promise resolving to the seed phrase.
419
426
  */
420
- async exportSeedPhrase(password) {
427
+ async exportSeedPhrase(password, keyringId) {
421
428
  await this.verifyPassword(password);
422
- assertHasUint8ArrayMnemonic(__classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0]);
423
- return __classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0].mnemonic;
429
+ if (!keyringId) {
430
+ assertHasUint8ArrayMnemonic(__classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0]);
431
+ return __classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0].mnemonic;
432
+ }
433
+ const selectedKeyring = __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringById).call(this, keyringId);
434
+ if (!selectedKeyring) {
435
+ throw new Error('Keyring not found');
436
+ }
437
+ assertHasUint8ArrayMnemonic(selectedKeyring);
438
+ return selectedKeyring.mnemonic;
424
439
  }
425
440
  /**
426
441
  * Gets the private key from the keyring controlling an address.
@@ -820,10 +835,24 @@ class KeyringController extends base_controller_1.BaseController {
820
835
  /**
821
836
  * Verifies the that the seed phrase restores the current keychain's accounts.
822
837
  *
838
+ * @param keyringId - The id of the keyring to verify.
823
839
  * @returns Promise resolving to the seed phrase as Uint8Array.
824
840
  */
825
- async verifySeedPhrase() {
826
- return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withControllerLock).call(this, async () => __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_verifySeedPhrase).call(this));
841
+ async verifySeedPhrase(keyringId) {
842
+ let keyring;
843
+ if (!keyringId) {
844
+ keyring = __classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0];
845
+ }
846
+ else {
847
+ keyring = __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringById).call(this, keyringId);
848
+ if (keyring.type !== KeyringTypes.hd) {
849
+ throw new Error(constants_1.KeyringControllerError.UnsupportedVerifySeedPhrase);
850
+ }
851
+ }
852
+ if (!keyring) {
853
+ throw new Error(constants_1.KeyringControllerError.NoHdKeyring);
854
+ }
855
+ return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withControllerLock).call(this, async () => __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_verifySeedPhrase).call(this, keyringId));
827
856
  }
828
857
  async withKeyring(selector, operation, options = {
829
858
  createIfMissing: false,
@@ -833,12 +862,15 @@ class KeyringController extends base_controller_1.BaseController {
833
862
  if ('address' in selector) {
834
863
  keyring = (await this.getKeyringForAccount(selector.address));
835
864
  }
836
- else {
865
+ else if ('type' in selector) {
837
866
  keyring = this.getKeyringsByType(selector.type)[selector.index || 0];
838
867
  if (!keyring && options.createIfMissing) {
839
868
  keyring = (await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_newKeyring).call(this, selector.type, options.createWithData));
840
869
  }
841
870
  }
871
+ else if ('id' in selector) {
872
+ keyring = __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringById).call(this, selector.id);
873
+ }
842
874
  if (!keyring) {
843
875
  throw new Error(constants_1.KeyringControllerError.KeyringNotFound);
844
876
  }
@@ -1038,7 +1070,7 @@ class KeyringController extends base_controller_1.BaseController {
1038
1070
  }
1039
1071
  }
1040
1072
  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() {
1073
+ _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
1074
  this.messagingSystem.registerActionHandler(`${name}:signMessage`, this.signMessage.bind(this));
1043
1075
  this.messagingSystem.registerActionHandler(`${name}:signPersonalMessage`, this.signPersonalMessage.bind(this));
1044
1076
  this.messagingSystem.registerActionHandler(`${name}:signTypedMessage`, this.signTypedMessage.bind(this));
@@ -1052,6 +1084,9 @@ _KeyringController_controllerOperationMutex = new WeakMap(), _KeyringController_
1052
1084
  this.messagingSystem.registerActionHandler(`${name}:patchUserOperation`, this.patchUserOperation.bind(this));
1053
1085
  this.messagingSystem.registerActionHandler(`${name}:signUserOperation`, this.signUserOperation.bind(this));
1054
1086
  this.messagingSystem.registerActionHandler(`${name}:addNewAccount`, this.addNewAccount.bind(this));
1087
+ }, _KeyringController_getKeyringById = function _KeyringController_getKeyringById(keyringId) {
1088
+ const index = this.state.keyringsMetadata.findIndex((metadata) => metadata.id === keyringId);
1089
+ return __classPrivateFieldGet(this, _KeyringController_keyrings, "f")[index];
1055
1090
  }, _KeyringController_getKeyringBuilderForType = function _KeyringController_getKeyringBuilderForType(type) {
1056
1091
  return __classPrivateFieldGet(this, _KeyringController_keyringBuilders, "f").find((keyringBuilder) => keyringBuilder.type === type);
1057
1092
  }, _KeyringController_addQRKeyring =
@@ -1065,7 +1100,7 @@ _KeyringController_controllerOperationMutex = new WeakMap(), _KeyringController_
1065
1100
  async function _KeyringController_addQRKeyring() {
1066
1101
  __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
1067
1102
  // 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));
1103
+ return (await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_newKeyring).call(this, KeyringTypes.qr, undefined));
1069
1104
  }, _KeyringController_subscribeToQRKeyringEvents = function _KeyringController_subscribeToQRKeyringEvents(qrKeyring) {
1070
1105
  __classPrivateFieldSet(this, _KeyringController_qrKeyringStateListener, (state) => {
1071
1106
  this.messagingSystem.publish(`${name}:qrKeyringStateChange`, state);
@@ -1104,23 +1139,28 @@ async function _KeyringController_createNewVaultWithKeyring(password, keyring) {
1104
1139
  });
1105
1140
  __classPrivateFieldSet(this, _KeyringController_password, password, "f");
1106
1141
  await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_clearKeyrings).call(this);
1142
+ __classPrivateFieldSet(this, _KeyringController_keyringsMetadata, [], "f");
1107
1143
  await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_createKeyringWithFirstAccount).call(this, keyring.type, keyring.opts);
1108
1144
  __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_setUnlocked).call(this);
1109
1145
  }, _KeyringController_verifySeedPhrase =
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
+ // This will never going to be undefined because we are checking for it in all of the callers
1158
+ if (!keyring) {
1119
1159
  throw new Error('No HD keyring found.');
1120
1160
  }
1121
- assertHasUint8ArrayMnemonic(primaryKeyring);
1122
- const seedWords = primaryKeyring.mnemonic;
1123
- const accounts = await primaryKeyring.getAccounts();
1161
+ assertHasUint8ArrayMnemonic(keyring);
1162
+ const seedWords = keyring.mnemonic;
1163
+ const accounts = await keyring.getAccounts();
1124
1164
  /* istanbul ignore if */
1125
1165
  if (accounts.length === 0) {
1126
1166
  throw new Error('Cannot verify an empty keyring.');
@@ -1168,7 +1208,7 @@ async function _KeyringController_getUpdatedKeyrings() {
1168
1208
  async function _KeyringController_getSerializedKeyrings({ includeUnsupported } = {
1169
1209
  includeUnsupported: true,
1170
1210
  }) {
1171
- const serializedKeyrings = await Promise.all(__classPrivateFieldGet(this, _KeyringController_keyrings, "f").map(async (keyring) => {
1211
+ const serializedKeyrings = await Promise.all(__classPrivateFieldGet(this, _KeyringController_keyrings, "f").map(async (keyring, index) => {
1172
1212
  const [type, data] = await Promise.all([
1173
1213
  keyring.type,
1174
1214
  keyring.serialize(),
@@ -1303,10 +1343,14 @@ async function _KeyringController_unlockKeyrings(password, encryptionKey, encryp
1303
1343
  this.update((state) => {
1304
1344
  state.vault = updatedState.vault;
1305
1345
  state.keyrings = updatedKeyrings;
1346
+ state.keyringsMetadata = __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f");
1306
1347
  if (updatedState.encryptionKey) {
1307
1348
  state.encryptionKey = updatedState.encryptionKey;
1308
1349
  state.encryptionSalt = JSON.parse(updatedState.vault).salt;
1309
1350
  }
1351
+ if (updatedKeyrings.length < __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f").length) {
1352
+ throw new Error(constants_1.KeyringControllerError.KeyringMetadataLengthMismatch);
1353
+ }
1310
1354
  });
1311
1355
  return true;
1312
1356
  });
@@ -1342,13 +1386,13 @@ async function _KeyringController_createKeyringWithFirstAccount(type, opts) {
1342
1386
  if (!firstAccount) {
1343
1387
  throw new Error(constants_1.KeyringControllerError.NoFirstAccount);
1344
1388
  }
1389
+ return firstAccount;
1345
1390
  }, _KeyringController_newKeyring =
1346
1391
  /**
1347
1392
  * Instantiate, initialize and return a new keyring of the given `type`,
1348
1393
  * using the given `opts`. The keyring is built using the keyring builder
1349
1394
  * registered for the given `type`.
1350
1395
  *
1351
- *
1352
1396
  * @param type - The type of keyring to add.
1353
1397
  * @param data - The data to restore a previously serialized keyring.
1354
1398
  * @returns The new keyring.
@@ -1356,6 +1400,10 @@ async function _KeyringController_createKeyringWithFirstAccount(type, opts) {
1356
1400
  */
1357
1401
  async function _KeyringController_newKeyring(type, data) {
1358
1402
  __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
1403
+ const newKeyringMetadata = {
1404
+ id: (0, ulid_1.ulid)(),
1405
+ name: '',
1406
+ };
1359
1407
  const keyringBuilder = __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringBuilderForType).call(this, type);
1360
1408
  if (!keyringBuilder) {
1361
1409
  throw new Error(`${constants_1.KeyringControllerError.NoKeyringBuilder}. Keyring type: ${type}`);
@@ -1383,6 +1431,10 @@ async function _KeyringController_newKeyring(type, data) {
1383
1431
  __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_subscribeToQRKeyringEvents).call(this, keyring);
1384
1432
  }
1385
1433
  __classPrivateFieldGet(this, _KeyringController_keyrings, "f").push(keyring);
1434
+ if (newKeyringMetadata &&
1435
+ __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f").length < __classPrivateFieldGet(this, _KeyringController_keyrings, "f").length) {
1436
+ __classPrivateFieldSet(this, _KeyringController_keyringsMetadata, [...__classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f"), newKeyringMetadata], "f");
1437
+ }
1386
1438
  return keyring;
1387
1439
  }, _KeyringController_clearKeyrings =
1388
1440
  /**
@@ -1435,19 +1487,22 @@ async function _KeyringController_destroyKeyring(keyring) {
1435
1487
  async function _KeyringController_removeEmptyKeyrings() {
1436
1488
  __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
1437
1489
  const validKeyrings = [];
1490
+ const validKeyringMetadata = [];
1438
1491
  // Since getAccounts returns a Promise
1439
1492
  // We need to wait to hear back form each keyring
1440
1493
  // in order to decide which ones are now valid (accounts.length > 0)
1441
- await Promise.all(__classPrivateFieldGet(this, _KeyringController_keyrings, "f").map(async (keyring) => {
1494
+ await Promise.all(__classPrivateFieldGet(this, _KeyringController_keyrings, "f").map(async (keyring, index) => {
1442
1495
  const accounts = await keyring.getAccounts();
1443
1496
  if (accounts.length > 0) {
1444
1497
  validKeyrings.push(keyring);
1498
+ validKeyringMetadata.push(this.state.keyringsMetadata[index]);
1445
1499
  }
1446
1500
  else {
1447
1501
  await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_destroyKeyring).call(this, keyring);
1448
1502
  }
1449
1503
  }));
1450
1504
  __classPrivateFieldSet(this, _KeyringController_keyrings, validKeyrings, "f");
1505
+ __classPrivateFieldSet(this, _KeyringController_keyringsMetadata, validKeyringMetadata, "f");
1451
1506
  }, _KeyringController_checkForDuplicate =
1452
1507
  /**
1453
1508
  * Checks for duplicate keypairs, using the the first account in the given
@@ -1509,6 +1564,7 @@ async function _KeyringController_withRollback(callback) {
1509
1564
  return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withControllerLock).call(this, async ({ releaseLock }) => {
1510
1565
  const currentSerializedKeyrings = await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getSerializedKeyrings).call(this);
1511
1566
  const currentPassword = __classPrivateFieldGet(this, _KeyringController_password, "f");
1567
+ const currentKeyringsMetadata = __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f");
1512
1568
  try {
1513
1569
  return await callback({ releaseLock });
1514
1570
  }
@@ -1516,6 +1572,7 @@ async function _KeyringController_withRollback(callback) {
1516
1572
  // Keyrings and password are restored to their previous state
1517
1573
  await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_restoreSerializedKeyrings).call(this, currentSerializedKeyrings);
1518
1574
  __classPrivateFieldSet(this, _KeyringController_password, currentPassword, "f");
1575
+ __classPrivateFieldSet(this, _KeyringController_keyringsMetadata, currentKeyringsMetadata, "f");
1519
1576
  throw e;
1520
1577
  }
1521
1578
  });