@metamask-previews/keyring-api 21.3.0-feb98c5 → 21.5.0-fd40efd

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 (86) hide show
  1. package/CHANGELOG.md +43 -3
  2. package/dist/api/account-options.cjs +4 -0
  3. package/dist/api/account-options.cjs.map +1 -1
  4. package/dist/api/account-options.d.cts +4 -0
  5. package/dist/api/account-options.d.cts.map +1 -1
  6. package/dist/api/account-options.d.mts +4 -0
  7. package/dist/api/account-options.d.mts.map +1 -1
  8. package/dist/api/account-options.mjs +4 -0
  9. package/dist/api/account-options.mjs.map +1 -1
  10. package/dist/api/keyring.cjs.map +1 -1
  11. package/dist/api/keyring.d.cts +13 -0
  12. package/dist/api/keyring.d.cts.map +1 -1
  13. package/dist/api/keyring.d.mts +13 -0
  14. package/dist/api/keyring.d.mts.map +1 -1
  15. package/dist/api/keyring.mjs.map +1 -1
  16. package/dist/api/transaction.cjs +64 -1
  17. package/dist/api/transaction.cjs.map +1 -1
  18. package/dist/api/transaction.d.cts +135 -0
  19. package/dist/api/transaction.d.cts.map +1 -1
  20. package/dist/api/transaction.d.mts +135 -0
  21. package/dist/api/transaction.d.mts.map +1 -1
  22. package/dist/api/transaction.mjs +64 -1
  23. package/dist/api/transaction.mjs.map +1 -1
  24. package/dist/api/v2/create-account/bip44.cjs +27 -1
  25. package/dist/api/v2/create-account/bip44.cjs.map +1 -1
  26. package/dist/api/v2/create-account/bip44.d.cts +46 -0
  27. package/dist/api/v2/create-account/bip44.d.cts.map +1 -1
  28. package/dist/api/v2/create-account/bip44.d.mts +46 -0
  29. package/dist/api/v2/create-account/bip44.d.mts.map +1 -1
  30. package/dist/api/v2/create-account/bip44.mjs +26 -0
  31. package/dist/api/v2/create-account/bip44.mjs.map +1 -1
  32. package/dist/api/v2/create-account/index.cjs +44 -0
  33. package/dist/api/v2/create-account/index.cjs.map +1 -1
  34. package/dist/api/v2/create-account/index.d.cts +44 -0
  35. package/dist/api/v2/create-account/index.d.cts.map +1 -1
  36. package/dist/api/v2/create-account/index.d.mts +44 -0
  37. package/dist/api/v2/create-account/index.d.mts.map +1 -1
  38. package/dist/api/v2/create-account/index.mjs +44 -1
  39. package/dist/api/v2/create-account/index.mjs.map +1 -1
  40. package/dist/api/v2/keyring-capabilities.cjs +7 -3
  41. package/dist/api/v2/keyring-capabilities.cjs.map +1 -1
  42. package/dist/api/v2/keyring-capabilities.d.cts +16 -9
  43. package/dist/api/v2/keyring-capabilities.d.cts.map +1 -1
  44. package/dist/api/v2/keyring-capabilities.d.mts +16 -9
  45. package/dist/api/v2/keyring-capabilities.d.mts.map +1 -1
  46. package/dist/api/v2/keyring-capabilities.mjs +7 -3
  47. package/dist/api/v2/keyring-capabilities.mjs.map +1 -1
  48. package/dist/api/v2/wrapper/keyring-wrapper.cjs +21 -3
  49. package/dist/api/v2/wrapper/keyring-wrapper.cjs.map +1 -1
  50. package/dist/api/v2/wrapper/keyring-wrapper.d.cts +9 -1
  51. package/dist/api/v2/wrapper/keyring-wrapper.d.cts.map +1 -1
  52. package/dist/api/v2/wrapper/keyring-wrapper.d.mts +9 -1
  53. package/dist/api/v2/wrapper/keyring-wrapper.d.mts.map +1 -1
  54. package/dist/api/v2/wrapper/keyring-wrapper.mjs +21 -3
  55. package/dist/api/v2/wrapper/keyring-wrapper.mjs.map +1 -1
  56. package/dist/eth/erc4337/types.d.cts +4 -4
  57. package/dist/eth/erc4337/types.d.mts +4 -4
  58. package/dist/eth/rpc/params.cjs +1 -1
  59. package/dist/eth/rpc/params.cjs.map +1 -1
  60. package/dist/eth/rpc/params.d.cts +16 -16
  61. package/dist/eth/rpc/params.d.cts.map +1 -1
  62. package/dist/eth/rpc/params.d.mts +16 -16
  63. package/dist/eth/rpc/params.d.mts.map +1 -1
  64. package/dist/eth/rpc/params.mjs +2 -2
  65. package/dist/eth/rpc/params.mjs.map +1 -1
  66. package/dist/eth/types.cjs +5 -2
  67. package/dist/eth/types.cjs.map +1 -1
  68. package/dist/eth/types.d.cts +6 -5
  69. package/dist/eth/types.d.cts.map +1 -1
  70. package/dist/eth/types.d.mts +6 -5
  71. package/dist/eth/types.d.mts.map +1 -1
  72. package/dist/eth/types.mjs +4 -1
  73. package/dist/eth/types.mjs.map +1 -1
  74. package/dist/events.d.cts +12 -0
  75. package/dist/events.d.cts.map +1 -1
  76. package/dist/events.d.mts +12 -0
  77. package/dist/events.d.mts.map +1 -1
  78. package/dist/rpc.cjs +12 -1
  79. package/dist/rpc.cjs.map +1 -1
  80. package/dist/rpc.d.cts +189 -0
  81. package/dist/rpc.d.cts.map +1 -1
  82. package/dist/rpc.d.mts +189 -0
  83. package/dist/rpc.d.mts.map +1 -1
  84. package/dist/rpc.mjs +12 -1
  85. package/dist/rpc.mjs.map +1 -1
  86. package/package.json +3 -3
