@metamask-previews/keyring-controller 16.0.0-preview-699063fc → 16.0.0-preview-eb2b1875

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.
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkZGV2QNCGjs = require('./chunk-ZGV2QNCG.js');
6
+ var _chunkNOCGQCUMjs = require('./chunk-NOCGQCUM.js');
7
7
 
8
8
  // src/KeyringController.ts
9
9
  var _util = require('@ethereumjs/util');
@@ -74,6 +74,14 @@ function assertIsExportableKeyEncryptor(encryptor) {
74
74
  throw new Error("KeyringController - The encryptor does not support encryption key export." /* UnsupportedEncryptionKeyExport */);
75
75
  }
76
76
  }
77
+ function assertIsValidPassword(password) {
78
+ if (typeof password !== "string") {
79
+ throw new Error("KeyringController - Password must be of type string." /* WrongPasswordType */);
80
+ }
81
+ if (!password || !password.length) {
82
+ throw new Error("KeyringController - Password cannot be empty." /* InvalidEmptyPassword */);
83
+ }
84
+ }
77
85
  function isSerializedKeyringsArray(array) {
78
86
  return typeof array === "object" && Array.isArray(array) && array.every((value) => value.type && _utils.isValidJson.call(void 0, value.data));
79
87
  }
@@ -81,11 +89,21 @@ async function displayForKeyring(keyring) {
81
89
  const accounts = await keyring.getAccounts();
82
90
  return {
83
91
  type: keyring.type,
84
- // Cast to `Hex[]` here is safe here because `accounts` has no nullish
85
- // values, and `normalize` returns `Hex` unless given a nullish value
86
- accounts: accounts.map(_ethsigutil.normalize)
92
+ // Cast to `string[]` here is safe here because `accounts` has no nullish
93
+ // values, and `normalize` returns `string` unless given a nullish value
94
+ accounts: accounts.map(normalize)
87
95
  };
88
96
  }
97
+ function isEthAddress(address) {
98
+ return (
99
+ // NOTE: This function only checks for lowercased strings
100
+ _utils.isStrictHexString.call(void 0, address.toLowerCase()) && // This checks for lowercased addresses and checksum addresses too
101
+ _utils.isValidHexAddress.call(void 0, address)
102
+ );
103
+ }
104
+ function normalize(address) {
105
+ return isEthAddress(address) ? _ethsigutil.normalize.call(void 0, address) : address;
106
+ }
89
107
  var _controllerOperationMutex, _vaultOperationMutex, _keyringBuilders, _keyrings, _unsupportedKeyrings, _password, _encryptor, _cacheEncryptionKey, _qrKeyringStateListener, _registerMessageHandlers, registerMessageHandlers_fn, _getKeyringBuilderForType, getKeyringBuilderForType_fn, _addQRKeyring, addQRKeyring_fn, _subscribeToQRKeyringEvents, subscribeToQRKeyringEvents_fn, _unsubscribeFromQRKeyringsEvents, unsubscribeFromQRKeyringsEvents_fn, _createNewVaultWithKeyring, createNewVaultWithKeyring_fn, _getUpdatedKeyrings, getUpdatedKeyrings_fn, _getSerializedKeyrings, getSerializedKeyrings_fn, _restoreSerializedKeyrings, restoreSerializedKeyrings_fn, _unlockKeyrings, unlockKeyrings_fn, _updateVault, updateVault_fn, _getAccountsFromKeyrings, getAccountsFromKeyrings_fn, _createKeyringWithFirstAccount, createKeyringWithFirstAccount_fn, _newKeyring, newKeyring_fn, _clearKeyrings, clearKeyrings_fn, _restoreKeyring, restoreKeyring_fn, _destroyKeyring, destroyKeyring_fn, _removeEmptyKeyrings, removeEmptyKeyrings_fn, _checkForDuplicate, checkForDuplicate_fn, _setUnlocked, setUnlocked_fn, _persistOrRollback, persistOrRollback_fn, _withRollback, withRollback_fn, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn, _withControllerLock, withControllerLock_fn, _withVaultLock, withVaultLock_fn;
90
108
  var KeyringController = class extends _basecontroller.BaseController {
91
109
  /**
@@ -124,14 +142,14 @@ var KeyringController = class extends _basecontroller.BaseController {
124
142
  * Constructor helper for registering this controller's messaging system
125
143
  * actions.
126
144
  */
127
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _registerMessageHandlers);
145
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _registerMessageHandlers);
128
146
  /**
129
147
  * Get the keyring builder for the given `type`.
130
148
  *
131
149
  * @param type - The type of keyring to get the builder for.
132
150
  * @returns The keyring builder, or undefined if none exists.
133
151
  */
134
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _getKeyringBuilderForType);
152
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _getKeyringBuilderForType);
135
153
  /**
136
154
  * Add qr hardware keyring.
137
155
  *
@@ -139,15 +157,15 @@ var KeyringController = class extends _basecontroller.BaseController {
139
157
  * @throws If a QRKeyring builder is not provided
140
158
  * when initializing the controller
141
159
  */
142
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _addQRKeyring);
160
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _addQRKeyring);
143
161
  /**
144
162
  * Subscribe to a QRKeyring state change events and
145
163
  * forward them through the messaging system.
146
164
  *
147
165
  * @param qrKeyring - The QRKeyring instance to subscribe to
148
166
  */
149
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _subscribeToQRKeyringEvents);
150
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _unsubscribeFromQRKeyringsEvents);
167
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _subscribeToQRKeyringEvents);
168
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _unsubscribeFromQRKeyringsEvents);
151
169
  /**
152
170
  * Create new vault with an initial keyring
153
171
  *
@@ -162,14 +180,14 @@ var KeyringController = class extends _basecontroller.BaseController {
162
180
  * @param keyring.opts - Optional parameters required to instantiate the keyring.
163
181
  * @returns A promise that resolves to the state.
164
182
  */
165
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _createNewVaultWithKeyring);
183
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _createNewVaultWithKeyring);
166
184
  /**
167
185
  * Get the updated array of each keyring's type and
168
186
  * accounts list.
169
187
  *
170
188
  * @returns A promise resolving to the updated keyrings array.
171
189
  */
172
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _getUpdatedKeyrings);
190
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _getUpdatedKeyrings);
173
191
  /**
174
192
  * Serialize the current array of keyring instances,
175
193
  * including unsupported keyrings by default.
@@ -178,13 +196,13 @@ var KeyringController = class extends _basecontroller.BaseController {
178
196
  * @param options.includeUnsupported - Whether to include unsupported keyrings.
179
197
  * @returns The serialized keyrings.
180
198
  */
181
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _getSerializedKeyrings);
199
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _getSerializedKeyrings);
182
200
  /**
183
201
  * Restore a serialized keyrings array.
184
202
  *
185
203
  * @param serializedKeyrings - The serialized keyrings array.
186
204
  */
187
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _restoreSerializedKeyrings);
205
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _restoreSerializedKeyrings);
188
206
  /**
189
207
  * Unlock Keyrings, decrypting the vault and deserializing all
190
208
  * keyrings contained in it, using a password or an encryption key with salt.
@@ -194,20 +212,20 @@ var KeyringController = class extends _basecontroller.BaseController {
194
212
  * @param encryptionSalt - The salt used to encrypt the vault.
195
213
  * @returns A promise resolving to the deserialized keyrings array.
196
214
  */
197
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _unlockKeyrings);
215
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _unlockKeyrings);
198
216
  /**
199
217
  * Update the vault with the current keyrings.
200
218
  *
201
219
  * @returns A promise resolving to `true` if the operation is successful.
202
220
  */
203
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _updateVault);
221
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _updateVault);
204
222
  /**
205
223
  * Retrieves all the accounts from keyrings instances
206
224
  * that are currently in memory.
207
225
  *
208
226
  * @returns A promise resolving to an array of accounts.
209
227
  */
