@metamask-previews/keyring-controller 21.0.3-preview-f2d81961 → 21.0.4-preview-71c2f67
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 +9 -24
- 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 +9 -24
- package/dist/KeyringController.mjs.map +1 -1
- package/package.json +1 -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.4]
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Ensure no duplicate accounts are persisted ([#5710](https://github.com/MetaMask/core/pull/5710))
|
|
15
|
+
|
|
10
16
|
## [21.0.3]
|
|
11
17
|
|
|
12
18
|
### Changed
|
|
@@ -748,7 +754,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
748
754
|
|
|
749
755
|
All changes listed after this point were applied to this package following the monorepo conversion.
|
|
750
756
|
|
|
751
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.
|
|
757
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.4...HEAD
|
|
758
|
+
[21.0.4]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.3...@metamask/keyring-controller@21.0.4
|
|
752
759
|
[21.0.3]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.2...@metamask/keyring-controller@21.0.3
|
|
753
760
|
[21.0.2]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.1...@metamask/keyring-controller@21.0.2
|
|
754
761
|
[21.0.1]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@21.0.0...@metamask/keyring-controller@21.0.1
|
|
@@ -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_getAccountsFromKeyrings, _KeyringController_createKeyringWithFirstAccount, _KeyringController_newKeyring, _KeyringController_createKeyring, _KeyringController_clearKeyrings, _KeyringController_restoreKeyring, _KeyringController_destroyKeyring, _KeyringController_removeEmptyKeyrings,
|
|
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_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");
|
|
@@ -1379,6 +1379,8 @@ async function _KeyringController_unlockKeyrings(password, encryptionKey, encryp
|
|
|
1379
1379
|
});
|
|
1380
1380
|
}, _KeyringController_updateVault = function _KeyringController_updateVault() {
|
|
1381
1381
|
return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_withVaultLock).call(this, async () => {
|
|
1382
|
+
// Ensure no duplicate accounts are persisted.
|
|
1383
|
+
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertNoDuplicateAccounts).call(this);
|
|
1382
1384
|
const { encryptionKey, encryptionSalt, vault } = this.state;
|
|
1383
1385
|
// READ THIS CAREFULLY:
|
|
1384
1386
|
// We do check if the vault is still considered up-to-date, if not, we would not re-use the
|
|
@@ -1528,7 +1530,6 @@ async function _KeyringController_createKeyring(type, data) {
|
|
|
1528
1530
|
await keyring.generateRandomMnemonic();
|
|
1529
1531
|
await keyring.addAccounts(1);
|
|
1530
1532
|
}
|
|
1531
|
-
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_checkForDuplicate).call(this, type, await keyring.getAccounts());
|
|
1532
1533
|
if (type === KeyringTypes.qr) {
|
|
1533
1534
|
// In case of a QR keyring type, we need to subscribe
|
|
1534
1535
|
// to its events after creating it
|
|
@@ -1614,32 +1615,16 @@ async function _KeyringController_removeEmptyKeyrings() {
|
|
|
1614
1615
|
}));
|
|
1615
1616
|
__classPrivateFieldSet(this, _KeyringController_keyrings, validKeyrings, "f");
|
|
1616
1617
|
__classPrivateFieldSet(this, _KeyringController_keyringsMetadata, validKeyringMetadata, "f");
|
|
1617
|
-
},
|
|
1618
|
+
}, _KeyringController_assertNoDuplicateAccounts =
|
|
1618
1619
|
/**
|
|
1619
|
-
*
|
|
1620
|
-
* array. Rejects if a duplicate is found.
|
|
1620
|
+
* Assert that there are no duplicate accounts in the keyrings.
|
|
1621
1621
|
*
|
|
1622
|
-
*
|
|
1623
|
-
*
|
|
1624
|
-
* @param type - The key pair type to check for.
|
|
1625
|
-
* @param newAccountArray - Array of new accounts.
|
|
1626
|
-
* @returns The account, if no duplicate is found.
|
|
1622
|
+
* @throws If there are duplicate accounts.
|
|
1627
1623
|
*/
|
|
1628
|
-
async function
|
|
1624
|
+
async function _KeyringController_assertNoDuplicateAccounts() {
|
|
1629
1625
|
const accounts = await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getAccountsFromKeyrings).call(this);
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
const isIncluded = Boolean(accounts.find((key) => newAccountArray[0] &&
|
|
1633
|
-
(key === newAccountArray[0] ||
|
|
1634
|
-
key === (0, utils_1.remove0x)(newAccountArray[0]))));
|
|
1635
|
-
if (isIncluded) {
|
|
1636
|
-
throw new Error(constants_1.KeyringControllerError.DuplicatedAccount);
|
|
1637
|
-
}
|
|
1638
|
-
return newAccountArray;
|
|
1639
|
-
}
|
|
1640
|
-
default: {
|
|
1641
|
-
return newAccountArray;
|
|
1642
|
-
}
|
|
1626
|
+
if (new Set(accounts).size !== accounts.length) {
|
|
1627
|
+
throw new Error(constants_1.KeyringControllerError.DuplicatedAccount);
|
|
1643
1628
|
}
|
|
1644
1629
|
}, _KeyringController_setUnlocked = function _KeyringController_setUnlocked() {
|
|
1645
1630
|
__classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertControllerMutexIsLocked).call(this);
|