@metamask-previews/keyring-controller 19.0.5-preview-59b4e66e → 19.0.5-preview-0adfc600

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,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,27 @@ 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
+ console.log('keyrings: ', __classPrivateFieldGet(this, _KeyringController_keyrings, "f"));
848
+ console.log('keyringId: ', keyringId);
849
+ console.log('metadata: ', __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f"));
850
+ keyring = __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringById).call(this, keyringId);
851
+ if (keyring.type !== KeyringTypes.hd) {
852
+ throw new Error(constants_1.KeyringControllerError.UnsupportedVerifySeedPhrase);
853
+ }
854
+ }
855
+ if (!keyring) {
856
+ throw new Error(constants_1.KeyringControllerError.NoHdKeyring);
857
+ }
858
+ return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withControllerLock).call(this, async () => __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_verifySeedPhrase).call(this, keyringId));
827
859
  }
828
860
  async withKeyring(selector, operation, options = {
829
861
  createIfMissing: false,
@@ -833,12 +865,15 @@ class KeyringController extends base_controller_1.BaseController {
833
865
  if ('address' in selector) {
834
866
  keyring = (await this.getKeyringForAccount(selector.address));
835
867
  }
836
- else {
868
+ else if ('type' in selector) {
837
869
  keyring = this.getKeyringsByType(selector.type)[selector.index || 0];
838
870
  if (!keyring && options.createIfMissing) {
839
871
  keyring = (await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_newKeyring).call(this, selector.type, options.createWithData));
840
872
  }
841
873
  }
874
+ else if ('id' in selector) {
875
+ keyring = __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringById).call(this, selector.id);
876
+ }
842
877
  if (!keyring) {
843
878
  throw new Error(constants_1.KeyringControllerError.KeyringNotFound);
844
879
  }
@@ -1038,7 +1073,7 @@ class KeyringController extends base_controller_1.BaseController {
1038
1073
  }
1039
1074
  }
1040
1075
  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() {
1076
+ _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
1077
  this.messagingSystem.registerActionHandler(`${name}:signMessage`, this.signMessage.bind(this));
1043
1078
  this.messagingSystem.registerActionHandler(`${name}:signPersonalMessage`, this.signPersonalMessage.bind(this));
1044
1079
  this.messagingSystem.registerActionHandler(`${name}:signTypedMessage`, this.signTypedMessage.bind(this));
@@ -1052,6 +1087,9 @@ _KeyringController_controllerOperationMutex = new WeakMap(), _KeyringController_
1052
1087
  this.messagingSystem.registerActionHandler(`${name}:patchUserOperation`, this.patchUserOperation.bind(this));
1053
1088
  this.messagingSystem.registerActionHandler(`${name}:signUserOperation`, this.signUserOperation.bind(this));
1054
1089
  this.messagingSystem.registerActionHandler(`${name}:addNewAccount`, this.addNewAccount.bind(this));
1090
+ }, _KeyringController_getKeyringById = function _KeyringController_getKeyringById(keyringId) {
1091
+ const index = this.state.keyringsMetadata.findIndex((metadata) => metadata.id === keyringId);
1092
+ return __classPrivateFieldGet(this, _KeyringController_keyrings, "f")[index];
1055
1093
  }, _KeyringController_getKeyringBuilderForType = function _KeyringController_getKeyringBuilderForType(type) {
1056
1094
  return __classPrivateFieldGet(this, _KeyringController_keyringBuilders, "f").find((keyringBuilder) => keyringBuilder.type === type);
1057
1095
  }, _KeyringController_addQRKeyring =
@@ -1065,7 +1103,7 @@ _KeyringController_controllerOperationMutex = new WeakMap(), _KeyringController_
1065
1103
  async function _KeyringController_addQRKeyring() {
1066
1104
  __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
1067
1105
  // 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));
1106
+ return (await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_newKeyring).call(this, KeyringTypes.qr, undefined));
1069
1107
  }, _KeyringController_subscribeToQRKeyringEvents = function _KeyringController_subscribeToQRKeyringEvents(qrKeyring) {
1070
1108
  __classPrivateFieldSet(this, _KeyringController_qrKeyringStateListener, (state) => {
1071
1109
  this.messagingSystem.publish(`${name}:qrKeyringStateChange`, state);
@@ -1110,17 +1148,21 @@ async function _KeyringController_createNewVaultWithKeyring(password, keyring) {
1110
1148
  /**
1111
1149
  * Internal non-exclusive method to verify the seed phrase.
1112
1150
  *
1151
+ * @param keyringId - The id of the keyring to verify the seed phrase for.
1113
1152
  * @returns A promise resolving to the seed phrase as Uint8Array.
1114
1153
  */
1115
- async function _KeyringController_verifySeedPhrase() {
1154
+ async function _KeyringController_verifySeedPhrase(keyringId) {
1116
1155
  __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
1117
- const primaryKeyring = this.getKeyringsByType(KeyringTypes.hd)[0];
1118
- if (!primaryKeyring) {
1156
+ const keyring = keyringId
1157
+ ? __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringById).call(this, keyringId)
1158
+ : this.getKeyringsByType(KeyringTypes.hd)[0];
1159
+ // This will never going to be undefined because we are checking for it in all of the callers
1160
+ if (!keyring) {
1119
1161
  throw new Error('No HD keyring found.');
1120
1162
  }
1121
- assertHasUint8ArrayMnemonic(primaryKeyring);
1122
- const seedWords = primaryKeyring.mnemonic;
1123
- const accounts = await primaryKeyring.getAccounts();
1163
+ assertHasUint8ArrayMnemonic(keyring);
1164
+ const seedWords = keyring.mnemonic;
1165
+ const accounts = await keyring.getAccounts();
1124
1166
  /* istanbul ignore if */
1125
1167
  if (accounts.length === 0) {
1126
1168
  throw new Error('Cannot verify an empty keyring.');
@@ -1168,7 +1210,7 @@ async function _KeyringController_getUpdatedKeyrings() {
1168
1210
  async function _KeyringController_getSerializedKeyrings({ includeUnsupported } = {
1169
1211
  includeUnsupported: true,
1170
1212
  }) {
1171
- const serializedKeyrings = await Promise.all(__classPrivateFieldGet(this, _KeyringController_keyrings, "f").map(async (keyring) => {
1213
+ const serializedKeyrings = await Promise.all(__classPrivateFieldGet(this, _KeyringController_keyrings, "f").map(async (keyring, index) => {
1172
1214
  const [type, data] = await Promise.all([
1173
1215
  keyring.type,
1174
1216
  keyring.serialize(),
@@ -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: (0, ulid_1.ulid)(),
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
  /**
@@ -1435,19 +1489,22 @@ async function _KeyringController_destroyKeyring(keyring) {
1435
1489
  async function _KeyringController_removeEmptyKeyrings() {
1436
1490
  __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
1437
1491
  const validKeyrings = [];
1492
+ const validKeyringMetadata = [];
1438
1493
  // Since getAccounts returns a Promise
1439
1494
  // We need to wait to hear back form each keyring
1440
1495
  // in order to decide which ones are now valid (accounts.length > 0)
1441
- await Promise.all(__classPrivateFieldGet(this, _KeyringController_keyrings, "f").map(async (keyring) => {
1496
+ await Promise.all(__classPrivateFieldGet(this, _KeyringController_keyrings, "f").map(async (keyring, index) => {
1442
1497
  const accounts = await keyring.getAccounts();
1443
1498
  if (accounts.length > 0) {
1444
1499
  validKeyrings.push(keyring);
1500
+ validKeyringMetadata.push(this.state.keyringsMetadata[index]);
1445
1501
  }
1446
1502
  else {
1447
1503
  await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_destroyKeyring).call(this, keyring);
1448
1504
  }
1449
1505
  }));
1450
1506
  __classPrivateFieldSet(this, _KeyringController_keyrings, validKeyrings, "f");
1507
+ __classPrivateFieldSet(this, _KeyringController_keyringsMetadata, validKeyringMetadata, "f");
1451
1508
  }, _KeyringController_checkForDuplicate =
1452
1509
  /**
1453
1510
  * Checks for duplicate keypairs, using the the first account in the given
@@ -1509,6 +1566,7 @@ async function _KeyringController_withRollback(callback) {
1509
1566
  return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withControllerLock).call(this, async ({ releaseLock }) => {
1510
1567
  const currentSerializedKeyrings = await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getSerializedKeyrings).call(this);
1511
1568
  const currentPassword = __classPrivateFieldGet(this, _KeyringController_password, "f");
1569
+ const currentKeyringsMetadata = __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f");
1512
1570
  try {
1513
1571
  return await callback({ releaseLock });
1514
1572
  }
@@ -1516,6 +1574,7 @@ async function _KeyringController_withRollback(callback) {
1516
1574
  // Keyrings and password are restored to their previous state
1517
1575
  await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_restoreSerializedKeyrings).call(this, currentSerializedKeyrings);
1518
1576
  __classPrivateFieldSet(this, _KeyringController_password, currentPassword, "f");
1577
+ __classPrivateFieldSet(this, _KeyringController_keyringsMetadata, currentKeyringsMetadata, "f");
1519
1578
  throw e;
1520
1579
  }
1521
1580
  });