210
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _getAccountsFromKeyrings);
228
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _getAccountsFromKeyrings);
211
229
  /**
212
230
  * Create a new keyring, ensuring that the first account is
213
231
  * also created.
@@ -216,7 +234,7 @@ var KeyringController = class extends _basecontroller.BaseController {
216
234
  * @param opts - Optional parameters required to instantiate the keyring.
217
235
  * @returns A promise that resolves if the operation is successful.
218
236
  */
219
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _createKeyringWithFirstAccount);
237
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _createKeyringWithFirstAccount);
220
238
  /**
221
239
  * Instantiate, initialize and return a new keyring of the given `type`,
222
240
  * using the given `opts`. The keyring is built using the keyring builder
@@ -228,12 +246,12 @@ var KeyringController = class extends _basecontroller.BaseController {
228
246
  * @returns The new keyring.
229
247
  * @throws If the keyring includes duplicated accounts.
230
248
  */
231
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _newKeyring);
249
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _newKeyring);
232
250
  /**
233
251
  * Remove all managed keyrings, destroying all their
234
252
  * instances in memory.
235
253
  */
236
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _clearKeyrings);
254
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _clearKeyrings);
237
255
  /**
238
256
  * Restore a Keyring from a provided serialized payload.
239
257
  * On success, returns the resulting keyring instance.
@@ -241,7 +259,7 @@ var KeyringController = class extends _basecontroller.BaseController {
241
259
  * @param serialized - The serialized keyring.
242
260
  * @returns The deserialized keyring or undefined if the keyring type is unsupported.
243
261
  */
244
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _restoreKeyring);
262
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _restoreKeyring);
245
263
  /**
246
264
  * Destroy Keyring
247
265
  *
@@ -251,14 +269,14 @@ var KeyringController = class extends _basecontroller.BaseController {
251
269
  *
252
270
  * @param keyring - The keyring to destroy.
253
271
  */
254
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _destroyKeyring);
272
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _destroyKeyring);
255
273
  /**
256
274
  * Remove empty keyrings.
257
275
  *
258
276
  * Loops through the keyrings and removes the ones with empty accounts
259
277
  * (usually after removing the last / only account) from a keyring.
260
278
  */
261
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _removeEmptyKeyrings);
279
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _removeEmptyKeyrings);
262
280
  /**
263
281
  * Checks for duplicate keypairs, using the the first account in the given
264
282
  * array. Rejects if a duplicate is found.
@@ -269,14 +287,14 @@ var KeyringController = class extends _basecontroller.BaseController {
269
287
  * @param newAccountArray - Array of new accounts.
270
288
  * @returns The account, if no duplicate is found.
271
289
  */
272
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _checkForDuplicate);
290
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _checkForDuplicate);
273
291
  /**
274
292
  * Set the `isUnlocked` to true and notify listeners
275
293
  * through the messenger.
276
294
  *
277
295
  * @fires KeyringController:unlock
278
296
  */
279
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _setUnlocked);
297
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _setUnlocked);
280
298
  /**
281
299
  * Execute the given function after acquiring the controller lock
282
300
  * and save the keyrings to state after it, or rollback to their
@@ -285,7 +303,7 @@ var KeyringController = class extends _basecontroller.BaseController {
285
303
  * @param fn - The function to execute.
286
304
  * @returns The result of the function.
287
305
  */
288
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _persistOrRollback);
306
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _persistOrRollback);
289
307
  /**
290
308
  * Execute the given function after acquiring the controller lock
291
309
  * and rollback keyrings and password states in case of error.
@@ -293,13 +311,13 @@ var KeyringController = class extends _basecontroller.BaseController {
293
311
  * @param fn - The function to execute atomically.
294
312
  * @returns The result of the function.
295
313
  */
296
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _withRollback);
314
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _withRollback);
297
315
  /**
298
316
  * Assert that the controller mutex is locked.
299
317
  *
300
318
  * @throws If the controller mutex is not locked.
301
319
  */
302
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _assertControllerMutexIsLocked);
320
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _assertControllerMutexIsLocked);
303
321
  /**
304
322
  * Lock the controller mutex before executing the given function,
305
323
  * and release it after the function is resolved or after an
@@ -312,7 +330,7 @@ var KeyringController = class extends _basecontroller.BaseController {
312
330
  * @param fn - The function to execute while the controller mutex is locked.
313
331
  * @returns The result of the function.
314
332
  */
315
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _withControllerLock);
333
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _withControllerLock);
316
334
  /**
317
335
  * Lock the vault mutex before executing the given function,
318
336
  * and release it after the function is resolved or after an
@@ -324,25 +342,25 @@ var KeyringController = class extends _basecontroller.BaseController {
324
342
  * @param fn - The function to execute while the vault mutex is locked.
325
343
  * @returns The result of the function.
326
344
  */
327
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _withVaultLock);
328
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _controllerOperationMutex, new (0, _asyncmutex.Mutex)());
329
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _vaultOperationMutex, new (0, _asyncmutex.Mutex)());
330
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _keyringBuilders, void 0);
331
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _keyrings, void 0);
332
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _unsupportedKeyrings, void 0);
333
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _password, void 0);
334
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _encryptor, void 0);
335
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _cacheEncryptionKey, void 0);
336
- _chunkZGV2QNCGjs.__privateAdd.call(void 0, this, _qrKeyringStateListener, void 0);
337
- _chunkZGV2QNCGjs.__privateSet.call(void 0, this, _keyringBuilders, keyringBuilders ? defaultKeyringBuilders.concat(keyringBuilders) : defaultKeyringBuilders);
338
- _chunkZGV2QNCGjs.__privateSet.call(void 0, this, _encryptor, encryptor);
339
- _chunkZGV2QNCGjs.__privateSet.call(void 0, this, _keyrings, []);
340
- _chunkZGV2QNCGjs.__privateSet.call(void 0, this, _unsupportedKeyrings, []);
341
- _chunkZGV2QNCGjs.__privateSet.call(void 0, this, _cacheEncryptionKey, Boolean(options.cacheEncryptionKey));
342
- if (_chunkZGV2QNCGjs.__privateGet.call(void 0, this, _cacheEncryptionKey)) {
345
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _withVaultLock);
346
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _controllerOperationMutex, new (0, _asyncmutex.Mutex)());
347
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _vaultOperationMutex, new (0, _asyncmutex.Mutex)());
348
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _keyringBuilders, void 0);
349
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _keyrings, void 0);
350
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _unsupportedKeyrings, void 0);
351
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _password, void 0);
352
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _encryptor, void 0);
353
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _cacheEncryptionKey, void 0);
354
+ _chunkNOCGQCUMjs.__privateAdd.call(void 0, this, _qrKeyringStateListener, void 0);
355
+ _chunkNOCGQCUMjs.__privateSet.call(void 0, this, _keyringBuilders, keyringBuilders ? defaultKeyringBuilders.concat(keyringBuilders) : defaultKeyringBuilders);
356
+ _chunkNOCGQCUMjs.__privateSet.call(void 0, this, _encryptor, encryptor);
357
+ _chunkNOCGQCUMjs.__privateSet.call(void 0, this, _keyrings, []);
358
+ _chunkNOCGQCUMjs.__privateSet.call(void 0, this, _unsupportedKeyrings, []);
359
+ _chunkNOCGQCUMjs.__privateSet.call(void 0, this, _cacheEncryptionKey, Boolean(options.cacheEncryptionKey));
360
+ if (_chunkNOCGQCUMjs.__privateGet.call(void 0, this, _cacheEncryptionKey)) {
343
361
  assertIsExportableKeyEncryptor(encryptor);
344
362
  }
345
- _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _registerMessageHandlers, registerMessageHandlers_fn).call(this);
363
+ _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _registerMessageHandlers, registerMessageHandlers_fn).call(this);
346
364
  }
347
365
  /**
348
366
  * Adds a new account to the default (first) HD seed phrase keyring.
@@ -352,7 +370,7 @@ var KeyringController = class extends _basecontroller.BaseController {
352
370
  * @returns Promise resolving to the added account address.
353
371
  */
