@metamask-previews/keyring-controller 19.2.1-preview-5b37150f → 19.2.1-preview-def92ff7
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 +0 -3
- package/dist/KeyringController.cjs +5 -12
- package/dist/KeyringController.cjs.map +1 -1
- package/dist/KeyringController.d.cts +4 -10
- package/dist/KeyringController.d.cts.map +1 -1
- package/dist/KeyringController.d.mts +4 -10
- package/dist/KeyringController.d.mts.map +1 -1
- package/dist/KeyringController.mjs +6 -13
- package/dist/KeyringController.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -11,9 +11,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
11
11
|
|
|
12
12
|
### Changed
|
|
13
13
|
|
|
14
|
-
- **BREAKING:** `addNewKeyring` method now returns `Promise<KeyringMetadata>` instead of `Promise<unknown>` ([#5372](https://github.com/MetaMask/core/pull/5372))
|
|
15
|
-
- Consumers can use the returned `KeyringMetadata.id` to access the created keyring instance via `withKeyring`.
|
|
16
|
-
- **BREAKING:** `withKeyring` method now requires a callback argument of type `({ keyring: SelectedKeyring; metadata: KeyringMetadata }) => Promise<CallbackResult>` ([#5372](https://github.com/MetaMask/core/pull/5372))
|
|
17
14
|
- Bump `@metamask/keyring-api"` from `^17.0.0` to `^17.2.0` ([#5366](https://github.com/MetaMask/core/pull/5366))
|
|
18
15
|
- Bump `@metamask/keyring-internal-api` from `^4.0.1` to `^4.0.3` ([#5356](https://github.com/MetaMask/core/pull/5356)), ([#5366](https://github.com/MetaMask/core/pull/5366))
|
|
19
16
|
|
|
@@ -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, _KeyringController_keyringsMetadata, _KeyringController_password, _KeyringController_qrKeyringStateListener, _KeyringController_registerMessageHandlers, _KeyringController_getKeyringById, _KeyringController_getKeyringByIdOrDefault,
|
|
39
|
+
var _KeyringController_instances, _KeyringController_controllerOperationMutex, _KeyringController_vaultOperationMutex, _KeyringController_keyringBuilders, _KeyringController_unsupportedKeyrings, _KeyringController_encryptor, _KeyringController_cacheEncryptionKey, _KeyringController_keyrings, _KeyringController_keyringsMetadata, _KeyringController_password, _KeyringController_qrKeyringStateListener, _KeyringController_registerMessageHandlers, _KeyringController_getKeyringById, _KeyringController_getKeyringByIdOrDefault, _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_createKeyring, _KeyringController_clearKeyrings, _KeyringController_restoreKeyring, _KeyringController_destroyKeyring, _KeyringController_removeEmptyKeyrings, _KeyringController_checkForDuplicate, _KeyringController_setUnlocked, _KeyringController_assertIsUnlocked, _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");
|
|
@@ -395,14 +395,14 @@ class KeyringController extends base_controller_1.BaseController {
|
|
|
395
395
|
* @param type - Keyring type name.
|
|
396
396
|
* @param opts - Keyring options.
|
|
397
397
|
* @throws If a builder for the given `type` does not exist.
|
|
398
|
-
* @returns Promise resolving to the
|
|
398
|
+
* @returns Promise resolving to the added keyring.
|
|
399
399
|
*/
|
|
400
400
|
async addNewKeyring(type, opts) {
|
|
401
401
|
__classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
|
|
402
402
|
if (type === KeyringTypes.qr) {
|
|
403
|
-
return
|
|
403
|
+
return this.getOrAddQRKeyring();
|
|
404
404
|
}
|
|
405
|
-
return __classPrivateFieldGet(this, _KeyringController_instances, "m",
|
|
405
|
+
return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_persistOrRollback).call(this, async () => __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_newKeyring).call(this, type, opts));
|
|
406
406
|
}
|
|
407
407
|
/**
|
|
408
408
|
* Method to verify a given password validity. Throws an
|
|
@@ -910,10 +910,7 @@ class KeyringController extends base_controller_1.BaseController {
|
|
|
910
910
|
if (!keyring) {
|
|
911
911
|
throw new Error(constants_1.KeyringControllerError.KeyringNotFound);
|
|
912
912
|
}
|
|
913
|
-
const result = await operation(
|
|
914
|
-
keyring,
|
|
915
|
-
metadata: __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringMetadata).call(this, keyring),
|
|
916
|
-
});
|
|
913
|
+
const result = await operation(keyring);
|
|
917
914
|
if (Object.is(result, keyring)) {
|
|
918
915
|
// Access to a keyring instance outside of controller safeguards
|
|
919
916
|
// should be discouraged, as it can lead to unexpected behavior.
|
|
@@ -1147,10 +1144,6 @@ _KeyringController_controllerOperationMutex = new WeakMap(), _KeyringController_
|
|
|
1147
1144
|
return __classPrivateFieldGet(this, _KeyringController_keyrings, "f")[0];
|
|
1148
1145
|
}
|
|
1149
1146
|
return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getKeyringById).call(this, keyringId);
|
|
1150
|
-
}, _KeyringController_getKeyringMetadata = function _KeyringController_getKeyringMetadata(keyring) {
|
|
1151
|
-
const index = __classPrivateFieldGet(this, _KeyringController_keyrings, "f").findIndex((keyringCandidate) => keyringCandidate === keyring);
|
|
1152
|
-
(0, utils_1.assert)(index !== -1, constants_1.KeyringControllerError.KeyringNotFound);
|
|
1153
|
-
return __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f")[index];
|
|
1154
1147
|
}, _KeyringController_getKeyringBuilderForType = function _KeyringController_getKeyringBuilderForType(type) {
|
|
1155
1148
|
return __classPrivateFieldGet(this, _KeyringController_keyringBuilders, "f").find((keyringBuilder) => keyringBuilder.type === type);
|
|
1156
1149
|
}, _KeyringController_addQRKeyring =
|