@metamask-previews/keyring-controller 19.0.7-preview-f51ef7f8 → 19.1.0-preview-cd1fb95d

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 CHANGED
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [19.1.0]
11
+
12
+ ### Added
13
+
14
+ - Add new keyring type for OneKey ([#5216](https://github.com/MetaMask/core/pull/5216))
15
+
16
+ ### Changed
17
+
18
+ - A specific error message is thrown when any operation is attempted while the controller is locked ([#5172](https://github.com/MetaMask/core/pull/5172))
19
+
10
20
  ## [19.0.7]
11
21
 
12
22
  ### Changed
@@ -660,7 +670,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
660
670
 
661
671
  All changes listed after this point were applied to this package following the monorepo conversion.
662
672
 
663
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@19.0.7...HEAD
673
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@19.1.0...HEAD
674
+ [19.1.0]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@19.0.7...@metamask/keyring-controller@19.1.0
664
675
  [19.0.7]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@19.0.6...@metamask/keyring-controller@19.0.7
665
676
  [19.0.6]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@19.0.5...@metamask/keyring-controller@19.0.6
666
677
  [19.0.5]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@19.0.4...@metamask/keyring-controller@19.0.5
@@ -59,6 +59,7 @@ var KeyringTypes;
59
59
  KeyringTypes["hd"] = "HD Key Tree";
60
60
  KeyringTypes["qr"] = "QR Hardware Wallet Device";
61
61
  KeyringTypes["trezor"] = "Trezor Hardware";
62
+ KeyringTypes["oneKey"] = "OneKey Hardware";
62
63
  KeyringTypes["ledger"] = "Ledger Hardware";
63
64
  KeyringTypes["lattice"] = "Lattice Hardware";
64
65
  KeyringTypes["snap"] = "Snap Keyring";
@@ -339,6 +340,30 @@ class KeyringController extends base_controller_1.BaseController {
339
340
  return addedAccountAddress;
340
341
  });
341
342
  }
343
+ async addNewAccounts(numberOfAccountsToAdd, accountCount) {
344
+ __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_assertIsUnlocked).call(this);
345
+ return __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_persistOrRollback).call(this, async () => {
346
+ const primaryKeyring = this.getKeyringsByType('HD Key Tree')[0];
347
+ if (!primaryKeyring) {
348
+ throw new Error('No HD keyring found');
349
+ }
350
+ const oldAccounts = await primaryKeyring.getAccounts();
351
+ if (accountCount && oldAccounts.length !== accountCount) {
352
+ if (accountCount > oldAccounts.length) {
353
+ throw new Error('Accounts out of sequence');
354
+ }
355
+ // we return the accounts already existing starting at index `accountCount`
356
+ const existingAccounts = oldAccounts.slice(accountCount);
357
+ if (!existingAccounts[0]) {
358
+ throw new Error(`Can't find account at index ${accountCount}`);
359
+ }
360
+ return existingAccounts;
361
+ }
362
+ const newAccounts = await primaryKeyring.addAccounts(numberOfAccountsToAdd);
363
+ await __classPrivateFieldGet(this, _KeyringController_instances, "m", _KeyringController_verifySeedPhrase).call(this);
364
+ return newAccounts;
365
+ });
366
+ }
342
367
  /**
343
368
  * Effectively the same as creating a new keychain then populating it
344
369
  * using the given seed phrase.
@@ -1086,6 +1111,7 @@ _KeyringController_controllerOperationMutex = new WeakMap(), _KeyringController_
1086
1111
  this.messagingSystem.registerActionHandler(`${name}:patchUserOperation`, this.patchUserOperation.bind(this));
1087
1112
  this.messagingSystem.registerActionHandler(`${name}:signUserOperation`, this.signUserOperation.bind(this));
1088
1113
  this.messagingSystem.registerActionHandler(`${name}:addNewAccount`, this.addNewAccount.bind(this));
1114
+ this.messagingSystem.registerActionHandler(`${name}:addNewAccounts`, this.addNewAccounts.bind(this));
1089
1115
  }, _KeyringController_getKeyringBuilderForType = function _KeyringController_getKeyringBuilderForType(type) {
1090
1116
  return __classPrivateFieldGet(this, _KeyringController_keyringBuilders, "f").find((keyringBuilder) => keyringBuilder.type === type);
1091
1117
  }, _KeyringController_addQRKeyring =
@@ -1382,7 +1408,6 @@ async function _KeyringController_createKeyringWithFirstAccount(type, opts) {
1382
1408
  * using the given `opts`. The keyring is built using the keyring builder
1383
1409
  * registered for the given `type`.
1384
1410
  *
1385
- *
1386
1411
  * @param type - The type of keyring to add.
1387
1412
  * @param data - The data to restore a previously serialized keyring.
1388
1413
  * @returns The new keyring.