354
372
  async addNewAccount(accountCount) {
355
- return _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
373
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
356
374
  const primaryKeyring = this.getKeyringsByType("HD Key Tree")[0];
357
375
  if (!primaryKeyring) {
358
376
  throw new Error("No HD keyring found");
@@ -381,22 +399,23 @@ var KeyringController = class extends _basecontroller.BaseController {
381
399
  * @returns Promise resolving to the added account address
382
400
  */
383
401
  async addNewAccountForKeyring(keyring, accountCount) {
384
- return _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
385
- const oldAccounts = await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _getAccountsFromKeyrings, getAccountsFromKeyrings_fn).call(this);
402
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
403
+ const oldAccounts = await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _getAccountsFromKeyrings, getAccountsFromKeyrings_fn).call(this);
386
404
  if (accountCount && oldAccounts.length !== accountCount) {
387
405
  if (accountCount > oldAccounts.length) {
388
406
  throw new Error("Account out of sequence");
389
407
  }
390
- const existingAccount = oldAccounts[accountCount];
391
- _utils.assertIsStrictHexString.call(void 0, existingAccount);
392
- return existingAccount;
408
+ return oldAccounts[accountCount];
393
409
  }
394
410
  await keyring.addAccounts(1);
395
- const addedAccountAddress = (await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _getAccountsFromKeyrings, getAccountsFromKeyrings_fn).call(this)).find(
411
+ const newAccounts = await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _getAccountsFromKeyrings, getAccountsFromKeyrings_fn).call(this);
412
+ const newAccount = newAccounts.find(
396
413
  (selectedAddress) => !oldAccounts.includes(selectedAddress)
397
414
  );
398
- _utils.assertIsStrictHexString.call(void 0, addedAccountAddress);
399
- return addedAccountAddress;
415
+ if (!newAccount) {
416
+ throw new Error("Could not find new created account");
417
+ }
418
+ return newAccount;
400
419
  });
401
420
  }
402
421
  /**
@@ -405,7 +424,7 @@ var KeyringController = class extends _basecontroller.BaseController {
405
424
  * @returns Promise resolving to the added account address.
406
425
  */
407
426
  async addNewAccountWithoutUpdate() {
408
- return _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
427
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
409
428
  const primaryKeyring = this.getKeyringsByType("HD Key Tree")[0];
410
429
  if (!primaryKeyring) {
411
430
  throw new Error("No HD keyring found");
@@ -425,11 +444,9 @@ var KeyringController = class extends _basecontroller.BaseController {
425
444
  * @returns Promise resolving when the operation ends successfully.
426
445
  */
427
446
  async createNewVaultAndRestore(password, seed) {
428
- return _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
429
- if (!password || !password.length) {
430
- throw new Error("Invalid password");
431
- }
432
- await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _createNewVaultWithKeyring, createNewVaultWithKeyring_fn).call(this, password, {
447
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
448
+ assertIsValidPassword(password);
449
+ await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _createNewVaultWithKeyring, createNewVaultWithKeyring_fn).call(this, password, {
433
450
  type: "HD Key Tree" /* hd */,
434
451
  opts: {
435
452
  mnemonic: seed,
@@ -445,10 +462,10 @@ var KeyringController = class extends _basecontroller.BaseController {
445
462
  * @returns Promise resolving when the operation ends successfully.
446
463
  */
447
464
  async createNewVaultAndKeychain(password) {
448
- return _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
449
- const accounts = await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _getAccountsFromKeyrings, getAccountsFromKeyrings_fn).call(this);
465
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
466
+ const accounts = await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _getAccountsFromKeyrings, getAccountsFromKeyrings_fn).call(this);
450
467
  if (!accounts.length) {
451
- await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _createNewVaultWithKeyring, createNewVaultWithKeyring_fn).call(this, password, {
468
+ await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _createNewVaultWithKeyring, createNewVaultWithKeyring_fn).call(this, password, {
452
469
  type: "HD Key Tree" /* hd */
453
470
  });
454
471
  }
@@ -466,7 +483,7 @@ var KeyringController = class extends _basecontroller.BaseController {
466
483
  if (type === "QR Hardware Wallet Device" /* qr */) {
467
484
  return this.getOrAddQRKeyring();
468
485
  }
469
- return _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _newKeyring, newKeyring_fn).call(this, type, opts));
486
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _newKeyring, newKeyring_fn).call(this, type, opts));
470
487
  }
471
488
  /**
472
489
  * Method to verify a given password validity. Throws an
@@ -478,7 +495,7 @@ var KeyringController = class extends _basecontroller.BaseController {
478
495
  if (!this.state.vault) {
479
496
  throw new Error("KeyringController - Cannot unlock without a previous vault." /* VaultError */);
480
497
  }
481
- await _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _encryptor).decrypt(password, this.state.vault);
498
+ await _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _encryptor).decrypt(password, this.state.vault);
482
499
  }
483
500
  /**
484
501
  * Returns the status of the vault.
@@ -496,8 +513,8 @@ var KeyringController = class extends _basecontroller.BaseController {
496
513
  */
497
514
  async exportSeedPhrase(password) {
498
515
  await this.verifyPassword(password);
499
- assertHasUint8ArrayMnemonic(_chunkZGV2QNCGjs.__privateGet.call(void 0, this, _keyrings)[0]);
500
- return _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _keyrings)[0].mnemonic;
516
+ assertHasUint8ArrayMnemonic(_chunkNOCGQCUMjs.__privateGet.call(void 0, this, _keyrings)[0]);
517
+ return _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _keyrings)[0].mnemonic;
501
518
  }
502
519
  /**
503
520
  * Gets the private key from the keyring controlling an address.
@@ -514,7 +531,7 @@ var KeyringController = class extends _basecontroller.BaseController {
514
531
  if (!keyring.exportAccount) {
515
532
  throw new Error("`KeyringController - The keyring for the current address does not support the method exportAccount" /* UnsupportedExportAccount */);
516
533
  }
517
- return await keyring.exportAccount(_ethsigutil.normalize.call(void 0, address));
534
+ return await keyring.exportAccount(normalize(address));
518
535
  }
519
536
  /**
520
537
  * Returns the public addresses of all accounts from every keyring.
@@ -536,14 +553,14 @@ var KeyringController = class extends _basecontroller.BaseController {
536
553
  * @returns Promise resolving to encyption public key of the `account` if one exists.
537
554
  */
538
555
  async getEncryptionPublicKey(account, opts) {
539
- const normalizedAddress = _ethsigutil.normalize.call(void 0, account);
556
+ const address = _ethsigutil.normalize.call(void 0, account);
540
557
  const keyring = await this.getKeyringForAccount(
541
558
  account
542
559
  );
543
560
  if (!keyring.getEncryptionPublicKey) {
544
561
  throw new Error("KeyringController - The keyring for the current address does not support the method getEncryptionPublicKey." /* UnsupportedGetEncryptionPublicKey */);
545
562
  }
546
- return await keyring.getEncryptionPublicKey(normalizedAddress, opts);
563
+ return await keyring.getEncryptionPublicKey(address, opts);
547
564
  }
548
565
  /**
549
566
  * Attempts to decrypt the provided message parameters.
@@ -574,23 +591,21 @@ var KeyringController = class extends _basecontroller.BaseController {
574
591
  * @returns Promise resolving to keyring of the `account` if one exists.
575
592
  */
