@metamask-previews/keyring-controller 15.0.0-preview-61ace68c → 15.0.0-preview-cb17e99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/KeyringController.js +2 -2
- package/dist/KeyringController.mjs +1 -1
- package/dist/{chunk-RVCG63UG.mjs → chunk-5VBIIMC6.mjs} +112 -74
- package/dist/chunk-5VBIIMC6.mjs.map +1 -0
- package/dist/{chunk-ISACMNF3.js → chunk-H4OUA6YG.js} +112 -74
- package/dist/chunk-H4OUA6YG.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/KeyringController.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-ISACMNF3.js.map +0 -1
- package/dist/chunk-RVCG63UG.mjs.map +0 -1
|
@@ -86,7 +86,7 @@ async function displayForKeyring(keyring) {
|
|
|
86
86
|
accounts: accounts.map(_ethsigutil.normalize)
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
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, _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, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn, _withControllerLock, withControllerLock_fn, _withVaultLock, withVaultLock_fn;
|
|
89
|
+
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
90
|
var KeyringController = class extends _basecontroller.BaseController {
|
|
91
91
|
/**
|
|
92
92
|
* Creates a KeyringController instance.
|
|
@@ -170,6 +170,21 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
170
170
|
* @returns A promise resolving to the updated keyrings array.
|
|
171
171
|
*/
|
|
172
172
|
_chunkQDPHKQONjs.__privateAdd.call(void 0, this, _getUpdatedKeyrings);
|
|
173
|
+
/**
|
|
174
|
+
* Serialize the current array of keyring instances,
|
|
175
|
+
* including unsupported keyrings by default.
|
|
176
|
+
*
|
|
177
|
+
* @param options - Method options.
|
|
178
|
+
* @param options.includeUnsupported - Whether to include unsupported keyrings.
|
|
179
|
+
* @returns The serialized keyrings.
|
|
180
|
+
*/
|
|
181
|
+
_chunkQDPHKQONjs.__privateAdd.call(void 0, this, _getSerializedKeyrings);
|
|
182
|
+
/**
|
|
183
|
+
* Restore a serialized keyrings array.
|
|
184
|
+
*
|
|
185
|
+
* @param serializedKeyrings - The serialized keyrings array.
|
|
186
|
+
*/
|
|
187
|
+
_chunkQDPHKQONjs.__privateAdd.call(void 0, this, _restoreSerializedKeyrings);
|
|
173
188
|
/**
|
|
174
189
|
* Unlock Keyrings, decrypting the vault and deserializing all
|
|
175
190
|
* keyrings contained in it, using a password or an encryption key with salt.
|
|
@@ -210,7 +225,6 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
210
225
|
*
|
|
211
226
|
* @param type - The type of keyring to add.
|
|
212
227
|
* @param data - The data to restore a previously serialized keyring.
|
|
213
|
-
* @param persist - Whether to persist the keyring to the vault.
|
|
214
228
|
* @returns The new keyring.
|
|
215
229
|
* @throws If the keyring includes duplicated accounts.
|
|
216
230
|
*/
|
|
@@ -218,9 +232,6 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
218
232
|
/**
|
|
219
233
|
* Remove all managed keyrings, destroying all their
|
|
220
234
|
* instances in memory.
|
|
221
|
-
*
|
|
222
|
-
* @param options - Operations options.
|
|
223
|
-
* @param options.skipStateUpdate - Whether to skip updating the controller state.
|
|
224
235
|
*/
|
|
225
236
|
_chunkQDPHKQONjs.__privateAdd.call(void 0, this, _clearKeyrings);
|
|
226
237
|
/**
|
|
@@ -266,6 +277,23 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
266
277
|
* @fires KeyringController:unlock
|
|
267
278
|
*/
|
|
268
279
|
_chunkQDPHKQONjs.__privateAdd.call(void 0, this, _setUnlocked);
|
|
280
|
+
/**
|
|
281
|
+
* Execute the given function after acquiring the controller lock
|
|
282
|
+
* and save the keyrings to state after it, or rollback to their
|
|
283
|
+
* previous state in case of error.
|
|
284
|
+
*
|
|
285
|
+
* @param fn - The function to execute.
|
|
286
|
+
* @returns The result of the function.
|
|
287
|
+
*/
|
|
288
|
+
_chunkQDPHKQONjs.__privateAdd.call(void 0, this, _persistOrRollback);
|
|
289
|
+
/**
|
|
290
|
+
* Execute the given function after acquiring the controller lock
|
|
291
|
+
* and rollback keyrings and password states in case of error.
|
|
292
|
+
*
|
|
293
|
+
* @param fn - The function to execute atomically.
|
|
294
|
+
* @returns The result of the function.
|
|
295
|
+
*/
|
|
296
|
+
_chunkQDPHKQONjs.__privateAdd.call(void 0, this, _withRollback);
|
|
269
297
|
/**
|
|
270
298
|
* Assert that the controller mutex is locked.
|
|
271
299
|
*
|
|
@@ -324,7 +352,7 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
324
352
|
* @returns Promise resolving to the added account address.
|
|
325
353
|
*/
|
|
326
354
|
async addNewAccount(accountCount) {
|
|
327
|
-
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this,
|
|
355
|
+
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
|
|
328
356
|
const primaryKeyring = this.getKeyringsByType("HD Key Tree")[0];
|
|
329
357
|
if (!primaryKeyring) {
|
|
330
358
|
throw new Error("No HD keyring found");
|
|
@@ -342,7 +370,6 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
342
370
|
}
|
|
343
371
|
const [addedAccountAddress] = await primaryKeyring.addAccounts(1);
|
|
344
372
|
await this.verifySeedPhrase();
|
|
345
|
-
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _updateVault, updateVault_fn).call(this);
|
|
346
373
|
return addedAccountAddress;
|
|
347
374
|
});
|
|
348
375
|
}
|
|
@@ -354,7 +381,7 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
354
381
|
* @returns Promise resolving to the added account address
|
|
355
382
|
*/
|
|
356
383
|
async addNewAccountForKeyring(keyring, accountCount) {
|
|
357
|
-
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this,
|
|
384
|
+
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
|
|
358
385
|
const oldAccounts = await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _getAccountsFromKeyrings, getAccountsFromKeyrings_fn).call(this);
|
|
359
386
|
if (accountCount && oldAccounts.length !== accountCount) {
|
|
360
387
|
if (accountCount > oldAccounts.length) {
|
|
@@ -365,7 +392,6 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
365
392
|
return existingAccount;
|
|
366
393
|
}
|
|
367
394
|
await keyring.addAccounts(1);
|
|
368
|
-
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _updateVault, updateVault_fn).call(this);
|
|
369
395
|
const addedAccountAddress = (await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _getAccountsFromKeyrings, getAccountsFromKeyrings_fn).call(this)).find(
|
|
370
396
|
(selectedAddress) => !oldAccounts.includes(selectedAddress)
|
|
371
397
|
);
|
|
@@ -379,13 +405,12 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
379
405
|
* @returns Promise resolving to the added account address.
|
|
380
406
|
*/
|
|
381
407
|
async addNewAccountWithoutUpdate() {
|
|
382
|
-
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this,
|
|
408
|
+
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
|
|
383
409
|
const primaryKeyring = this.getKeyringsByType("HD Key Tree")[0];
|
|
384
410
|
if (!primaryKeyring) {
|
|
385
411
|
throw new Error("No HD keyring found");
|
|
386
412
|
}
|
|
387
413
|
const [addedAccountAddress] = await primaryKeyring.addAccounts(1);
|
|
388
|
-
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _updateVault, updateVault_fn).call(this);
|
|
389
414
|
await this.verifySeedPhrase();
|
|
390
415
|
return addedAccountAddress;
|
|
391
416
|
});
|
|
@@ -400,7 +425,7 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
400
425
|
* @returns Promise resolving when the operation ends successfully.
|
|
401
426
|
*/
|
|
402
427
|
async createNewVaultAndRestore(password, seed) {
|
|
403
|
-
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this,
|
|
428
|
+
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
|
|
404
429
|
if (!password || !password.length) {
|
|
405
430
|
throw new Error("Invalid password");
|
|
406
431
|
}
|
|
@@ -420,7 +445,7 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
420
445
|
* @returns Promise resolving when the operation ends successfully.
|
|
421
446
|
*/
|
|
422
447
|
async createNewVaultAndKeychain(password) {
|
|
423
|
-
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this,
|
|
448
|
+
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
|
|
424
449
|
const accounts = await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _getAccountsFromKeyrings, getAccountsFromKeyrings_fn).call(this);
|
|
425
450
|
if (!accounts.length) {
|
|
426
451
|
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _createNewVaultWithKeyring, createNewVaultWithKeyring_fn).call(this, password, {
|
|
@@ -441,7 +466,7 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
441
466
|
if (type === "QR Hardware Wallet Device" /* qr */) {
|
|
442
467
|
return this.getOrAddQRKeyring();
|
|
443
468
|
}
|
|
444
|
-
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this,
|
|
469
|
+
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _newKeyring, newKeyring_fn).call(this, type, opts));
|
|
445
470
|
}
|
|
446
471
|
/**
|
|
447
472
|
* Method to verify a given password validity. Throws an
|
|
@@ -593,7 +618,7 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
593
618
|
* operation completes.
|
|
594
619
|
*/
|
|
595
620
|
async persistAllKeyrings() {
|
|
596
|
-
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this,
|
|
621
|
+
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => true);
|
|
597
622
|
}
|
|
598
623
|
/**
|
|
599
624
|
* Imports an account with the specified import strategy.
|
|
@@ -604,7 +629,7 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
604
629
|
* @returns Promise resolving to the imported account address.
|
|
605
630
|
*/
|
|
606
631
|
async importAccountWithStrategy(strategy, args) {
|
|
607
|
-
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this,
|
|
632
|
+
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
|
|
608
633
|
let privateKey;
|
|
609
634
|
switch (strategy) {
|
|
610
635
|
case "privateKey":
|
|
@@ -638,7 +663,9 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
638
663
|
default:
|
|
639
664
|
throw new Error(`Unexpected import strategy: '${strategy}'`);
|
|
640
665
|
}
|
|
641
|
-
const newKeyring = await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _newKeyring, newKeyring_fn).call(this, "Simple Key Pair" /* simple */, [
|
|
666
|
+
const newKeyring = await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _newKeyring, newKeyring_fn).call(this, "Simple Key Pair" /* simple */, [
|
|
667
|
+
privateKey
|
|
668
|
+
]);
|
|
642
669
|
const accounts = await newKeyring.getAccounts();
|
|
643
670
|
return accounts[0];
|
|
644
671
|
});
|
|
@@ -651,7 +678,7 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
651
678
|
* @returns Promise resolving when the account is removed.
|
|
652
679
|
*/
|
|
653
680
|
async removeAccount(address) {
|
|
654
|
-
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this,
|
|
681
|
+
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
|
|
655
682
|
const keyring = await this.getKeyringForAccount(
|
|
656
683
|
address
|
|
657
684
|
);
|
|
@@ -663,7 +690,6 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
663
690
|
if (accounts.length === 0) {
|
|
664
691
|
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _removeEmptyKeyrings, removeEmptyKeyrings_fn).call(this);
|
|
665
692
|
}
|
|
666
|
-
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _updateVault, updateVault_fn).call(this);
|
|
667
693
|
});
|
|
668
694
|
this.messagingSystem.publish(`${name}:accountRemoved`, address);
|
|
669
695
|
}
|
|
@@ -673,14 +699,14 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
673
699
|
* @returns Promise resolving when the operation completes.
|
|
674
700
|
*/
|
|
675
701
|
async setLocked() {
|
|
676
|
-
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this,
|
|
702
|
+
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _withRollback, withRollback_fn).call(this, async () => {
|
|
677
703
|
_chunkQDPHKQONjs.__privateMethod.call(void 0, this, _unsubscribeFromQRKeyringsEvents, unsubscribeFromQRKeyringsEvents_fn).call(this);
|
|
678
704
|
_chunkQDPHKQONjs.__privateSet.call(void 0, this, _password, void 0);
|
|
705
|
+
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _clearKeyrings, clearKeyrings_fn).call(this);
|
|
679
706
|
this.update((state) => {
|
|
680
707
|
state.isUnlocked = false;
|
|
681
708
|
state.keyrings = [];
|
|
682
709
|
});
|
|
683
|
-
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _clearKeyrings, clearKeyrings_fn).call(this);
|
|
684
710
|
this.messagingSystem.publish(`${name}:lock`);
|
|
685
711
|
});
|
|
686
712
|
}
|
|
@@ -839,13 +865,9 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
839
865
|
* @returns Promise resolving when the operation completes.
|
|
840
866
|
*/
|
|
841
867
|
async submitEncryptionKey(encryptionKey, encryptionSalt) {
|
|
842
|
-
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this,
|
|
868
|
+
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _withRollback, withRollback_fn).call(this, async () => {
|
|
843
869
|
_chunkQDPHKQONjs.__privateSet.call(void 0, this, _keyrings, await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _unlockKeyrings, unlockKeyrings_fn).call(this, void 0, encryptionKey, encryptionSalt));
|
|
844
870
|
_chunkQDPHKQONjs.__privateMethod.call(void 0, this, _setUnlocked, setUnlocked_fn).call(this);
|
|
845
|
-
const qrKeyring = this.getQRKeyring();
|
|
846
|
-
if (qrKeyring) {
|
|
847
|
-
_chunkQDPHKQONjs.__privateMethod.call(void 0, this, _subscribeToQRKeyringEvents, subscribeToQRKeyringEvents_fn).call(this, qrKeyring);
|
|
848
|
-
}
|
|
849
871
|
});
|
|
850
872
|
}
|
|
851
873
|
/**
|
|
@@ -856,13 +878,9 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
856
878
|
* @returns Promise resolving when the operation completes.
|
|
857
879
|
*/
|
|
858
880
|
async submitPassword(password) {
|
|
859
|
-
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this,
|
|
881
|
+
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _withRollback, withRollback_fn).call(this, async () => {
|
|
860
882
|
_chunkQDPHKQONjs.__privateSet.call(void 0, this, _keyrings, await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _unlockKeyrings, unlockKeyrings_fn).call(this, password));
|
|
861
883
|
_chunkQDPHKQONjs.__privateMethod.call(void 0, this, _setUnlocked, setUnlocked_fn).call(this);
|
|
862
|
-
const qrKeyring = this.getQRKeyring();
|
|
863
|
-
if (qrKeyring) {
|
|
864
|
-
_chunkQDPHKQONjs.__privateMethod.call(void 0, this, _subscribeToQRKeyringEvents, subscribeToQRKeyringEvents_fn).call(this, qrKeyring);
|
|
865
|
-
}
|
|
866
884
|
});
|
|
867
885
|
}
|
|
868
886
|
/**
|
|
@@ -913,15 +931,14 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
913
931
|
* @returns The added keyring
|
|
914
932
|
*/
|
|
915
933
|
async getOrAddQRKeyring() {
|
|
916
|
-
return this.getQRKeyring() || await _chunkQDPHKQONjs.__privateMethod.call(void 0, this,
|
|
934
|
+
return this.getQRKeyring() || await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _addQRKeyring, addQRKeyring_fn).call(this));
|
|
917
935
|
}
|
|
918
936
|
// TODO: Replace `any` with type
|
|
919
937
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
920
938
|
async restoreQRKeyring(serialized) {
|
|
921
|
-
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this,
|
|
939
|
+
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
|
|
922
940
|
const keyring = this.getQRKeyring() || await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _addQRKeyring, addQRKeyring_fn).call(this);
|
|
923
941
|
keyring.deserialize(serialized);
|
|
924
|
-
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _updateVault, updateVault_fn).call(this);
|
|
925
942
|
});
|
|
926
943
|
}
|
|
927
944
|
async resetQRKeyringState() {
|
|
@@ -949,7 +966,7 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
949
966
|
(await this.getOrAddQRKeyring()).cancelSync();
|
|
950
967
|
}
|
|
951
968
|
async connectQRHardware(page) {
|
|
952
|
-
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this,
|
|
969
|
+
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
|
|
953
970
|
try {
|
|
954
971
|
const keyring = this.getQRKeyring() || await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _addQRKeyring, addQRKeyring_fn).call(this);
|
|
955
972
|
let accounts;
|
|
@@ -975,11 +992,10 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
975
992
|
});
|
|
976
993
|
}
|
|
977
994
|
async unlockQRHardwareWalletAccount(index) {
|
|
978
|
-
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this,
|
|
995
|
+
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
|
|
979
996
|
const keyring = this.getQRKeyring() || await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _addQRKeyring, addQRKeyring_fn).call(this);
|
|
980
997
|
keyring.setAccountToUnlock(index);
|
|
981
998
|
await keyring.addAccounts(1);
|
|
982
|
-
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _updateVault, updateVault_fn).call(this);
|
|
983
999
|
});
|
|
984
1000
|
}
|
|
985
1001
|
async getAccountKeyringType(account) {
|
|
@@ -989,7 +1005,7 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
989
1005
|
return keyring.type;
|
|
990
1006
|
}
|
|
991
1007
|
async forgetQRDevice() {
|
|
992
|
-
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this,
|
|
1008
|
+
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _persistOrRollback, persistOrRollback_fn).call(this, async () => {
|
|
993
1009
|
const keyring = this.getQRKeyring();
|
|
994
1010
|
if (!keyring) {
|
|
995
1011
|
return { removedAccounts: [], remainingAccounts: [] };
|
|
@@ -1000,7 +1016,6 @@ var KeyringController = class extends _basecontroller.BaseController {
|
|
|
1000
1016
|
const removedAccounts = allAccounts.filter(
|
|
1001
1017
|
(address) => !remainingAccounts.includes(address)
|
|
1002
1018
|
);
|
|
1003
|
-
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _updateVault, updateVault_fn).call(this);
|
|
1004
1019
|
return { removedAccounts, remainingAccounts };
|
|
1005
1020
|
});
|
|
1006
1021
|
}
|
|
@@ -1074,15 +1089,9 @@ getKeyringBuilderForType_fn = function(type) {
|
|
|
1074
1089
|
_addQRKeyring = new WeakSet();
|
|
1075
1090
|
addQRKeyring_fn = async function() {
|
|
1076
1091
|
_chunkQDPHKQONjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
|
|
1077
|
-
|
|
1092
|
+
return await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _newKeyring, newKeyring_fn).call(this, "QR Hardware Wallet Device" /* qr */, {
|
|
1078
1093
|
accounts: []
|
|
1079
1094
|
});
|
|
1080
|
-
const accounts = await qrKeyring.getAccounts();
|
|
1081
|
-
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _checkForDuplicate, checkForDuplicate_fn).call(this, "QR Hardware Wallet Device" /* qr */, accounts);
|
|
1082
|
-
_chunkQDPHKQONjs.__privateGet.call(void 0, this, _keyrings).push(qrKeyring);
|
|
1083
|
-
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _updateVault, updateVault_fn).call(this);
|
|
1084
|
-
_chunkQDPHKQONjs.__privateMethod.call(void 0, this, _subscribeToQRKeyringEvents, subscribeToQRKeyringEvents_fn).call(this, qrKeyring);
|
|
1085
|
-
return qrKeyring;
|
|
1086
1095
|
};
|
|
1087
1096
|
_subscribeToQRKeyringEvents = new WeakSet();
|
|
1088
1097
|
subscribeToQRKeyringEvents_fn = function(qrKeyring) {
|
|
@@ -1117,6 +1126,31 @@ _getUpdatedKeyrings = new WeakSet();
|
|
|
1117
1126
|
getUpdatedKeyrings_fn = async function() {
|
|
1118
1127
|
return Promise.all(_chunkQDPHKQONjs.__privateGet.call(void 0, this, _keyrings).map(displayForKeyring));
|
|
1119
1128
|
};
|
|
1129
|
+
_getSerializedKeyrings = new WeakSet();
|
|
1130
|
+
getSerializedKeyrings_fn = async function({ includeUnsupported } = {
|
|
1131
|
+
includeUnsupported: true
|
|
1132
|
+
}) {
|
|
1133
|
+
const serializedKeyrings = await Promise.all(
|
|
1134
|
+
_chunkQDPHKQONjs.__privateGet.call(void 0, this, _keyrings).map(async (keyring) => {
|
|
1135
|
+
const [type, data] = await Promise.all([
|
|
1136
|
+
keyring.type,
|
|
1137
|
+
keyring.serialize()
|
|
1138
|
+
]);
|
|
1139
|
+
return { type, data };
|
|
1140
|
+
})
|
|
1141
|
+
);
|
|
1142
|
+
if (includeUnsupported) {
|
|
1143
|
+
serializedKeyrings.push(..._chunkQDPHKQONjs.__privateGet.call(void 0, this, _unsupportedKeyrings));
|
|
1144
|
+
}
|
|
1145
|
+
return serializedKeyrings;
|
|
1146
|
+
};
|
|
1147
|
+
_restoreSerializedKeyrings = new WeakSet();
|
|
1148
|
+
restoreSerializedKeyrings_fn = async function(serializedKeyrings) {
|
|
1149
|
+
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _clearKeyrings, clearKeyrings_fn).call(this);
|
|
1150
|
+
for (const serializedKeyring of serializedKeyrings) {
|
|
1151
|
+
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _restoreKeyring, restoreKeyring_fn).call(this, serializedKeyring);
|
|
1152
|
+
}
|
|
1153
|
+
};
|
|
1120
1154
|
_unlockKeyrings = new WeakSet();
|
|
1121
1155
|
unlockKeyrings_fn = async function(password, encryptionKey, encryptionSalt) {
|
|
1122
1156
|
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _withVaultLock, withVaultLock_fn).call(this, async ({ releaseLock }) => {
|
|
@@ -1124,7 +1158,6 @@ unlockKeyrings_fn = async function(password, encryptionKey, encryptionSalt) {
|
|
|
1124
1158
|
if (!encryptedVault) {
|
|
1125
1159
|
throw new Error("KeyringController - Cannot unlock without a previous vault." /* VaultError */);
|
|
1126
1160
|
}
|
|
1127
|
-
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _clearKeyrings, clearKeyrings_fn).call(this, { skipStateUpdate: true });
|
|
1128
1161
|
let vault;
|
|
1129
1162
|
const updatedState = {};
|
|
1130
1163
|
if (_chunkQDPHKQONjs.__privateGet.call(void 0, this, _cacheEncryptionKey)) {
|
|
@@ -1164,7 +1197,7 @@ unlockKeyrings_fn = async function(password, encryptionKey, encryptionSalt) {
|
|
|
1164
1197
|
if (!isSerializedKeyringsArray(vault)) {
|
|
1165
1198
|
throw new Error("KeyringController - The decrypted vault has an unexpected shape." /* VaultDataError */);
|
|
1166
1199
|
}
|
|
1167
|
-
await
|
|
1200
|
+
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _restoreSerializedKeyrings, restoreSerializedKeyrings_fn).call(this, vault);
|
|
1168
1201
|
const updatedKeyrings = await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _getUpdatedKeyrings, getUpdatedKeyrings_fn).call(this);
|
|
1169
1202
|
this.update((state) => {
|
|
1170
1203
|
state.keyrings = updatedKeyrings;
|
|
@@ -1187,16 +1220,7 @@ updateVault_fn = function() {
|
|
|
1187
1220
|
if (!_chunkQDPHKQONjs.__privateGet.call(void 0, this, _password) && !encryptionKey) {
|
|
1188
1221
|
throw new Error("KeyringController - Cannot persist vault without password and encryption key" /* MissingCredentials */);
|
|
1189
1222
|
}
|
|
1190
|
-
const serializedKeyrings = await
|
|
1191
|
-
_chunkQDPHKQONjs.__privateGet.call(void 0, this, _keyrings).map(async (keyring) => {
|
|
1192
|
-
const [type, data] = await Promise.all([
|
|
1193
|
-
keyring.type,
|
|
1194
|
-
keyring.serialize()
|
|
1195
|
-
]);
|
|
1196
|
-
return { type, data };
|
|
1197
|
-
})
|
|
1198
|
-
);
|
|
1199
|
-
serializedKeyrings.push(..._chunkQDPHKQONjs.__privateGet.call(void 0, this, _unsupportedKeyrings));
|
|
1223
|
+
const serializedKeyrings = await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _getSerializedKeyrings, getSerializedKeyrings_fn).call(this);
|
|
1200
1224
|
if (!serializedKeyrings.some((keyring) => keyring.type === "HD Key Tree" /* hd */)) {
|
|
1201
1225
|
throw new Error("KeyringController - No HD Keyring found" /* NoHdKeyring */);
|
|
1202
1226
|
}
|
|
@@ -1257,14 +1281,14 @@ getAccountsFromKeyrings_fn = async function() {
|
|
|
1257
1281
|
_createKeyringWithFirstAccount = new WeakSet();
|
|
1258
1282
|
createKeyringWithFirstAccount_fn = async function(type, opts) {
|
|
1259
1283
|
_chunkQDPHKQONjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
|
|
1260
|
-
const keyring = await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _newKeyring, newKeyring_fn).call(this, type, opts
|
|
1284
|
+
const keyring = await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _newKeyring, newKeyring_fn).call(this, type, opts);
|
|
1261
1285
|
const [firstAccount] = await keyring.getAccounts();
|
|
1262
1286
|
if (!firstAccount) {
|
|
1263
1287
|
throw new Error("KeyringController - First Account not found." /* NoFirstAccount */);
|
|
1264
1288
|
}
|
|
1265
1289
|
};
|
|
1266
1290
|
_newKeyring = new WeakSet();
|
|
1267
|
-
newKeyring_fn = async function(type, data
|
|
1291
|
+
newKeyring_fn = async function(type, data) {
|
|
1268
1292
|
_chunkQDPHKQONjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
|
|
1269
1293
|
const keyringBuilder = _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _getKeyringBuilderForType, getKeyringBuilderForType_fn).call(this, type);
|
|
1270
1294
|
if (!keyringBuilder) {
|
|
@@ -1287,34 +1311,26 @@ newKeyring_fn = async function(type, data, persist = false) {
|
|
|
1287
1311
|
await keyring.addAccounts(1);
|
|
1288
1312
|
}
|
|
1289
1313
|
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _checkForDuplicate, checkForDuplicate_fn).call(this, type, await keyring.getAccounts());
|
|
1290
|
-
if (
|
|
1291
|
-
_chunkQDPHKQONjs.
|
|
1292
|
-
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _updateVault, updateVault_fn).call(this);
|
|
1314
|
+
if (type === "QR Hardware Wallet Device" /* qr */) {
|
|
1315
|
+
_chunkQDPHKQONjs.__privateMethod.call(void 0, this, _subscribeToQRKeyringEvents, subscribeToQRKeyringEvents_fn).call(this, keyring);
|
|
1293
1316
|
}
|
|
1317
|
+
_chunkQDPHKQONjs.__privateGet.call(void 0, this, _keyrings).push(keyring);
|
|
1294
1318
|
return keyring;
|
|
1295
1319
|
};
|
|
1296
1320
|
_clearKeyrings = new WeakSet();
|
|
1297
|
-
clearKeyrings_fn = async function(
|
|
1321
|
+
clearKeyrings_fn = async function() {
|
|
1298
1322
|
_chunkQDPHKQONjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
|
|
1299
1323
|
for (const keyring of _chunkQDPHKQONjs.__privateGet.call(void 0, this, _keyrings)) {
|
|
1300
1324
|
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _destroyKeyring, destroyKeyring_fn).call(this, keyring);
|
|
1301
1325
|
}
|
|
1302
1326
|
_chunkQDPHKQONjs.__privateSet.call(void 0, this, _keyrings, []);
|
|
1303
|
-
if (!options.skipStateUpdate) {
|
|
1304
|
-
this.update((state) => {
|
|
1305
|
-
state.keyrings = [];
|
|
1306
|
-
});
|
|
1307
|
-
}
|
|
1308
1327
|
};
|
|
1309
1328
|
_restoreKeyring = new WeakSet();
|
|
1310
1329
|
restoreKeyring_fn = async function(serialized) {
|
|
1311
1330
|
_chunkQDPHKQONjs.__privateMethod.call(void 0, this, _assertControllerMutexIsLocked, assertControllerMutexIsLocked_fn).call(this);
|
|
1312
1331
|
try {
|
|
1313
1332
|
const { type, data } = serialized;
|
|
1314
|
-
|
|
1315
|
-
await keyring.getAccounts();
|
|
1316
|
-
_chunkQDPHKQONjs.__privateGet.call(void 0, this, _keyrings).push(keyring);
|
|
1317
|
-
return keyring;
|
|
1333
|
+
return await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _newKeyring, newKeyring_fn).call(this, type, data);
|
|
1318
1334
|
} catch (_) {
|
|
1319
1335
|
_chunkQDPHKQONjs.__privateGet.call(void 0, this, _unsupportedKeyrings).push(serialized);
|
|
1320
1336
|
return void 0;
|
|
@@ -1368,6 +1384,28 @@ setUnlocked_fn = function() {
|
|
|
1368
1384
|
});
|
|
1369
1385
|
this.messagingSystem.publish(`${name}:unlock`);
|
|
1370
1386
|
};
|
|
1387
|
+
_persistOrRollback = new WeakSet();
|
|
1388
|
+
persistOrRollback_fn = async function(fn) {
|
|
1389
|
+
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _withRollback, withRollback_fn).call(this, async ({ releaseLock }) => {
|
|
1390
|
+
const callbackResult = await fn({ releaseLock });
|
|
1391
|
+
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _updateVault, updateVault_fn).call(this);
|
|
1392
|
+
return callbackResult;
|
|
1393
|
+
});
|
|
1394
|
+
};
|
|
1395
|
+
_withRollback = new WeakSet();
|
|
1396
|
+
withRollback_fn = async function(fn) {
|
|
1397
|
+
return _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _withControllerLock, withControllerLock_fn).call(this, async ({ releaseLock }) => {
|
|
1398
|
+
const currentSerializedKeyrings = await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _getSerializedKeyrings, getSerializedKeyrings_fn).call(this);
|
|
1399
|
+
const currentPassword = _chunkQDPHKQONjs.__privateGet.call(void 0, this, _password);
|
|
1400
|
+
try {
|
|
1401
|
+
return await fn({ releaseLock });
|
|
1402
|
+
} catch (e) {
|
|
1403
|
+
await _chunkQDPHKQONjs.__privateMethod.call(void 0, this, _restoreSerializedKeyrings, restoreSerializedKeyrings_fn).call(this, currentSerializedKeyrings);
|
|
1404
|
+
_chunkQDPHKQONjs.__privateSet.call(void 0, this, _password, currentPassword);
|
|
1405
|
+
throw e;
|
|
1406
|
+
}
|
|
1407
|
+
});
|
|
1408
|
+
};
|
|
1371
1409
|
_assertControllerMutexIsLocked = new WeakSet();
|
|
1372
1410
|
assertControllerMutexIsLocked_fn = function() {
|
|
1373
1411
|
if (!_chunkQDPHKQONjs.__privateGet.call(void 0, this, _controllerOperationMutex).isLocked()) {
|
|
@@ -1403,4 +1441,4 @@ var KeyringController_default = KeyringController;
|
|
|
1403
1441
|
|
|
1404
1442
|
|
|
1405
1443
|
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;
|
|
1406
|
-
//# sourceMappingURL=chunk-
|
|
1444
|
+
//# sourceMappingURL=chunk-H4OUA6YG.js.map
|