@metamask/keyring-api 21.3.0 → 21.4.0

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.
Files changed (163) hide show
  1. package/CHANGELOG.md +32 -2
  2. package/README.md +4 -0
  3. package/dist/api/account-options.cjs +44 -7
  4. package/dist/api/account-options.cjs.map +1 -1
  5. package/dist/api/account-options.d.cts +41 -3
  6. package/dist/api/account-options.d.cts.map +1 -1
  7. package/dist/api/account-options.d.mts +41 -3
  8. package/dist/api/account-options.d.mts.map +1 -1
  9. package/dist/api/account-options.mjs +43 -6
  10. package/dist/api/account-options.mjs.map +1 -1
  11. package/dist/api/account.d.cts +4 -0
  12. package/dist/api/account.d.cts.map +1 -1
  13. package/dist/api/account.d.mts +4 -0
  14. package/dist/api/account.d.mts.map +1 -1
  15. package/dist/api/keyring.cjs +0 -2
  16. package/dist/api/keyring.cjs.map +1 -1
  17. package/dist/api/keyring.d.cts +13 -0
  18. package/dist/api/keyring.d.cts.map +1 -1
  19. package/dist/api/keyring.d.mts +13 -0
  20. package/dist/api/keyring.d.mts.map +1 -1
  21. package/dist/api/keyring.mjs +0 -2
  22. package/dist/api/keyring.mjs.map +1 -1
  23. package/dist/api/v2/create-account/bip44.cjs +27 -1
  24. package/dist/api/v2/create-account/bip44.cjs.map +1 -1
  25. package/dist/api/v2/create-account/bip44.d.cts +46 -0
  26. package/dist/api/v2/create-account/bip44.d.cts.map +1 -1
  27. package/dist/api/v2/create-account/bip44.d.mts +46 -0
  28. package/dist/api/v2/create-account/bip44.d.mts.map +1 -1
  29. package/dist/api/v2/create-account/bip44.mjs +26 -0
  30. package/dist/api/v2/create-account/bip44.mjs.map +1 -1
  31. package/dist/api/v2/create-account/custom.cjs +14 -0
  32. package/dist/api/v2/create-account/custom.cjs.map +1 -0
  33. package/dist/api/v2/create-account/custom.d.cts +25 -0
  34. package/dist/api/v2/create-account/custom.d.cts.map +1 -0
  35. package/dist/api/v2/create-account/custom.d.mts +25 -0
  36. package/dist/api/v2/create-account/custom.d.mts.map +1 -0
  37. package/dist/api/v2/create-account/custom.mjs +11 -0
  38. package/dist/api/v2/create-account/custom.mjs.map +1 -0
  39. package/dist/api/v2/create-account/index.cjs +21 -0
  40. package/dist/api/v2/create-account/index.cjs.map +1 -1
  41. package/dist/api/v2/create-account/index.d.cts +26 -1
  42. package/dist/api/v2/create-account/index.d.cts.map +1 -1
  43. package/dist/api/v2/create-account/index.d.mts +26 -1
  44. package/dist/api/v2/create-account/index.d.mts.map +1 -1
  45. package/dist/api/v2/create-account/index.mjs +22 -1
  46. package/dist/api/v2/create-account/index.mjs.map +1 -1
  47. package/dist/api/v2/index.cjs +1 -0
  48. package/dist/api/v2/index.cjs.map +1 -1
  49. package/dist/api/v2/index.d.cts +1 -0
  50. package/dist/api/v2/index.d.cts.map +1 -1
  51. package/dist/api/v2/index.d.mts +1 -0
  52. package/dist/api/v2/index.d.mts.map +1 -1
  53. package/dist/api/v2/index.mjs +1 -0
  54. package/dist/api/v2/index.mjs.map +1 -1
  55. package/dist/api/v2/keyring-capabilities.cjs +17 -3
  56. package/dist/api/v2/keyring-capabilities.cjs.map +1 -1
  57. package/dist/api/v2/keyring-capabilities.d.cts +31 -9
  58. package/dist/api/v2/keyring-capabilities.d.cts.map +1 -1
  59. package/dist/api/v2/keyring-capabilities.d.mts +31 -9
  60. package/dist/api/v2/keyring-capabilities.d.mts.map +1 -1
  61. package/dist/api/v2/keyring-capabilities.mjs +18 -4
  62. package/dist/api/v2/keyring-capabilities.mjs.map +1 -1
  63. package/dist/api/v2/wrapper/index.cjs +19 -0
  64. package/dist/api/v2/wrapper/index.cjs.map +1 -0
  65. package/dist/api/v2/wrapper/index.d.cts +3 -0
  66. package/dist/api/v2/wrapper/index.d.cts.map +1 -0
  67. package/dist/api/v2/wrapper/index.d.mts +3 -0
  68. package/dist/api/v2/wrapper/index.d.mts.map +1 -0
  69. package/dist/api/v2/wrapper/index.mjs +3 -0
  70. package/dist/api/v2/wrapper/index.mjs.map +1 -0
  71. package/dist/api/v2/wrapper/keyring-account-registry.cjs +135 -0
  72. package/dist/api/v2/wrapper/keyring-account-registry.cjs.map +1 -0
  73. package/dist/api/v2/wrapper/keyring-account-registry.d.cts +88 -0
  74. package/dist/api/v2/wrapper/keyring-account-registry.d.cts.map +1 -0
  75. package/dist/api/v2/wrapper/keyring-account-registry.d.mts +88 -0
  76. package/dist/api/v2/wrapper/keyring-account-registry.d.mts.map +1 -0
  77. package/dist/api/v2/wrapper/keyring-account-registry.mjs +131 -0
  78. package/dist/api/v2/wrapper/keyring-account-registry.mjs.map +1 -0
  79. package/dist/api/v2/wrapper/keyring-wrapper.cjs +134 -0
  80. package/dist/api/v2/wrapper/keyring-wrapper.cjs.map +1 -0
  81. package/dist/api/v2/wrapper/keyring-wrapper.d.cts +154 -0
  82. package/dist/api/v2/wrapper/keyring-wrapper.d.cts.map +1 -0
  83. package/dist/api/v2/wrapper/keyring-wrapper.d.mts +154 -0
  84. package/dist/api/v2/wrapper/keyring-wrapper.d.mts.map +1 -0
  85. package/dist/api/v2/wrapper/keyring-wrapper.mjs +130 -0
  86. package/dist/api/v2/wrapper/keyring-wrapper.mjs.map +1 -0
  87. package/dist/btc/types.d.cts +16 -0
  88. package/dist/btc/types.d.cts.map +1 -1
  89. package/dist/btc/types.d.mts +16 -0
  90. package/dist/btc/types.d.mts.map +1 -1
  91. package/dist/eth/erc4337/types.d.cts +4 -4
  92. package/dist/eth/erc4337/types.d.mts +4 -4
  93. package/dist/eth/index.cjs +2 -0
  94. package/dist/eth/index.cjs.map +1 -1
  95. package/dist/eth/index.d.cts +2 -0
  96. package/dist/eth/index.d.cts.map +1 -1
  97. package/dist/eth/index.d.mts +2 -0
  98. package/dist/eth/index.d.mts.map +1 -1
  99. package/dist/eth/index.mjs +2 -0
  100. package/dist/eth/index.mjs.map +1 -1
  101. package/dist/eth/rpc/index.cjs +18 -0
  102. package/dist/eth/rpc/index.cjs.map +1 -0
  103. package/dist/eth/rpc/index.d.cts +2 -0
  104. package/dist/eth/rpc/index.d.cts.map +1 -0
  105. package/dist/eth/rpc/index.d.mts +2 -0
  106. package/dist/eth/rpc/index.d.mts.map +1 -0
  107. package/dist/eth/rpc/index.mjs +2 -0
  108. package/dist/eth/rpc/index.mjs.map +1 -0
  109. package/dist/eth/rpc/params.cjs +151 -0
  110. package/dist/eth/rpc/params.cjs.map +1 -0
  111. package/dist/eth/rpc/params.d.cts +215 -0
  112. package/dist/eth/rpc/params.d.cts.map +1 -0
  113. package/dist/eth/rpc/params.d.mts +215 -0
  114. package/dist/eth/rpc/params.d.mts.map +1 -0
  115. package/dist/eth/rpc/params.mjs +148 -0
  116. package/dist/eth/rpc/params.mjs.map +1 -0
  117. package/dist/eth/types.cjs.map +1 -1
  118. package/dist/eth/types.d.cts +13 -5
  119. package/dist/eth/types.d.cts.map +1 -1
  120. package/dist/eth/types.d.mts +13 -5
  121. package/dist/eth/types.d.mts.map +1 -1
  122. package/dist/eth/types.mjs.map +1 -1
  123. package/dist/eth/v2/eth-keyring-wrapper.cjs +165 -0
  124. package/dist/eth/v2/eth-keyring-wrapper.cjs.map +1 -0
  125. package/dist/eth/v2/eth-keyring-wrapper.d.cts +54 -0
  126. package/dist/eth/v2/eth-keyring-wrapper.d.cts.map +1 -0
  127. package/dist/eth/v2/eth-keyring-wrapper.d.mts +54 -0
  128. package/dist/eth/v2/eth-keyring-wrapper.d.mts.map +1 -0
  129. package/dist/eth/v2/eth-keyring-wrapper.mjs +161 -0
  130. package/dist/eth/v2/eth-keyring-wrapper.mjs.map +1 -0
  131. package/dist/eth/v2/index.cjs +18 -0
  132. package/dist/eth/v2/index.cjs.map +1 -0
  133. package/dist/eth/v2/index.d.cts +2 -0
  134. package/dist/eth/v2/index.d.cts.map +1 -0
  135. package/dist/eth/v2/index.d.mts +2 -0
  136. package/dist/eth/v2/index.d.mts.map +1 -0
  137. package/dist/eth/v2/index.mjs +2 -0
  138. package/dist/eth/v2/index.mjs.map +1 -0
  139. package/dist/events.cjs +0 -2
  140. package/dist/events.cjs.map +1 -1
  141. package/dist/events.d.cts +16 -0
  142. package/dist/events.d.cts.map +1 -1
  143. package/dist/events.d.mts +16 -0
  144. package/dist/events.d.mts.map +1 -1
  145. package/dist/events.mjs +0 -2
  146. package/dist/events.mjs.map +1 -1
  147. package/dist/rpc.cjs +27 -12
  148. package/dist/rpc.cjs.map +1 -1
  149. package/dist/rpc.d.cts +200 -12
  150. package/dist/rpc.d.cts.map +1 -1
  151. package/dist/rpc.d.mts +200 -12
  152. package/dist/rpc.d.mts.map +1 -1
  153. package/dist/rpc.mjs +27 -12
  154. package/dist/rpc.mjs.map +1 -1
  155. package/dist/sol/types.d.cts +4 -0
  156. package/dist/sol/types.d.cts.map +1 -1
  157. package/dist/sol/types.d.mts +4 -0
  158. package/dist/sol/types.d.mts.map +1 -1
  159. package/dist/trx/types.d.cts +4 -0
  160. package/dist/trx/types.d.cts.map +1 -1
  161. package/dist/trx/types.d.mts +4 -0
  162. package/dist/trx/types.d.mts.map +1 -1
  163. package/package.json +9 -4