576
593
  async getKeyringForAccount(account) {
577
- const hexed = _ethsigutil.normalize.call(void 0, account);
594
+ const address = normalize(account);
578
595
  const candidates = await Promise.all(
579
- _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _keyrings).map(async (keyring) => {
596
+ _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _keyrings).map(async (keyring) => {
580
597
  return Promise.all([keyring, keyring.getAccounts()]);
581
598
  })
582
599
  );
583
600
  const winners = candidates.filter((candidate) => {
584
- const accounts = candidate[1].map(_ethsigutil.normalize);
585
- return accounts.includes(hexed);
601
+ const accounts = candidate[1].map(normalize);
602
+ return accounts.includes(address);
586
603
  });
587
604
  if (winners.length && winners[0]?.length) {
588
605
  return winners[0][0];
589
606
  }
590
607
  let errorInfo = "";
591
- if (!_utils.isValidHexAddress.call(void 0, hexed)) {
592
- errorInfo = "The address passed in is invalid/empty";
593
- } else if (!candidates.length) {
608
+ if (!candidates.length) {
594
609
  errorInfo = "There are no keyrings";
595
610
  } else if (!winners.length) {
596
611
  errorInfo = "There are keyrings, but none match the address";
@@ -609,7 +624,7 @@ var KeyringController = class extends _basecontroller.BaseController {
609
624
  * @returns An array of keyrings of the given type.
610
625
  */
611
626
  getKeyringsByType(type) {
612
- return _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _keyrings).filter((keyring) => keyring.type === type);
627
+ return _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _keyrings).filter((keyring) => keyring.type === type);
613
628
  }
614
629
  /**
615
630
  * Persist all serialized keyrings in the vault.
@@ -619,7 +634,7 @@ var KeyringController = class extends _basecontroller.BaseController {
619
634
  * operation completes.
620
635
  */
621
636
  async persistAllKeyrings() {
622
- return _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => true);
637
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => true);
623
638
  }
624
639
  /**
625
640
  * Imports an account with the specified import strategy.
@@ -630,7 +645,7 @@ var KeyringController = class extends _basecontroller.BaseController {
630
645
  * @returns Promise resolving to the imported account address.
631
646
  */
632
647
  async importAccountWithStrategy(strategy, args) {
633
- return _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
648
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
634
649
  let privateKey;
635
650
  switch (strategy) {
636
651
  case "privateKey":
@@ -664,7 +679,7 @@ var KeyringController = class extends _basecontroller.BaseController {
664
679
  default:
665
680
  throw new Error(`Unexpected import strategy: '${strategy}'`);
666
681
  }
667
- const newKeyring = await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _newKeyring, newKeyring_fn).call(this, "Simple Key Pair" /* simple */, [
682
+ const newKeyring = await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _newKeyring, newKeyring_fn).call(this, "Simple Key Pair" /* simple */, [
668
683
  privateKey
669
684
  ]);
670
685
  const accounts = await newKeyring.getAccounts();
@@ -679,7 +694,7 @@ var KeyringController = class extends _basecontroller.BaseController {
679
694
  * @returns Promise resolving when the account is removed.
680
695
  */
681
696
  async removeAccount(address) {
682
- await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
697
+ await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
683
698
  const keyring = await this.getKeyringForAccount(
684
699
  address
685
700
  );
@@ -689,7 +704,7 @@ var KeyringController = class extends _basecontroller.BaseController {
689
704
  await keyring.removeAccount(address);
690
705
  const accounts = await keyring.getAccounts();
691
706
  if (accounts.length === 0) {
692
- await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _removeEmptyKeyrings, removeEmptyKeyrings_fn).call(this);
707
+ await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _removeEmptyKeyrings, removeEmptyKeyrings_fn).call(this);
693
708
  }
694
709
  });
695
710
  this.messagingSystem.publish(`${name}:accountRemoved`, address);
@@ -700,10 +715,10 @@ var KeyringController = class extends _basecontroller.BaseController {
700
715
  * @returns Promise resolving when the operation completes.
701
716
  */
702
717
  async setLocked() {
703
- return _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _withRollback, withRollback_fn).call(this, async () => {
704
- _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _unsubscribeFromQRKeyringsEvents, unsubscribeFromQRKeyringsEvents_fn).call(this);
705
- _chunkZGV2QNCGjs.__privateSet.call(void 0, this, _password, void 0);
706
- await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _clearKeyrings, clearKeyrings_fn).call(this);
718
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _withRollback, withRollback_fn).call(this, async () => {
719
+ _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _unsubscribeFromQRKeyringsEvents, unsubscribeFromQRKeyringsEvents_fn).call(this);
720
+ _chunkNOCGQCUMjs.__privateSet.call(void 0, this, _password, void 0);
721
+ await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _clearKeyrings, clearKeyrings_fn).call(this);
707
722
  this.update((state) => {
708
723
  state.isUnlocked = false;
709
724
  state.keyrings = [];
@@ -744,7 +759,7 @@ var KeyringController = class extends _basecontroller.BaseController {
744
759
  if (!keyring.signPersonalMessage) {
745
760
  throw new Error("KeyringController - The keyring for the current address does not support the method signPersonalMessage." /* UnsupportedSignPersonalMessage */);
746
761
  }
747
- const normalizedData = _ethsigutil.normalize.call(void 0, messageParams.data);
762
+ const normalizedData = normalize(messageParams.data);
748
763
  return await keyring.signPersonalMessage(address, normalizedData);
749
764
  }
750
765
  /**
@@ -857,6 +872,27 @@ var KeyringController = class extends _basecontroller.BaseController {
857
872
  }
858
873
  return await keyring.signUserOperation(address, userOp, executionContext);
859
874
  }
875
+ /**
876
+ * Changes the password used to encrypt the vault.
877
+ *
878
+ * @param password - The new password.
879
+ * @returns Promise resolving when the operation completes.
880
+ */
881
+ changePassword(password) {
882
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
883
+ if (!this.state.isUnlocked) {
884
+ throw new Error("KeyringController - Cannot persist vault without password and encryption key" /* MissingCredentials */);
885
+ }
886
+ assertIsValidPassword(password);
887
+ _chunkNOCGQCUMjs.__privateSet.call(void 0, this, _password, password);
888
+ if (_chunkNOCGQCUMjs.__privateGet.call(void 0, this, _cacheEncryptionKey)) {
889
+ this.update((state) => {
890
+ delete state.encryptionKey;
891
+ delete state.encryptionSalt;
892
+ });
893
+ }
894
+ });
895
+ }
860
896
  /**
861
897
  * Attempts to decrypt the current vault and load its keyrings,
862
898
  * using the given encryption key and salt.
@@ -866,9 +902,9 @@ var KeyringController = class extends _basecontroller.BaseController {
866
902
  * @returns Promise resolving when the operation completes.
867
903
  */
868
904
  async submitEncryptionKey(encryptionKey, encryptionSalt) {
869
- return _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _withRollback, withRollback_fn).call(this, async () => {
870
- _chunkZGV2QNCGjs.__privateSet.call(void 0, this, _keyrings, await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _unlockKeyrings, unlockKeyrings_fn).call(this, void 0, encryptionKey, encryptionSalt));
871
- _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _setUnlocked, setUnlocked_fn).call(this);
905
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _withRollback, withRollback_fn).call(this, async () => {
906
+ _chunkNOCGQCUMjs.__privateSet.call(void 0, this, _keyrings, await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _unlockKeyrings, unlockKeyrings_fn).call(this, void 0, encryptionKey, encryptionSalt));
907
+ _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _setUnlocked, setUnlocked_fn).call(this);
872
908
  });
873
909
  }
874
910
  /**
@@ -879,9 +915,9 @@ var KeyringController = class extends _basecontroller.BaseController {
879
915
  * @returns Promise resolving when the operation completes.
880
916
  */
881
917
  async submitPassword(password) {
882
- return _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _withRollback, withRollback_fn).call(this, async () => {
883
- _chunkZGV2QNCGjs.__privateSet.call(void 0, this, _keyrings, await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _unlockKeyrings, unlockKeyrings_fn).call(this, password));
884
- _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _setUnlocked, setUnlocked_fn).call(this);
918
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _withRollback, withRollback_fn).call(this, async () => {
919
+ _chunkNOCGQCUMjs.__privateSet.call(void 0, this, _keyrings, await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _unlockKeyrings, unlockKeyrings_fn).call(this, password));
920
+ _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _setUnlocked, setUnlocked_fn).call(this);
885
921
  });
