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