@metamask-previews/keyring-controller 19.0.5-preview-aec8dc46 → 19.0.5-preview-0adfc600
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -51,7 +51,6 @@ const ethereumjs_wallet_1 = __importStar(require("ethereumjs-wallet"));
|
|
|
51
51
|
// When generating a ULID within the same millisecond, monotonicFactory provides some guarantees regarding sort order.
|
|
52
52
|
const ulid_1 = require("ulid");
|
|
53
53
|
const constants_1 = require("./constants.cjs");
|
|
54
|
-
const ulid = (0, ulid_1.monotonicFactory)();
|
|
55
54
|
const name = 'KeyringController';
|
|
56
55
|
/**
|
|
57
56
|
* Available keyring types
|
|
@@ -845,6 +844,9 @@ class KeyringController extends base_controller_1.BaseController {
|
|
|
845
844
|
keyring = __classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0];
|
|
846
845
|
}
|
|
847
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"));
|
|
848
850
|
keyring = __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringById).call(this, keyringId);
|
|
849
851
|
if (keyring.type !== KeyringTypes.hd) {
|
|
850
852
|
throw new Error(constants_1.KeyringControllerError.UnsupportedVerifySeedPhrase);
|
|
@@ -1154,6 +1156,7 @@ async function _KeyringController_verifySeedPhrase(keyringId) {
|
|
|
1154
1156
|
const keyring = keyringId
|
|
1155
1157
|
? __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringById).call(this, keyringId)
|
|
1156
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
|
|
1157
1160
|
if (!keyring) {
|
|
1158
1161
|
throw new Error('No HD keyring found.');
|
|
1159
1162
|
}
|
|
@@ -1229,9 +1232,6 @@ async function _KeyringController_restoreSerializedKeyrings(serializedKeyrings)
|
|
|
1229
1232
|
for (const serializedKeyring of serializedKeyrings) {
|
|
1230
1233
|
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_restoreKeyring).call(this, serializedKeyring);
|
|
1231
1234
|
}
|
|
1232
|
-
if (__classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f").length > __classPrivateFieldGet(this, _KeyringController_keyrings, "f").length) {
|
|
1233
|
-
throw new Error(constants_1.KeyringControllerError.KeyringMetadataLengthMismatch);
|
|
1234
|
-
}
|
|
1235
1235
|
}, _KeyringController_unlockKeyrings =
|
|
1236
1236
|
/**
|
|
1237
1237
|
* Unlock Keyrings, decrypting the vault and deserializing all
|
|
@@ -1403,7 +1403,7 @@ async function _KeyringController_createKeyringWithFirstAccount(type, opts) {
|
|
|
1403
1403
|
async function _KeyringController_newKeyring(type, data) {
|
|
1404
1404
|
__classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
|
|
1405
1405
|
const newKeyringMetadata = {
|
|
1406
|
-
id: ulid
|
|
1406
|
+
id: (0, ulid_1.ulid)(),
|
|
1407
1407
|
name: '',
|
|
1408
1408
|
};
|
|
1409
1409
|
const keyringBuilder = __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringBuilderForType).call(this, type);
|
|
@@ -1449,10 +1449,6 @@ async function _KeyringController_clearKeyrings() {
|
|
|
1449
1449
|
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_destroyKeyring).call(this, keyring);
|
|
1450
1450
|
}
|
|
1451
1451
|
__classPrivateFieldSet(this, _KeyringController_keyrings, [], "f");
|
|
1452
|
-
__classPrivateFieldSet(this, _KeyringController_keyringsMetadata, [], "f");
|
|
1453
|
-
// this.update((state) => {
|
|
1454
|
-
// state.keyringsMetadata = [];
|
|
1455
|
-
// });
|
|
1456
1452
|
}, _KeyringController_restoreKeyring =
|
|
1457
1453
|
/**
|
|
1458
1454
|
* Restore a Keyring from a provided serialized payload.
|
|
@@ -1570,6 +1566,7 @@ async function _KeyringController_withRollback(callback) {
|
|
|
1570
1566
|
return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withControllerLock).call(this, async ({ releaseLock }) => {
|
|
1571
1567
|
const currentSerializedKeyrings = await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getSerializedKeyrings).call(this);
|
|
1572
1568
|
const currentPassword = __classPrivateFieldGet(this, _KeyringController_password, "f");
|
|
1569
|
+
const currentKeyringsMetadata = __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f");
|
|
1573
1570
|
try {
|
|
1574
1571
|
return await callback({ releaseLock });
|
|
1575
1572
|
}
|
|
@@ -1577,6 +1574,7 @@ async function _KeyringController_withRollback(callback) {
|
|
|
1577
1574
|
// Keyrings and password are restored to their previous state
|
|
1578
1575
|
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_restoreSerializedKeyrings).call(this, currentSerializedKeyrings);
|
|
1579
1576
|
__classPrivateFieldSet(this, _KeyringController_password, currentPassword, "f");
|
|
1577
|
+
__classPrivateFieldSet(this, _KeyringController_keyringsMetadata, currentKeyringsMetadata, "f");
|
|
1580
1578
|
throw e;
|
|
1581
1579
|
}
|
|
1582
1580
|
});
|