886
922
  }
887
923
  /**
@@ -900,7 +936,7 @@ var KeyringController = class extends _basecontroller.BaseController {
900
936
  if (accounts.length === 0) {
901
937
  throw new Error("Cannot verify an empty keyring.");
902
938
  }
903
- const hdKeyringBuilder = _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _getKeyringBuilderForType, getKeyringBuilderForType_fn).call(this, "HD Key Tree" /* hd */);
939
+ const hdKeyringBuilder = _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _getKeyringBuilderForType, getKeyringBuilderForType_fn).call(this, "HD Key Tree" /* hd */);
904
940
  const hdKeyring = hdKeyringBuilder();
905
941
  await hdKeyring.deserialize({
906
942
  mnemonic: seedWords,
@@ -920,14 +956,14 @@ var KeyringController = class extends _basecontroller.BaseController {
920
956
  async withKeyring(selector, operation, options = {
921
957
  createIfMissing: false
922
958
  }) {
923
- return _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
959
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
924
960
  let keyring;
925
961
  if ("address" in selector) {
926
962
  keyring = await this.getKeyringForAccount(selector.address);
927
963
  } else {
928
964
  keyring = this.getKeyringsByType(selector.type)[selector.index || 0];
929
965
  if (!keyring && options.createIfMissing) {
930
- keyring = await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _newKeyring, newKeyring_fn).call(this, selector.type, options.createWithData);
966
+ keyring = await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _newKeyring, newKeyring_fn).call(this, selector.type, options.createWithData);
931
967
  }
932
968
  }
933
969
  if (!keyring) {
@@ -955,13 +991,13 @@ var KeyringController = class extends _basecontroller.BaseController {
955
991
  * @returns The added keyring
956
992
  */
957
993
  async getOrAddQRKeyring() {
958
- return this.getQRKeyring() || await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _addQRKeyring, addQRKeyring_fn).call(this));
994
+ return this.getQRKeyring() || await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _addQRKeyring, addQRKeyring_fn).call(this));
959
995
  }
960
996
  // TODO: Replace `any` with type
961
997
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
962
998
  async restoreQRKeyring(serialized) {
963
- return _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
964
- const keyring = this.getQRKeyring() || await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _addQRKeyring, addQRKeyring_fn).call(this);
999
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
1000
+ const keyring = this.getQRKeyring() || await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _addQRKeyring, addQRKeyring_fn).call(this);
965
1001
  keyring.deserialize(serialized);
966
1002
  });
967
1003
  }
@@ -990,9 +1026,9 @@ var KeyringController = class extends _basecontroller.BaseController {
990
1026
  (await this.getOrAddQRKeyring()).cancelSync();
991
1027
  }
992
1028
  async connectQRHardware(page) {
993
- return _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
1029
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
994
1030
  try {
995
- const keyring = this.getQRKeyring() || await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _addQRKeyring, addQRKeyring_fn).call(this);
1031
+ const keyring = this.getQRKeyring() || await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _addQRKeyring, addQRKeyring_fn).call(this);
996
1032
  let accounts;
997
1033
  switch (page) {
998
1034
  case -1:
@@ -1016,8 +1052,8 @@ var KeyringController = class extends _basecontroller.BaseController {
1016
1052
  });
1017
1053
  }
1018
1054
  async unlockQRHardwareWalletAccount(index) {
1019
- return _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
1020
- const keyring = this.getQRKeyring() || await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _addQRKeyring, addQRKeyring_fn).call(this);
1055
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
1056
+ const keyring = this.getQRKeyring() || await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _addQRKeyring, addQRKeyring_fn).call(this);
1021
1057
  keyring.setAccountToUnlock(index);
1022
1058
  await keyring.addAccounts(1);
1023
1059
  });
@@ -1029,14 +1065,14 @@ var KeyringController = class extends _basecontroller.BaseController {
1029
1065
  return keyring.type;
1030
1066
  }
1031
1067
  async forgetQRDevice() {
1032
- return _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
1068
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
1033
1069
  const keyring = this.getQRKeyring();
1034
1070
  if (!keyring) {
1035
1071
  return { removedAccounts: [], remainingAccounts: [] };
1036
1072
  }
1037
- const allAccounts = await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _getAccountsFromKeyrings, getAccountsFromKeyrings_fn).call(this);
1073
+ const allAccounts = await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _getAccountsFromKeyrings, getAccountsFromKeyrings_fn).call(this);
1038
1074
  keyring.forgetDevice();
1039
- const remainingAccounts = await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _getAccountsFromKeyrings, getAccountsFromKeyrings_fn).call(this);
1075
+ const remainingAccounts = await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _getAccountsFromKeyrings, getAccountsFromKeyrings_fn).call(this);
1040
1076
  const removedAccounts = allAccounts.filter(
1041
1077
  (address) => !remainingAccounts.includes(address)
1042
1078
  );
@@ -1106,21 +1142,21 @@ registerMessageHandlers_fn = function() {
1106
1142
  };
1107
1143
  _getKeyringBuilderForType = new WeakSet();
1108
1144
  getKeyringBuilderForType_fn = function(type) {
1109
- return _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _keyringBuilders).find(
1145
+ return _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _keyringBuilders).find(
1110
1146
  (keyringBuilder) => keyringBuilder.type === type
1111
1147
  );
1112
1148
  };
1113
1149
  _addQRKeyring = new WeakSet();
1114
1150
  addQRKeyring_fn = async function() {
1115
- _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
1116
- return await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _newKeyring, newKeyring_fn).call(this, "QR Hardware Wallet Device" /* qr */);
1151
+ _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
1152
+ return await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _newKeyring, newKeyring_fn).call(this, "QR Hardware Wallet Device" /* qr */);
1117
1153
  };
1118
1154
  _subscribeToQRKeyringEvents = new WeakSet();
1119
1155
  subscribeToQRKeyringEvents_fn = function(qrKeyring) {
1120
- _chunkZGV2QNCGjs.__privateSet.call(void 0, this, _qrKeyringStateListener, (state) => {
1156
+ _chunkNOCGQCUMjs.__privateSet.call(void 0, this, _qrKeyringStateListener, (state) => {
1121
1157
  this.messagingSystem.publish(`${name}:qrKeyringStateChange`, state);
1122
1158
  });
1123
- qrKeyring.getMemStore().subscribe(_chunkZGV2QNCGjs.__privateGet.call(void 0, this, _qrKeyringStateListener));
1159
+ qrKeyring.getMemStore().subscribe(_chunkNOCGQCUMjs.__privateGet.call(void 0, this, _qrKeyringStateListener));
1124
1160
  };
1125
1161
  _unsubscribeFromQRKeyringsEvents = new WeakSet();
1126
1162
  unsubscribeFromQRKeyringsEvents_fn = function() {
@@ -1128,32 +1164,32 @@ unsubscribeFromQRKeyringsEvents_fn = function() {
1128
1164
  "QR Hardware Wallet Device" /* qr */
1129
1165
  );
1130
1166
  qrKeyrings.forEach((qrKeyring) => {
1131
- if (_chunkZGV2QNCGjs.__privateGet.call(void 0, this, _qrKeyringStateListener)) {
1132
- qrKeyring.getMemStore().unsubscribe(_chunkZGV2QNCGjs.__privateGet.call(void 0, this, _qrKeyringStateListener));
1167
+ if (_chunkNOCGQCUMjs.__privateGet.call(void 0, this, _qrKeyringStateListener)) {
1168
+ qrKeyring.getMemStore().unsubscribe(_chunkNOCGQCUMjs.__privateGet.call(void 0, this, _qrKeyringStateListener));
1133
1169
  }
1134
1170
  });
1135
1171
  };
1136
1172
  _createNewVaultWithKeyring = new WeakSet();
1137
1173
  createNewVaultWithKeyring_fn = async function(password, keyring) {
1138
- _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
1174
+ _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
1139
1175
  if (typeof password !== "string") {
1140
1176
  throw new TypeError("KeyringController - Password must be of type string." /* WrongPasswordType */);
1141
1177
  }
1142
- _chunkZGV2QNCGjs.__privateSet.call(void 0, this, _password, password);
1143
- await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _clearKeyrings, clearKeyrings_fn).call(this);
1144
- await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _createKeyringWithFirstAccount, createKeyringWithFirstAccount_fn).call(this, keyring.type, keyring.opts);
1145
- _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _setUnlocked, setUnlocked_fn).call(this);
1178
+ _chunkNOCGQCUMjs.__privateSet.call(void 0, this, _password, password);
1179
+ await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _clearKeyrings, clearKeyrings_fn).call(this);
1180
+ await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _createKeyringWithFirstAccount, createKeyringWithFirstAccount_fn).call(this, keyring.type, keyring.opts);
1181
+ _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _setUnlocked, setUnlocked_fn).call(this);
1146
1182
  };