@@ -80,4 +80,50 @@ export declare const CreateAccountBip44DiscoverOptionsStruct: import("@metamask/
80
80
  * compatibility with other wallets.
81
81
  */
82
82
  export type CreateAccountBip44DiscoverOptions = Infer<typeof CreateAccountBip44DiscoverOptionsStruct>;
83
+ /**
84
+ * Struct for {@link CreateAccountBip44DeriveIndexRangeOptions}.
85
+ */
86
+ export declare const CreateAccountBip44DeriveIndexRangeOptionsStruct: import("@metamask/superstruct").Struct<{
87
+ type: "bip44:derive-index-range";
88
+ range: {
89
+ from: number;
90
+ to: number;
91
+ };
92
+ entropySource: string;
93
+ }, {
94
+ /**
95
+ * The type of the options.
96
+ */
97
+ type: import("@metamask/superstruct").Struct<"bip44:derive-index-range", "bip44:derive-index-range">;
98
+ /**
99
+ * ID of the entropy source to be used to derive the accounts.
100
+ */
101
+ entropySource: import("@metamask/superstruct").Struct<string, null>;
102
+ /**
103
+ * The range of account group indices to derive (inclusive on both ends).
104
+ */
105
+ range: import("@metamask/superstruct").Struct<{
106
+ from: number;
107
+ to: number;
108
+ }, {
109
+ /**
110
+ * The starting index of the account group range (inclusive).
111
+ */
112
+ from: import("@metamask/superstruct").Struct<number, null>;
113
+ /**
114
+ * The ending index of the account group range (inclusive).
115
+ */
116
+ to: import("@metamask/superstruct").Struct<number, null>;
117
+ }>;
118
+ }>;
119
+ /**
120
+ * Options for creating accounts by deriving a range of BIP-44 account indices.
121
+ *
122
+ * The range is inclusive on both ends, meaning range.from=0 and range.to=5
123
+ * will create accounts for group indices 0, 1, 2, 3, 4, and 5.
124
+ *
125
+ * Note that the keyring can support non-standard BIP-44 paths for
126
+ * compatibility with other wallets.
127
+ */
128
+ export type CreateAccountBip44DeriveIndexRangeOptions = Infer<typeof CreateAccountBip44DeriveIndexRangeOptionsStruct>;
83
129
  //# sourceMappingURL=bip44.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bip44.d.mts","sourceRoot":"","sources":["../../../../src/api/v2/create-account/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,KAAK,EACX,8BAA8B;AAI/B;;GAEG;AACH,eAAO,MAAM,yCAAyC;;;;;IACpD;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAAG,KAAK,CACrD,OAAO,yCAAyC,CACjD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0CAA0C;;;;;IACrD;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,oCAAoC,GAAG,KAAK,CACtD,OAAO,0CAA0C,CAClD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uCAAuC;;;;;IAClD;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,iCAAiC,GAAG,KAAK,CACnD,OAAO,uCAAuC,CAC/C,CAAC"}
1
+ {"version":3,"file":"bip44.d.mts","sourceRoot":"","sources":["../../../../src/api/v2/create-account/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,KAAK,EACX,8BAA8B;AAI/B;;GAEG;AACH,eAAO,MAAM,yCAAyC;;;;;IACpD;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAAG,KAAK,CACrD,OAAO,yCAAyC,CACjD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0CAA0C;;;;;IACrD;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,oCAAoC,GAAG,KAAK,CACtD,OAAO,0CAA0C,CAClD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uCAAuC;;;;;IAClD;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,iCAAiC,GAAG,KAAK,CACnD,OAAO,uCAAuC,CAC/C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,+CAA+C;;;;;;;;IAC1D;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;;;;QAED;;WAEG;;QAEH;;WAEG;;;EAGL,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,MAAM,yCAAyC,GAAG,KAAK,CAC3D,OAAO,+CAA+C,CACvD,CAAC"}
@@ -51,4 +51,30 @@ export const CreateAccountBip44DiscoverOptionsStruct = object({
51
51
  */
52
52
  groupIndex: number(),
53
53
  });
54
+ /**
55
+ * Struct for {@link CreateAccountBip44DeriveIndexRangeOptions}.
56
+ */
57
+ export const CreateAccountBip44DeriveIndexRangeOptionsStruct = object({
58
+ /**
59
+ * The type of the options.
60
+ */
61
+ type: literal('bip44:derive-index-range'),
62
+ /**
63
+ * ID of the entropy source to be used to derive the accounts.
64
+ */
65
+ entropySource: string(),
66
+ /**
67
+ * The range of account group indices to derive (inclusive on both ends).
68
+ */
69
+ range: object({
70
+ /**
71
+ * The starting index of the account group range (inclusive).
72
+ */
73
+ from: number(),
74
+ /**
75
+ * The ending index of the account group range (inclusive).
76
+ */
77
+ to: number(),
78
+ }),
79
+ });
54
80
  //# sourceMappingURL=bip44.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bip44.mjs","sourceRoot":"","sources":["../../../../src/api/v2/create-account/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,MAAM,EACN,MAAM,EACN,MAAM,EAEP,8BAA8B;AAE/B,OAAO,EAAE,oBAAoB,EAAE,6BAAyB;AAExD;;GAEG;AACH,MAAM,CAAC,MAAM,yCAAyC,GAAG,MAAM,CAAC;IAC9D;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,mBAAmB,CAAC;IAClC;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE;IACvB;;OAEG;IACH,cAAc,EAAE,oBAAoB;CACrC,CAAC,CAAC;AASH;;GAEG;AACH,MAAM,CAAC,MAAM,0CAA0C,GAAG,MAAM,CAAC;IAC/D;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC;IACnC;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE;IACvB;;OAEG;IACH,UAAU,EAAE,MAAM,EAAE;CACrB,CAAC,CAAC;AAYH;;GAEG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,MAAM,CAAC;IAC5D;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,gBAAgB,CAAC;IAC/B;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE;IACvB;;OAEG;IACH,UAAU,EAAE,MAAM,EAAE;CACrB,CAAC,CAAC","sourcesContent":["import {\n literal,\n number,\n object,\n string,\n type Infer,\n} from '@metamask/superstruct';\n\nimport { DerivationPathStruct } from '../../derivation';\n\n/**\n * Struct for {@link CreateAccountBip44DerivePathOptions}.\n */\nexport const CreateAccountBip44DerivePathOptionsStruct = object({\n /**\n * Type of the options.\n */\n type: literal('bip44:derive-path'),\n /**\n * ID of the entropy source to be used to derive the account.\n */\n entropySource: string(),\n /**\n * BIP-44 derivation path to be used to derive the account.\n */\n derivationPath: DerivationPathStruct,\n});\n\n/**\n * Options for creating an account using the given BIP-44 derivation path.\n */\nexport type CreateAccountBip44DerivePathOptions = Infer<\n typeof CreateAccountBip44DerivePathOptionsStruct\n>;\n\n/**\n * Struct for {@link CreateAccountBip44DeriveIndexOptions}.\n */\nexport const CreateAccountBip44DeriveIndexOptionsStruct = object({\n /**\n * The type of the options.\n */\n type: literal('bip44:derive-index'),\n /**\n * ID of the entropy source to be used to derive the account.\n */\n entropySource: string(),\n /**\n * The index of the account group to be derived.\n */\n groupIndex: number(),\n});\n\n/**\n * Options for creating an account using the given BIP-44 account group index.\n *\n * Note that the keyring can support non-standard BIP-44 paths for\n * compatibility with other wallets.\n */\nexport type CreateAccountBip44DeriveIndexOptions = Infer<\n typeof CreateAccountBip44DeriveIndexOptionsStruct\n>;\n\n/**\n * Struct for {@link CreateAccountBip44DiscoverOptions}.\n */\nexport const CreateAccountBip44DiscoverOptionsStruct = object({\n /**\n * The type of the options.\n */\n type: literal('bip44:discover'),\n /**\n * ID of the entropy source to be used to derive the account.\n */\n entropySource: string(),\n /**\n * The index of the account group to be derived.\n */\n groupIndex: number(),\n});\n\n/**\n * Options for creating accounts by performing a BIP-44 account discovery.\n *\n * Note that the keyring can support non-standard BIP-44 paths for\n * compatibility with other wallets.\n */\nexport type CreateAccountBip44DiscoverOptions = Infer<\n typeof CreateAccountBip44DiscoverOptionsStruct\n>;\n"]}
1
+ {"version":3,"file":"bip44.mjs","sourceRoot":"","sources":["../../../../src/api/v2/create-account/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,MAAM,EACN,MAAM,EACN,MAAM,EAEP,8BAA8B;AAE/B,OAAO,EAAE,oBAAoB,EAAE,6BAAyB;AAExD;;GAEG;AACH,MAAM,CAAC,MAAM,yCAAyC,GAAG,MAAM,CAAC;IAC9D;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,mBAAmB,CAAC;IAClC;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE;IACvB;;OAEG;IACH,cAAc,EAAE,oBAAoB;CACrC,CAAC,CAAC;AASH;;GAEG;AACH,MAAM,CAAC,MAAM,0CAA0C,GAAG,MAAM,CAAC;IAC/D;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC;IACnC;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE;IACvB;;OAEG;IACH,UAAU,EAAE,MAAM,EAAE;CACrB,CAAC,CAAC;AAYH;;GAEG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,MAAM,CAAC;IAC5D;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,gBAAgB,CAAC;IAC/B;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE;IACvB;;OAEG;IACH,UAAU,EAAE,MAAM,EAAE;CACrB,CAAC,CAAC;AAYH;;GAEG;AACH,MAAM,CAAC,MAAM,+CAA+C,GAAG,MAAM,CAAC;IACpE;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,0BAA0B,CAAC;IACzC;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE;IACvB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;QACZ;;WAEG;QACH,IAAI,EAAE,MAAM,EAAE;QACd;;WAEG;QACH,EAAE,EAAE,MAAM,EAAE;KACb,CAAC;CACH,CAAC,CAAC","sourcesContent":["import {\n literal,\n number,\n object,\n string,\n type Infer,\n} from '@metamask/superstruct';\n\nimport { DerivationPathStruct } from '../../derivation';\n\n/**\n * Struct for {@link CreateAccountBip44DerivePathOptions}.\n */\nexport const CreateAccountBip44DerivePathOptionsStruct = object({\n /**\n * Type of the options.\n */\n type: literal('bip44:derive-path'),\n /**\n * ID of the entropy source to be used to derive the account.\n */\n entropySource: string(),\n /**\n * BIP-44 derivation path to be used to derive the account.\n */\n derivationPath: DerivationPathStruct,\n});\n\n/**\n * Options for creating an account using the given BIP-44 derivation path.\n */\nexport type CreateAccountBip44DerivePathOptions = Infer<\n typeof CreateAccountBip44DerivePathOptionsStruct\n>;\n\n/**\n * Struct for {@link CreateAccountBip44DeriveIndexOptions}.\n */\nexport const CreateAccountBip44DeriveIndexOptionsStruct = object({\n /**\n * The type of the options.\n */\n type: literal('bip44:derive-index'),\n /**\n * ID of the entropy source to be used to derive the account.\n */\n entropySource: string(),\n /**\n * The index of the account group to be derived.\n */\n groupIndex: number(),\n});\n\n/**\n * Options for creating an account using the given BIP-44 account group index.\n *\n * Note that the keyring can support non-standard BIP-44 paths for\n * compatibility with other wallets.\n */\nexport type CreateAccountBip44DeriveIndexOptions = Infer<\n typeof CreateAccountBip44DeriveIndexOptionsStruct\n>;\n\n/**\n * Struct for {@link CreateAccountBip44DiscoverOptions}.\n */\nexport const CreateAccountBip44DiscoverOptionsStruct = object({\n /**\n * The type of the options.\n */\n type: literal('bip44:discover'),\n /**\n * ID of the entropy source to be used to derive the account.\n */\n entropySource: string(),\n /**\n * The index of the account group to be derived.\n */\n groupIndex: number(),\n});\n\n/**\n * Options for creating accounts by performing a BIP-44 account discovery.\n *\n * Note that the keyring can support non-standard BIP-44 paths for\n * compatibility with other wallets.\n */\nexport type CreateAccountBip44DiscoverOptions = Infer<\n typeof CreateAccountBip44DiscoverOptionsStruct\n>;\n\n/**\n * Struct for {@link CreateAccountBip44DeriveIndexRangeOptions}.\n */\nexport const CreateAccountBip44DeriveIndexRangeOptionsStruct = object({\n /**\n * The type of the options.\n */\n type: literal('bip44:derive-index-range'),\n /**\n * ID of the entropy source to be used to derive the accounts.\n */\n entropySource: string(),\n /**\n * The range of account group indices to derive (inclusive on both ends).\n */\n range: object({\n /**\n * The starting index of the account group range (inclusive).\n */\n from: number(),\n /**\n * The ending index of the account group range (inclusive).\n */\n to: number(),\n }),\n});\n\n/**\n * Options for creating accounts by deriving a range of BIP-44 account indices.\n *\n * The range is inclusive on both ends, meaning range.from=0 and range.to=5\n * will create accounts for group indices 0, 1, 2, 3, 4, and 5.\n *\n * Note that the keyring can support non-standard BIP-44 paths for\n * compatibility with other wallets.\n */\nexport type CreateAccountBip44DeriveIndexRangeOptions = Infer<\n typeof CreateAccountBip44DeriveIndexRangeOptionsStruct\n>;\n"]}
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.CreateAccountOptionsStruct = exports.AccountCreationType = void 0;
18
+ exports.assertCreateAccountOptionIsSupported = assertCreateAccountOptionIsSupported;
18
19
  const keyring_utils_1 = require("@metamask/keyring-utils");
19
20
  const bip44_1 = require("./bip44.cjs");
20
21
  const custom_1 = require("./custom.cjs");
@@ -39,6 +40,14 @@ var AccountCreationType;
39
40
  * index.
40
41
  */
41
42
  AccountCreationType["Bip44DeriveIndex"] = "bip44:derive-index";
43
+ /**
44
+ * Represents accounts created by deriving a range of BIP-44 account indices.
45
+ *
46
+ * More than one account can be created per index, for example, the keyring
47
+ * can create multiple account types (e.g., P2PKH, P2TR, P2WPKH) for each
48
+ * account index in the range.
49
+ */
50
+ AccountCreationType["Bip44DeriveIndexRange"] = "bip44:derive-index-range";
42
51
  /**
43
52
  * Represents accounts created through BIP-44 account discovery.
44
53
  *
@@ -69,6 +78,8 @@ exports.CreateAccountOptionsStruct = (0, keyring_utils_1.selectiveUnion)((value)
69
78
  return bip44_1.CreateAccountBip44DerivePathOptionsStruct;
70
79
  case AccountCreationType.Bip44DeriveIndex:
71
80
  return bip44_1.CreateAccountBip44DeriveIndexOptionsStruct;
81
+ case AccountCreationType.Bip44DeriveIndexRange:
82
+ return bip44_1.CreateAccountBip44DeriveIndexRangeOptionsStruct;
72
83
  case AccountCreationType.Bip44Discover:
73
84
  return bip44_1.CreateAccountBip44DiscoverOptionsStruct;
74
85
  case AccountCreationType.PrivateKeyImport:
@@ -80,4 +91,37 @@ exports.CreateAccountOptionsStruct = (0, keyring_utils_1.selectiveUnion)((value)
80
91
  return bip44_1.CreateAccountBip44DerivePathOptionsStruct;
81
92
  }
82
93
  });
94
+ /**
95
+ * Asserts that a given create account option type is supported by the keyring.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * createAccounts(options: CreateAccountOptions) {
100
+ * assertCreateAccountOptionIsSupported(options, [
101
+ * ${AccountCreationType.Bip44DeriveIndex},
102
+ * ${AccountCreationType.Bip44DeriveIndexRange},
103
+ * ] as const);
104
+ *
105
+ * // At this point, TypeScript knows that options.type is either Bip44DeriveIndex or Bip44DeriveIndexRange.
106
+ * if (options.type === AccountCreationType.Bip44DeriveIndex) {
107
+ * ... // Handle Bip44DeriveIndex case.
108
+ * } else {
109
+ * ... // Handle Bip44DeriveIndexRange case.
110
+ * }
111
+ * ...
112
+ * return accounts;
113
+ * }
114
+ * ```
115
+ *
116
+ * @param options - The create account option object to check.
117
+ * @param supportedTypes - The list of supported create account option types for this keyring.
118
+ * @throws Will throw an error if the provided options are not supported.
119
+ */
120
+ function assertCreateAccountOptionIsSupported(options, supportedTypes) {
121
+ const { type } = options;
122
+ const types = supportedTypes;
123
+ if (!types.includes(type)) {
124
+ throw new Error(`Unsupported create account option type: ${type}`);
125
+ }
126
+ }
83
127
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2DAAyD;AAGzD,uCAIiB;AACjB,yCAA4D;AAC5D,mDAAqE;AAErE,8CAAwB;AACxB,+CAAyB;AACzB,oDAA8B;AAE9B;;GAEG;AACH,IAAY,mBAoCX;AApCD,WAAY,mBAAmB;IAC7B;;OAEG;IACH,4DAAqC,CAAA;IAErC;;;;;;OAMG;IACH,8DAAuC,CAAA;IAEvC;;;;;;OAMG;IACH,uDAAgC,CAAA;IAEhC;;OAEG;IACH,8DAAuC,CAAA;IAEvC;;;;;OAKG;IACH,wCAAiB,CAAA;AACnB,CAAC,EApCW,mBAAmB,mCAAnB,mBAAmB,QAoC9B;AAED;;GAEG;AACU,QAAA,0BAA0B,GAAG,IAAA,8BAAc,EAAC,CAAC,KAAU,EAAE,EAAE;IACtE,MAAM,mBAAmB,GAAG,KAAK,EAAE,IAA2B,CAAC;IAC/D,QAAQ,mBAAmB,EAAE,CAAC;QAC5B,KAAK,mBAAmB,CAAC,eAAe;YACtC,OAAO,iDAAyC,CAAC;QACnD,KAAK,mBAAmB,CAAC,gBAAgB;YACvC,OAAO,kDAA0C,CAAC;QACpD,KAAK,mBAAmB,CAAC,aAAa;YACpC,OAAO,+CAAuC,CAAC;QACjD,KAAK,mBAAmB,CAAC,gBAAgB;YACvC,OAAO,kDAAoC,CAAC;QAC9C,KAAK,mBAAmB,CAAC,MAAM;YAC7B,OAAO,yCAAgC,CAAC;QAC1C;YACE,wGAAwG;YACxG,OAAO,iDAAyC,CAAC;IACrD,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { selectiveUnion } from '@metamask/keyring-utils';\nimport { type Infer } from '@metamask/superstruct';\n\nimport {\n CreateAccountBip44DiscoverOptionsStruct,\n CreateAccountBip44DeriveIndexOptionsStruct,\n CreateAccountBip44DerivePathOptionsStruct,\n} from './bip44';\nimport { CreateAccountCustomOptionsStruct } from './custom';\nimport { CreateAccountPrivateKeyOptionsStruct } from './private-key';\n\nexport * from './bip44';\nexport * from './custom';\nexport * from './private-key';\n\n/**\n * Enum representing the different ways an account can be created.\n */\nexport enum AccountCreationType {\n /**\n * Represents an account created using a BIP-44 derivation path.\n */\n Bip44DerivePath = 'bip44:derive-path',\n\n /**\n * Represents accounts created using a BIP-44 account index.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44DeriveIndex = 'bip44:derive-index',\n\n /**\n * Represents accounts created through BIP-44 account discovery.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44Discover = 'bip44:discover',\n\n /**\n * Represents an account imported from a private key.\n */\n PrivateKeyImport = 'private-key:import',\n\n /**\n * Represents an account created using a custom, keyring-specific method.\n *\n * This is used by keyrings that have non-standard account creation flows\n * and declare `custom.createAccounts: true` in their capabilities.\n */\n Custom = 'custom',\n}\n\n/**\n * Struct for {@link CreateAccountOptions}.\n */\nexport const CreateAccountOptionsStruct = selectiveUnion((value: any) => {\n const accountCreationType = value?.type as AccountCreationType;\n switch (accountCreationType) {\n case AccountCreationType.Bip44DerivePath:\n return CreateAccountBip44DerivePathOptionsStruct;\n case AccountCreationType.Bip44DeriveIndex:\n return CreateAccountBip44DeriveIndexOptionsStruct;\n case AccountCreationType.Bip44Discover:\n return CreateAccountBip44DiscoverOptionsStruct;\n case AccountCreationType.PrivateKeyImport:\n return CreateAccountPrivateKeyOptionsStruct;\n case AccountCreationType.Custom:\n return CreateAccountCustomOptionsStruct;\n default:\n // Return first struct as fallback - validation will fail with proper error indicating the type mismatch\n return CreateAccountBip44DerivePathOptionsStruct;\n }\n});\n\n/**\n * Represents the available options for creating a new account.\n */\nexport type CreateAccountOptions = Infer<typeof CreateAccountOptionsStruct>;\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAyHA,oFAeC;AAxID,2DAAyD;AAGzD,uCAKiB;AACjB,yCAA4D;AAC5D,mDAAqE;AAErE,8CAAwB;AACxB,+CAAyB;AACzB,oDAA8B;AAE9B;;GAEG;AACH,IAAY,mBA6CX;AA7CD,WAAY,mBAAmB;IAC7B;;OAEG;IACH,4DAAqC,CAAA;IAErC;;;;;;OAMG;IACH,8DAAuC,CAAA;IAEvC;;;;;;OAMG;IACH,yEAAkD,CAAA;IAElD;;;;;;OAMG;IACH,uDAAgC,CAAA;IAEhC;;OAEG;IACH,8DAAuC,CAAA;IAEvC;;;;;OAKG;IACH,wCAAiB,CAAA;AACnB,CAAC,EA7CW,mBAAmB,mCAAnB,mBAAmB,QA6C9B;AAED;;GAEG;AACU,QAAA,0BAA0B,GAAG,IAAA,8BAAc,EAAC,CAAC,KAAU,EAAE,EAAE;IACtE,MAAM,mBAAmB,GAAG,KAAK,EAAE,IAA2B,CAAC;IAC/D,QAAQ,mBAAmB,EAAE,CAAC;QAC5B,KAAK,mBAAmB,CAAC,eAAe;YACtC,OAAO,iDAAyC,CAAC;QACnD,KAAK,mBAAmB,CAAC,gBAAgB;YACvC,OAAO,kDAA0C,CAAC;QACpD,KAAK,mBAAmB,CAAC,qBAAqB;YAC5C,OAAO,uDAA+C,CAAC;QACzD,KAAK,mBAAmB,CAAC,aAAa;YACpC,OAAO,+CAAuC,CAAC;QACjD,KAAK,mBAAmB,CAAC,gBAAgB;YACvC,OAAO,kDAAoC,CAAC;QAC9C,KAAK,mBAAmB,CAAC,MAAM;YAC7B,OAAO,yCAAgC,CAAC;QAC1C;YACE,wGAAwG;YACxG,OAAO,iDAAyC,CAAC;IACrD,CAAC;AACH,CAAC,CAAC,CAAC;AAOH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,oCAAoC,CAKlD,OAAgB,EAChB,cAAoC;IAGpC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACzB,MAAM,KAAK,GAA4C,cAAc,CAAC;IAEtE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,2CAA2C,IAAI,EAAE,CAAC,CAAC;IACrE,CAAC;AACH,CAAC","sourcesContent":["import { selectiveUnion } from '@metamask/keyring-utils';\nimport { type Infer } from '@metamask/superstruct';\n\nimport {\n CreateAccountBip44DiscoverOptionsStruct,\n CreateAccountBip44DeriveIndexOptionsStruct,\n CreateAccountBip44DeriveIndexRangeOptionsStruct,\n CreateAccountBip44DerivePathOptionsStruct,\n} from './bip44';\nimport { CreateAccountCustomOptionsStruct } from './custom';\nimport { CreateAccountPrivateKeyOptionsStruct } from './private-key';\n\nexport * from './bip44';\nexport * from './custom';\nexport * from './private-key';\n\n/**\n * Enum representing the different ways an account can be created.\n */\nexport enum AccountCreationType {\n /**\n * Represents an account created using a BIP-44 derivation path.\n */\n Bip44DerivePath = 'bip44:derive-path',\n\n /**\n * Represents accounts created using a BIP-44 account index.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44DeriveIndex = 'bip44:derive-index',\n\n /**\n * Represents accounts created by deriving a range of BIP-44 account indices.\n *\n * More than one account can be created per index, for example, the keyring\n * can create multiple account types (e.g., P2PKH, P2TR, P2WPKH) for each\n * account index in the range.\n */\n Bip44DeriveIndexRange = 'bip44:derive-index-range',\n\n /**\n * Represents accounts created through BIP-44 account discovery.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44Discover = 'bip44:discover',\n\n /**\n * Represents an account imported from a private key.\n */\n PrivateKeyImport = 'private-key:import',\n\n /**\n * Represents an account created using a custom, keyring-specific method.\n *\n * This is used by keyrings that have non-standard account creation flows\n * and declare `custom.createAccounts: true` in their capabilities.\n */\n Custom = 'custom',\n}\n\n/**\n * Struct for {@link CreateAccountOptions}.\n */\nexport const CreateAccountOptionsStruct = selectiveUnion((value: any) => {\n const accountCreationType = value?.type as AccountCreationType;\n switch (accountCreationType) {\n case AccountCreationType.Bip44DerivePath:\n return CreateAccountBip44DerivePathOptionsStruct;\n case AccountCreationType.Bip44DeriveIndex:\n return CreateAccountBip44DeriveIndexOptionsStruct;\n case AccountCreationType.Bip44DeriveIndexRange:\n return CreateAccountBip44DeriveIndexRangeOptionsStruct;\n case AccountCreationType.Bip44Discover:\n return CreateAccountBip44DiscoverOptionsStruct;\n case AccountCreationType.PrivateKeyImport:\n return CreateAccountPrivateKeyOptionsStruct;\n case AccountCreationType.Custom:\n return CreateAccountCustomOptionsStruct;\n default:\n // Return first struct as fallback - validation will fail with proper error indicating the type mismatch\n return CreateAccountBip44DerivePathOptionsStruct;\n }\n});\n\n/**\n * Represents the available options for creating a new account.\n */\nexport type CreateAccountOptions = Infer<typeof CreateAccountOptionsStruct>;\n\n/**\n * Asserts that a given create account option type is supported by the keyring.\n *\n * @example\n * ```ts\n * createAccounts(options: CreateAccountOptions) {\n * assertCreateAccountOptionIsSupported(options, [\n * ${AccountCreationType.Bip44DeriveIndex},\n * ${AccountCreationType.Bip44DeriveIndexRange},\n * ] as const);\n *\n * // At this point, TypeScript knows that options.type is either Bip44DeriveIndex or Bip44DeriveIndexRange.\n * if (options.type === AccountCreationType.Bip44DeriveIndex) {\n * ... // Handle Bip44DeriveIndex case.\n * } else {\n * ... // Handle Bip44DeriveIndexRange case.\n * }\n * ...\n * return accounts;\n * }\n * ```\n *\n * @param options - The create account option object to check.\n * @param supportedTypes - The list of supported create account option types for this keyring.\n * @throws Will throw an error if the provided options are not supported.\n */\nexport function assertCreateAccountOptionIsSupported<\n Options extends CreateAccountOptions,\n // We use template literal types to enforce string-literal over strict enum values.\n Type extends `${CreateAccountOptions['type']}`,\n>(\n options: Options,\n supportedTypes: readonly `${Type}`[],\n // Use intersection to avoid widening `type` beyond `Options['type']`.\n): asserts options is Options & { type: `${Type}` & `${Options['type']}` } {\n const { type } = options;\n const types: readonly CreateAccountOptions['type'][] = supportedTypes;\n\n if (!types.includes(type)) {\n throw new Error(`Unsupported create account option type: ${type}`);\n }\n}\n"]}
@@ -18,6 +18,14 @@ export declare enum AccountCreationType {
18
18
  * index.
19
19
  */
20
20
  Bip44DeriveIndex = "bip44:derive-index",
21
+ /**
22
+ * Represents accounts created by deriving a range of BIP-44 account indices.
23
+ *
24
+ * More than one account can be created per index, for example, the keyring
25
+ * can create multiple account types (e.g., P2PKH, P2TR, P2WPKH) for each
26
+ * account index in the range.
27
+ */
28
+ Bip44DeriveIndexRange = "bip44:derive-index-range",
21
29
  /**
22
30
  * Represents accounts created through BIP-44 account discovery.
23
31
  *
@@ -53,6 +61,13 @@ export declare const CreateAccountOptionsStruct: import("@metamask/superstruct")
53
61
  type: "bip44:discover";
54
62
  groupIndex: number;
55
63
  entropySource: string;
64
+ } | {
65
+ type: "bip44:derive-index-range";
66
+ range: {
67
+ from: number;
68
+ to: number;
69
+ };
70
+ entropySource: string;
56
71
  } | {
57
72
  type: "custom";
58
73
  } | {
@@ -65,4 +80,33 @@ export declare const CreateAccountOptionsStruct: import("@metamask/superstruct")
65
80
  * Represents the available options for creating a new account.
66
81
  */
67
82
  export type CreateAccountOptions = Infer<typeof CreateAccountOptionsStruct>;
83
+ /**
84
+ * Asserts that a given create account option type is supported by the keyring.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * createAccounts(options: CreateAccountOptions) {
89
+ * assertCreateAccountOptionIsSupported(options, [
90
+ * ${AccountCreationType.Bip44DeriveIndex},
91
+ * ${AccountCreationType.Bip44DeriveIndexRange},
92
+ * ] as const);
93
+ *
94
+ * // At this point, TypeScript knows that options.type is either Bip44DeriveIndex or Bip44DeriveIndexRange.
95
+ * if (options.type === AccountCreationType.Bip44DeriveIndex) {
96
+ * ... // Handle Bip44DeriveIndex case.
97
+ * } else {
98
+ * ... // Handle Bip44DeriveIndexRange case.
99
+ * }
100
+ * ...
101
+ * return accounts;
102
+ * }
103
+ * ```
104
+ *
105
+ * @param options - The create account option object to check.
106
+ * @param supportedTypes - The list of supported create account option types for this keyring.
107
+ * @throws Will throw an error if the provided options are not supported.
108
+ */
109
+ export declare function assertCreateAccountOptionIsSupported<Options extends CreateAccountOptions, Type extends `${CreateAccountOptions['type']}`>(options: Options, supportedTypes: readonly `${Type}`[]): asserts options is Options & {
110
+ type: `${Type}` & `${Options['type']}`;
111
+ };
68
112
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,8BAA8B;AAUnD,4BAAwB;AACxB,6BAAyB;AACzB,kCAA8B;AAE9B;;GAEG;AACH,oBAAY,mBAAmB;IAC7B;;OAEG;IACH,eAAe,sBAAsB;IAErC;;;;;;OAMG;IACH,gBAAgB,uBAAuB;IAEvC;;;;;;OAMG;IACH,aAAa,mBAAmB;IAEhC;;OAEG;IACH,gBAAgB,uBAAuB;IAEvC;;;;;OAKG;IACH,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;QAiBrC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,8BAA8B;AAWnD,4BAAwB;AACxB,6BAAyB;AACzB,kCAA8B;AAE9B;;GAEG;AACH,oBAAY,mBAAmB;IAC7B;;OAEG;IACH,eAAe,sBAAsB;IAErC;;;;;;OAMG;IACH,gBAAgB,uBAAuB;IAEvC;;;;;;OAMG;IACH,qBAAqB,6BAA6B;IAElD;;;;;;OAMG;IACH,aAAa,mBAAmB;IAEhC;;OAEG;IACH,gBAAgB,uBAAuB;IAEvC;;;;;OAKG;IACH,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;QAmBrC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,oCAAoC,CAClD,OAAO,SAAS,oBAAoB,EAEpC,IAAI,SAAS,GAAG,oBAAoB,CAAC,MAAM,CAAC,EAAE,EAE9C,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,SAAS,GAAG,IAAI,EAAE,EAAE,GAEnC,OAAO,CAAC,OAAO,IAAI,OAAO,GAAG;IAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAA;CAAE,CAOzE"}
@@ -18,6 +18,14 @@ export declare enum AccountCreationType {
18
18
  * index.
19
19
  */
20
20
  Bip44DeriveIndex = "bip44:derive-index",
21
+ /**
22
+ * Represents accounts created by deriving a range of BIP-44 account indices.
23
+ *
24
+ * More than one account can be created per index, for example, the keyring
25
+ * can create multiple account types (e.g., P2PKH, P2TR, P2WPKH) for each
26
+ * account index in the range.
27
+ */
28
+ Bip44DeriveIndexRange = "bip44:derive-index-range",
21
29
  /**
22
30
  * Represents accounts created through BIP-44 account discovery.
23
31
  *
@@ -53,6 +61,13 @@ export declare const CreateAccountOptionsStruct: import("@metamask/superstruct")
53
61
  type: "bip44:discover";
54
62
  groupIndex: number;
55
63
  entropySource: string;
64
+ } | {
65
+ type: "bip44:derive-index-range";
66
+ range: {
67
+ from: number;
68
+ to: number;
69
+ };
70
+ entropySource: string;
56
71
  } | {
57
72
  type: "custom";
58
73
  } | {
@@ -65,4 +80,33 @@ export declare const CreateAccountOptionsStruct: import("@metamask/superstruct")
65
80
  * Represents the available options for creating a new account.
66
81
  */
67
82
  export type CreateAccountOptions = Infer<typeof CreateAccountOptionsStruct>;
83
+ /**
84
+ * Asserts that a given create account option type is supported by the keyring.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * createAccounts(options: CreateAccountOptions) {
89
+ * assertCreateAccountOptionIsSupported(options, [
90
+ * ${AccountCreationType.Bip44DeriveIndex},
91
+ * ${AccountCreationType.Bip44DeriveIndexRange},
92
+ * ] as const);
93
+ *
94
+ * // At this point, TypeScript knows that options.type is either Bip44DeriveIndex or Bip44DeriveIndexRange.
95
+ * if (options.type === AccountCreationType.Bip44DeriveIndex) {
96
+ * ... // Handle Bip44DeriveIndex case.
97
+ * } else {
98
+ * ... // Handle Bip44DeriveIndexRange case.
99
+ * }
100
+ * ...
101
+ * return accounts;
102
+ * }
103
+ * ```
104
+ *
105
+ * @param options - The create account option object to check.
106
+ * @param supportedTypes - The list of supported create account option types for this keyring.
107
+ * @throws Will throw an error if the provided options are not supported.
108
+ */
109
+ export declare function assertCreateAccountOptionIsSupported<Options extends CreateAccountOptions, Type extends `${CreateAccountOptions['type']}`>(options: Options, supportedTypes: readonly `${Type}`[]): asserts options is Options & {
110
+ type: `${Type}` & `${Options['type']}`;
111
+ };
68
112
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,8BAA8B;AAUnD,4BAAwB;AACxB,6BAAyB;AACzB,kCAA8B;AAE9B;;GAEG;AACH,oBAAY,mBAAmB;IAC7B;;OAEG;IACH,eAAe,sBAAsB;IAErC;;;;;;OAMG;IACH,gBAAgB,uBAAuB;IAEvC;;;;;;OAMG;IACH,aAAa,mBAAmB;IAEhC;;OAEG;IACH,gBAAgB,uBAAuB;IAEvC;;;;;OAKG;IACH,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;QAiBrC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,8BAA8B;AAWnD,4BAAwB;AACxB,6BAAyB;AACzB,kCAA8B;AAE9B;;GAEG;AACH,oBAAY,mBAAmB;IAC7B;;OAEG;IACH,eAAe,sBAAsB;IAErC;;;;;;OAMG;IACH,gBAAgB,uBAAuB;IAEvC;;;;;;OAMG;IACH,qBAAqB,6BAA6B;IAElD;;;;;;OAMG;IACH,aAAa,mBAAmB;IAEhC;;OAEG;IACH,gBAAgB,uBAAuB;IAEvC;;;;;OAKG;IACH,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;QAmBrC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,oCAAoC,CAClD,OAAO,SAAS,oBAAoB,EAEpC,IAAI,SAAS,GAAG,oBAAoB,CAAC,MAAM,CAAC,EAAE,EAE9C,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,SAAS,GAAG,IAAI,EAAE,EAAE,GAEnC,OAAO,CAAC,OAAO,IAAI,OAAO,GAAG;IAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAA;CAAE,CAOzE"}
@@ -1,5 +1,5 @@
1
1
  import { selectiveUnion } from "@metamask/keyring-utils";
2
- import { CreateAccountBip44DiscoverOptionsStruct, CreateAccountBip44DeriveIndexOptionsStruct, CreateAccountBip44DerivePathOptionsStruct } from "./bip44.mjs";
2
+ import { CreateAccountBip44DiscoverOptionsStruct, CreateAccountBip44DeriveIndexOptionsStruct, CreateAccountBip44DeriveIndexRangeOptionsStruct, CreateAccountBip44DerivePathOptionsStruct } from "./bip44.mjs";
3
3
  import { CreateAccountCustomOptionsStruct } from "./custom.mjs";
4
4
  import { CreateAccountPrivateKeyOptionsStruct } from "./private-key.mjs";
5
5
  export * from "./bip44.mjs";
@@ -22,6 +22,14 @@ export var AccountCreationType;
22
22
  * index.
23
23
  */
24
24
  AccountCreationType["Bip44DeriveIndex"] = "bip44:derive-index";
25
+ /**
26
+ * Represents accounts created by deriving a range of BIP-44 account indices.
27
+ *
28
+ * More than one account can be created per index, for example, the keyring
29
+ * can create multiple account types (e.g., P2PKH, P2TR, P2WPKH) for each
30
+ * account index in the range.
31
+ */
32
+ AccountCreationType["Bip44DeriveIndexRange"] = "bip44:derive-index-range";
25
33
  /**
26
34
  * Represents accounts created through BIP-44 account discovery.
27
35
  *
@@ -52,6 +60,8 @@ export const CreateAccountOptionsStruct = selectiveUnion((value) => {
52
60
  return CreateAccountBip44DerivePathOptionsStruct;
53
61
  case AccountCreationType.Bip44DeriveIndex:
54
62
  return CreateAccountBip44DeriveIndexOptionsStruct;
63
+ case AccountCreationType.Bip44DeriveIndexRange:
64
+ return CreateAccountBip44DeriveIndexRangeOptionsStruct;
55
65
  case AccountCreationType.Bip44Discover:
56
66
  return CreateAccountBip44DiscoverOptionsStruct;
57
67
  case AccountCreationType.PrivateKeyImport:
@@ -63,4 +73,37 @@ export const CreateAccountOptionsStruct = selectiveUnion((value) => {
63
73
  return CreateAccountBip44DerivePathOptionsStruct;
64
74
  }
65
75
  });
76
+ /**
77
+ * Asserts that a given create account option type is supported by the keyring.
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * createAccounts(options: CreateAccountOptions) {
82
+ * assertCreateAccountOptionIsSupported(options, [
83
+ * ${AccountCreationType.Bip44DeriveIndex},
84
+ * ${AccountCreationType.Bip44DeriveIndexRange},
85
+ * ] as const);
86
+ *
87
+ * // At this point, TypeScript knows that options.type is either Bip44DeriveIndex or Bip44DeriveIndexRange.
88
+ * if (options.type === AccountCreationType.Bip44DeriveIndex) {
89
+ * ... // Handle Bip44DeriveIndex case.
90
+ * } else {
91
+ * ... // Handle Bip44DeriveIndexRange case.
92
+ * }
93
+ * ...
94
+ * return accounts;
95
+ * }
96
+ * ```
97
+ *
98
+ * @param options - The create account option object to check.
99
+ * @param supportedTypes - The list of supported create account option types for this keyring.
100
+ * @throws Will throw an error if the provided options are not supported.
101
+ */
102
+ export function assertCreateAccountOptionIsSupported(options, supportedTypes) {
103
+ const { type } = options;
104
+ const types = supportedTypes;
105
+ if (!types.includes(type)) {
106
+ throw new Error(`Unsupported create account option type: ${type}`);
107
+ }
108
+ }
66
109
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gCAAgC;AAGzD,OAAO,EACL,uCAAuC,EACvC,0CAA0C,EAC1C,yCAAyC,EAC1C,oBAAgB;AACjB,OAAO,EAAE,gCAAgC,EAAE,qBAAiB;AAC5D,OAAO,EAAE,oCAAoC,EAAE,0BAAsB;AAErE,4BAAwB;AACxB,6BAAyB;AACzB,kCAA8B;AAE9B;;GAEG;AACH,MAAM,CAAN,IAAY,mBAoCX;AApCD,WAAY,mBAAmB;IAC7B;;OAEG;IACH,4DAAqC,CAAA;IAErC;;;;;;OAMG;IACH,8DAAuC,CAAA;IAEvC;;;;;;OAMG;IACH,uDAAgC,CAAA;IAEhC;;OAEG;IACH,8DAAuC,CAAA;IAEvC;;;;;OAKG;IACH,wCAAiB,CAAA;AACnB,CAAC,EApCW,mBAAmB,KAAnB,mBAAmB,QAoC9B;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,cAAc,CAAC,CAAC,KAAU,EAAE,EAAE;IACtE,MAAM,mBAAmB,GAAG,KAAK,EAAE,IAA2B,CAAC;IAC/D,QAAQ,mBAAmB,EAAE,CAAC;QAC5B,KAAK,mBAAmB,CAAC,eAAe;YACtC,OAAO,yCAAyC,CAAC;QACnD,KAAK,mBAAmB,CAAC,gBAAgB;YACvC,OAAO,0CAA0C,CAAC;QACpD,KAAK,mBAAmB,CAAC,aAAa;YACpC,OAAO,uCAAuC,CAAC;QACjD,KAAK,mBAAmB,CAAC,gBAAgB;YACvC,OAAO,oCAAoC,CAAC;QAC9C,KAAK,mBAAmB,CAAC,MAAM;YAC7B,OAAO,gCAAgC,CAAC;QAC1C;YACE,wGAAwG;YACxG,OAAO,yCAAyC,CAAC;IACrD,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { selectiveUnion } from '@metamask/keyring-utils';\nimport { type Infer } from '@metamask/superstruct';\n\nimport {\n CreateAccountBip44DiscoverOptionsStruct,\n CreateAccountBip44DeriveIndexOptionsStruct,\n CreateAccountBip44DerivePathOptionsStruct,\n} from './bip44';\nimport { CreateAccountCustomOptionsStruct } from './custom';\nimport { CreateAccountPrivateKeyOptionsStruct } from './private-key';\n\nexport * from './bip44';\nexport * from './custom';\nexport * from './private-key';\n\n/**\n * Enum representing the different ways an account can be created.\n */\nexport enum AccountCreationType {\n /**\n * Represents an account created using a BIP-44 derivation path.\n */\n Bip44DerivePath = 'bip44:derive-path',\n\n /**\n * Represents accounts created using a BIP-44 account index.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44DeriveIndex = 'bip44:derive-index',\n\n /**\n * Represents accounts created through BIP-44 account discovery.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44Discover = 'bip44:discover',\n\n /**\n * Represents an account imported from a private key.\n */\n PrivateKeyImport = 'private-key:import',\n\n /**\n * Represents an account created using a custom, keyring-specific method.\n *\n * This is used by keyrings that have non-standard account creation flows\n * and declare `custom.createAccounts: true` in their capabilities.\n */\n Custom = 'custom',\n}\n\n/**\n * Struct for {@link CreateAccountOptions}.\n */\nexport const CreateAccountOptionsStruct = selectiveUnion((value: any) => {\n const accountCreationType = value?.type as AccountCreationType;\n switch (accountCreationType) {\n case AccountCreationType.Bip44DerivePath:\n return CreateAccountBip44DerivePathOptionsStruct;\n case AccountCreationType.Bip44DeriveIndex:\n return CreateAccountBip44DeriveIndexOptionsStruct;\n case AccountCreationType.Bip44Discover:\n return CreateAccountBip44DiscoverOptionsStruct;\n case AccountCreationType.PrivateKeyImport:\n return CreateAccountPrivateKeyOptionsStruct;\n case AccountCreationType.Custom:\n return CreateAccountCustomOptionsStruct;\n default:\n // Return first struct as fallback - validation will fail with proper error indicating the type mismatch\n return CreateAccountBip44DerivePathOptionsStruct;\n }\n});\n\n/**\n * Represents the available options for creating a new account.\n */\nexport type CreateAccountOptions = Infer<typeof CreateAccountOptionsStruct>;\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gCAAgC;AAGzD,OAAO,EACL,uCAAuC,EACvC,0CAA0C,EAC1C,+CAA+C,EAC/C,yCAAyC,EAC1C,oBAAgB;AACjB,OAAO,EAAE,gCAAgC,EAAE,qBAAiB;AAC5D,OAAO,EAAE,oCAAoC,EAAE,0BAAsB;AAErE,4BAAwB;AACxB,6BAAyB;AACzB,kCAA8B;AAE9B;;GAEG;AACH,MAAM,CAAN,IAAY,mBA6CX;AA7CD,WAAY,mBAAmB;IAC7B;;OAEG;IACH,4DAAqC,CAAA;IAErC;;;;;;OAMG;IACH,8DAAuC,CAAA;IAEvC;;;;;;OAMG;IACH,yEAAkD,CAAA;IAElD;;;;;;OAMG;IACH,uDAAgC,CAAA;IAEhC;;OAEG;IACH,8DAAuC,CAAA;IAEvC;;;;;OAKG;IACH,wCAAiB,CAAA;AACnB,CAAC,EA7CW,mBAAmB,KAAnB,mBAAmB,QA6C9B;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,cAAc,CAAC,CAAC,KAAU,EAAE,EAAE;IACtE,MAAM,mBAAmB,GAAG,KAAK,EAAE,IAA2B,CAAC;IAC/D,QAAQ,mBAAmB,EAAE,CAAC;QAC5B,KAAK,mBAAmB,CAAC,eAAe;YACtC,OAAO,yCAAyC,CAAC;QACnD,KAAK,mBAAmB,CAAC,gBAAgB;YACvC,OAAO,0CAA0C,CAAC;QACpD,KAAK,mBAAmB,CAAC,qBAAqB;YAC5C,OAAO,+CAA+C,CAAC;QACzD,KAAK,mBAAmB,CAAC,aAAa;YACpC,OAAO,uCAAuC,CAAC;QACjD,KAAK,mBAAmB,CAAC,gBAAgB;YACvC,OAAO,oCAAoC,CAAC;QAC9C,KAAK,mBAAmB,CAAC,MAAM;YAC7B,OAAO,gCAAgC,CAAC;QAC1C;YACE,wGAAwG;YACxG,OAAO,yCAAyC,CAAC;IACrD,CAAC;AACH,CAAC,CAAC,CAAC;AAOH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,oCAAoC,CAKlD,OAAgB,EAChB,cAAoC;IAGpC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACzB,MAAM,KAAK,GAA4C,cAAc,CAAC;IAEtE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,2CAA2C,IAAI,EAAE,CAAC,CAAC;IACrE,CAAC;AACH,CAAC","sourcesContent":["import { selectiveUnion } from '@metamask/keyring-utils';\nimport { type Infer } from '@metamask/superstruct';\n\nimport {\n CreateAccountBip44DiscoverOptionsStruct,\n CreateAccountBip44DeriveIndexOptionsStruct,\n CreateAccountBip44DeriveIndexRangeOptionsStruct,\n CreateAccountBip44DerivePathOptionsStruct,\n} from './bip44';\nimport { CreateAccountCustomOptionsStruct } from './custom';\nimport { CreateAccountPrivateKeyOptionsStruct } from './private-key';\n\nexport * from './bip44';\nexport * from './custom';\nexport * from './private-key';\n\n/**\n * Enum representing the different ways an account can be created.\n */\nexport enum AccountCreationType {\n /**\n * Represents an account created using a BIP-44 derivation path.\n */\n Bip44DerivePath = 'bip44:derive-path',\n\n /**\n * Represents accounts created using a BIP-44 account index.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44DeriveIndex = 'bip44:derive-index',\n\n /**\n * Represents accounts created by deriving a range of BIP-44 account indices.\n *\n * More than one account can be created per index, for example, the keyring\n * can create multiple account types (e.g., P2PKH, P2TR, P2WPKH) for each\n * account index in the range.\n */\n Bip44DeriveIndexRange = 'bip44:derive-index-range',\n\n /**\n * Represents accounts created through BIP-44 account discovery.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44Discover = 'bip44:discover',\n\n /**\n * Represents an account imported from a private key.\n */\n PrivateKeyImport = 'private-key:import',\n\n /**\n * Represents an account created using a custom, keyring-specific method.\n *\n * This is used by keyrings that have non-standard account creation flows\n * and declare `custom.createAccounts: true` in their capabilities.\n */\n Custom = 'custom',\n}\n\n/**\n * Struct for {@link CreateAccountOptions}.\n */\nexport const CreateAccountOptionsStruct = selectiveUnion((value: any) => {\n const accountCreationType = value?.type as AccountCreationType;\n switch (accountCreationType) {\n case AccountCreationType.Bip44DerivePath:\n return CreateAccountBip44DerivePathOptionsStruct;\n case AccountCreationType.Bip44DeriveIndex:\n return CreateAccountBip44DeriveIndexOptionsStruct;\n case AccountCreationType.Bip44DeriveIndexRange:\n return CreateAccountBip44DeriveIndexRangeOptionsStruct;\n case AccountCreationType.Bip44Discover:\n return CreateAccountBip44DiscoverOptionsStruct;\n case AccountCreationType.PrivateKeyImport:\n return CreateAccountPrivateKeyOptionsStruct;\n case AccountCreationType.Custom:\n return CreateAccountCustomOptionsStruct;\n default:\n // Return first struct as fallback - validation will fail with proper error indicating the type mismatch\n return CreateAccountBip44DerivePathOptionsStruct;\n }\n});\n\n/**\n * Represents the available options for creating a new account.\n */\nexport type CreateAccountOptions = Infer<typeof CreateAccountOptionsStruct>;\n\n/**\n * Asserts that a given create account option type is supported by the keyring.\n *\n * @example\n * ```ts\n * createAccounts(options: CreateAccountOptions) {\n * assertCreateAccountOptionIsSupported(options, [\n * ${AccountCreationType.Bip44DeriveIndex},\n * ${AccountCreationType.Bip44DeriveIndexRange},\n * ] as const);\n *\n * // At this point, TypeScript knows that options.type is either Bip44DeriveIndex or Bip44DeriveIndexRange.\n * if (options.type === AccountCreationType.Bip44DeriveIndex) {\n * ... // Handle Bip44DeriveIndex case.\n * } else {\n * ... // Handle Bip44DeriveIndexRange case.\n * }\n * ...\n * return accounts;\n * }\n * ```\n *\n * @param options - The create account option object to check.\n * @param supportedTypes - The list of supported create account option types for this keyring.\n * @throws Will throw an error if the provided options are not supported.\n */\nexport function assertCreateAccountOptionIsSupported<\n Options extends CreateAccountOptions,\n // We use template literal types to enforce string-literal over strict enum values.\n Type extends `${CreateAccountOptions['type']}`,\n>(\n options: Options,\n supportedTypes: readonly `${Type}`[],\n // Use intersection to avoid widening `type` beyond `Options['type']`.\n): asserts options is Options & { type: `${Type}` & `${Options['type']}` } {\n const { type } = options;\n const types: readonly CreateAccountOptions['type'][] = supportedTypes;\n\n if (!types.includes(type)) {\n throw new Error(`Unsupported create account option type: ${type}`);\n }\n}\n"]}
@@ -19,15 +19,19 @@ exports.KeyringCapabilitiesStruct = (0, superstruct_1.object)({
19
19
  /**
20
20
  * Whether the keyring supports deriving accounts from a specific BIP-44 path.
21
21
  */
22
- derivePath: (0, superstruct_1.boolean)(),
22
+ derivePath: (0, superstruct_1.exactOptional)((0, superstruct_1.boolean)()),
23
23
  /**
24
24
  * Whether the keyring supports deriving accounts from a BIP-44 account index.
25
25
  */
26
- deriveIndex: (0, superstruct_1.boolean)(),
26
+ deriveIndex: (0, superstruct_1.exactOptional)((0, superstruct_1.boolean)()),
27
+ /**
28
+ * Whether the keyring supports deriving accounts from a range of BIP-44 account indices.
29
+ */
30
+ deriveIndexRange: (0, superstruct_1.exactOptional)((0, superstruct_1.boolean)()),
27
31
  /**
28
32
  * Whether the keyring supports BIP-44 account discovery.
29
33
  */
30
- discover: (0, superstruct_1.boolean)(),
34
+ discover: (0, superstruct_1.exactOptional)((0, superstruct_1.boolean)()),
31
35
  })),
32
36
  /**
33
37
  * Private key capabilities supported by this keyring.
@@ -1 +1 @@
1
- {"version":3,"file":"keyring-capabilities.cjs","sourceRoot":"","sources":["../../../src/api/v2/keyring-capabilities.ts"],"names":[],"mappings":";;;AAAA,uDAQ+B;AAE/B,mDAGuB;AACvB,sCAA4C;AAE5C;;GAEG;AACU,QAAA,yBAAyB,GAAG,IAAA,oBAAM,EAAC;IAC9C;;OAEG;IACH,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,wBAAiB,CAAC,CAAC;IAC1C;;OAEG;IACH,KAAK,EAAE,IAAA,2BAAa,EAClB,IAAA,oBAAM,EAAC;QACL;;WAEG;QACH,UAAU,EAAE,IAAA,qBAAO,GAAE;QACrB;;WAEG;QACH,WAAW,EAAE,IAAA,qBAAO,GAAE;QACtB;;WAEG;QACH,QAAQ,EAAE,IAAA,qBAAO,GAAE;KACpB,CAAC,CACH;IACD;;OAEG;IACH,UAAU,EAAE,IAAA,2BAAa,EACvB,IAAA,oBAAM,EAAC;QACL;;WAEG;QACH,aAAa,EAAE,IAAA,2BAAa,EAAC,IAAA,mBAAK,EAAC,0CAA4B,CAAC,CAAC;QACjE;;WAEG;QACH,aAAa,EAAE,IAAA,2BAAa,EAAC,IAAA,mBAAK,EAAC,0CAA4B,CAAC,CAAC;KAClE,CAAC,CACH;IACD;;;;;;OAMG;IACH,MAAM,EAAE,IAAA,2BAAa,EACnB,IAAA,qBAAO,EACL,IAAA,oBAAM,EAAC;QACL,cAAc,EAAE,IAAA,qBAAO,GAAE;KAC1B,CAAC,CACH,CACF;CACF,CAAC,CAAC","sourcesContent":["import {\n array,\n boolean,\n exactOptional,\n nonempty,\n object,\n partial,\n type Infer,\n} from '@metamask/superstruct';\n\nimport {\n ExportPrivateKeyFormatStruct,\n ImportPrivateKeyFormatStruct,\n} from './private-key';\nimport { CaipChainIdStruct } from '../caip';\n\n/**\n * Struct for {@link KeyringCapabilities}.\n */\nexport const KeyringCapabilitiesStruct = object({\n /**\n * List of CAIP-2 chain IDs that this keyring supports.\n */\n scopes: nonempty(array(CaipChainIdStruct)),\n /**\n * BIP-44 capabilities supported by this keyring.\n */\n bip44: exactOptional(\n object({\n /**\n * Whether the keyring supports deriving accounts from a specific BIP-44 path.\n */\n derivePath: boolean(),\n /**\n * Whether the keyring supports deriving accounts from a BIP-44 account index.\n */\n deriveIndex: boolean(),\n /**\n * Whether the keyring supports BIP-44 account discovery.\n */\n discover: boolean(),\n }),\n ),\n /**\n * Private key capabilities supported by this keyring.\n */\n privateKey: exactOptional(\n object({\n /**\n * List of supported formats for importing private keys.\n */\n importFormats: exactOptional(array(ImportPrivateKeyFormatStruct)),\n /**\n * List of supported formats for exporting private keys.\n */\n exportFormats: exactOptional(array(ExportPrivateKeyFormatStruct)),\n }),\n ),\n /**\n * Indicates which KeyringV2 methods accept non-standard options.\n *\n * When a method is set to `true`, it signals that the keyring implementation\n * accepts custom options for that method, different from the standard API.\n * This is a workaround for keyrings with very specific requirements.\n */\n custom: exactOptional(\n partial(\n object({\n createAccounts: boolean(),\n }),\n ),\n ),\n});\n\n/**\n * Type representing the capabilities supported by a keyring.\n *\n * @example\n * ```ts\n * const capabilities: KeyringCapabilities = {\n * scopes: ['bip122:_'],\n * bip44: {\n * derivePath: true,\n * deriveIndex: true,\n * discover: true,\n * },\n * privateKey: {\n * importFormats: [\n * { encoding: 'base58', type: 'bip122:p2sh' },\n * { encoding: 'base58', type: 'bip122:p2tr' },\n * { encoding: 'base58', type: 'bip122:p2pkh' },\n * { encoding: 'base58', type: 'bip122:p2wpkh' },\n * ],\n * exportFormats: [\n * { encoding: 'base58' },\n * { encoding: 'base58' },\n * ],\n * },\n * };\n * ```\n */\nexport type KeyringCapabilities = Infer<typeof KeyringCapabilitiesStruct>;\n"]}
1
+ {"version":3,"file":"keyring-capabilities.cjs","sourceRoot":"","sources":["../../../src/api/v2/keyring-capabilities.ts"],"names":[],"mappings":";;;AAAA,uDAQ+B;AAE/B,mDAGuB;AACvB,sCAA4C;AAE5C;;GAEG;AACU,QAAA,yBAAyB,GAAG,IAAA,oBAAM,EAAC;IAC9C;;OAEG;IACH,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,wBAAiB,CAAC,CAAC;IAC1C;;OAEG;IACH,KAAK,EAAE,IAAA,2BAAa,EAClB,IAAA,oBAAM,EAAC;QACL;;WAEG;QACH,UAAU,EAAE,IAAA,2BAAa,EAAC,IAAA,qBAAO,GAAE,CAAC;QACpC;;WAEG;QACH,WAAW,EAAE,IAAA,2BAAa,EAAC,IAAA,qBAAO,GAAE,CAAC;QACrC;;WAEG;QACH,gBAAgB,EAAE,IAAA,2BAAa,EAAC,IAAA,qBAAO,GAAE,CAAC;QAC1C;;WAEG;QACH,QAAQ,EAAE,IAAA,2BAAa,EAAC,IAAA,qBAAO,GAAE,CAAC;KACnC,CAAC,CACH;IACD;;OAEG;IACH,UAAU,EAAE,IAAA,2BAAa,EACvB,IAAA,oBAAM,EAAC;QACL;;WAEG;QACH,aAAa,EAAE,IAAA,2BAAa,EAAC,IAAA,mBAAK,EAAC,0CAA4B,CAAC,CAAC;QACjE;;WAEG;QACH,aAAa,EAAE,IAAA,2BAAa,EAAC,IAAA,mBAAK,EAAC,0CAA4B,CAAC,CAAC;KAClE,CAAC,CACH;IACD;;;;;;OAMG;IACH,MAAM,EAAE,IAAA,2BAAa,EACnB,IAAA,qBAAO,EACL,IAAA,oBAAM,EAAC;QACL,cAAc,EAAE,IAAA,qBAAO,GAAE;KAC1B,CAAC,CACH,CACF;CACF,CAAC,CAAC","sourcesContent":["import {\n array,\n boolean,\n exactOptional,\n nonempty,\n object,\n partial,\n type Infer,\n} from '@metamask/superstruct';\n\nimport {\n ExportPrivateKeyFormatStruct,\n ImportPrivateKeyFormatStruct,\n} from './private-key';\nimport { CaipChainIdStruct } from '../caip';\n\n/**\n * Struct for {@link KeyringCapabilities}.\n */\nexport const KeyringCapabilitiesStruct = object({\n /**\n * List of CAIP-2 chain IDs that this keyring supports.\n */\n scopes: nonempty(array(CaipChainIdStruct)),\n /**\n * BIP-44 capabilities supported by this keyring.\n */\n bip44: exactOptional(\n object({\n /**\n * Whether the keyring supports deriving accounts from a specific BIP-44 path.\n */\n derivePath: exactOptional(boolean()),\n /**\n * Whether the keyring supports deriving accounts from a BIP-44 account index.\n */\n deriveIndex: exactOptional(boolean()),\n /**\n * Whether the keyring supports deriving accounts from a range of BIP-44 account indices.\n */\n deriveIndexRange: exactOptional(boolean()),\n /**\n * Whether the keyring supports BIP-44 account discovery.\n */\n discover: exactOptional(boolean()),\n }),\n ),\n /**\n * Private key capabilities supported by this keyring.\n */\n privateKey: exactOptional(\n object({\n /**\n * List of supported formats for importing private keys.\n */\n importFormats: exactOptional(array(ImportPrivateKeyFormatStruct)),\n /**\n * List of supported formats for exporting private keys.\n */\n exportFormats: exactOptional(array(ExportPrivateKeyFormatStruct)),\n }),\n ),\n /**\n * Indicates which KeyringV2 methods accept non-standard options.\n *\n * When a method is set to `true`, it signals that the keyring implementation\n * accepts custom options for that method, different from the standard API.\n * This is a workaround for keyrings with very specific requirements.\n */\n custom: exactOptional(\n partial(\n object({\n createAccounts: boolean(),\n }),\n ),\n ),\n});\n\n/**\n * Type representing the capabilities supported by a keyring.\n *\n * @example\n * ```ts\n * const capabilities: KeyringCapabilities = {\n * scopes: ['bip122:_'],\n * bip44: {\n * derivePath: true,\n * deriveIndex: true,\n * deriveIndexRange: true,\n * discover: true,\n * },\n * privateKey: {\n * importFormats: [\n * { encoding: 'base58', type: 'bip122:p2sh' },\n * { encoding: 'base58', type: 'bip122:p2tr' },\n * { encoding: 'base58', type: 'bip122:p2pkh' },\n * { encoding: 'base58', type: 'bip122:p2wpkh' },\n * ],\n * exportFormats: [\n * { encoding: 'base58' },\n * { encoding: 'base58' },\n * ],\n * },\n * };\n * ```\n */\nexport type KeyringCapabilities = Infer<typeof KeyringCapabilitiesStruct>;\n"]}
@@ -8,9 +8,10 @@ export declare const KeyringCapabilitiesStruct: import("@metamask/superstruct").
8
8
  createAccounts?: boolean | undefined;
9
9
  };
10
10
  bip44?: {
11
- derivePath: boolean;
12
- deriveIndex: boolean;
13
- discover: boolean;
11
+ derivePath?: boolean;
12
+ deriveIndex?: boolean;
13
+ deriveIndexRange?: boolean;
14
+ discover?: boolean;
14
15
  };
15
16
  privateKey?: {
16
17
  importFormats?: {
@@ -30,22 +31,27 @@ export declare const KeyringCapabilitiesStruct: import("@metamask/superstruct").
30
31
  * BIP-44 capabilities supported by this keyring.
31
32
  */
32
33
  bip44: import("@metamask/superstruct").ExactOptionalStruct<{
33
- derivePath: boolean;
34
- deriveIndex: boolean;
35
- discover: boolean;
34
+ derivePath?: boolean;
35
+ deriveIndex?: boolean;
36
+ deriveIndexRange?: boolean;
37
+ discover?: boolean;
36
38
  }, {
37
39
  /**
38
40
  * Whether the keyring supports deriving accounts from a specific BIP-44 path.
39
41
  */
40
- derivePath: import("@metamask/superstruct").Struct<boolean, null>;
42
+ derivePath: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
41
43
  /**
42
44
  * Whether the keyring supports deriving accounts from a BIP-44 account index.
43
45
  */
44
- deriveIndex: import("@metamask/superstruct").Struct<boolean, null>;
46
+ deriveIndex: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
47
+ /**
48
+ * Whether the keyring supports deriving accounts from a range of BIP-44 account indices.
49
+ */
50
+ deriveIndexRange: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
45
51
  /**
46
52
  * Whether the keyring supports BIP-44 account discovery.
47
53
  */
48
- discover: import("@metamask/superstruct").Struct<boolean, null>;
54
+ discover: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
49
55
  }>;
50
56
  /**
51
57
  * Private key capabilities supported by this keyring.
@@ -122,6 +128,7 @@ export declare const KeyringCapabilitiesStruct: import("@metamask/superstruct").
122
128
  * bip44: {
123
129
  * derivePath: true,
124
130
  * deriveIndex: true,
131
+ * deriveIndexRange: true,
125
132
  * discover: true,
126
133
  * },
127
134
  * privateKey: {
@@ -1 +1 @@
1
- {"version":3,"file":"keyring-capabilities.d.cts","sourceRoot":"","sources":["../../../src/api/v2/keyring-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,KAAK,EACX,8BAA8B;AAQ/B;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;IACpC;;OAEG;;IAEH;;OAEG;;;;;;QAGC;;WAEG;;QAEH;;WAEG;;QAEH;;WAEG;;;IAIP;;OAEG;;;;;;;;;;QAGC;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;QAEH;;WAEG;;;;;;;;;;;;IAIP;;;;;;OAMG;;;;;;EAQH,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
1
+ {"version":3,"file":"keyring-capabilities.d.cts","sourceRoot":"","sources":["../../../src/api/v2/keyring-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,KAAK,EACX,8BAA8B;AAQ/B;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;IACpC;;OAEG;;IAEH;;OAEG;;;;;;;QAGC;;WAEG;;QAEH;;WAEG;;QAEH;;WAEG;;QAEH;;WAEG;;;IAIP;;OAEG;;;;;;;;;;QAGC;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;QAEH;;WAEG;;;;;;;;;;;;IAIP;;;;;;OAMG;;;;;;EAQH,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
@@ -8,9 +8,10 @@ export declare const KeyringCapabilitiesStruct: import("@metamask/superstruct").
8
8
  createAccounts?: boolean | undefined;
9
9
  };
10
10
  bip44?: {
11
- derivePath: boolean;
12
- deriveIndex: boolean;
13
- discover: boolean;
11
+ derivePath?: boolean;
12
+ deriveIndex?: boolean;
13
+ deriveIndexRange?: boolean;
14
+ discover?: boolean;
14
15
  };
15
16
  privateKey?: {
16
17
  importFormats?: {
@@ -30,22 +31,27 @@ export declare const KeyringCapabilitiesStruct: import("@metamask/superstruct").
30
31
  * BIP-44 capabilities supported by this keyring.
31
32
  */
32
33
  bip44: import("@metamask/superstruct").ExactOptionalStruct<{
33
- derivePath: boolean;
34
- deriveIndex: boolean;
35
- discover: boolean;
34
+ derivePath?: boolean;
35
+ deriveIndex?: boolean;
36
+ deriveIndexRange?: boolean;
37
+ discover?: boolean;
36
38
  }, {
37
39
  /**
38
40
  * Whether the keyring supports deriving accounts from a specific BIP-44 path.
39
41
  */
40
- derivePath: import("@metamask/superstruct").Struct<boolean, null>;
42
+ derivePath: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
41
43
  /**
42
44
  * Whether the keyring supports deriving accounts from a BIP-44 account index.
43
45
  */
44
- deriveIndex: import("@metamask/superstruct").Struct<boolean, null>;
46
+ deriveIndex: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
47
+ /**
48
+ * Whether the keyring supports deriving accounts from a range of BIP-44 account indices.
49
+ */
50
+ deriveIndexRange: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
45
51
  /**
46
52
  * Whether the keyring supports BIP-44 account discovery.
47
53
  */
48
- discover: import("@metamask/superstruct").Struct<boolean, null>;
54
+ discover: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
49
55
  }>;
50
56
  /**
51
57
  * Private key capabilities supported by this keyring.
@@ -122,6 +128,7 @@ export declare const KeyringCapabilitiesStruct: import("@metamask/superstruct").
122
128
  * bip44: {
123
129
  * derivePath: true,
124
130
  * deriveIndex: true,
131
+ * deriveIndexRange: true,
125
132
  * discover: true,
126
133
  * },
127
134
  * privateKey: {
@@ -1 +1 @@
1
- {"version":3,"file":"keyring-capabilities.d.mts","sourceRoot":"","sources":["../../../src/api/v2/keyring-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,KAAK,EACX,8BAA8B;AAQ/B;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;IACpC;;OAEG;;IAEH;;OAEG;;;;;;QAGC;;WAEG;;QAEH;;WAEG;;QAEH;;WAEG;;;IAIP;;OAEG;;;;;;;;;;QAGC;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;QAEH;;WAEG;;;;;;;;;;;;IAIP;;;;;;OAMG;;;;;;EAQH,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
1
+ {"version":3,"file":"keyring-capabilities.d.mts","sourceRoot":"","sources":["../../../src/api/v2/keyring-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,KAAK,EACX,8BAA8B;AAQ/B;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;IACpC;;OAEG;;IAEH;;OAEG;;;;;;;QAGC;;WAEG;;QAEH;;WAEG;;QAEH;;WAEG;;QAEH;;WAEG;;;IAIP;;OAEG;;;;;;;;;;QAGC;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;QAEH;;WAEG;;;;;;;;;;;;IAIP;;;;;;OAMG;;;;;;EAQH,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
@@ -16,15 +16,19 @@ export const KeyringCapabilitiesStruct = object({
16
16
  /**
17
17
  * Whether the keyring supports deriving accounts from a specific BIP-44 path.
18
18
  */
19
- derivePath: boolean(),
19
+ derivePath: exactOptional(boolean()),
20
20
  /**
21
21
  * Whether the keyring supports deriving accounts from a BIP-44 account index.
22
22
  */
23
- deriveIndex: boolean(),
23
+ deriveIndex: exactOptional(boolean()),
24
+ /**
25
+ * Whether the keyring supports deriving accounts from a range of BIP-44 account indices.
26
+ */
27
+ deriveIndexRange: exactOptional(boolean()),
24
28
  /**
25
29
  * Whether the keyring supports BIP-44 account discovery.
26
30
  */
27
- discover: boolean(),
31
+ discover: exactOptional(boolean()),
28
32
  })),
29
33
  /**
30
34
  * Private key capabilities supported by this keyring.