@metamask-previews/keyring-controller 19.0.5-preview-37653b42 → 19.0.5-preview-082735ba
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 -44
- 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 -43
- 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 +2 -2
|
@@ -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,30 +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
|
-
// Do not attempt to return a keyring if the fingerprint is not provided
|
|
221
|
-
if (!fingerprint) {
|
|
222
|
-
return undefined;
|
|
223
|
-
}
|
|
224
|
-
const fingerprints = await Promise.all(
|
|
225
|
-
// @ts-expect-error TODO: update type in @metamask/utils
|
|
226
|
-
keyrings.map((kr) => kr?.getFingerprint?.()));
|
|
227
|
-
const index = fingerprints.indexOf(fingerprint);
|
|
228
|
-
return keyrings[index];
|
|
229
|
-
}
|
|
230
|
-
exports.getKeyringByFingerprint = getKeyringByFingerprint;
|
|
231
209
|
/**
|
|
232
210
|
* Check if address is an ethereum address
|
|
233
211
|
*
|
|
@@ -453,27 +431,12 @@ class KeyringController extends base_controller_1.BaseController {
|
|
|
453
431
|
* Gets the seed phrase of the HD keyring.
|
|
454
432
|
*
|
|
455
433
|
* @param password - Password of the keyring.
|
|
456
|
-
* @param keyringId - The keyring identifier.
|
|
457
434
|
* @returns Promise resolving to the seed phrase.
|
|
458
435
|
*/
|
|
459
|
-
async exportSeedPhrase(password
|
|
436
|
+
async exportSeedPhrase(password) {
|
|
460
437
|
await this.verifyPassword(password);
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
keyring = await getKeyringByFingerprint(__classPrivateFieldGet(this, _KeyringController_keyrings, "f"), keyringId);
|
|
464
|
-
if (!keyring) {
|
|
465
|
-
throw new Error(constants_1.KeyringControllerError.KeyringNotFound);
|
|
466
|
-
}
|
|
467
|
-
if (keyring.type !== KeyringTypes.hd) {
|
|
468
|
-
throw new Error(constants_1.KeyringControllerError.UnsupportedExportSeedPhrase);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
else {
|
|
472
|
-
// There will always be an HD keyring
|
|
473
|
-
keyring = this.getKeyringsByType(KeyringTypes.hd)[0];
|
|
474
|
-
}
|
|
475
|
-
assertHasUint8ArrayMnemonic(keyring);
|
|
476
|
-
return keyring.mnemonic;
|
|
438
|
+
assertHasUint8ArrayMnemonic(__classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0]);
|
|
439
|
+
return __classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0].mnemonic;
|
|
477
440
|
}
|
|
478
441
|
/**
|
|
479
442
|
* Gets the private key from the keyring controlling an address.
|
|
@@ -887,9 +850,6 @@ class KeyringController extends base_controller_1.BaseController {
|
|
|
887
850
|
if ('address' in selector) {
|
|
888
851
|
keyring = (await this.getKeyringForAccount(selector.address));
|
|
889
852
|
}
|
|
890
|
-
else if ('fingerprint' in selector) {
|
|
891
|
-
keyring = (await getKeyringByFingerprint(__classPrivateFieldGet(this, _KeyringController_keyrings, "f"), selector.fingerprint));
|
|
892
|
-
}
|
|
893
853
|
else {
|
|
894
854
|
keyring = this.getKeyringsByType(selector.type)[selector.index || 0];
|
|
895
855
|
if (!keyring && options.createIfMissing) {
|