1147
1183
  _getUpdatedKeyrings = new WeakSet();
1148
1184
  getUpdatedKeyrings_fn = async function() {
1149
- return Promise.all(_chunkZGV2QNCGjs.__privateGet.call(void 0, this, _keyrings).map(displayForKeyring));
1185
+ return Promise.all(_chunkNOCGQCUMjs.__privateGet.call(void 0, this, _keyrings).map(displayForKeyring));
1150
1186
  };
1151
1187
  _getSerializedKeyrings = new WeakSet();
1152
1188
  getSerializedKeyrings_fn = async function({ includeUnsupported } = {
1153
1189
  includeUnsupported: true
1154
1190
  }) {
1155
1191
  const serializedKeyrings = await Promise.all(
1156
- _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _keyrings).map(async (keyring) => {
1192
+ _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _keyrings).map(async (keyring) => {
1157
1193
  const [type, data] = await Promise.all([
1158
1194
  keyring.type,
1159
1195
  keyring.serialize()
@@ -1162,35 +1198,35 @@ getSerializedKeyrings_fn = async function({ includeUnsupported } = {
1162
1198
  })
1163
1199
  );
1164
1200
  if (includeUnsupported) {
1165
- serializedKeyrings.push(..._chunkZGV2QNCGjs.__privateGet.call(void 0, this, _unsupportedKeyrings));
1201
+ serializedKeyrings.push(..._chunkNOCGQCUMjs.__privateGet.call(void 0, this, _unsupportedKeyrings));
1166
1202
  }
1167
1203
  return serializedKeyrings;
1168
1204
  };
1169
1205
  _restoreSerializedKeyrings = new WeakSet();
1170
1206
  restoreSerializedKeyrings_fn = async function(serializedKeyrings) {
1171
- await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _clearKeyrings, clearKeyrings_fn).call(this);
1207
+ await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _clearKeyrings, clearKeyrings_fn).call(this);
1172
1208
  for (const serializedKeyring of serializedKeyrings) {
1173
- await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _restoreKeyring, restoreKeyring_fn).call(this, serializedKeyring);
1209
+ await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _restoreKeyring, restoreKeyring_fn).call(this, serializedKeyring);
1174
1210
  }
1175
1211
  };
1176
1212
  _unlockKeyrings = new WeakSet();
1177
1213
  unlockKeyrings_fn = async function(password, encryptionKey, encryptionSalt) {
1178
- return _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _withVaultLock, withVaultLock_fn).call(this, async ({ releaseLock }) => {
1214
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _withVaultLock, withVaultLock_fn).call(this, async ({ releaseLock }) => {
1179
1215
  const encryptedVault = this.state.vault;
1180
1216
  if (!encryptedVault) {
1181
1217
  throw new Error("KeyringController - Cannot unlock without a previous vault." /* VaultError */);
1182
1218
  }
1183
1219
  let vault;
1184
1220
  const updatedState = {};
1185
- if (_chunkZGV2QNCGjs.__privateGet.call(void 0, this, _cacheEncryptionKey)) {
1186
- assertIsExportableKeyEncryptor(_chunkZGV2QNCGjs.__privateGet.call(void 0, this, _encryptor));
1221
+ if (_chunkNOCGQCUMjs.__privateGet.call(void 0, this, _cacheEncryptionKey)) {
1222
+ assertIsExportableKeyEncryptor(_chunkNOCGQCUMjs.__privateGet.call(void 0, this, _encryptor));
1187
1223
  if (password) {
1188
- const result = await _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _encryptor).decryptWithDetail(
1224
+ const result = await _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _encryptor).decryptWithDetail(
1189
1225
  password,
1190
1226
  encryptedVault
1191
1227
  );
1192
1228
  vault = result.vault;
1193
- _chunkZGV2QNCGjs.__privateSet.call(void 0, this, _password, password);
1229
+ _chunkNOCGQCUMjs.__privateSet.call(void 0, this, _password, password);
1194
1230
  updatedState.encryptionKey = result.exportedKeyString;
1195
1231
  updatedState.encryptionSalt = result.salt;
1196
1232
  } else {
@@ -1201,8 +1237,8 @@ unlockKeyrings_fn = async function(password, encryptionKey, encryptionSalt) {
1201
1237
  if (typeof encryptionKey !== "string") {
1202
1238
  throw new TypeError("KeyringController - Password must be of type string." /* WrongPasswordType */);
1203
1239
  }
1204
- const key = await _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _encryptor).importKey(encryptionKey);
1205
- vault = await _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _encryptor).decryptWithKey(
1240
+ const key = await _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _encryptor).importKey(encryptionKey);
1241
+ vault = await _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _encryptor).decryptWithKey(
1206
1242
  key,
1207
1243
  parsedEncryptedVault
1208
1244
  );
@@ -1213,14 +1249,14 @@ unlockKeyrings_fn = async function(password, encryptionKey, encryptionSalt) {
1213
1249
  if (typeof password !== "string") {
1214
1250
  throw new TypeError("KeyringController - Password must be of type string." /* WrongPasswordType */);
1215
1251
  }
1216
- vault = await _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _encryptor).decrypt(password, encryptedVault);
1217
- _chunkZGV2QNCGjs.__privateSet.call(void 0, this, _password, password);
1252
+ vault = await _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _encryptor).decrypt(password, encryptedVault);
1253
+ _chunkNOCGQCUMjs.__privateSet.call(void 0, this, _password, password);
1218
1254
  }
1219
1255
  if (!isSerializedKeyringsArray(vault)) {
1220
1256
  throw new Error("KeyringController - The decrypted vault has an unexpected shape." /* VaultDataError */);
1221
1257
  }
1222
- await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _restoreSerializedKeyrings, restoreSerializedKeyrings_fn).call(this, vault);
1223
- const updatedKeyrings = await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _getUpdatedKeyrings, getUpdatedKeyrings_fn).call(this);
1258
+ await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _restoreSerializedKeyrings, restoreSerializedKeyrings_fn).call(this, vault);
1259
+ const updatedKeyrings = await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _getUpdatedKeyrings, getUpdatedKeyrings_fn).call(this);
1224
1260
  this.update((state) => {
1225
1261
  state.keyrings = updatedKeyrings;
1226
1262
  if (updatedState.encryptionKey || updatedState.encryptionSalt) {
@@ -1228,56 +1264,54 @@ unlockKeyrings_fn = async function(password, encryptionKey, encryptionSalt) {
1228
1264
  state.encryptionSalt = updatedState.encryptionSalt;
1229
1265
  }
1230
1266
  });
1231
- if (_chunkZGV2QNCGjs.__privateGet.call(void 0, this, _password) && (!_chunkZGV2QNCGjs.__privateGet.call(void 0, this, _cacheEncryptionKey) || !encryptionKey) && _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _encryptor).isVaultUpdated && !_chunkZGV2QNCGjs.__privateGet.call(void 0, this, _encryptor).isVaultUpdated(encryptedVault)) {
1267
+ if (_chunkNOCGQCUMjs.__privateGet.call(void 0, this, _password) && (!_chunkNOCGQCUMjs.__privateGet.call(void 0, this, _cacheEncryptionKey) || !encryptionKey) && _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _encryptor).isVaultUpdated && !_chunkNOCGQCUMjs.__privateGet.call(void 0, this, _encryptor).isVaultUpdated(encryptedVault)) {
1232
1268
  releaseLock();
1233
- await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _updateVault, updateVault_fn).call(this);
1269
+ await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _updateVault, updateVault_fn).call(this);
1234
1270
  }
