@metamask-previews/keyring-controller 21.0.5-preview-8b9e6f7b → 21.0.6-preview-36565d85
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 +8 -1
- package/dist/KeyringController.cjs +27 -6
- package/dist/KeyringController.cjs.map +1 -1
- package/dist/KeyringController.d.cts.map +1 -1
- package/dist/KeyringController.d.mts.map +1 -1
- package/dist/KeyringController.mjs +28 -6
- package/dist/KeyringController.mjs.map +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [21.0.6]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Prevent emitting `:stateChange` from `withKeyring` unnecessarily ([#5732](https://github.com/MetaMask/core/pull/5732))
|
|
15
|
+
|
|
10
16
|
## [21.0.5]
|
|
11
17
|
|
|
12
18
|
### Changed
|
|
@@ -764,7 +770,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
764
770
|
|
|
765
771
|
All changes listed after this point were applied to this package following the monorepo conversion.
|
|
766
772
|
|
|
767
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.
|
|
773
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.6...HEAD
|
|
774
|
+
[21.0.6]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.5...@metamask/keyring-controller@21.0.6
|
|
768
775
|
[21.0.5]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.4...@metamask/keyring-controller@21.0.5
|
|
769
776
|
[21.0.4]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.3...@metamask/keyring-controller@21.0.4
|
|
770
777
|
[21.0.3]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.2...@metamask/keyring-controller@21.0.3
|
|
@@ -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_encryptor, _KeyringController_cacheEncryptionKey, _KeyringController_keyrings, _KeyringController_unsupportedKeyrings, _KeyringController_keyringsMetadata, _KeyringController_password, _KeyringController_qrKeyringStateListener, _KeyringController_registerMessageHandlers, _KeyringController_getKeyringById, _KeyringController_getKeyringByIdOrDefault, _KeyringController_getKeyringMetadata, _KeyringController_getKeyringBuilderForType, _KeyringController_addQRKeyring, _KeyringController_subscribeToQRKeyringEvents, _KeyringController_unsubscribeFromQRKeyringsEvents, _KeyringController_createNewVaultWithKeyring, _KeyringController_verifySeedPhrase, _KeyringController_getUpdatedKeyrings, _KeyringController_getSerializedKeyrings, _KeyringController_restoreSerializedKeyrings, _KeyringController_unlockKeyrings, _KeyringController_updateVault, _KeyringController_upgradeVaultEncryptionParams, _KeyringController_getAccountsFromKeyrings, _KeyringController_createKeyringWithFirstAccount, _KeyringController_newKeyring, _KeyringController_createKeyring, _KeyringController_clearKeyrings, _KeyringController_restoreKeyring, _KeyringController_destroyKeyring, _KeyringController_removeEmptyKeyrings, _KeyringController_assertNoDuplicateAccounts, _KeyringController_setUnlocked, _KeyringController_assertIsUnlocked, _KeyringController_persistOrRollback, _KeyringController_withRollback, _KeyringController_assertControllerMutexIsLocked, _KeyringController_withControllerLock, _KeyringController_withVaultLock;
|
|
39
|
+
var _KeyringController_instances, _KeyringController_controllerOperationMutex, _KeyringController_vaultOperationMutex, _KeyringController_keyringBuilders, _KeyringController_encryptor, _KeyringController_cacheEncryptionKey, _KeyringController_keyrings, _KeyringController_unsupportedKeyrings, _KeyringController_keyringsMetadata, _KeyringController_password, _KeyringController_qrKeyringStateListener, _KeyringController_registerMessageHandlers, _KeyringController_getKeyringById, _KeyringController_getKeyringByIdOrDefault, _KeyringController_getKeyringMetadata, _KeyringController_getKeyringBuilderForType, _KeyringController_addQRKeyring, _KeyringController_subscribeToQRKeyringEvents, _KeyringController_unsubscribeFromQRKeyringsEvents, _KeyringController_createNewVaultWithKeyring, _KeyringController_verifySeedPhrase, _KeyringController_getUpdatedKeyrings, _KeyringController_getSerializedKeyrings, _KeyringController_getSessionState, _KeyringController_restoreSerializedKeyrings, _KeyringController_unlockKeyrings, _KeyringController_updateVault, _KeyringController_upgradeVaultEncryptionParams, _KeyringController_getAccountsFromKeyrings, _KeyringController_createKeyringWithFirstAccount, _KeyringController_newKeyring, _KeyringController_createKeyring, _KeyringController_clearKeyrings, _KeyringController_restoreKeyring, _KeyringController_destroyKeyring, _KeyringController_removeEmptyKeyrings, _KeyringController_assertNoDuplicateAccounts, _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");
|
|
@@ -48,6 +48,7 @@ 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
|
+
const lodash_1 = require("lodash");
|
|
51
52
|
// When generating a ULID within the same millisecond, monotonicFactory provides some guarantees regarding sort order.
|
|
52
53
|
const ulid_1 = require("ulid");
|
|
53
54
|
const constants_1 = require("./constants.cjs");
|
|
@@ -553,8 +554,11 @@ class KeyringController extends base_controller_1.BaseController {
|
|
|
553
554
|
* operation completes.
|
|
554
555
|
*/
|
|
555
556
|
async persistAllKeyrings() {
|
|
556
|
-
__classPrivateFieldGet(this, _KeyringController_instances, "m",
|
|
557
|
-
|
|
557
|
+
return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withRollback).call(this, async () => {
|
|
558
|
+
__classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
|
|
559
|
+
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_updateVault).call(this);
|
|
560
|
+
return true;
|
|
561
|
+
});
|
|
558
562
|
}
|
|
559
563
|
/**
|
|
560
564
|
* Imports an account with the specified import strategy.
|
|
@@ -1294,6 +1298,19 @@ async function _KeyringController_getSerializedKeyrings({ includeUnsupported } =
|
|
|
1294
1298
|
serializedKeyrings.push(...__classPrivateFieldGet(this, _KeyringController_unsupportedKeyrings, "f"));
|
|
1295
1299
|
}
|
|
1296
1300
|
return serializedKeyrings;
|
|
1301
|
+
}, _KeyringController_getSessionState =
|
|
1302
|
+
/**
|
|
1303
|
+
* Get a snapshot of session data held by class variables.
|
|
1304
|
+
*
|
|
1305
|
+
* @returns An object with serialized keyrings, keyrings metadata,
|
|
1306
|
+
* and the user password.
|
|
1307
|
+
*/
|
|
1308
|
+
async function _KeyringController_getSessionState() {
|
|
1309
|
+
return {
|
|
1310
|
+
keyrings: await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getSerializedKeyrings).call(this),
|
|
1311
|
+
keyringsMetadata: __classPrivateFieldGet(this, _KeyringController_keyringsMetadata, "f").slice(),
|
|
1312
|
+
password: __classPrivateFieldGet(this, _KeyringController_password, "f"),
|
|
1313
|
+
};
|
|
1297
1314
|
}, _KeyringController_restoreSerializedKeyrings =
|
|
1298
1315
|
/**
|
|
1299
1316
|
* Restore a serialized keyrings array.
|
|
@@ -1659,7 +1676,7 @@ async function _KeyringController_assertNoDuplicateAccounts() {
|
|
|
1659
1676
|
}, _KeyringController_persistOrRollback =
|
|
1660
1677
|
/**
|
|
1661
1678
|
* Execute the given function after acquiring the controller lock
|
|
1662
|
-
* and save the
|
|
1679
|
+
* and save the vault to state after it (only if needed), or rollback to their
|
|
1663
1680
|
* previous state in case of error.
|
|
1664
1681
|
*
|
|
1665
1682
|
* @param callback - The function to execute.
|
|
@@ -1667,9 +1684,13 @@ async function _KeyringController_assertNoDuplicateAccounts() {
|
|
|
1667
1684
|
*/
|
|
1668
1685
|
async function _KeyringController_persistOrRollback(callback) {
|
|
1669
1686
|
return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withRollback).call(this, async ({ releaseLock }) => {
|
|
1687
|
+
const oldState = await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getSessionState).call(this);
|
|
1670
1688
|
const callbackResult = await callback({ releaseLock });
|
|
1671
|
-
|
|
1672
|
-
|
|
1689
|
+
const newState = await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getSessionState).call(this);
|
|
1690
|
+
// State is committed only if the operation is successful and need to trigger a vault update.
|
|
1691
|
+
if (!(0, lodash_1.isEqual)(oldState, newState)) {
|
|
1692
|
+
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_updateVault).call(this);
|
|
1693
|
+
}
|
|
1673
1694
|
return callbackResult;
|
|
1674
1695
|
});
|
|
1675
1696
|
}, _KeyringController_withRollback =
|