@metamask-previews/keyring-controller 21.0.6-preview-780c8df → 21.0.6-preview-515e9b9c
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 +4 -0
- package/dist/KeyringController.cjs +8 -5
- 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 +8 -5
- package/dist/KeyringController.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
13
13
|
- The metadata is now stored in each keyring object in the `state.keyrings` array.
|
|
14
14
|
- When updating to this version, we recommend removing the `keyringsMetadata` state and all state referencing a keyring ID with a migration. New metadata will be generated for each keyring automatically after the update.
|
|
15
15
|
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Keyrings with duplicate accounts are skipped as unsupported on unlock ([#5775](https://github.com/MetaMask/core/pull/5775))
|
|
19
|
+
|
|
16
20
|
## [21.0.6]
|
|
17
21
|
|
|
18
22
|
### Changed
|
|
@@ -1485,11 +1485,12 @@ async function _KeyringController_unlockKeyrings(password, encryptionKey, encryp
|
|
|
1485
1485
|
* Retrieves all the accounts from keyrings instances
|
|
1486
1486
|
* that are currently in memory.
|
|
1487
1487
|
*
|
|
1488
|
+
* @param additionalKeyrings - Additional keyrings to include in the search.
|
|
1488
1489
|
* @returns A promise resolving to an array of accounts.
|
|
1489
1490
|
*/
|
|
1490
|
-
async function _KeyringController_getAccountsFromKeyrings() {
|
|
1491
|
-
const keyrings = __classPrivateFieldGet(this, _KeyringController_keyrings, "f");
|
|
1492
|
-
const keyringArrays = await Promise.all(keyrings.map(async (
|
|
1491
|
+
async function _KeyringController_getAccountsFromKeyrings(additionalKeyrings = []) {
|
|
1492
|
+
const keyrings = __classPrivateFieldGet(this, _KeyringController_keyrings, "f").map(({ keyring }) => keyring);
|
|
1493
|
+
const keyringArrays = await Promise.all([...keyrings, ...additionalKeyrings].map(async (keyring) => keyring.getAccounts()));
|
|
1493
1494
|
const addresses = keyringArrays.reduce((res, arr) => {
|
|
1494
1495
|
return res.concat(arr);
|
|
1495
1496
|
}, []);
|
|
@@ -1606,6 +1607,7 @@ async function _KeyringController_restoreKeyring(serialized) {
|
|
|
1606
1607
|
let newMetadata = false;
|
|
1607
1608
|
let metadata = serializedMetadata;
|
|
1608
1609
|
const keyring = await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_createKeyring).call(this, type, data);
|
|
1610
|
+
await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertNoDuplicateAccounts).call(this, [keyring]);
|
|
1609
1611
|
// If metadata is missing, assume the data is from an installation before
|
|
1610
1612
|
// we had keyring metadata.
|
|
1611
1613
|
if (!metadata) {
|
|
@@ -1664,10 +1666,11 @@ async function _KeyringController_removeEmptyKeyrings() {
|
|
|
1664
1666
|
/**
|
|
1665
1667
|
* Assert that there are no duplicate accounts in the keyrings.
|
|
1666
1668
|
*
|
|
1669
|
+
* @param additionalKeyrings - Additional keyrings to include in the check.
|
|
1667
1670
|
* @throws If there are duplicate accounts.
|
|
1668
1671
|
*/
|
|
1669
|
-
async function _KeyringController_assertNoDuplicateAccounts() {
|
|
1670
|
-
const accounts = await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getAccountsFromKeyrings).call(this);
|
|
1672
|
+
async function _KeyringController_assertNoDuplicateAccounts(additionalKeyrings = []) {
|
|
1673
|
+
const accounts = await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_getAccountsFromKeyrings).call(this, additionalKeyrings);
|
|
1671
1674
|
if (new Set(accounts).size !== accounts.length) {
|
|
1672
1675
|
throw new Error(constants_1.KeyringControllerError.DuplicatedAccount);
|
|
1673
1676
|
}
|