1235
- return _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _keyrings);
1271
+ return _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _keyrings);
1236
1272
  });
1237
1273
  };
1238
1274
  _updateVault = new WeakSet();
1239
1275
  updateVault_fn = function() {
1240
- return _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _withVaultLock, withVaultLock_fn).call(this, async () => {
1276
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _withVaultLock, withVaultLock_fn).call(this, async () => {
1241
1277
  const { encryptionKey, encryptionSalt } = this.state;
1242
- if (!_chunkZGV2QNCGjs.__privateGet.call(void 0, this, _password) && !encryptionKey) {
1278
+ if (!_chunkNOCGQCUMjs.__privateGet.call(void 0, this, _password) && !encryptionKey) {
1243
1279
  throw new Error("KeyringController - Cannot persist vault without password and encryption key" /* MissingCredentials */);
1244
1280
  }
1245
- const serializedKeyrings = await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _getSerializedKeyrings, getSerializedKeyrings_fn).call(this);
1281
+ const serializedKeyrings = await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _getSerializedKeyrings, getSerializedKeyrings_fn).call(this);
1246
1282
  if (!serializedKeyrings.some((keyring) => keyring.type === "HD Key Tree" /* hd */)) {
1247
1283
  throw new Error("KeyringController - No HD Keyring found" /* NoHdKeyring */);
1248
1284
  }
1249
1285
  const updatedState = {};
1250
- if (_chunkZGV2QNCGjs.__privateGet.call(void 0, this, _cacheEncryptionKey)) {
1251
- assertIsExportableKeyEncryptor(_chunkZGV2QNCGjs.__privateGet.call(void 0, this, _encryptor));
1286
+ if (_chunkNOCGQCUMjs.__privateGet.call(void 0, this, _cacheEncryptionKey)) {
1287
+ assertIsExportableKeyEncryptor(_chunkNOCGQCUMjs.__privateGet.call(void 0, this, _encryptor));
1252
1288
  if (encryptionKey) {
1253
- const key = await _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _encryptor).importKey(encryptionKey);
1254
- const vaultJSON = await _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _encryptor).encryptWithKey(
1289
+ const key = await _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _encryptor).importKey(encryptionKey);
1290
+ const vaultJSON = await _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _encryptor).encryptWithKey(
1255
1291
  key,
1256
1292
  serializedKeyrings
1257
1293
  );
1258
1294
  vaultJSON.salt = encryptionSalt;
1259
1295
  updatedState.vault = JSON.stringify(vaultJSON);
1260
- } else if (_chunkZGV2QNCGjs.__privateGet.call(void 0, this, _password)) {
1261
- const { vault: newVault, exportedKeyString } = await _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _encryptor).encryptWithDetail(
1262
- _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _password),
1296
+ } else if (_chunkNOCGQCUMjs.__privateGet.call(void 0, this, _password)) {
1297
+ const { vault: newVault, exportedKeyString } = await _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _encryptor).encryptWithDetail(
1298
+ _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _password),
1263
1299
  serializedKeyrings
1264
1300
  );
1265
1301
  updatedState.vault = newVault;
1266
1302
  updatedState.encryptionKey = exportedKeyString;
1267
1303
  }
1268
1304
  } else {
1269
- if (typeof _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _password) !== "string") {
1270
- throw new TypeError("KeyringController - Password must be of type string." /* WrongPasswordType */);
1271
- }
1272
- updatedState.vault = await _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _encryptor).encrypt(
1273
- _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _password),
1305
+ assertIsValidPassword(_chunkNOCGQCUMjs.__privateGet.call(void 0, this, _password));
1306
+ updatedState.vault = await _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _encryptor).encrypt(
1307
+ _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _password),
1274
1308
  serializedKeyrings
1275
1309
  );
1276
1310
  }
1277
1311
  if (!updatedState.vault) {
1278
1312
  throw new Error("KeyringController - Cannot persist vault without vault information" /* MissingVaultData */);
1279
1313
  }
1280
- const updatedKeyrings = await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _getUpdatedKeyrings, getUpdatedKeyrings_fn).call(this);
1314
+ const updatedKeyrings = await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _getUpdatedKeyrings, getUpdatedKeyrings_fn).call(this);
1281
1315
  this.update((state) => {
1282
1316
  state.vault = updatedState.vault;
1283
1317
  state.keyrings = updatedKeyrings;
@@ -1291,19 +1325,19 @@ updateVault_fn = function() {
1291
1325
  };
1292
1326
  _getAccountsFromKeyrings = new WeakSet();
1293
1327
  getAccountsFromKeyrings_fn = async function() {
1294
- const keyrings = _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _keyrings);
1328
+ const keyrings = _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _keyrings);
1295
1329
  const keyringArrays = await Promise.all(
1296
1330
  keyrings.map(async (keyring) => keyring.getAccounts())
1297
1331
  );
1298
1332
  const addresses = keyringArrays.reduce((res, arr) => {
1299
1333
  return res.concat(arr);
1300
1334
  }, []);
1301
- return addresses.map(_ethsigutil.normalize);
1335
+ return addresses.map(normalize);
1302
1336
  };
1303
1337
  _createKeyringWithFirstAccount = new WeakSet();
1304
1338
  createKeyringWithFirstAccount_fn = async function(type, opts) {
1305
- _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
1306
- const keyring = await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _newKeyring, newKeyring_fn).call(this, type, opts);
1339
+ _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
1340
+ const keyring = await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _newKeyring, newKeyring_fn).call(this, type, opts);
1307
1341
  const [firstAccount] = await keyring.getAccounts();
1308
1342
  if (!firstAccount) {
1309
1343
  throw new Error("KeyringController - First Account not found." /* NoFirstAccount */);
@@ -1311,8 +1345,8 @@ createKeyringWithFirstAccount_fn = async function(type, opts) {
1311
1345
  };
1312
1346
  _newKeyring = new WeakSet();
1313
1347
  newKeyring_fn = async function(type, data) {
1314
- _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
1315
- const keyringBuilder = _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _getKeyringBuilderForType, getKeyringBuilderForType_fn).call(this, type);
1348
+ _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
1349
+ const keyringBuilder = _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _getKeyringBuilderForType, getKeyringBuilderForType_fn).call(this, type);
1316
1350
  if (!keyringBuilder) {
1317
1351
  throw new Error(
1318
1352
  `${"KeyringController - No keyringBuilder found for keyring" /* NoKeyringBuilder */}. Keyring type: ${type}`
@@ -1332,29 +1366,29 @@ newKeyring_fn = async function(type, data) {
1332
1366
  keyring.generateRandomMnemonic();
1333
1367
  await keyring.addAccounts(1);
1334
1368
  }
1335
- await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _checkForDuplicate, checkForDuplicate_fn).call(this, type, await keyring.getAccounts());
1369
+ await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _checkForDuplicate, checkForDuplicate_fn).call(this, type, await keyring.getAccounts());
1336
1370
  if (type === "QR Hardware Wallet Device" /* qr */) {
1337
- _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _subscribeToQRKeyringEvents, subscribeToQRKeyringEvents_fn).call(this, keyring);
1371
+ _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _subscribeToQRKeyringEvents, subscribeToQRKeyringEvents_fn).call(this, keyring);
1338
1372
  }
1339
- _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _keyrings).push(keyring);
1373
+ _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _keyrings).push(keyring);
1340
1374
  return keyring;
1341
1375
  };
