@metamask-previews/keyring-controller 19.0.4-preview-5b9e9f05 → 19.0.4-preview-77c9cd86
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 +4 -40
- package/dist/KeyringController.cjs.map +1 -1
- package/dist/KeyringController.d.cts +1 -26
- package/dist/KeyringController.d.cts.map +1 -1
- package/dist/KeyringController.d.mts +1 -26
- package/dist/KeyringController.d.mts.map +1 -1
- package/dist/KeyringController.mjs +6 -39
- package/dist/KeyringController.mjs.map +1 -1
- package/dist/constants.cjs +0 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +1 -2
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +1 -2
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +0 -1
- package/dist/constants.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -38,7 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
};
|
|
39
39
|
var _KeyringController_instances, _KeyringController_controllerOperationMutex, _KeyringController_vaultOperationMutex, _KeyringController_keyringBuilders, _KeyringController_keyrings, _KeyringController_unsupportedKeyrings, _KeyringController_password, _KeyringController_encryptor, _KeyringController_cacheEncryptionKey, _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
|
-
exports.KeyringController = exports.
|
|
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");
|
|
43
43
|
const base_controller_1 = require("@metamask/base-controller");
|
|
44
44
|
const encryptorUtils = __importStar(require("@metamask/browser-passworder"));
|
|
@@ -204,26 +204,8 @@ async function displayForKeyring(keyring) {
|
|
|
204
204
|
// Cast to `string[]` here is safe here because `accounts` has no nullish
|
|
205
205
|
// values, and `normalize` returns `string` unless given a nullish value
|
|
206
206
|
accounts: accounts.map(normalize),
|
|
207
|
-
// @ts-expect-error TODO: update type in @metamask/utils
|
|
208
|
-
fingerprint: await keyring?.getFingerprint?.(),
|
|
209
207
|
};
|
|
210
208
|
}
|
|
211
|
-
exports.displayForKeyring = displayForKeyring;
|
|
212
|
-
/**
|
|
213
|
-
* Retrieves a keyring from an array of keyrings based on its fingerprint.
|
|
214
|
-
*
|
|
215
|
-
* @param keyrings - Array of keyrings to search through.
|
|
216
|
-
* @param fingerprint - The fingerprint to match against.
|
|
217
|
-
* @returns Promise resolving to the matching keyring, or undefined if not found.
|
|
218
|
-
*/
|
|
219
|
-
async function getKeyringByFingerprint(keyrings, fingerprint) {
|
|
220
|
-
const fingerprints = await Promise.all(
|
|
221
|
-
// @ts-expect-error TODO: update type in @metamask/utils
|
|
222
|
-
keyrings.map((kr) => kr?.getFingerprint?.()));
|
|
223
|
-
const index = fingerprints.indexOf(fingerprint);
|
|
224
|
-
return keyrings[index];
|
|
225
|
-
}
|
|
226
|
-
exports.getKeyringByFingerprint = getKeyringByFingerprint;
|
|
227
209
|
/**
|
|
228
210
|
* Check if address is an ethereum address
|
|
229
211
|
*
|
|
@@ -449,27 +431,12 @@ class KeyringController extends base_controller_1.BaseController {
|
|
|
449
431
|
* Gets the seed phrase of the HD keyring.
|
|
450
432
|
*
|
|
451
433
|
* @param password - Password of the keyring.
|
|
452
|
-
* @param keyringId - The keyring identifier.
|
|
453
434
|
* @returns Promise resolving to the seed phrase.
|
|
454
435
|
*/
|
|
455
|
-
async exportSeedPhrase(password
|
|
436
|
+
async exportSeedPhrase(password) {
|
|
456
437
|
await this.verifyPassword(password);
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
keyring = await getKeyringByFingerprint(__classPrivateFieldGet(this, _KeyringController_keyrings, "f"), keyringId);
|
|
460
|
-
if (!keyring) {
|
|
461
|
-
throw new Error(constants_1.KeyringControllerError.KeyringNotFound);
|
|
462
|
-
}
|
|
463
|
-
if (keyring.type !== KeyringTypes.hd) {
|
|
464
|
-
throw new Error(constants_1.KeyringControllerError.UnsupportedExportSeedPhrase);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
else {
|
|
468
|
-
// There will always be an HD keyring
|
|
469
|
-
keyring = this.getKeyringsByType(KeyringTypes.hd)[0];
|
|
470
|
-
}
|
|
471
|
-
assertHasUint8ArrayMnemonic(keyring);
|
|
472
|
-
return keyring.mnemonic;
|
|
438
|
+
assertHasUint8ArrayMnemonic(__classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0]);
|
|
439
|
+
return __classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0].mnemonic;
|
|
473
440
|
}
|
|
474
441
|
/**
|
|
475
442
|
* Gets the private key from the keyring controlling an address.
|
|
@@ -883,9 +850,6 @@ class KeyringController extends base_controller_1.BaseController {
|
|
|
883
850
|
if ('address' in selector) {
|
|
884
851
|
keyring = (await this.getKeyringForAccount(selector.address));
|
|
885
852
|
}
|
|
886
|
-
else if ('fingerprint' in selector) {
|
|
887
|
-
keyring = (await getKeyringByFingerprint(__classPrivateFieldGet(this, _KeyringController_keyrings, "f"), selector.fingerprint));
|
|
888
|
-
}
|
|
889
853
|
else {
|
|
890
854
|
keyring = this.getKeyringsByType(selector.type)[selector.index || 0];
|
|
891
855
|
if (!keyring && options.createIfMissing) {
|