@metamask-previews/keyring-controller 19.0.5-preview-0adfc600 → 19.0.5-preview-958adf52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/KeyringController.cjs +22 -81
- 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 -81
- 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 +4 -9
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Bump `@metamask/keyring-api"` from `^16.1.0` to `^17.0.0` ([#5280](https://github.com/MetaMask/core/pull/5280))
|
|
13
|
+
|
|
10
14
|
## [19.0.5]
|
|
11
15
|
|
|
12
16
|
### Changed
|
|
@@ -36,7 +36,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
36
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
39
|
-
var _KeyringController_instances, _KeyringController_controllerOperationMutex, _KeyringController_vaultOperationMutex, _KeyringController_keyringBuilders, _KeyringController_unsupportedKeyrings, _KeyringController_encryptor, _KeyringController_cacheEncryptionKey, _KeyringController_keyrings,
|
|
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,27 +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
|
-
console.log('keyrings: ', __classPrivateFieldGet(this, _KeyringController_keyrings, "f"));
|
|
848
|
-
console.log('keyringId: ', keyringId);
|
|
849
|
-
console.log('metadata: ', __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f"));
|
|
850
|
-
keyring = __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringById).call(this, keyringId);
|
|
851
|
-
if (keyring.type !== KeyringTypes.hd) {
|
|
852
|
-
throw new Error(constants_1.KeyringControllerError.UnsupportedVerifySeedPhrase);
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
if (!keyring) {
|
|
856
|
-
throw new Error(constants_1.KeyringControllerError.NoHdKeyring);
|
|
857
|
-
}
|
|
858
|
-
return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withControllerLock).call(this, async () => __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_verifySeedPhrase).call(this, keyringId));
|
|
825
|
+
async verifySeedPhrase() {
|
|
826
|
+
return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withControllerLock).call(this, async () => __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_verifySeedPhrase).call(this));
|
|
859
827
|
}
|
|
860
828
|
async withKeyring(selector, operation, options = {
|
|
861
829
|
createIfMissing: false,
|
|
@@ -865,15 +833,12 @@ class KeyringController extends base_controller_1.BaseController {
|
|
|
865
833
|
if ('address' in selector) {
|
|
866
834
|
keyring = (await this.getKeyringForAccount(selector.address));
|
|
867
835
|
}
|
|
868
|
-
else
|
|
836
|
+
else {
|
|
869
837
|
keyring = this.getKeyringsByType(selector.type)[selector.index || 0];
|
|
870
838
|
if (!keyring && options.createIfMissing) {
|
|
871
839
|
keyring = (await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_newKeyring).call(this, selector.type, options.createWithData));
|
|
872
840
|
}
|
|
873
841
|
}
|
|
874
|
-
else if ('id' in selector) {
|
|
875
|
-
keyring = __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringById).call(this, selector.id);
|
|
876
|
-
}
|
|
877
842
|
if (!keyring) {
|
|
878
843
|
throw new Error(constants_1.KeyringControllerError.KeyringNotFound);
|
|
879
844
|
}
|
|
@@ -1073,7 +1038,7 @@ class KeyringController extends base_controller_1.BaseController {
|
|
|
1073
1038
|
}
|
|
1074
1039
|
}
|
|
1075
1040
|
exports.KeyringController = KeyringController;
|
|
1076
|
-
_KeyringController_controllerOperationMutex = new WeakMap(), _KeyringController_vaultOperationMutex = new WeakMap(), _KeyringController_keyringBuilders = new WeakMap(), _KeyringController_unsupportedKeyrings = new WeakMap(), _KeyringController_encryptor = new WeakMap(), _KeyringController_cacheEncryptionKey = new WeakMap(), _KeyringController_keyrings = new WeakMap(),
|
|
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() {
|
|
1077
1042
|
this.messagingSystem.registerActionHandler(`${name}:signMessage`, this.signMessage.bind(this));
|
|
1078
1043
|
this.messagingSystem.registerActionHandler(`${name}:signPersonalMessage`, this.signPersonalMessage.bind(this));
|
|
1079
1044
|
this.messagingSystem.registerActionHandler(`${name}:signTypedMessage`, this.signTypedMessage.bind(this));
|
|
@@ -1087,9 +1052,6 @@ _KeyringController_controllerOperationMutex = new WeakMap(), _KeyringController_
|
|
|
1087
1052
|
this.messagingSystem.registerActionHandler(`${name}:patchUserOperation`, this.patchUserOperation.bind(this));
|
|
1088
1053
|
this.messagingSystem.registerActionHandler(`${name}:signUserOperation`, this.signUserOperation.bind(this));
|
|
1089
1054
|
this.messagingSystem.registerActionHandler(`${name}:addNewAccount`, this.addNewAccount.bind(this));
|
|
1090
|
-
}, _KeyringController_getKeyringById = function _KeyringController_getKeyringById(keyringId) {
|
|
1091
|
-
const index = this.state.keyringsMetadata.findIndex((metadata) => metadata.id === keyringId);
|
|
1092
|
-
return __classPrivateFieldGet(this, _KeyringController_keyrings, "f")[index];
|
|
1093
1055
|
}, _KeyringController_getKeyringBuilderForType = function _KeyringController_getKeyringBuilderForType(type) {
|
|
1094
1056
|
return __classPrivateFieldGet(this, _KeyringController_keyringBuilders, "f").find((keyringBuilder) => keyringBuilder.type === type);
|
|
1095
1057
|
}, _KeyringController_addQRKeyring =
|
|
@@ -1103,7 +1065,7 @@ _KeyringController_controllerOperationMutex = new WeakMap(), _KeyringController_
|
|
|
1103
1065
|
async function _KeyringController_addQRKeyring() {
|
|
1104
1066
|
__classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
|
|
1105
1067
|
// QRKeyring is not yet compatible with Keyring type from @metamask/utils
|
|
1106
|
-
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));
|
|
1107
1069
|
}, _KeyringController_subscribeToQRKeyringEvents = function _KeyringController_subscribeToQRKeyringEvents(qrKeyring) {
|
|
1108
1070
|
__classPrivateFieldSet(this, _KeyringController_qrKeyringStateListener, (state) => {
|
|
1109
1071
|
this.messagingSystem.publish(`${name}:qrKeyringStateChange`, state);
|
|
@@ -1148,21 +1110,17 @@ async function _KeyringController_createNewVaultWithKeyring(password, keyring) {
|
|
|
1148
1110
|
/**
|
|
1149
1111
|
* Internal non-exclusive method to verify the seed phrase.
|
|
1150
1112
|
*
|
|
1151
|
-
* @param keyringId - The id of the keyring to verify the seed phrase for.
|
|
1152
1113
|
* @returns A promise resolving to the seed phrase as Uint8Array.
|
|
1153
1114
|
*/
|
|
1154
|
-
async function _KeyringController_verifySeedPhrase(
|
|
1115
|
+
async function _KeyringController_verifySeedPhrase() {
|
|
1155
1116
|
__classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
|
|
1156
|
-
const
|
|
1157
|
-
|
|
1158
|
-
: this.getKeyringsByType(KeyringTypes.hd)[0];
|
|
1159
|
-
// This will never going to be undefined because we are checking for it in all of the callers
|
|
1160
|
-
if (!keyring) {
|
|
1117
|
+
const primaryKeyring = this.getKeyringsByType(KeyringTypes.hd)[0];
|
|
1118
|
+
if (!primaryKeyring) {
|
|
1161
1119
|
throw new Error('No HD keyring found.');
|
|
1162
1120
|
}
|
|
1163
|
-
assertHasUint8ArrayMnemonic(
|
|
1164
|
-
const seedWords =
|
|
1165
|
-
const accounts = await
|
|
1121
|
+
assertHasUint8ArrayMnemonic(primaryKeyring);
|
|
1122
|
+
const seedWords = primaryKeyring.mnemonic;
|
|
1123
|
+
const accounts = await primaryKeyring.getAccounts();
|
|
1166
1124
|
/* istanbul ignore if */
|
|
1167
1125
|
if (accounts.length === 0) {
|
|
1168
1126
|
throw new Error('Cannot verify an empty keyring.');
|
|
@@ -1210,7 +1168,7 @@ async function _KeyringController_getUpdatedKeyrings() {
|
|
|
1210
1168
|
async function _KeyringController_getSerializedKeyrings({ includeUnsupported } = {
|
|
1211
1169
|
includeUnsupported: true,
|
|
1212
1170
|
}) {
|
|
1213
|
-
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) => {
|
|
1214
1172
|
const [type, data] = await Promise.all([
|
|
1215
1173
|
keyring.type,
|
|
1216
1174
|
keyring.serialize(),
|
|
@@ -1345,14 +1303,10 @@ async function _KeyringController_unlockKeyrings(password, encryptionKey, encryp
|
|
|
1345
1303
|
this.update((state) => {
|
|
1346
1304
|
state.vault = updatedState.vault;
|
|
1347
1305
|
state.keyrings = updatedKeyrings;
|
|
1348
|
-
state.keyringsMetadata = __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f");
|
|
1349
1306
|
if (updatedState.encryptionKey) {
|
|
1350
1307
|
state.encryptionKey = updatedState.encryptionKey;
|
|
1351
1308
|
state.encryptionSalt = JSON.parse(updatedState.vault).salt;
|
|
1352
1309
|
}
|
|
1353
|
-
if (updatedKeyrings.length < __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f").length) {
|
|
1354
|
-
throw new Error(constants_1.KeyringControllerError.KeyringMetadataLengthMismatch);
|
|
1355
|
-
}
|
|
1356
1310
|
});
|
|
1357
1311
|
return true;
|
|
1358
1312
|
});
|
|
@@ -1388,13 +1342,13 @@ async function _KeyringController_createKeyringWithFirstAccount(type, opts) {
|
|
|
1388
1342
|
if (!firstAccount) {
|
|
1389
1343
|
throw new Error(constants_1.KeyringControllerError.NoFirstAccount);
|
|
1390
1344
|
}
|
|
1391
|
-
return firstAccount;
|
|
1392
1345
|
}, _KeyringController_newKeyring =
|
|
1393
1346
|
/**
|
|
1394
1347
|
* Instantiate, initialize and return a new keyring of the given `type`,
|
|
1395
1348
|
* using the given `opts`. The keyring is built using the keyring builder
|
|
1396
1349
|
* registered for the given `type`.
|
|
1397
1350
|
*
|
|
1351
|
+
*
|
|
1398
1352
|
* @param type - The type of keyring to add.
|
|
1399
1353
|
* @param data - The data to restore a previously serialized keyring.
|
|
1400
1354
|
* @returns The new keyring.
|
|
@@ -1402,10 +1356,6 @@ async function _KeyringController_createKeyringWithFirstAccount(type, opts) {
|
|
|
1402
1356
|
*/
|
|
1403
1357
|
async function _KeyringController_newKeyring(type, data) {
|
|
1404
1358
|
__classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
|
|
1405
|
-
const newKeyringMetadata = {
|
|
1406
|
-
id: (0, ulid_1.ulid)(),
|
|
1407
|
-
name: '',
|
|
1408
|
-
};
|
|
1409
1359
|
const keyringBuilder = __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringBuilderForType).call(this, type);
|
|
1410
1360
|
if (!keyringBuilder) {
|
|
1411
1361
|
throw new Error(`${constants_1.KeyringControllerError.NoKeyringBuilder}. Keyring type: ${type}`);
|
|
@@ -1433,10 +1383,6 @@ async function _KeyringController_newKeyring(type, data) {
|
|
|
1433
1383
|
__classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_subscribeToQRKeyringEvents).call(this, keyring);
|
|
1434
1384
|
}
|
|
1435
1385
|
__classPrivateFieldGet(this, _KeyringController_keyrings, "f").push(keyring);
|
|
1436
|
-
if (newKeyringMetadata &&
|
|
1437
|
-
__classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f").length < __classPrivateFieldGet(this, _KeyringController_keyrings, "f").length) {
|
|
1438
|
-
__classPrivateFieldSet(this, _KeyringController_keyringsMetadata, [...__classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f"), newKeyringMetadata], "f");
|
|
1439
|
-
}
|
|
1440
1386
|
return keyring;
|
|
1441
1387
|
}, _KeyringController_clearKeyrings =
|
|
1442
1388
|
/**
|
|
@@ -1489,22 +1435,19 @@ async function _KeyringController_destroyKeyring(keyring) {
|
|
|
1489
1435
|
async function _KeyringController_removeEmptyKeyrings() {
|
|
1490
1436
|
__classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
|
|
1491
1437
|
const validKeyrings = [];
|
|
1492
|
-
const validKeyringMetadata = [];
|
|
1493
1438
|
// Since getAccounts returns a Promise
|
|
1494
1439
|
// We need to wait to hear back form each keyring
|
|
1495
1440
|
// in order to decide which ones are now valid (accounts.length > 0)
|
|
1496
|
-
await Promise.all(__classPrivateFieldGet(this, _KeyringController_keyrings, "f").map(async (keyring
|
|
1441
|
+
await Promise.all(__classPrivateFieldGet(this, _KeyringController_keyrings, "f").map(async (keyring) => {
|
|
1497
1442
|
const accounts = await keyring.getAccounts();
|
|
1498
1443
|
if (accounts.length > 0) {
|
|
1499
1444
|
validKeyrings.push(keyring);
|
|
1500
|
-
validKeyringMetadata.push(this.state.keyringsMetadata[index]);
|
|
1501
1445
|
}
|
|
1502
1446
|
else {
|
|
1503
1447
|
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_destroyKeyring).call(this, keyring);
|
|
1504
1448
|
}
|
|
1505
1449
|
}));
|
|
1506
1450
|
__classPrivateFieldSet(this, _KeyringController_keyrings, validKeyrings, "f");
|
|
1507
|
-
__classPrivateFieldSet(this, _KeyringController_keyringsMetadata, validKeyringMetadata, "f");
|
|
1508
1451
|
}, _KeyringController_checkForDuplicate =
|
|
1509
1452
|
/**
|
|
1510
1453
|
* Checks for duplicate keypairs, using the the first account in the given
|
|
@@ -1566,7 +1509,6 @@ async function _KeyringController_withRollback(callback) {
|
|
|
1566
1509
|
return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withControllerLock).call(this, async ({ releaseLock }) => {
|
|
1567
1510
|
const currentSerializedKeyrings = await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getSerializedKeyrings).call(this);
|
|
1568
1511
|
const currentPassword = __classPrivateFieldGet(this, _KeyringController_password, "f");
|
|
1569
|
-
const currentKeyringsMetadata = __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f");
|
|
1570
1512
|
try {
|
|
1571
1513
|
return await callback({ releaseLock });
|
|
1572
1514
|
}
|
|
@@ -1574,7 +1516,6 @@ async function _KeyringController_withRollback(callback) {
|
|
|
1574
1516
|
// Keyrings and password are restored to their previous state
|
|
1575
1517
|
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_restoreSerializedKeyrings).call(this, currentSerializedKeyrings);
|
|
1576
1518
|
__classPrivateFieldSet(this, _KeyringController_password, currentPassword, "f");
|
|
1577
|
-
__classPrivateFieldSet(this, _KeyringController_keyringsMetadata, currentKeyringsMetadata, "f");
|
|
1578
1519
|
throw e;
|
|
1579
1520
|
}
|
|
1580
1521
|
});
|