1342
1376
  _clearKeyrings = new WeakSet();
1343
1377
  clearKeyrings_fn = async function() {
1344
- _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
1345
- for (const keyring of _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _keyrings)) {
1346
- await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _destroyKeyring, destroyKeyring_fn).call(this, keyring);
1378
+ _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
1379
+ for (const keyring of _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _keyrings)) {
1380
+ await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _destroyKeyring, destroyKeyring_fn).call(this, keyring);
1347
1381
  }
1348
- _chunkZGV2QNCGjs.__privateSet.call(void 0, this, _keyrings, []);
1382
+ _chunkNOCGQCUMjs.__privateSet.call(void 0, this, _keyrings, []);
1349
1383
  };
1350
1384
  _restoreKeyring = new WeakSet();
1351
1385
  restoreKeyring_fn = async function(serialized) {
1352
- _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
1386
+ _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
1353
1387
  try {
1354
1388
  const { type, data } = serialized;
1355
- return await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _newKeyring, newKeyring_fn).call(this, type, data);
1389
+ return await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _newKeyring, newKeyring_fn).call(this, type, data);
1356
1390
  } catch (_) {
1357
- _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _unsupportedKeyrings).push(serialized);
1391
+ _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _unsupportedKeyrings).push(serialized);
1358
1392
  return void 0;
1359
1393
  }
1360
1394
  };
@@ -1364,23 +1398,23 @@ destroyKeyring_fn = async function(keyring) {
1364
1398
  };
1365
1399
  _removeEmptyKeyrings = new WeakSet();
1366
1400
  removeEmptyKeyrings_fn = async function() {
1367
- _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
1401
+ _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
1368
1402
  const validKeyrings = [];
1369
1403
  await Promise.all(
1370
- _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _keyrings).map(async (keyring) => {
1404
+ _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _keyrings).map(async (keyring) => {
1371
1405
  const accounts = await keyring.getAccounts();
1372
1406
  if (accounts.length > 0) {
1373
1407
  validKeyrings.push(keyring);
1374
1408
  } else {
1375
- await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _destroyKeyring, destroyKeyring_fn).call(this, keyring);
1409
+ await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _destroyKeyring, destroyKeyring_fn).call(this, keyring);
1376
1410
  }
1377
1411
  })
1378
1412
  );
1379
- _chunkZGV2QNCGjs.__privateSet.call(void 0, this, _keyrings, validKeyrings);
1413
+ _chunkNOCGQCUMjs.__privateSet.call(void 0, this, _keyrings, validKeyrings);
1380
1414
  };
1381
1415
  _checkForDuplicate = new WeakSet();
1382
1416
  checkForDuplicate_fn = async function(type, newAccountArray) {
1383
- const accounts = await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _getAccountsFromKeyrings, getAccountsFromKeyrings_fn).call(this);
1417
+ const accounts = await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _getAccountsFromKeyrings, getAccountsFromKeyrings_fn).call(this);
1384
1418
  switch (type) {
1385
1419
  case "Simple Key Pair" /* simple */: {
1386
1420
  const isIncluded = Boolean(
@@ -1400,7 +1434,7 @@ checkForDuplicate_fn = async function(type, newAccountArray) {
1400
1434
  };
1401
1435
  _setUnlocked = new WeakSet();
1402
1436
  setUnlocked_fn = function() {
1403
- _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
1437
+ _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
1404
1438
  this.update((state) => {
1405
1439
  state.isUnlocked = true;
1406
1440
  });
@@ -1408,40 +1442,40 @@ setUnlocked_fn = function() {
1408
1442
  };
1409
1443
  _persistOrRollback = new WeakSet();
1410
1444
  persistOrRollback_fn = async function(fn) {
1411
- return _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _withRollback, withRollback_fn).call(this, async ({ releaseLock }) => {
1445
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _withRollback, withRollback_fn).call(this, async ({ releaseLock }) => {
1412
1446
  const callbackResult = await fn({ releaseLock });
1413
- await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _updateVault, updateVault_fn).call(this);
1447
+ await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _updateVault, updateVault_fn).call(this);
1414
1448
  return callbackResult;
1415
1449
  });
1416
1450
  };
1417
1451
  _withRollback = new WeakSet();
1418
1452
  withRollback_fn = async function(fn) {
1419
- return _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _withControllerLock, withControllerLock_fn).call(this, async ({ releaseLock }) => {
1420
- const currentSerializedKeyrings = await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _getSerializedKeyrings, getSerializedKeyrings_fn).call(this);
1421
- const currentPassword = _chunkZGV2QNCGjs.__privateGet.call(void 0, this, _password);
1453
+ return _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _withControllerLock, withControllerLock_fn).call(this, async ({ releaseLock }) => {
1454
+ const currentSerializedKeyrings = await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _getSerializedKeyrings, getSerializedKeyrings_fn).call(this);
1455
+ const currentPassword = _chunkNOCGQCUMjs.__privateGet.call(void 0, this, _password);
1422
1456
  try {
1423
1457
  return await fn({ releaseLock });
1424
1458
  } catch (e) {
1425
- await _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _restoreSerializedKeyrings, restoreSerializedKeyrings_fn).call(this, currentSerializedKeyrings);
1426
- _chunkZGV2QNCGjs.__privateSet.call(void 0, this, _password, currentPassword);
1459
+ await _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _restoreSerializedKeyrings, restoreSerializedKeyrings_fn).call(this, currentSerializedKeyrings);
1460
+ _chunkNOCGQCUMjs.__privateSet.call(void 0, this, _password, currentPassword);
1427
1461
  throw e;
1428
1462
  }
1429
1463
  });
1430
1464
  };
1431
1465
  _assertControllerMutexIsLocked = new WeakSet();
1432
1466
  assertControllerMutexIsLocked_fn = function() {
1433
- if (!_chunkZGV2QNCGjs.__privateGet.call(void 0, this, _controllerOperationMutex).isLocked()) {
1467
+ if (!_chunkNOCGQCUMjs.__privateGet.call(void 0, this, _controllerOperationMutex).isLocked()) {
1434
1468
  throw new Error("KeyringController - attempt to update vault during a non mutually exclusive operation" /* ControllerLockRequired */);
1435
1469
  }
1436
1470
  };
1437
1471
  _withControllerLock = new WeakSet();
1438
1472
  withControllerLock_fn = async function(fn) {
1439
- return withLock(_chunkZGV2QNCGjs.__privateGet.call(void 0, this, _controllerOperationMutex), fn);
1473
+ return withLock(_chunkNOCGQCUMjs.__privateGet.call(void 0, this, _controllerOperationMutex), fn);
1440
1474
  };
1441
1475
  _withVaultLock = new WeakSet();
1442
1476
  withVaultLock_fn = async function(fn) {
1443
- _chunkZGV2QNCGjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
1444
- return withLock(_chunkZGV2QNCGjs.__privateGet.call(void 0, this, _vaultOperationMutex), fn);
1477
+ _chunkNOCGQCUMjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
1478
+ return withLock(_chunkNOCGQCUMjs.__privateGet.call(void 0, this, _vaultOperationMutex), fn);
1445
1479
  };
1446
1480
  async function withLock(mutex, fn) {
1447
1481
  const releaseLock = await mutex.acquire();
@@ -1463,4 +1497,4 @@ var KeyringController_default = KeyringController;
1463
1497
 
1464
1498
 
1465
1499
  exports.KeyringTypes = KeyringTypes; exports.isCustodyKeyring = isCustodyKeyring; exports.AccountImportStrategy = AccountImportStrategy; exports.SignTypedDataVersion = SignTypedDataVersion; exports.keyringBuilderFactory = keyringBuilderFactory; exports.getDefaultKeyringState = getDefaultKeyringState; exports.KeyringController = KeyringController; exports.KeyringController_default = KeyringController_default;
1466
- //# sourceMappingURL=chunk-7SZS2WCD.js.map
1500
+ //# sourceMappingURL=chunk-MQE27VFX.js.map