package/CHANGELOG.md CHANGED
@@ -7,11 +7,40 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [21.4.0]
11
+
12
+ ### Added
13
+
14
+ - Add `Keyring.createAccounts` optional method ([#448](https://github.com/MetaMask/accounts/pull/448))
15
+ - This method is part of the keyring v2 specification and set as optional for backwards compatibility.
16
+ - This method can be used to create one or more accounts using the new keyring v2 account creation typed options.
17
+ - Add RPC support for this method through `KeyringRpcMethod.CreateAccounts`.
18
+ - Add support for account derivations using range of indices in `KeyringV2` ([#451](https://github.com/MetaMask/accounts/pull/451))
19
+ - Add `bip44:derive-index-range` capability to `KeyringCapabilities`.
20
+ - Add `AccountCreationType.Bip44DeriveIndexRange` and `CreateAccountBip44DeriveIndexRangeOptions`.
21
+ - Add support for custom capabilities and entropy types in `KeyringV2` ([#415](https://github.com/MetaMask/accounts/pull/415))
22
+ - Add `custom` capability to `KeyringCapabilities` for keyrings with non-standard `createAccounts` method.
23
+ - Add `KeyringAccountEntropyTypeOption.Custom` for custom/opaque entropy sources.
24
+ - Add `AccountCreationType.Custom` and `CreateAccountCustomOptions` for custom account creation flows.
25
+ - Add `EthKeyringWrapper` abstract class for Ethereum-based `KeyringV2` implementations ([#404](https://github.com/MetaMask/accounts/pull/404))
26
+ - Provides common Ethereum signing method routing (`submitRequest`) for all Ethereum-based keyrings.
27
+ - Add `KeyringWrapper` base class to adapt legacy keyrings to `KeyringV2` ([#398](https://github.com/MetaMask/accounts/pull/398)),([#402](https://github.com/MetaMask/accounts/pull/402)), ([#409](https://github.com/MetaMask/accounts/pull/409)), ([#410](https://github.com/MetaMask/accounts/pull/410))
28
+
29
+ ### Changed
30
+
31
+ - Make BIP-44 capabilities optional in `KeyringCapabilities` ([#453](https://github.com/MetaMask/accounts/pull/453))
32
+ - The `derivePath`, `deriveIndex`, `deriveIndexRange`, and `discover` capabilities are now optional.
33
+ - A capability set to `true` indicates support, while `false` or `undefined` indicates no support.
34
+ - Keyrings no longer need to explicitly set unsupported capabilities to `false`.
35
+ - Change `KeyringWrapper.capabilities` from a readonly property to a getter ([#447](https://github.com/MetaMask/accounts/pull/447))
36
+ - Allows subclasses to override and return capabilities dynamically based on runtime state.
37
+ - Refine `EthAddressStruct` in order to make it compatible with the `Hex` type from `@metamask/utils` ([#405](https://github.com/MetaMask/accounts/pull/405))
38
+
10
39
  ## [21.3.0]
11
40
 
12
41
  ### Added
13
42
 
14
- - Add initial `Keyringv2` interface ([#397](https://github.com/MetaMask/accounts/pull/397))
43
+ - Add initial `KeyringV2` interface ([#397](https://github.com/MetaMask/accounts/pull/397))
15
44
  - This is an on-going work and should not be used for now.
16
45
  - Add new Tron methods `signMessage` and `signTransaction` ([#401](https://github.com/MetaMask/accounts/pull/401))
17
46
 
@@ -655,7 +684,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
655
684
  - SnapController keyring client. It is intended to be used by MetaMask to talk to the snap.
656
685
  - Helper functions to create keyring handler in the snap.
657
686
 
658
- [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@21.3.0...HEAD
687
+ [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@21.4.0...HEAD
688
+ [21.4.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@21.3.0...@metamask/keyring-api@21.4.0
659
689
  [21.3.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@21.2.0...@metamask/keyring-api@21.3.0
660
690
  [21.2.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@21.1.0...@metamask/keyring-api@21.2.0
661
691
  [21.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@21.0.0...@metamask/keyring-api@21.1.0
package/README.md CHANGED
@@ -230,6 +230,10 @@ A unified keyring interface, designed to work for both native (EVM) keyrings and
230
230
  - Interface name: `KeyringV2`
231
231
  - Location: `@metamask/keyring-api/src/api/v2/keyring.ts`
232
232
 
233
+ ### Keyring wrapper
234
+
235
+ The `KeyringWrapper` helper adapts existing keyrings that implement the legacy `Keyring` interface to the new `KeyringV2` interface. It is intended to be subclassed in concrete keyrings, overriding the account management and request-handling methods to delegate to the underlying implementation.
236
+
233
237
  ## Migrating from 0.1.x to 0.2.x
234
238
 
235
239
  The following changes were made to the API, which may require changes to your
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KeyringAccountOptionsStruct = exports.KeyringAccountEntropyOptionsStruct = exports.KeyringAccountEntropyPrivateKeyOptionsStruct = exports.KeyringAccountEntropyMnemonicOptionsStruct = exports.KeyringAccountEntropyTypeOption = void 0;
3
+ exports.KeyringAccountOptionsStruct = exports.KeyringAccountEntropyOptionsStruct = exports.KeyringAccountEntropyCustomOptionsStruct = exports.KeyringAccountEntropyPrivateKeyOptionsStruct = exports.KeyringAccountEntropyMnemonicOptionsStruct = exports.KeyringAccountEntropyTypeOption = void 0;
4
4
  const keyring_utils_1 = require("@metamask/keyring-utils");
5
5
  const superstruct_1 = require("@metamask/superstruct");
6
6
  const utils_1 = require("@metamask/utils");
@@ -17,6 +17,11 @@ var KeyringAccountEntropyTypeOption;
17
17
  * Indicates that the account was imported from a private key.
18
18
  */
19
19
  KeyringAccountEntropyTypeOption["PrivateKey"] = "private-key";
20
+ /**
21
+ * Indicates that the account was created with custom, keyring-specific entropy.
22
+ * This is an opaque type where the entropy source is managed internally by the keyring.
23
+ */
24
+ KeyringAccountEntropyTypeOption["Custom"] = "custom";
20
25
  })(KeyringAccountEntropyTypeOption || (exports.KeyringAccountEntropyTypeOption = KeyringAccountEntropyTypeOption = {}));
21
26
  /**
22
27
  * Keyring account options struct for mnemonics (BIP-44).
@@ -51,20 +56,43 @@ exports.KeyringAccountEntropyPrivateKeyOptionsStruct = (0, superstruct_1.object)
51
56
  */
52
57
  type: (0, superstruct_1.literal)(`${KeyringAccountEntropyTypeOption.PrivateKey}`),
53
58
  });
59
+ /**
60
+ * Keyring account options struct for custom entropy.
61
+ *
62
+ * This is an opaque type where the entropy source is managed internally by the keyring.
63
+ * It behaves similarly to a private key import but allows keyrings to define their own
64
+ * entropy management strategy.
65
+ */
66
+ exports.KeyringAccountEntropyCustomOptionsStruct = (0, superstruct_1.object)({
67
+ /**
68
+ * Indicates that the account was created with custom, keyring-specific entropy.
69
+ */
70
+ type: (0, superstruct_1.literal)(`${KeyringAccountEntropyTypeOption.Custom}`),
71
+ });
54
72
  /**
55
73
  * Keyring account entropy options struct.
56
74
  */
57
75
  exports.KeyringAccountEntropyOptionsStruct = (0, keyring_utils_1.selectiveUnion)((value) => {
58
- return (0, utils_1.isPlainObject)(value) &&
59
- value.type === KeyringAccountEntropyTypeOption.PrivateKey
60
- ? exports.KeyringAccountEntropyPrivateKeyOptionsStruct
61
- : exports.KeyringAccountEntropyMnemonicOptionsStruct;
76
+ if (!(0, utils_1.isPlainObject)(value)) {
77
+ return exports.KeyringAccountEntropyMnemonicOptionsStruct;
78
+ }
79
+ switch (value.type) {
80
+ case KeyringAccountEntropyTypeOption.PrivateKey:
81
+ return exports.KeyringAccountEntropyPrivateKeyOptionsStruct;
82
+ case KeyringAccountEntropyTypeOption.Custom:
83
+ return exports.KeyringAccountEntropyCustomOptionsStruct;
84
+ case KeyringAccountEntropyTypeOption.Mnemonic:
85
+ return exports.KeyringAccountEntropyMnemonicOptionsStruct;
86
+ default:
87
+ return exports.KeyringAccountEntropyMnemonicOptionsStruct;
88
+ }
62
89
  });
63
90
  /**
64
91
  * Keyring options struct. This represents various options for a Keyring account object.
65
92
  *
66
- * See {@link KeyringAccountEntropyMnemonicOptionsStruct} and
67
- * {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.
93
+ * See {@link KeyringAccountEntropyMnemonicOptionsStruct},
94
+ * {@link KeyringAccountEntropyPrivateKeyOptionsStruct}, and
95
+ * {@link KeyringAccountEntropyCustomOptionsStruct}.
68
96
  *
69
97
  * @example
70
98
  * ```ts
@@ -91,6 +119,15 @@ exports.KeyringAccountEntropyOptionsStruct = (0, keyring_utils_1.selectiveUnion)
91
119
  * @example
92
120
  * ```ts
93
121
  * {
122
+ * entropy: {
123
+ * type: 'custom',
124
+ * },
125
+ * }
126
+ * ```
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * {
94
131
  * some: {
95
132
  * untyped: 'options',
96
133
  * something: true,
@@ -1 +1 @@
1
- {"version":3,"file":"account-options.cjs","sourceRoot":"","sources":["../../src/api/account-options.ts"],"names":[],"mappings":";;;AAAA,2DAA8E;AAE9E,uDAQ+B;AAC/B,2CAA4D;AAE5D;;GAEG;AACH,IAAY,+BAUX;AAVD,WAAY,+BAA+B;IACzC;;OAEG;IACH,wDAAqB,CAAA;IAErB;;OAEG;IACH,6DAA0B,CAAA;AAC5B,CAAC,EAVW,+BAA+B,+CAA/B,+BAA+B,QAU1C;AAED;;GAEG;AACU,QAAA,0CAA0C,GAAG,IAAA,oB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type { Infer } from '@metamask/superstruct';\nimport {\n boolean,\n intersection,\n literal,\n number,\n object,\n record,\n string,\n} from '@metamask/superstruct';\nimport { isPlainObject, JsonStruct } from '@metamask/utils';\n\n/**\n * Keyring account entropy valid types.\n */\nexport enum KeyringAccountEntropyTypeOption {\n /**\n * Indicates that the account was created from a mnemonic phrase.\n */\n Mnemonic = 'mnemonic',\n\n /**\n * Indicates that the account was imported from a private key.\n */\n PrivateKey = 'private-key',\n}\n\n/**\n * Keyring account options struct for mnemonics (BIP-44).\n */\nexport const KeyringAccountEntropyMnemonicOptionsStruct = object({\n /**\n * Indicates that the account was created from a mnemonic phrase.\n */\n type: literal(`${KeyringAccountEntropyTypeOption.Mnemonic}`),\n\n /**\n * The ID of the entropy source.\n */\n id: string(), // TODO: Define a struct for entropy source.\n\n /**\n * The BIP-44 derivation path used to derive the account.\n */\n derivationPath: string(),\n\n /**\n * Index used to group accounts in the UI.\n *\n * Accounts sharing the same `groupIndex` are displayed together as a\n * multichain account group.\n */\n groupIndex: number(),\n});\n\n/**\n * Keyring account options for mnemonics (BIP-44) {@link KeyringAccountEntropyMnemonicOptionsStruct}.\n */\nexport type KeyringAccountEntropyMnemonicOptions = Infer<\n typeof KeyringAccountEntropyMnemonicOptionsStruct\n>;\n\n/**\n * Keyring account options struct for private keys.\n */\nexport const KeyringAccountEntropyPrivateKeyOptionsStruct = object({\n /**\n * Indicates that the account was imported from a private key.\n */\n type: literal(`${KeyringAccountEntropyTypeOption.PrivateKey}`),\n});\n\n/**\n * Keyring account options for private keys {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.\n */\nexport type KeyringAccountEntropyPrivateKeyOptions = Infer<\n typeof KeyringAccountEntropyPrivateKeyOptionsStruct\n>;\n\n/**\n * Keyring account entropy options struct.\n */\nexport const KeyringAccountEntropyOptionsStruct = selectiveUnion(\n (value: any) => {\n return isPlainObject(value) &&\n value.type === KeyringAccountEntropyTypeOption.PrivateKey\n ? KeyringAccountEntropyPrivateKeyOptionsStruct\n : KeyringAccountEntropyMnemonicOptionsStruct;\n },\n);\n\n/**\n * Keyring account entropy options {@link KeyringAccountEntropyOptionsStruct}.\n */\nexport type KeyringAccountEntropyOptions = Infer<\n typeof KeyringAccountEntropyOptionsStruct\n>;\n\n/**\n * Keyring options struct. This represents various options for a Keyring account object.\n *\n * See {@link KeyringAccountEntropyMnemonicOptionsStruct} and\n * {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.\n *\n * @example\n * ```ts\n * {\n * entropy: {\n * type: 'mnemonic',\n * id: '01K0BX6VDR5DPDPGGNA8PZVBVB',\n * derivationPath: \"m/44'/60'/0'/0/0\",\n * groupIndex: 0,\n * },\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * entropy: {\n * type: 'private-key',\n * },\n * exportable: true,\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * some: {\n * untyped: 'options',\n * something: true,\n * },\n * }\n * ```\n */\nexport const KeyringAccountOptionsStruct = intersection([\n // Non-Typed options (retro-compatibility):\n record(string(), JsonStruct),\n\n // Typed options. We use `type` instead of `object` here, to allow\n // extra properties. Also, since we use `record` + `intersection` we\n // are guaranteed that all field values will match the `JsonStruct`.\n //\n // READ THIS CAREFULLY:\n // Previous options that can be matched by this struct will be breaking\n // existing keyring account options.\n type({\n /**\n * Entropy options.\n */\n entropy: exactOptional(KeyringAccountEntropyOptionsStruct),\n\n /**\n * Indicates whether the account can be exported.\n */\n exportable: exactOptional(boolean()),\n }),\n]);\n\n/**\n * Keyring account options {@link KeyringAccountOptionsStruct}.\n */\nexport type KeyringAccountOptions = Infer<typeof KeyringAccountOptionsStruct>;\n"]}
1
+ {"version":3,"file":"account-options.cjs","sourceRoot":"","sources":["../../src/api/account-options.ts"],"names":[],"mappings":";;;AAAA,2DAA8E;AAE9E,uDAQ+B;AAC/B,2CAA4D;AAE5D;;GAEG;AACH,IAAY,+BAgBX;AAhBD,WAAY,+BAA+B;IACzC;;OAEG;IACH,wDAAqB,CAAA;IAErB;;OAEG;I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ACF,CAAC;AASF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACU,QAAA,2BAA2B,GAAG,IAAA,0BAAY,EAAC;IACtD,2CAA2C;IAC3C,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,kBAAU,CAAC;IAE5B,kEAAkE;IAClE,oEAAoE;IACpE,oEAAoE;IACpE,EAAE;IACF,uBAAuB;IACvB,uEAAuE;IACvE,oCAAoC;IACpC,IAAA,oBAAI,EAAC;QACH;;WAEG;QACH,OAAO,EAAE,IAAA,6BAAa,EAAC,0CAAkC,CAAC;QAE1D;;WAEG;QACH,UAAU,EAAE,IAAA,6BAAa,EAAC,IAAA,qBAAO,GAAE,CAAC;KACrC,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { exactOptional, selectiveUnion, type } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n boolean,\n intersection,\n literal,\n number,\n object,\n record,\n string,\n} from '@metamask/superstruct';\nimport { isPlainObject, JsonStruct } from '@metamask/utils';\n\n/**\n * Keyring account entropy valid types.\n */\nexport enum KeyringAccountEntropyTypeOption {\n /**\n * Indicates that the account was created from a mnemonic phrase.\n */\n Mnemonic = 'mnemonic',\n\n /**\n * Indicates that the account was imported from a private key.\n */\n PrivateKey = 'private-key',\n\n /**\n * Indicates that the account was created with custom, keyring-specific entropy.\n * This is an opaque type where the entropy source is managed internally by the keyring.\n */\n Custom = 'custom',\n}\n\n/**\n * Keyring account options struct for mnemonics (BIP-44).\n */\nexport const KeyringAccountEntropyMnemonicOptionsStruct = object({\n /**\n * Indicates that the account was created from a mnemonic phrase.\n */\n type: literal(`${KeyringAccountEntropyTypeOption.Mnemonic}`),\n\n /**\n * The ID of the entropy source.\n */\n id: string(), // TODO: Define a struct for entropy source.\n\n /**\n * The BIP-44 derivation path used to derive the account.\n */\n derivationPath: string(),\n\n /**\n * Index used to group accounts in the UI.\n *\n * Accounts sharing the same `groupIndex` are displayed together as a\n * multichain account group.\n */\n groupIndex: number(),\n});\n\n/**\n * Keyring account options for mnemonics (BIP-44) {@link KeyringAccountEntropyMnemonicOptionsStruct}.\n */\nexport type KeyringAccountEntropyMnemonicOptions = Infer<\n typeof KeyringAccountEntropyMnemonicOptionsStruct\n>;\n\n/**\n * Keyring account options struct for private keys.\n */\nexport const KeyringAccountEntropyPrivateKeyOptionsStruct = object({\n /**\n * Indicates that the account was imported from a private key.\n */\n type: literal(`${KeyringAccountEntropyTypeOption.PrivateKey}`),\n});\n\n/**\n * Keyring account options for private keys {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.\n */\nexport type KeyringAccountEntropyPrivateKeyOptions = Infer<\n typeof KeyringAccountEntropyPrivateKeyOptionsStruct\n>;\n\n/**\n * Keyring account options struct for custom entropy.\n *\n * This is an opaque type where the entropy source is managed internally by the keyring.\n * It behaves similarly to a private key import but allows keyrings to define their own\n * entropy management strategy.\n */\nexport const KeyringAccountEntropyCustomOptionsStruct = object({\n /**\n * Indicates that the account was created with custom, keyring-specific entropy.\n */\n type: literal(`${KeyringAccountEntropyTypeOption.Custom}`),\n});\n\n/**\n * Keyring account options for custom entropy {@link KeyringAccountEntropyCustomOptionsStruct}.\n */\nexport type KeyringAccountEntropyCustomOptions = Infer<\n typeof KeyringAccountEntropyCustomOptionsStruct\n>;\n\n/**\n * Keyring account entropy options struct.\n */\nexport const KeyringAccountEntropyOptionsStruct = selectiveUnion(\n (value: any) => {\n if (!isPlainObject(value)) {\n return KeyringAccountEntropyMnemonicOptionsStruct;\n }\n\n switch (value.type) {\n case KeyringAccountEntropyTypeOption.PrivateKey:\n return KeyringAccountEntropyPrivateKeyOptionsStruct;\n case KeyringAccountEntropyTypeOption.Custom:\n return KeyringAccountEntropyCustomOptionsStruct;\n case KeyringAccountEntropyTypeOption.Mnemonic:\n return KeyringAccountEntropyMnemonicOptionsStruct;\n default:\n return KeyringAccountEntropyMnemonicOptionsStruct;\n }\n },\n);\n\n/**\n * Keyring account entropy options {@link KeyringAccountEntropyOptionsStruct}.\n */\nexport type KeyringAccountEntropyOptions = Infer<\n typeof KeyringAccountEntropyOptionsStruct\n>;\n\n/**\n * Keyring options struct. This represents various options for a Keyring account object.\n *\n * See {@link KeyringAccountEntropyMnemonicOptionsStruct},\n * {@link KeyringAccountEntropyPrivateKeyOptionsStruct}, and\n * {@link KeyringAccountEntropyCustomOptionsStruct}.\n *\n * @example\n * ```ts\n * {\n * entropy: {\n * type: 'mnemonic',\n * id: '01K0BX6VDR5DPDPGGNA8PZVBVB',\n * derivationPath: \"m/44'/60'/0'/0/0\",\n * groupIndex: 0,\n * },\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * entropy: {\n * type: 'private-key',\n * },\n * exportable: true,\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * entropy: {\n * type: 'custom',\n * },\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * some: {\n * untyped: 'options',\n * something: true,\n * },\n * }\n * ```\n */\nexport const KeyringAccountOptionsStruct = intersection([\n // Non-Typed options (retro-compatibility):\n record(string(), JsonStruct),\n\n // Typed options. We use `type` instead of `object` here, to allow\n // extra properties. Also, since we use `record` + `intersection` we\n // are guaranteed that all field values will match the `JsonStruct`.\n //\n // READ THIS CAREFULLY:\n // Previous options that can be matched by this struct will be breaking\n // existing keyring account options.\n type({\n /**\n * Entropy options.\n */\n entropy: exactOptional(KeyringAccountEntropyOptionsStruct),\n\n /**\n * Indicates whether the account can be exported.\n */\n exportable: exactOptional(boolean()),\n }),\n]);\n\n/**\n * Keyring account options {@link KeyringAccountOptionsStruct}.\n */\nexport type KeyringAccountOptions = Infer<typeof KeyringAccountOptionsStruct>;\n"]}
@@ -10,7 +10,12 @@ export declare enum KeyringAccountEntropyTypeOption {
10
10
  /**
11
11
  * Indicates that the account was imported from a private key.
12
12
  */
13
- PrivateKey = "private-key"
13
+ PrivateKey = "private-key",
14
+ /**
15
+ * Indicates that the account was created with custom, keyring-specific entropy.
16
+ * This is an opaque type where the entropy source is managed internally by the keyring.
17
+ */
18
+ Custom = "custom"
14
19
  }
15
20
  /**
16
21
  * Keyring account options struct for mnemonics (BIP-44).
@@ -60,6 +65,25 @@ export declare const KeyringAccountEntropyPrivateKeyOptionsStruct: import("@meta
60
65
  * Keyring account options for private keys {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.
61
66
  */
62
67
  export type KeyringAccountEntropyPrivateKeyOptions = Infer<typeof KeyringAccountEntropyPrivateKeyOptionsStruct>;
68
+ /**
69
+ * Keyring account options struct for custom entropy.
70
+ *
71
+ * This is an opaque type where the entropy source is managed internally by the keyring.
72
+ * It behaves similarly to a private key import but allows keyrings to define their own
73
+ * entropy management strategy.
74
+ */
75
+ export declare const KeyringAccountEntropyCustomOptionsStruct: import("@metamask/superstruct").Struct<{
76
+ type: "custom";
77
+ }, {
78
+ /**
79
+ * Indicates that the account was created with custom, keyring-specific entropy.
80
+ */
81
+ type: import("@metamask/superstruct").Struct<"custom", "custom">;
82
+ }>;
83
+ /**
84
+ * Keyring account options for custom entropy {@link KeyringAccountEntropyCustomOptionsStruct}.
85
+ */
86
+ export type KeyringAccountEntropyCustomOptions = Infer<typeof KeyringAccountEntropyCustomOptionsStruct>;
63
87
  /**
64
88
  * Keyring account entropy options struct.
65
89
  */
@@ -70,6 +94,8 @@ export declare const KeyringAccountEntropyOptionsStruct: import("@metamask/super
70
94
  groupIndex: number;
71
95
  } | {
72
96
  type: "private-key";
97
+ } | {
98
+ type: "custom";
73
99
  }, null>;
74
100
  /**
75
101
  * Keyring account entropy options {@link KeyringAccountEntropyOptionsStruct}.
@@ -78,8 +104,9 @@ export type KeyringAccountEntropyOptions = Infer<typeof KeyringAccountEntropyOpt
78
104
  /**
79
105
  * Keyring options struct. This represents various options for a Keyring account object.
80
106
  *
81
- * See {@link KeyringAccountEntropyMnemonicOptionsStruct} and
82
- * {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.
107
+ * See {@link KeyringAccountEntropyMnemonicOptionsStruct},
108
+ * {@link KeyringAccountEntropyPrivateKeyOptionsStruct}, and
109
+ * {@link KeyringAccountEntropyCustomOptionsStruct}.
83
110
  *
84
111
  * @example
85
112
  * ```ts
@@ -106,6 +133,15 @@ export type KeyringAccountEntropyOptions = Infer<typeof KeyringAccountEntropyOpt
106
133
  * @example
107
134
  * ```ts
108
135
  * {
136
+ * entropy: {
137
+ * type: 'custom',
138
+ * },
139
+ * }
140
+ * ```
141
+ *
142
+ * @example
143
+ * ```ts
144
+ * {
109
145
  * some: {
110
146
  * untyped: 'options',
111
147
  * something: true,
@@ -121,6 +157,8 @@ export declare const KeyringAccountOptionsStruct: import("@metamask/superstruct"
121
157
  groupIndex: number;
122
158
  } | {
123
159
  type: "private-key";
160
+ } | {
161
+ type: "custom";
124
162
  };
125
163
  exportable?: boolean;
126
164
  }, null>;
@@ -1 +1 @@
1
- {"version":3,"file":"account-options.d.cts","sourceRoot":"","sources":["../../src/api/account-options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAYnD;;GAEG;AACH,oBAAY,+BAA+B;IACzC;;OAEG;IACH,QAAQ,aAAa;IAErB;;OAEG;IACH,UAAU,gBAAgB;CAC3B;AAED;;GAEG;AACH,eAAO,MAAM,0CAA0C;;;;;;IACrD;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;;;OAKG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,KAAK,CACtD,OAAO,0CAA0C,CAClD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4CAA4C;;;IACvD;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG,KAAK,CACxD,OAAO,4CAA4C,CACpD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kCAAkC;;;;;;;QAO9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,KAAK,CAC9C,OAAO,kCAAkC,C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;AAEH;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
@@ -10,7 +10,12 @@ export declare enum KeyringAccountEntropyTypeOption {
10
10
  /**
11
11
  * Indicates that the account was imported from a private key.
12
12
  */
13
- PrivateKey = "private-key"
13
+ PrivateKey = "private-key",
14
+ /**
15
+ * Indicates that the account was created with custom, keyring-specific entropy.
16
+ * This is an opaque type where the entropy source is managed internally by the keyring.
17
+ */
18
+ Custom = "custom"
14
19
  }
15
20
  /**
16
21
  * Keyring account options struct for mnemonics (BIP-44).
@@ -60,6 +65,25 @@ export declare const KeyringAccountEntropyPrivateKeyOptionsStruct: import("@meta
60
65
  * Keyring account options for private keys {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.
61
66
  */
62
67
  export type KeyringAccountEntropyPrivateKeyOptions = Infer<typeof KeyringAccountEntropyPrivateKeyOptionsStruct>;
68
+ /**
69
+ * Keyring account options struct for custom entropy.
70
+ *
71
+ * This is an opaque type where the entropy source is managed internally by the keyring.
72
+ * It behaves similarly to a private key import but allows keyrings to define their own
73
+ * entropy management strategy.
74
+ */
75
+ export declare const KeyringAccountEntropyCustomOptionsStruct: import("@metamask/superstruct").Struct<{
76
+ type: "custom";
77
+ }, {
78
+ /**
79
+ * Indicates that the account was created with custom, keyring-specific entropy.
80
+ */
81
+ type: import("@metamask/superstruct").Struct<"custom", "custom">;
82
+ }>;
83
+ /**
84
+ * Keyring account options for custom entropy {@link KeyringAccountEntropyCustomOptionsStruct}.
85
+ */
86
+ export type KeyringAccountEntropyCustomOptions = Infer<typeof KeyringAccountEntropyCustomOptionsStruct>;
63
87
  /**
64
88
  * Keyring account entropy options struct.
65
89
  */
@@ -70,6 +94,8 @@ export declare const KeyringAccountEntropyOptionsStruct: import("@metamask/super
70
94
  groupIndex: number;
71
95
  } | {
72
96
  type: "private-key";
97
+ } | {
98
+ type: "custom";
73
99
  }, null>;
74
100
  /**
75
101
  * Keyring account entropy options {@link KeyringAccountEntropyOptionsStruct}.
@@ -78,8 +104,9 @@ export type KeyringAccountEntropyOptions = Infer<typeof KeyringAccountEntropyOpt
78
104
  /**
79
105
  * Keyring options struct. This represents various options for a Keyring account object.
80
106
  *
81
- * See {@link KeyringAccountEntropyMnemonicOptionsStruct} and
82
- * {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.
107
+ * See {@link KeyringAccountEntropyMnemonicOptionsStruct},
108
+ * {@link KeyringAccountEntropyPrivateKeyOptionsStruct}, and
109
+ * {@link KeyringAccountEntropyCustomOptionsStruct}.
83
110
  *
84
111
  * @example
85
112
  * ```ts
@@ -106,6 +133,15 @@ export type KeyringAccountEntropyOptions = Infer<typeof KeyringAccountEntropyOpt
106
133
  * @example
107
134
  * ```ts
108
135
  * {
136
+ * entropy: {
137
+ * type: 'custom',
138
+ * },
139
+ * }
140
+ * ```
141
+ *
142
+ * @example
143
+ * ```ts
144
+ * {
109
145
  * some: {
110
146
  * untyped: 'options',
111
147
  * something: true,
@@ -121,6 +157,8 @@ export declare const KeyringAccountOptionsStruct: import("@metamask/superstruct"
121
157
  groupIndex: number;
122
158
  } | {
123
159
  type: "private-key";
160
+ } | {
161
+ type: "custom";
124
162
  };
125
163
  exportable?: boolean;
126
164
  }, null>;
@@ -1 +1 @@
1
- {"version":3,"file":"account-options.d.mts","sourceRoot":"","sources":["../../src/api/account-options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAYnD;;GAEG;AACH,oBAAY,+BAA+B;IACzC;;OAEG;IACH,QAAQ,aAAa;IAErB;;OAEG;IACH,UAAU,gBAAgB;CAC3B;AAED;;GAEG;AACH,eAAO,MAAM,0CAA0C;;;;;;IACrD;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;;;OAKG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,KAAK,CACtD,OAAO,0CAA0C,CAClD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4CAA4C;;;IACvD;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG,KAAK,CACxD,OAAO,4CAA4C,CACpD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kCAAkC;;;;;;;QAO9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,KAAK,CAC9C,OAAO,kCAAkC,CAC1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;QAsBtC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
1
+ {"version":3,"file":"account-options.d.mts","sourceRoot":"","sources":["../../src/api/account-options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAYnD;;GAEG;AACH,oBAAY,+BAA+B;IACzC;;OAEG;IACH,QAAQ,aAAa;IAErB;;OAEG;IACH,UAAU,gBAAgB;IAE1B;;;OAGG;IACH,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,0CAA0C;;;;;;IACrD;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;;;OAKG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,KAAK,CACtD,OAAO,0CAA0C,CAClD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4CAA4C;;;IACvD;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG,KAAK,CACxD,OAAO,4CAA4C,CACpD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,wCAAwC;;;IACnD;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG,KAAK,CACpD,OAAO,wCAAwC,CAChD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kCAAkC;;;;;;;;;QAiB9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,KAAK,CAC9C,OAAO,kCAAkC,CAC1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;QAsBtC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
@@ -14,6 +14,11 @@ export var KeyringAccountEntropyTypeOption;
14
14
  * Indicates that the account was imported from a private key.
15
15
  */
16
16
  KeyringAccountEntropyTypeOption["PrivateKey"] = "private-key";
17
+ /**
18
+ * Indicates that the account was created with custom, keyring-specific entropy.
19
+ * This is an opaque type where the entropy source is managed internally by the keyring.
20
+ */
21
+ KeyringAccountEntropyTypeOption["Custom"] = "custom";
17
22
  })(KeyringAccountEntropyTypeOption || (KeyringAccountEntropyTypeOption = {}));
18
23
  /**
19
24
  * Keyring account options struct for mnemonics (BIP-44).
@@ -48,20 +53,43 @@ export const KeyringAccountEntropyPrivateKeyOptionsStruct = object({
48
53
  */
49
54
  type: literal(`${KeyringAccountEntropyTypeOption.PrivateKey}`),
50
55
  });
56
+ /**
57
+ * Keyring account options struct for custom entropy.
58
+ *
59
+ * This is an opaque type where the entropy source is managed internally by the keyring.
60
+ * It behaves similarly to a private key import but allows keyrings to define their own
61
+ * entropy management strategy.
62
+ */
63
+ export const KeyringAccountEntropyCustomOptionsStruct = object({
64
+ /**
65
+ * Indicates that the account was created with custom, keyring-specific entropy.
66
+ */
67
+ type: literal(`${KeyringAccountEntropyTypeOption.Custom}`),
68
+ });
51
69
  /**
52
70
  * Keyring account entropy options struct.
53
71
  */
54
72
  export const KeyringAccountEntropyOptionsStruct = selectiveUnion((value) => {
55
- return isPlainObject(value) &&
56
- value.type === KeyringAccountEntropyTypeOption.PrivateKey
57
- ? KeyringAccountEntropyPrivateKeyOptionsStruct
58
- : KeyringAccountEntropyMnemonicOptionsStruct;
73
+ if (!isPlainObject(value)) {
74
+ return KeyringAccountEntropyMnemonicOptionsStruct;
75
+ }
76
+ switch (value.type) {
77
+ case KeyringAccountEntropyTypeOption.PrivateKey:
78
+ return KeyringAccountEntropyPrivateKeyOptionsStruct;
79
+ case KeyringAccountEntropyTypeOption.Custom:
80
+ return KeyringAccountEntropyCustomOptionsStruct;
81
+ case KeyringAccountEntropyTypeOption.Mnemonic:
82
+ return KeyringAccountEntropyMnemonicOptionsStruct;
83
+ default:
84
+ return KeyringAccountEntropyMnemonicOptionsStruct;
85
+ }
59
86
  });
60
87
  /**
61
88
  * Keyring options struct. This represents various options for a Keyring account object.
62
89
  *
63
- * See {@link KeyringAccountEntropyMnemonicOptionsStruct} and
64
- * {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.
90
+ * See {@link KeyringAccountEntropyMnemonicOptionsStruct},
91
+ * {@link KeyringAccountEntropyPrivateKeyOptionsStruct}, and
92
+ * {@link KeyringAccountEntropyCustomOptionsStruct}.
65
93
  *
66
94
  * @example
67
95
  * ```ts
@@ -88,6 +116,15 @@ export const KeyringAccountEntropyOptionsStruct = selectiveUnion((value) => {
88
116
  * @example
89
117
  * ```ts
90
118
  * {
119
+ * entropy: {
120
+ * type: 'custom',
121
+ * },
122
+ * }
123
+ * ```
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * {
91
128
  * some: {
92
129
  * untyped: 'options',
93
130
  * something: true,
@@ -1 +1 @@
1
- {"version":3,"file":"account-options.mjs","sourceRoot":"","sources":["../../src/api/account-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,IAAI,EAAE,gCAAgC;AAE9E,OAAO,EACL,OAAO,EACP,YAAY,EACZ,OAAO,EACP,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACP,8BAA8B;AAC/B,OAAO,EAAE,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EG;QACH,OAAO,EAAE,aAAa,CAAC,kCAAkC,CAAC;QAE1D;;WAEG;QACH,UAAU,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC;KACrC,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { exactOptional, selectiveUnion, type } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n boolean,\n intersection,\n literal,\n number,\n object,\n record,\n string,\n} from '@metamask/superstruct';\nimport { isPlainObject, JsonStruct } from '@metamask/utils';\n\n/**\n * Keyring account entropy valid types.\n */\nexport enum KeyringAccountEntropyTypeOption {\n /**\n * Indicates that the account was created from a mnemonic phrase.\n */\n Mnemonic = 'mnemonic',\n\n /**\n * Indicates that the account was imported from a private key.\n */\n PrivateKey = 'private-key',\n}\n\n/**\n * Keyring account options struct for mnemonics (BIP-44).\n */\nexport const KeyringAccountEntropyMnemonicOptionsStruct = object({\n /**\n * Indicates that the account was created from a mnemonic phrase.\n */\n type: literal(`${KeyringAccountEntropyTypeOption.Mnemonic}`),\n\n /**\n * The ID of the entropy source.\n */\n id: string(), // TODO: Define a struct for entropy source.\n\n /**\n * The BIP-44 derivation path used to derive the account.\n */\n derivationPath: string(),\n\n /**\n * Index used to group accounts in the UI.\n *\n * Accounts sharing the same `groupIndex` are displayed together as a\n * multichain account group.\n */\n groupIndex: number(),\n});\n\n/**\n * Keyring account options for mnemonics (BIP-44) {@link KeyringAccountEntropyMnemonicOptionsStruct}.\n */\nexport type KeyringAccountEntropyMnemonicOptions = Infer<\n typeof KeyringAccountEntropyMnemonicOptionsStruct\n>;\n\n/**\n * Keyring account options struct for private keys.\n */\nexport const KeyringAccountEntropyPrivateKeyOptionsStruct = object({\n /**\n * Indicates that the account was imported from a private key.\n */\n type: literal(`${KeyringAccountEntropyTypeOption.PrivateKey}`),\n});\n\n/**\n * Keyring account options for private keys {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.\n */\nexport type KeyringAccountEntropyPrivateKeyOptions = Infer<\n typeof KeyringAccountEntropyPrivateKeyOptionsStruct\n>;\n\n/**\n * Keyring account entropy options struct.\n */\nexport const KeyringAccountEntropyOptionsStruct = selectiveUnion(\n (value: any) => {\n return isPlainObject(value) &&\n value.type === KeyringAccountEntropyTypeOption.PrivateKey\n ? KeyringAccountEntropyPrivateKeyOptionsStruct\n : KeyringAccountEntropyMnemonicOptionsStruct;\n },\n);\n\n/**\n * Keyring account entropy options {@link KeyringAccountEntropyOptionsStruct}.\n */\nexport type KeyringAccountEntropyOptions = Infer<\n typeof KeyringAccountEntropyOptionsStruct\n>;\n\n/**\n * Keyring options struct. This represents various options for a Keyring account object.\n *\n * See {@link KeyringAccountEntropyMnemonicOptionsStruct} and\n * {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.\n *\n * @example\n * ```ts\n * {\n * entropy: {\n * type: 'mnemonic',\n * id: '01K0BX6VDR5DPDPGGNA8PZVBVB',\n * derivationPath: \"m/44'/60'/0'/0/0\",\n * groupIndex: 0,\n * },\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * entropy: {\n * type: 'private-key',\n * },\n * exportable: true,\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * some: {\n * untyped: 'options',\n * something: true,\n * },\n * }\n * ```\n */\nexport const KeyringAccountOptionsStruct = intersection([\n // Non-Typed options (retro-compatibility):\n record(string(), JsonStruct),\n\n // Typed options. We use `type` instead of `object` here, to allow\n // extra properties. Also, since we use `record` + `intersection` we\n // are guaranteed that all field values will match the `JsonStruct`.\n //\n // READ THIS CAREFULLY:\n // Previous options that can be matched by this struct will be breaking\n // existing keyring account options.\n type({\n /**\n * Entropy options.\n */\n entropy: exactOptional(KeyringAccountEntropyOptionsStruct),\n\n /**\n * Indicates whether the account can be exported.\n */\n exportable: exactOptional(boolean()),\n }),\n]);\n\n/**\n * Keyring account options {@link KeyringAccountOptionsStruct}.\n */\nexport type KeyringAccountOptions = Infer<typeof KeyringAccountOptionsStruct>;\n"]}
1
+ {"version":3,"file":"account-options.mjs","sourceRoot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K,CAAC,EAAE,CAAC;QAC1B,OAAO,0CAA0C,CAAC;IACpD,CAAC;IAED,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,+BAA+B,CAAC,UAAU;YAC7C,OAAO,4CAA4C,CAAC;QACtD,KAAK,+BAA+B,CAAC,MAAM;YACzC,OAAO,wCAAwC,CAAC;QAClD,KAAK,+BAA+B,CAAC,QAAQ;YAC3C,OAAO,0CAA0C,CAAC;QACpD;YACE,OAAO,0CAA0C,CAAC;IACtD,CAAC;AACH,CAAC,CACF,CAAC;AASF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,YAAY,CAAC;IACtD,2CAA2C;IAC3C,MAAM,CAAC,MAAM,EAAE,EAAE,UAAU,CAAC;IAE5B,kEAAkE;IAClE,oEAAoE;IACpE,oEAAoE;IACpE,EAAE;IACF,uBAAuB;IACvB,uEAAuE;IACvE,oCAAoC;IACpC,IAAI,CAAC;QACH;;WAEG;QACH,OAAO,EAAE,aAAa,CAAC,kCAAkC,CAAC;QAE1D;;WAEG;QACH,UAAU,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC;KACrC,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { exactOptional, selectiveUnion, type } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n boolean,\n intersection,\n literal,\n number,\n object,\n record,\n string,\n} from '@metamask/superstruct';\nimport { isPlainObject, JsonStruct } from '@metamask/utils';\n\n/**\n * Keyring account entropy valid types.\n */\nexport enum KeyringAccountEntropyTypeOption {\n /**\n * Indicates that the account was created from a mnemonic phrase.\n */\n Mnemonic = 'mnemonic',\n\n /**\n * Indicates that the account was imported from a private key.\n */\n PrivateKey = 'private-key',\n\n /**\n * Indicates that the account was created with custom, keyring-specific entropy.\n * This is an opaque type where the entropy source is managed internally by the keyring.\n */\n Custom = 'custom',\n}\n\n/**\n * Keyring account options struct for mnemonics (BIP-44).\n */\nexport const KeyringAccountEntropyMnemonicOptionsStruct = object({\n /**\n * Indicates that the account was created from a mnemonic phrase.\n */\n type: literal(`${KeyringAccountEntropyTypeOption.Mnemonic}`),\n\n /**\n * The ID of the entropy source.\n */\n id: string(), // TODO: Define a struct for entropy source.\n\n /**\n * The BIP-44 derivation path used to derive the account.\n */\n derivationPath: string(),\n\n /**\n * Index used to group accounts in the UI.\n *\n * Accounts sharing the same `groupIndex` are displayed together as a\n * multichain account group.\n */\n groupIndex: number(),\n});\n\n/**\n * Keyring account options for mnemonics (BIP-44) {@link KeyringAccountEntropyMnemonicOptionsStruct}.\n */\nexport type KeyringAccountEntropyMnemonicOptions = Infer<\n typeof KeyringAccountEntropyMnemonicOptionsStruct\n>;\n\n/**\n * Keyring account options struct for private keys.\n */\nexport const KeyringAccountEntropyPrivateKeyOptionsStruct = object({\n /**\n * Indicates that the account was imported from a private key.\n */\n type: literal(`${KeyringAccountEntropyTypeOption.PrivateKey}`),\n});\n\n/**\n * Keyring account options for private keys {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.\n */\nexport type KeyringAccountEntropyPrivateKeyOptions = Infer<\n typeof KeyringAccountEntropyPrivateKeyOptionsStruct\n>;\n\n/**\n * Keyring account options struct for custom entropy.\n *\n * This is an opaque type where the entropy source is managed internally by the keyring.\n * It behaves similarly to a private key import but allows keyrings to define their own\n * entropy management strategy.\n */\nexport const KeyringAccountEntropyCustomOptionsStruct = object({\n /**\n * Indicates that the account was created with custom, keyring-specific entropy.\n */\n type: literal(`${KeyringAccountEntropyTypeOption.Custom}`),\n});\n\n/**\n * Keyring account options for custom entropy {@link KeyringAccountEntropyCustomOptionsStruct}.\n */\nexport type KeyringAccountEntropyCustomOptions = Infer<\n typeof KeyringAccountEntropyCustomOptionsStruct\n>;\n\n/**\n * Keyring account entropy options struct.\n */\nexport const KeyringAccountEntropyOptionsStruct = selectiveUnion(\n (value: any) => {\n if (!isPlainObject(value)) {\n return KeyringAccountEntropyMnemonicOptionsStruct;\n }\n\n switch (value.type) {\n case KeyringAccountEntropyTypeOption.PrivateKey:\n return KeyringAccountEntropyPrivateKeyOptionsStruct;\n case KeyringAccountEntropyTypeOption.Custom:\n return KeyringAccountEntropyCustomOptionsStruct;\n case KeyringAccountEntropyTypeOption.Mnemonic:\n return KeyringAccountEntropyMnemonicOptionsStruct;\n default:\n return KeyringAccountEntropyMnemonicOptionsStruct;\n }\n },\n);\n\n/**\n * Keyring account entropy options {@link KeyringAccountEntropyOptionsStruct}.\n */\nexport type KeyringAccountEntropyOptions = Infer<\n typeof KeyringAccountEntropyOptionsStruct\n>;\n\n/**\n * Keyring options struct. This represents various options for a Keyring account object.\n *\n * See {@link KeyringAccountEntropyMnemonicOptionsStruct},\n * {@link KeyringAccountEntropyPrivateKeyOptionsStruct}, and\n * {@link KeyringAccountEntropyCustomOptionsStruct}.\n *\n * @example\n * ```ts\n * {\n * entropy: {\n * type: 'mnemonic',\n * id: '01K0BX6VDR5DPDPGGNA8PZVBVB',\n * derivationPath: \"m/44'/60'/0'/0/0\",\n * groupIndex: 0,\n * },\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * entropy: {\n * type: 'private-key',\n * },\n * exportable: true,\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * entropy: {\n * type: 'custom',\n * },\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * some: {\n * untyped: 'options',\n * something: true,\n * },\n * }\n * ```\n */\nexport const KeyringAccountOptionsStruct = intersection([\n // Non-Typed options (retro-compatibility):\n record(string(), JsonStruct),\n\n // Typed options. We use `type` instead of `object` here, to allow\n // extra properties. Also, since we use `record` + `intersection` we\n // are guaranteed that all field values will match the `JsonStruct`.\n //\n // READ THIS CAREFULLY:\n // Previous options that can be matched by this struct will be breaking\n // existing keyring account options.\n type({\n /**\n * Entropy options.\n */\n entropy: exactOptional(KeyringAccountEntropyOptionsStruct),\n\n /**\n * Indicates whether the account can be exported.\n */\n exportable: exactOptional(boolean()),\n }),\n]);\n\n/**\n * Keyring account options {@link KeyringAccountOptionsStruct}.\n */\nexport type KeyringAccountOptions = Infer<typeof KeyringAccountOptionsStruct>;\n"]}
@@ -70,6 +70,8 @@ export declare const KeyringAccountStruct: import("@metamask/superstruct").Struc
70
70
  groupIndex: number;
71
71
  } | {
72
72
  type: "private-key";
73
+ } | {
74
+ type: "custom";
73
75
  };
74
76
  exportable?: boolean;
75
77
  };
@@ -114,6 +116,8 @@ export declare const KeyringAccountStruct: import("@metamask/superstruct").Struc
114
116
  groupIndex: number;
115
117
  } | {
116
118
  type: "private-key";
119
+ } | {
120
+ type: "custom";
117
121
  };
118
122
  exportable?: boolean;
119
123
  }, null>;
@@ -1 +1 @@
1
- {"version":3,"file":"account.d.cts","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAMnD;;GAEG;AACH,oBAAY,cAAc;IACxB,GAAG,eAAe;IAClB,OAAO,mBAAmB;CAC3B;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,KAAK,iBAAiB;IACtB,IAAI,gBAAgB;IACpB,MAAM,kBAAkB;IACxB,IAAI,gBAAgB;CACrB;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,WAAW,wBAAwB;CACpC;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,GAAG,aAAa;CACjB;AAED;;;GAGG;AACH,oBAAY,cAAc;IACxB,OAAO,gBAAgB;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,GAAG,cAAc,CAAC,GAAG,EAAE,GACvB,GAAG,cAAc,CAAC,OAAO,EAAE,GAC3B,GAAG,cAAc,CAAC,KAAK,EAAE,GACzB,GAAG,cAAc,CAAC,IAAI,EAAE,GACxB,GAAG,cAAc,CAAC,MAAM,EAAE,GAC1B,GAAG,cAAc,CAAC,IAAI,EAAE,GACxB,GAAG,cAAc,CAAC,WAAW,EAAE,GAC/B,GAAG,cAA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AO,EAAE,CAAC;AAEhC;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;EAUnC,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;IAC/B;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;IAaH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
@@ -70,6 +70,8 @@ export declare const KeyringAccountStruct: import("@metamask/superstruct").Struc
70
70
  groupIndex: number;
71
71
  } | {
72
72
  type: "private-key";
73
+ } | {
74
+ type: "custom";
73
75
  };
74
76
  exportable?: boolean;
75
77
  };
@@ -114,6 +116,8 @@ export declare const KeyringAccountStruct: import("@metamask/superstruct").Struc
114
116
  groupIndex: number;
115
117
  } | {
116
118
  type: "private-key";
119
+ } | {
120
+ type: "custom";
117
121
  };
118
122
  exportable?: boolean;
119
123
  }, null>;
@@ -1 +1 @@
1
- {"version":3,"file":"account.d.mts","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAMnD;;GAEG;AACH,oBAAY,cAAc;IACxB,GAAG,eAAe;IAClB,OAAO,mBAAmB;CAC3B;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,KAAK,iBAAiB;IACtB,IAAI,gBAAgB;IACpB,MAAM,kBAAkB;IACxB,IAAI,gBAAgB;CACrB;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,WAAW,wBAAwB;CACpC;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,GAAG,aAAa;CACjB;AAED;;;GAGG;AACH,oBAAY,cAAc;IACxB,OAAO,gBAAgB;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,GAAG,cAAc,CAAC,GAA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C3B,GAAG,cAAc,CAAC,KAAK,EAAE,GACzB,GAAG,cAAc,CAAC,IAAI,EAAE,GACxB,GAAG,cAAc,CAAC,MAAM,EAAE,GAC1B,GAAG,cAAc,CAAC,IAAI,EAAE,GACxB,GAAG,cAAc,CAAC,WAAW,EAAE,GAC/B,GAAG,cAAc,CAAC,GAAG,EAAE,GACvB,GAAG,cAAc,CAAC,OAAO,EAAE,CAAC;AAEhC;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;EAUnC,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;IAC/B;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;IAaH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
@@ -1,5 +1,3 @@
1
1
  "use strict";
2
- /* eslint-disable @typescript-eslint/no-redundant-type-constituents */
3
- // This rule seems to be triggering a false positive on the `KeyringAccount`.
4
2
  Object.defineProperty(exports, "__esModule", { value: true });
5
3
  //# sourceMappingURL=keyring.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyring.cjs","sourceRoot":"","sources":["../../src/api/keyring.ts"],"names":[],"mappings":";AAAA,sEAAsE;AACtE,6EAA6E","sourcesContent":["/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\n// This rule seems to be triggering a false positive on the `KeyringAccount`.\n\nimport type { AccountId, JsonRpcRequest } from '@metamask/keyring-utils';\nimport type { Json } from '@metamask/utils';\n\nimport type { KeyringAccount } from './account';\nimport type { ResolvedAccountAddress } from './address';\nimport type { Balance } from './balance';\nimport type { CaipChainId, CaipAssetType, CaipAssetTypeOrId } from './caip';\nimport type { DiscoveredAccount } from './discovery';\nimport type { EntropySourceId } from './entropy';\nimport type { KeyringAccountData } from './export';\nimport type { MetaMaskOptions } from './options';\nimport type { Paginated, Pagination } from './pagination';\nimport type { KeyringRequest } from './request';\nimport type { KeyringResponse } from './response';\nimport type { Transaction } from './transaction';\n\n/**\n * Keyring interface.\n *\n * Represents the functionality and operations related to managing accounts and\n * handling requests.\n */\nexport type Keyring = {\n /**\n * List accounts.\n *\n * Retrieves an array of KeyringAccount objects representing the available\n * accounts.\n *\n * @returns A promise that resolves to an array of KeyringAccount objects.\n */\n listAccounts(): Promise<KeyringAccount[]>;\n\n /**\n * Get an account.\n *\n * Retrieves the KeyringAccount object for the given account ID.\n *\n * @param id - The ID of the account to retrieve.\n * @returns A promise that resolves to the KeyringAccount object if found, or\n * undefined otherwise.\n */\n getAccount(id: string): Promise<KeyringAccount | undefined>;\n\n /**\n * Create an account.\n *\n * Creates a new account with optional, keyring-defined, account options.\n *\n * @param options - Keyring-defined options for the account (optional). The\n * 'metamask' internal options needs to be re-emitted during `notify:*` events.\n * @returns A promise that resolves to the newly created KeyringAccount\n * object without any private information.\n */\n createAccount(\n options?: Record<string, Json> & MetaMaskOptions,\n ): Promise<KeyringAccount>;\n\n /**\n * Lists the assets of an account (fungibles and non-fungibles) represented\n * by their respective CAIP-19:\n * - Asset types for fungibles assets.\n * - Asset IDs for non-fungible ones.\n *\n * @param id - The ID of the account to list the assets for.\n * @returns A promise that resolves to list of assets for that account.\n */\n listAccountAssets?(id: string): Promise<CaipAssetTypeOrId[]>;\n\n /**\n * Lists the transactions of an account, paginated and ordered by the most\n * recent first.\n *\n * The pagination options are used to limit the number of transactions in the\n * response and to iterate over the results.\n *\n * @param id - The ID of the account to list the transactions for.\n * @param pagination - The pagination options.\n * @returns A promise that resolves to the next page of transactions.\n */\n listAccountTransactions?(\n id: string,\n pagination: Pagination,\n ): Promise<Paginated<Transaction>>;\n\n /**\n * Discover accounts.\n *\n * This method is called by the client to allow the keyring to discover\n * existing accounts based on the provided scopes and entropy source ID. Are\n * considered existing accounts, accounts that have at least one transaction,\n * as per BIP-44.\n *\n * The `groupIndex` is used to group accounts with the same value. In\n * strictly BIP-44 wallets, it matches `account_index`, but in wallets that\n * deviate from BIP-44 recommendations, it may align with a different path\n * level for compatibility.\n *\n * @param scopes - The list of scopes for account discovery.\n * @param entropySource - The ID of the entropy source used to derive the accounts.\n * @param groupIndex - The group index that should be used to derive the accounts.\n * @returns A promise resolving to a list of discovered accounts.\n */\n discoverAccounts?(\n scopes: CaipChainId[],\n entropySource: EntropySourceId,\n groupIndex: number,\n ): Promise<DiscoveredAccount[]>;\n\n /**\n * Retrieve the balances of a given account.\n *\n * This method fetches the balances of specified assets for a given account\n * ID. It returns a promise that resolves to an object where the keys are\n * asset types and the values are balance objects containing the amount and\n * unit.\n *\n * @example\n * ```ts\n * await keyring.getAccountBalances(\n * '43550276-c7d6-4fac-87c7-00390ad0ce90',\n * ['bip122:000000000019d6689c085ae165831e93/slip44:0']\n * );\n * // Returns something similar to:\n * // {\n * // 'bip122:000000000019d6689c085ae165831e93/slip44:0': {\n * // amount: '0.0001',\n * // unit: 'BTC',\n * // }\n * // }\n * ```\n * @param id - ID of the account to retrieve the balances for.\n * @param assets - Array of asset types (CAIP-19) to retrieve balances for.\n * @returns A promise that resolves to an object mapping asset types to their\n * respective balances.\n */\n getAccountBalances?(\n id: string,\n assets: CaipAssetType[],\n ): Promise<Record<CaipAssetType, Balance>>;\n\n /**\n * Resolves the address of an account from a signing request.\n *\n * This is required by the routing system of MetaMask to dispatch\n * incoming non-EVM dapp signing requests.\n *\n * @param scope - Request's scope (CAIP-2).\n * @param request - Signing request object.\n * @returns A Promise that resolves to the account address that must\n * be used to process this signing request, or null if none candidates\n * could be found.\n */\n resolveAccountAddress?(\n scope: CaipChainId,\n request: JsonRpcRequest,\n ): Promise<ResolvedAccountAddress | null>;\n\n /**\n * Set the selected accounts.\n *\n * @param accounts - The accounts to set as selected.\n */\n setSelectedAccounts?(accounts: AccountId[]): Promise<void>;\n\n /**\n * Filter supported chains for a given account.\n *\n * @param id - ID of the account to be checked.\n * @param chains - List of chains (CAIP-2) to be checked.\n * @returns A Promise that resolves to a filtered list of CAIP-2 IDs\n * representing the supported chains.\n */\n filterAccountChains(id: string, chains: string[]): Promise<string[]>;\n\n /**\n * Update an account.\n *\n * Updates the account with the given account object. Does nothing if the\n * account does not exist.\n *\n * @param account - The updated account object.\n * @returns A promise that resolves when the account is successfully updated.\n */\n updateAccount(account: KeyringAccount): Promise<void>;\n\n /**\n * Delete an account from the keyring.\n *\n * Deletes the account with the given ID from the keyring.\n *\n * @param id - The ID of the account to delete.\n * @returns A promise that resolves when the account is successfully deleted.\n */\n deleteAccount(id: string): Promise<void>;\n\n /**\n * Exports an account's private key.\n *\n * If the keyring cannot export a private key, this function should throw an\n * error.\n *\n * @param id - The ID of the account to export.\n * @returns A promise that resolves to the exported account.\n */\n exportAccount?(id: string): Promise<KeyringAccountData>;\n\n /**\n * List all submitted requests.\n *\n * Retrieves an array of KeyringRequest objects representing the submitted\n * requests.\n *\n * @returns A promise that resolves to an array of KeyringRequest objects.\n */\n listRequests?(): Promise<KeyringRequest[]>;\n\n /**\n * Get a request.\n *\n * Retrieves the KeyringRequest object for the given request ID.\n *\n * @param id - The ID of the request to retrieve.\n * @returns A promise that resolves to the KeyringRequest object if found, or\n * undefined otherwise.\n */\n getRequest?(id: string): Promise<KeyringRequest | undefined>;\n\n /**\n * Submit a request.\n *\n * Submits the given KeyringRequest object.\n *\n * @param request - The KeyringRequest object to submit.\n * @returns A promise that resolves to the request response.\n */\n submitRequest(request: KeyringRequest): Promise<KeyringResponse>;\n\n /**\n * Approve a request.\n *\n * Approves the request with the given ID and sets the response if provided.\n *\n * @param id - The ID of the request to approve.\n * @param data - The response to the request (optional).\n * @returns A promise that resolves when the request is successfully\n * approved.\n */\n approveRequest?(id: string, data?: Record<string, Json>): Promise<void>;\n\n /**\n * Reject a request.\n *\n * Rejects the request with the given ID.\n *\n * @param id - The ID of the request to reject.\n * @returns A promise that resolves when the request is successfully\n * rejected.\n */\n rejectRequest?(id: string): Promise<void>;\n};\n"]}
1
+ {"version":3,"file":"keyring.cjs","sourceRoot":"","sources":["../../src/api/keyring.ts"],"names":[],"mappings":"","sourcesContent":["import type { AccountId, JsonRpcRequest } from '@metamask/keyring-utils';\nimport type { Json } from '@metamask/utils';\n\nimport type { KeyringAccount } from './account';\nimport type { ResolvedAccountAddress } from './address';\nimport type { Balance } from './balance';\nimport type { CaipChainId, CaipAssetType, CaipAssetTypeOrId } from './caip';\nimport type { DiscoveredAccount } from './discovery';\nimport type { EntropySourceId } from './entropy';\nimport type { KeyringAccountData } from './export';\nimport type { MetaMaskOptions } from './options';\nimport type { Paginated, Pagination } from './pagination';\nimport type { KeyringRequest } from './request';\nimport type { KeyringResponse } from './response';\nimport type { Transaction } from './transaction';\nimport type { CreateAccountOptions } from './v2';\n\n/**\n * Keyring interface.\n *\n * Represents the functionality and operations related to managing accounts and\n * handling requests.\n */\nexport type Keyring = {\n /**\n * List accounts.\n *\n * Retrieves an array of KeyringAccount objects representing the available\n * accounts.\n *\n * @returns A promise that resolves to an array of KeyringAccount objects.\n */\n listAccounts(): Promise<KeyringAccount[]>;\n\n /**\n * Get an account.\n *\n * Retrieves the KeyringAccount object for the given account ID.\n *\n * @param id - The ID of the account to retrieve.\n * @returns A promise that resolves to the KeyringAccount object if found, or\n * undefined otherwise.\n */\n getAccount(id: string): Promise<KeyringAccount | undefined>;\n\n /**\n * Create an account.\n *\n * Creates a new account with optional, keyring-defined, account options.\n *\n * @param options - Keyring-defined options for the account (optional). The\n * 'metamask' internal options needs to be re-emitted during `notify:*` events.\n * @returns A promise that resolves to the newly created KeyringAccount\n * object without any private information.\n */\n createAccount(\n options?: Record<string, Json> & MetaMaskOptions,\n ): Promise<KeyringAccount>;\n\n /**\n * Creates one or more new accounts according to the provided options.\n *\n * Deterministic account creation MUST be idempotent, meaning that for\n * deterministic algorithms, like BIP-44, calling this method with the same\n * options should always return the same accounts, even if the accounts\n * already exist in the keyring.\n *\n * @param options - Options describing how to create the account(s).\n * @returns A promise that resolves to an array of the created account objects.\n */\n createAccounts?(options: CreateAccountOptions): Promise<KeyringAccount[]>;\n\n /**\n * Lists the assets of an account (fungibles and non-fungibles) represented\n * by their respective CAIP-19:\n * - Asset types for fungibles assets.\n * - Asset IDs for non-fungible ones.\n *\n * @param id - The ID of the account to list the assets for.\n * @returns A promise that resolves to list of assets for that account.\n */\n listAccountAssets?(id: string): Promise<CaipAssetTypeOrId[]>;\n\n /**\n * Lists the transactions of an account, paginated and ordered by the most\n * recent first.\n *\n * The pagination options are used to limit the number of transactions in the\n * response and to iterate over the results.\n *\n * @param id - The ID of the account to list the transactions for.\n * @param pagination - The pagination options.\n * @returns A promise that resolves to the next page of transactions.\n */\n listAccountTransactions?(\n id: string,\n pagination: Pagination,\n ): Promise<Paginated<Transaction>>;\n\n /**\n * Discover accounts.\n *\n * This method is called by the client to allow the keyring to discover\n * existing accounts based on the provided scopes and entropy source ID. Are\n * considered existing accounts, accounts that have at least one transaction,\n * as per BIP-44.\n *\n * The `groupIndex` is used to group accounts with the same value. In\n * strictly BIP-44 wallets, it matches `account_index`, but in wallets that\n * deviate from BIP-44 recommendations, it may align with a different path\n * level for compatibility.\n *\n * @param scopes - The list of scopes for account discovery.\n * @param entropySource - The ID of the entropy source used to derive the accounts.\n * @param groupIndex - The group index that should be used to derive the accounts.\n * @returns A promise resolving to a list of discovered accounts.\n */\n discoverAccounts?(\n scopes: CaipChainId[],\n entropySource: EntropySourceId,\n groupIndex: number,\n ): Promise<DiscoveredAccount[]>;\n\n /**\n * Retrieve the balances of a given account.\n *\n * This method fetches the balances of specified assets for a given account\n * ID. It returns a promise that resolves to an object where the keys are\n * asset types and the values are balance objects containing the amount and\n * unit.\n *\n * @example\n * ```ts\n * await keyring.getAccountBalances(\n * '43550276-c7d6-4fac-87c7-00390ad0ce90',\n * ['bip122:000000000019d6689c085ae165831e93/slip44:0']\n * );\n * // Returns something similar to:\n * // {\n * // 'bip122:000000000019d6689c085ae165831e93/slip44:0': {\n * // amount: '0.0001',\n * // unit: 'BTC',\n * // }\n * // }\n * ```\n * @param id - ID of the account to retrieve the balances for.\n * @param assets - Array of asset types (CAIP-19) to retrieve balances for.\n * @returns A promise that resolves to an object mapping asset types to their\n * respective balances.\n */\n getAccountBalances?(\n id: string,\n assets: CaipAssetType[],\n ): Promise<Record<CaipAssetType, Balance>>;\n\n /**\n * Resolves the address of an account from a signing request.\n *\n * This is required by the routing system of MetaMask to dispatch\n * incoming non-EVM dapp signing requests.\n *\n * @param scope - Request's scope (CAIP-2).\n * @param request - Signing request object.\n * @returns A Promise that resolves to the account address that must\n * be used to process this signing request, or null if none candidates\n * could be found.\n */\n resolveAccountAddress?(\n scope: CaipChainId,\n request: JsonRpcRequest,\n ): Promise<ResolvedAccountAddress | null>;\n\n /**\n * Set the selected accounts.\n *\n * @param accounts - The accounts to set as selected.\n */\n setSelectedAccounts?(accounts: AccountId[]): Promise<void>;\n\n /**\n * Filter supported chains for a given account.\n *\n * @param id - ID of the account to be checked.\n * @param chains - List of chains (CAIP-2) to be checked.\n * @returns A Promise that resolves to a filtered list of CAIP-2 IDs\n * representing the supported chains.\n */\n filterAccountChains(id: string, chains: string[]): Promise<string[]>;\n\n /**\n * Update an account.\n *\n * Updates the account with the given account object. Does nothing if the\n * account does not exist.\n *\n * @param account - The updated account object.\n * @returns A promise that resolves when the account is successfully updated.\n */\n updateAccount(account: KeyringAccount): Promise<void>;\n\n /**\n * Delete an account from the keyring.\n *\n * Deletes the account with the given ID from the keyring.\n *\n * @param id - The ID of the account to delete.\n * @returns A promise that resolves when the account is successfully deleted.\n */\n deleteAccount(id: string): Promise<void>;\n\n /**\n * Exports an account's private key.\n *\n * If the keyring cannot export a private key, this function should throw an\n * error.\n *\n * @param id - The ID of the account to export.\n * @returns A promise that resolves to the exported account.\n */\n exportAccount?(id: string): Promise<KeyringAccountData>;\n\n /**\n * List all submitted requests.\n *\n * Retrieves an array of KeyringRequest objects representing the submitted\n * requests.\n *\n * @returns A promise that resolves to an array of KeyringRequest objects.\n */\n listRequests?(): Promise<KeyringRequest[]>;\n\n /**\n * Get a request.\n *\n * Retrieves the KeyringRequest object for the given request ID.\n *\n * @param id - The ID of the request to retrieve.\n * @returns A promise that resolves to the KeyringRequest object if found, or\n * undefined otherwise.\n */\n getRequest?(id: string): Promise<KeyringRequest | undefined>;\n\n /**\n * Submit a request.\n *\n * Submits the given KeyringRequest object.\n *\n * @param request - The KeyringRequest object to submit.\n * @returns A promise that resolves to the request response.\n */\n submitRequest(request: KeyringRequest): Promise<KeyringResponse>;\n\n /**\n * Approve a request.\n *\n * Approves the request with the given ID and sets the response if provided.\n *\n * @param id - The ID of the request to approve.\n * @param data - The response to the request (optional).\n * @returns A promise that resolves when the request is successfully\n * approved.\n */\n approveRequest?(id: string, data?: Record<string, Json>): Promise<void>;\n\n /**\n * Reject a request.\n *\n * Rejects the request with the given ID.\n *\n * @param id - The ID of the request to reject.\n * @returns A promise that resolves when the request is successfully\n * rejected.\n */\n rejectRequest?(id: string): Promise<void>;\n};\n"]}
@@ -12,6 +12,7 @@ import type { Paginated, Pagination } from "./pagination.cjs";
12
12
  import type { KeyringRequest } from "./request.cjs";
13
13
  import type { KeyringResponse } from "./response.cjs";
14
14
  import type { Transaction } from "./transaction.cjs";
15
+ import type { CreateAccountOptions } from "./v2/index.cjs";
15
16
  /**
16
17
  * Keyring interface.
17
18
  *
@@ -49,6 +50,18 @@ export type Keyring = {
49
50
  * object without any private information.
50
51
  */
51
52
  createAccount(options?: Record<string, Json> & MetaMaskOptions): Promise<KeyringAccount>;
53
+ /**
54
+ * Creates one or more new accounts according to the provided options.
55
+ *
56
+ * Deterministic account creation MUST be idempotent, meaning that for
57
+ * deterministic algorithms, like BIP-44, calling this method with the same
58
+ * options should always return the same accounts, even if the accounts
59
+ * already exist in the keyring.
60
+ *
61
+ * @param options - Options describing how to create the account(s).
62
+ * @returns A promise that resolves to an array of the created account objects.
63
+ */
64
+ createAccounts?(options: CreateAccountOptions): Promise<KeyringAccount[]>;
52
65
  /**
53
66
  * Lists the assets of an account (fungibles and non-fungibles) represented
54
67
  * by their respective CAIP-19: