@account-kit/smart-contracts 4.0.0-alpha.1 → 4.0.0-alpha.11

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 (184) hide show
  1. package/dist/cjs/plugindefs/multi-owner/config.js +16 -17
  2. package/dist/cjs/plugindefs/multi-owner/config.js.map +1 -1
  3. package/dist/cjs/plugindefs/multisig/config.js +15 -15
  4. package/dist/cjs/plugindefs/multisig/config.js.map +1 -1
  5. package/dist/cjs/plugindefs/session-key/config.js +17 -17
  6. package/dist/cjs/plugindefs/session-key/config.js.map +1 -1
  7. package/dist/cjs/src/index.d.ts +1 -1
  8. package/dist/cjs/src/index.js +4 -3
  9. package/dist/cjs/src/index.js.map +1 -1
  10. package/dist/cjs/src/light-account/accounts/account.d.ts +5 -6
  11. package/dist/cjs/src/light-account/accounts/account.js +3 -2
  12. package/dist/cjs/src/light-account/accounts/account.js.map +1 -1
  13. package/dist/cjs/src/light-account/accounts/base.d.ts +7 -6
  14. package/dist/cjs/src/light-account/accounts/base.js +8 -8
  15. package/dist/cjs/src/light-account/accounts/base.js.map +1 -1
  16. package/dist/cjs/src/light-account/accounts/multiOwner.d.ts +5 -5
  17. package/dist/cjs/src/light-account/accounts/multiOwner.js +3 -2
  18. package/dist/cjs/src/light-account/accounts/multiOwner.js.map +1 -1
  19. package/dist/cjs/src/light-account/clients/alchemyClient.d.ts +1 -1
  20. package/dist/cjs/src/light-account/clients/alchemyClient.js.map +1 -1
  21. package/dist/cjs/src/light-account/clients/client.d.ts +1 -2
  22. package/dist/cjs/src/light-account/clients/client.js +3 -3
  23. package/dist/cjs/src/light-account/clients/client.js.map +1 -1
  24. package/dist/cjs/src/light-account/clients/multiOwnerAlchemyClient.d.ts +2 -2
  25. package/dist/cjs/src/light-account/clients/multiOwnerAlchemyClient.js.map +1 -1
  26. package/dist/cjs/src/light-account/clients/multiOwnerLightAccount.d.ts +1 -2
  27. package/dist/cjs/src/light-account/clients/multiOwnerLightAccount.js +3 -3
  28. package/dist/cjs/src/light-account/clients/multiOwnerLightAccount.js.map +1 -1
  29. package/dist/cjs/src/light-account/decorators/lightAccount.js.map +1 -1
  30. package/dist/cjs/src/light-account/decorators/multiOwnerLightAccount.js.map +1 -1
  31. package/dist/cjs/src/light-account/types.d.ts +23 -31
  32. package/dist/cjs/src/light-account/types.js.map +1 -1
  33. package/dist/cjs/src/light-account/utils.d.ts +7 -10
  34. package/dist/cjs/src/light-account/utils.js +59 -87
  35. package/dist/cjs/src/light-account/utils.js.map +1 -1
  36. package/dist/cjs/src/msca/client/alchemyClient.d.ts +1 -1
  37. package/dist/cjs/src/msca/client/alchemyClient.js.map +1 -1
  38. package/dist/cjs/src/msca/client/client.d.ts +2 -6
  39. package/dist/cjs/src/msca/client/client.js +6 -6
  40. package/dist/cjs/src/msca/client/client.js.map +1 -1
  41. package/dist/cjs/src/msca/client/multiSigAlchemyClient.d.ts +1 -1
  42. package/dist/cjs/src/msca/client/multiSigAlchemyClient.js +1 -1
  43. package/dist/cjs/src/msca/client/multiSigAlchemyClient.js.map +1 -1
  44. package/dist/cjs/src/msca/plugins/multisig/middleware.js.map +1 -1
  45. package/dist/cjs/src/msca/plugins/multisig/utils/formatSignatures.js.map +1 -1
  46. package/dist/cjs/src/msca/plugins/multisig/utils/splitAggregatedSignature.d.ts +3 -2
  47. package/dist/cjs/src/msca/plugins/multisig/utils/splitAggregatedSignature.js.map +1 -1
  48. package/dist/cjs/src/msca/plugins/session-key/permissions.js.map +1 -1
  49. package/dist/cjs/src/msca/plugins/session-key/signer.js.map +1 -1
  50. package/dist/cjs/src/msca/utils.js +11 -10
  51. package/dist/cjs/src/msca/utils.js.map +1 -1
  52. package/dist/esm/plugindefs/multi-owner/config.js +1 -2
  53. package/dist/esm/plugindefs/multi-owner/config.js.map +1 -1
  54. package/dist/esm/plugindefs/multisig/config.js +1 -1
  55. package/dist/esm/plugindefs/multisig/config.js.map +1 -1
  56. package/dist/esm/plugindefs/session-key/config.js +1 -1
  57. package/dist/esm/plugindefs/session-key/config.js.map +1 -1
  58. package/dist/esm/src/index.d.ts +1 -1
  59. package/dist/esm/src/index.js +1 -1
  60. package/dist/esm/src/index.js.map +1 -1
  61. package/dist/esm/src/light-account/accounts/account.d.ts +5 -6
  62. package/dist/esm/src/light-account/accounts/account.js +3 -2
  63. package/dist/esm/src/light-account/accounts/account.js.map +1 -1
  64. package/dist/esm/src/light-account/accounts/base.d.ts +7 -6
  65. package/dist/esm/src/light-account/accounts/base.js +8 -8
  66. package/dist/esm/src/light-account/accounts/base.js.map +1 -1
  67. package/dist/esm/src/light-account/accounts/multiOwner.d.ts +5 -5
  68. package/dist/esm/src/light-account/accounts/multiOwner.js +4 -3
  69. package/dist/esm/src/light-account/accounts/multiOwner.js.map +1 -1
  70. package/dist/esm/src/light-account/clients/alchemyClient.d.ts +1 -1
  71. package/dist/esm/src/light-account/clients/alchemyClient.js.map +1 -1
  72. package/dist/esm/src/light-account/clients/client.d.ts +1 -2
  73. package/dist/esm/src/light-account/clients/client.js +3 -3
  74. package/dist/esm/src/light-account/clients/client.js.map +1 -1
  75. package/dist/esm/src/light-account/clients/multiOwnerAlchemyClient.d.ts +2 -2
  76. package/dist/esm/src/light-account/clients/multiOwnerAlchemyClient.js.map +1 -1
  77. package/dist/esm/src/light-account/clients/multiOwnerLightAccount.d.ts +1 -2
  78. package/dist/esm/src/light-account/clients/multiOwnerLightAccount.js +3 -3
  79. package/dist/esm/src/light-account/clients/multiOwnerLightAccount.js.map +1 -1
  80. package/dist/esm/src/light-account/decorators/lightAccount.js.map +1 -1
  81. package/dist/esm/src/light-account/decorators/multiOwnerLightAccount.js.map +1 -1
  82. package/dist/esm/src/light-account/types.d.ts +23 -31
  83. package/dist/esm/src/light-account/types.js.map +1 -1
  84. package/dist/esm/src/light-account/utils.d.ts +7 -10
  85. package/dist/esm/src/light-account/utils.js +57 -84
  86. package/dist/esm/src/light-account/utils.js.map +1 -1
  87. package/dist/esm/src/msca/client/alchemyClient.d.ts +1 -1
  88. package/dist/esm/src/msca/client/alchemyClient.js.map +1 -1
  89. package/dist/esm/src/msca/client/client.d.ts +2 -6
  90. package/dist/esm/src/msca/client/client.js +6 -6
  91. package/dist/esm/src/msca/client/client.js.map +1 -1
  92. package/dist/esm/src/msca/client/multiSigAlchemyClient.d.ts +1 -1
  93. package/dist/esm/src/msca/client/multiSigAlchemyClient.js +1 -1
  94. package/dist/esm/src/msca/client/multiSigAlchemyClient.js.map +1 -1
  95. package/dist/esm/src/msca/plugins/multisig/middleware.js.map +1 -1
  96. package/dist/esm/src/msca/plugins/multisig/utils/formatSignatures.js.map +1 -1
  97. package/dist/esm/src/msca/plugins/multisig/utils/splitAggregatedSignature.d.ts +3 -2
  98. package/dist/esm/src/msca/plugins/multisig/utils/splitAggregatedSignature.js.map +1 -1
  99. package/dist/esm/src/msca/plugins/session-key/permissions.js.map +1 -1
  100. package/dist/esm/src/msca/plugins/session-key/signer.js.map +1 -1
  101. package/dist/esm/src/msca/utils.js +2 -1
  102. package/dist/esm/src/msca/utils.js.map +1 -1
  103. package/dist/types/plugindefs/multi-owner/config.d.ts.map +1 -1
  104. package/dist/types/src/index.d.ts +1 -1
  105. package/dist/types/src/index.d.ts.map +1 -1
  106. package/dist/types/src/light-account/accounts/account.d.ts +5 -6
  107. package/dist/types/src/light-account/accounts/account.d.ts.map +1 -1
  108. package/dist/types/src/light-account/accounts/base.d.ts +7 -6
  109. package/dist/types/src/light-account/accounts/base.d.ts.map +1 -1
  110. package/dist/types/src/light-account/accounts/multiOwner.d.ts +5 -5
  111. package/dist/types/src/light-account/accounts/multiOwner.d.ts.map +1 -1
  112. package/dist/types/src/light-account/clients/alchemyClient.d.ts +1 -1
  113. package/dist/types/src/light-account/clients/alchemyClient.d.ts.map +1 -1
  114. package/dist/types/src/light-account/clients/client.d.ts +1 -2
  115. package/dist/types/src/light-account/clients/client.d.ts.map +1 -1
  116. package/dist/types/src/light-account/clients/multiOwnerAlchemyClient.d.ts +2 -2
  117. package/dist/types/src/light-account/clients/multiOwnerAlchemyClient.d.ts.map +1 -1
  118. package/dist/types/src/light-account/clients/multiOwnerLightAccount.d.ts +1 -2
  119. package/dist/types/src/light-account/clients/multiOwnerLightAccount.d.ts.map +1 -1
  120. package/dist/types/src/light-account/decorators/lightAccount.d.ts +1 -1
  121. package/dist/types/src/light-account/decorators/multiOwnerLightAccount.d.ts +1 -1
  122. package/dist/types/src/light-account/types.d.ts +23 -118
  123. package/dist/types/src/light-account/types.d.ts.map +1 -1
  124. package/dist/types/src/light-account/utils.d.ts +19 -48
  125. package/dist/types/src/light-account/utils.d.ts.map +1 -1
  126. package/dist/types/src/msca/client/alchemyClient.d.ts +1 -1
  127. package/dist/types/src/msca/client/alchemyClient.d.ts.map +1 -1
  128. package/dist/types/src/msca/client/client.d.ts +2 -6
  129. package/dist/types/src/msca/client/client.d.ts.map +1 -1
  130. package/dist/types/src/msca/client/multiSigAlchemyClient.d.ts +1 -1
  131. package/dist/types/src/msca/client/multiSigAlchemyClient.d.ts.map +1 -1
  132. package/dist/types/src/msca/plugins/multisig/middleware.d.ts +6 -6
  133. package/dist/types/src/msca/plugins/multisig/utils/formatSignatures.d.ts +3 -3
  134. package/dist/types/src/msca/plugins/multisig/utils/splitAggregatedSignature.d.ts +13 -12
  135. package/dist/types/src/msca/plugins/multisig/utils/splitAggregatedSignature.d.ts.map +1 -1
  136. package/dist/types/src/msca/plugins/session-key/permissions.d.ts +147 -1
  137. package/dist/types/src/msca/plugins/session-key/permissions.d.ts.map +1 -1
  138. package/dist/types/src/msca/plugins/session-key/signer.d.ts +71 -1
  139. package/dist/types/src/msca/plugins/session-key/signer.d.ts.map +1 -1
  140. package/dist/types/src/msca/utils.d.ts +6 -6
  141. package/dist/types/src/msca/utils.d.ts.map +1 -1
  142. package/package.json +7 -6
  143. package/plugindefs/multi-owner/config.ts +1 -2
  144. package/plugindefs/multisig/config.ts +1 -1
  145. package/plugindefs/session-key/config.ts +1 -1
  146. package/src/index.ts +2 -1
  147. package/src/light-account/accounts/account.ts +24 -45
  148. package/src/light-account/accounts/base.ts +39 -68
  149. package/src/light-account/accounts/multiOwner.ts +29 -43
  150. package/src/light-account/clients/alchemyClient.ts +2 -2
  151. package/src/light-account/clients/client.ts +8 -13
  152. package/src/light-account/clients/multiOwnerAlchemyClient.ts +3 -3
  153. package/src/light-account/clients/multiOwnerLightAccount.ts +11 -13
  154. package/src/light-account/decorators/lightAccount.ts +1 -1
  155. package/src/light-account/decorators/multiOwnerLightAccount.ts +1 -1
  156. package/src/light-account/types.ts +31 -188
  157. package/src/light-account/utils.ts +91 -246
  158. package/src/msca/client/alchemyClient.ts +2 -2
  159. package/src/msca/client/client.ts +24 -36
  160. package/src/msca/client/multiSigAlchemyClient.ts +5 -5
  161. package/src/msca/plugins/multisig/middleware.ts +6 -6
  162. package/src/msca/plugins/multisig/utils/formatSignatures.ts +3 -3
  163. package/src/msca/plugins/multisig/utils/splitAggregatedSignature.ts +15 -12
  164. package/src/msca/plugins/session-key/permissions.ts +147 -1
  165. package/src/msca/plugins/session-key/signer.ts +71 -1
  166. package/src/msca/utils.ts +15 -13
  167. package/dist/cjs/src/light-account/e2e-tests/constants.d.ts +0 -6
  168. package/dist/cjs/src/light-account/e2e-tests/constants.js +0 -10
  169. package/dist/cjs/src/light-account/e2e-tests/constants.js.map +0 -1
  170. package/dist/cjs/src/light-account/schema.d.ts +0 -21
  171. package/dist/cjs/src/light-account/schema.js +0 -30
  172. package/dist/cjs/src/light-account/schema.js.map +0 -1
  173. package/dist/esm/src/light-account/e2e-tests/constants.d.ts +0 -6
  174. package/dist/esm/src/light-account/e2e-tests/constants.js +0 -7
  175. package/dist/esm/src/light-account/e2e-tests/constants.js.map +0 -1
  176. package/dist/esm/src/light-account/schema.d.ts +0 -21
  177. package/dist/esm/src/light-account/schema.js +0 -27
  178. package/dist/esm/src/light-account/schema.js.map +0 -1
  179. package/dist/types/src/light-account/e2e-tests/constants.d.ts +0 -7
  180. package/dist/types/src/light-account/e2e-tests/constants.d.ts.map +0 -1
  181. package/dist/types/src/light-account/schema.d.ts +0 -22
  182. package/dist/types/src/light-account/schema.d.ts.map +0 -1
  183. package/src/light-account/e2e-tests/constants.ts +0 -8
  184. package/src/light-account/schema.ts +0 -39
@@ -1,3 +1,4 @@
1
+ import type { SmartAccountSigner } from "@aa-sdk/core";
1
2
  import {
2
3
  AlchemyProviderConfigSchema,
3
4
  createAlchemyPublicRpcClient,
@@ -17,7 +18,6 @@ import {
17
18
  type MultiOwnerPluginActions,
18
19
  type PluginManagerActions,
19
20
  } from "@account-kit/smart-contracts";
20
- import type { SmartAccountSigner } from "@aa-sdk/core";
21
21
  import {
22
22
  custom,
23
23
  type Chain,
@@ -58,7 +58,7 @@ export function createModularAccountAlchemyClient<
58
58
  * @example
59
59
  * ```ts
60
60
  * import { createModularAccountAlchemyClient } from "@account-kit/smart-contracts";
61
- * import { sepolia } from "@account-kit/infra/chains";
61
+ * import { sepolia } from "@account-kit/infra";
62
62
  * import { LocalAccountSigner } from "@aa-sdk/core";
63
63
  * import { generatePrivateKey } from "viem"
64
64
  *
@@ -40,29 +40,21 @@ export type CreateMultiOwnerModularAccountClientParams<
40
40
  TTransport extends Transport = Transport,
41
41
  TChain extends Chain | undefined = Chain | undefined,
42
42
  TSigner extends SmartAccountSigner = SmartAccountSigner
43
- > = {
44
- account: Omit<
45
- CreateMultiOwnerModularAccountParams<TTransport, TSigner>,
46
- "transport" | "chain"
47
- >;
48
- } & Omit<
49
- CreateLightAccountClientParams<TTransport, TChain, TSigner>,
50
- "account"
51
- >;
43
+ > = Omit<
44
+ CreateMultiOwnerModularAccountParams<TTransport, TSigner>,
45
+ "transport" | "chain"
46
+ > &
47
+ Omit<CreateLightAccountClientParams<TTransport, TChain, TSigner>, "account">;
52
48
 
53
49
  export type CreateMultisigModularAccountClientParams<
54
50
  TTransport extends Transport = Transport,
55
51
  TChain extends Chain | undefined = Chain | undefined,
56
52
  TSigner extends SmartAccountSigner = SmartAccountSigner
57
- > = {
58
- account: Omit<
59
- CreateMultisigModularAccountParams<TTransport, TSigner>,
60
- "transport" | "chain"
61
- >;
62
- } & Omit<
63
- CreateLightAccountClientParams<TTransport, TChain, TSigner>,
64
- "account"
65
- >;
53
+ > = Omit<
54
+ CreateMultisigModularAccountParams<TTransport, TSigner>,
55
+ "transport" | "chain"
56
+ > &
57
+ Omit<CreateLightAccountClientParams<TTransport, TChain, TSigner>, "account">;
66
58
 
67
59
  export function createMultiOwnerModularAccountClient<
68
60
  TChain extends Chain | undefined = Chain | undefined,
@@ -88,14 +80,13 @@ export function createMultiOwnerModularAccountClient<
88
80
  * import { createMultiOwnerModularAccountClient } from "@account-kit/smart-contracts";
89
81
  * import { LocalAccountSigner } from "@aa-sdk/core";
90
82
  * import { sepolia } from "viem/chains";
91
- * import { http, generatePrivateKey } from "viem"
83
+ * import { http } from "viem";
84
+ * import { generatePrivateKey } from "viem/accounts";
92
85
  *
93
86
  * const accountClient = await createMultiOwnerModularAccountClient({
94
87
  * chain: sepolia,
95
88
  * transport: http("RPC_URL"),
96
- * account: {
97
- * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())
98
- * }
89
+ * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())
99
90
  * });
100
91
  * ```
101
92
  *
@@ -103,19 +94,18 @@ export function createMultiOwnerModularAccountClient<
103
94
  * @returns {Promise<SmartAccountClient>} A promise that resolves to a `SmartAccountClient` instance with extended plugin actions
104
95
  */
105
96
  export async function createMultiOwnerModularAccountClient({
106
- account,
107
97
  transport,
108
98
  chain,
109
- ...clientConfig
99
+ ...params
110
100
  }: CreateMultiOwnerModularAccountClientParams): Promise<SmartAccountClient> {
111
101
  const modularAccount = await createMultiOwnerModularAccount({
112
- ...account,
102
+ ...params,
113
103
  transport,
114
104
  chain,
115
105
  });
116
106
 
117
107
  return createSmartAccountClient({
118
- ...clientConfig,
108
+ ...params,
119
109
  transport,
120
110
  chain,
121
111
  account: modularAccount,
@@ -151,16 +141,15 @@ export function createMultisigModularAccountClient<
151
141
  * import { createMultisigModularAccountClient } from "@account-kit/smart-contracts";
152
142
  * import { LocalAccountSigner } from "@aa-sdk/core";
153
143
  * import { sepolia } from "viem/chains";
154
- * import { http, generatePrivateKey } from "viem"
144
+ * import { http } from "viem"
145
+ * import { generatePrivateKey } from "viem/accounts";
155
146
  *
156
147
  * const accountClient = await createMultisigModularAccountClient({
157
148
  * chain: sepolia,
158
149
  * transport: http("RPC_URL"),
159
- * account: {
160
- * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),
161
- * owners: [...], // other owners on the account
162
- * threshold: 2, // 2 of N signatures
163
- * }
150
+ * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),
151
+ * owners: [], // other owners on the account
152
+ * threshold: 2, // 2 of N signatures
164
153
  * });
165
154
  * ```
166
155
  *
@@ -168,10 +157,9 @@ export function createMultisigModularAccountClient<
168
157
  * @returns {Promise<SmartAccountClient<Transport, Chain, MultisigModularAccount<SmartAccountSigner>, {}, SmartAccountClientRpcSchema, MultisigUserOperationContext>>} a promise that resolves to a `SmartAccountClient` object extended with the multisig modular account and additional actions
169
158
  */
170
159
  export async function createMultisigModularAccountClient({
171
- account,
172
160
  transport,
173
161
  chain,
174
- ...clientConfig
162
+ ...params
175
163
  }: CreateMultisigModularAccountClientParams): Promise<
176
164
  SmartAccountClient<
177
165
  Transport,
@@ -183,13 +171,13 @@ export async function createMultisigModularAccountClient({
183
171
  >
184
172
  > {
185
173
  const modularAccount = await createMultisigModularAccount({
186
- ...account,
174
+ ...params,
187
175
  transport,
188
176
  chain,
189
177
  });
190
178
 
191
179
  const client = createSmartAccountClient({
192
- ...clientConfig,
180
+ ...params,
193
181
  transport,
194
182
  chain,
195
183
  account: modularAccount,
@@ -1,3 +1,7 @@
1
+ import {
2
+ smartAccountClientActions,
3
+ type SmartAccountSigner,
4
+ } from "@aa-sdk/core";
1
5
  import {
2
6
  AlchemyProviderConfigSchema,
3
7
  createAlchemyPublicRpcClient,
@@ -19,10 +23,6 @@ import {
19
23
  type MultisigUserOperationContext,
20
24
  type PluginManagerActions,
21
25
  } from "@account-kit/smart-contracts";
22
- import {
23
- smartAccountClientActions,
24
- type SmartAccountSigner,
25
- } from "@aa-sdk/core";
26
26
  import {
27
27
  custom,
28
28
  type Chain,
@@ -71,7 +71,7 @@ export function createMultisigAccountAlchemyClient<
71
71
  * @example
72
72
  * ```ts
73
73
  * import { createMultisigAccountAlchemyClient } from "@account-kit/smart-contracts";
74
- * import { sepolia } from "@account-kit/infra/chains";
74
+ * import { sepolia } from "@account-kit/infra";
75
75
  * import { LocalAccountSigner } from "@aa-sdk/core";
76
76
  * import { generatePrivateKey } from "viem"
77
77
  *
@@ -27,12 +27,12 @@ import {
27
27
  * This middleware handles correctly aggregating signatures passed through
28
28
  * as context when sending UserOperations, proposing UserOperations, or adding signatures to a UserOperation.
29
29
  *
30
- * @param struct the user operation struct to be signed
31
- * @param param the parameters to be passed to the middleware
32
- * @param param.account the account to be used for signing
33
- * @param param.client the smart account client that will be used for RPC requests
34
- * @param param.context the context object containing the signatures to be aggregated {@link MultisigUserOperationContext}
35
- * @returns a Promise containing a UserOperation with an aggregated signature in the `signature` field
30
+ * @param {Deferrable<UserOperationStruct<TEntryPointVersion>>} struct the user operation struct to be signed
31
+ * @param {ClientMiddlewareArgs<TAccount, C, TContext, TEntryPointVersion>} args the parameters to be passed to the middleware
32
+ * @param {UserOperationOverrides<TEntryPointVersion>} args.account the account to be used for signing
33
+ * @param {MiddlewareClient} args.client the smart account client that will be used for RPC requests
34
+ * @param {MultisigUserOperationContext} args.context the context object containing the signatures to be aggregated MultisigUserOperationContext
35
+ * @returns {Promise<Deferrable<UserOperationStruct<TEntryPointVersion>>>} a Promise containing a UserOperation with an aggregated signature in the `signature` field
36
36
  */
37
37
  export const multisigSignatureMiddleware: ClientMiddlewareFn<
38
38
  MultisigUserOperationContext
@@ -8,9 +8,9 @@ import type { Signature } from "../types";
8
8
  * by signer address. The EOA SIGS contain the 65 signautre data for EOA signers and 65 bytes containing SIGNER | OFFSET | V for contract signers.
9
9
  * The OFFSET is used to fetch the signature data from the CONTRACT_SIG_DATAS.
10
10
  *
11
- * @param signatures the array of {@link Signature} objects to combine into the correct aggregated signature format excluding the upper limits
12
- * @param usingMaxValues a boolean indicating wether or not the UserOperation is using the UPPER_LIMIT for the gas and fee values
13
- * @returns the Hex representation of the signature
11
+ * @param {Signature[]} signatures the array of Signature objects to combine into the correct aggregated signature format excluding the upper limits
12
+ * @param {boolean} usingMaxValues a boolean indicating wether or not the UserOperation is using the UPPER_LIMIT for the gas and fee values
13
+ * @returns {Hex} the Hex representation of the signature
14
14
  */
15
15
  export const formatSignatures = (
16
16
  signatures: Signature[],
@@ -19,15 +19,23 @@ export type SplitAggregateSignatureParams<
19
19
  account: SmartContractAccount;
20
20
  request: UserOperationRequest<TEntryPointVersion>;
21
21
  };
22
+
23
+ export type SplitAggregateSignatureResult = {
24
+ upperLimitPvg: Hex;
25
+ upperLimitMaxFeePerGas: Hex;
26
+ upperLimitMaxPriorityFeePerGas: Hex;
27
+ signatures: Signature[];
28
+ };
29
+
22
30
  /**
23
31
  * Takes an aggregated signature and threshold and splits it into its components
24
32
  *
25
- * @param args - the arguments for the split
26
- * @param args.aggregateSignature - the aggregated signature to split
27
- * @param args.threshold - the threshold for the signature
28
- * @param args.account - the account which the signature is valid for
29
- * @param args.request - the user operation request that the signature is for
30
- * @returns the signature split into its upper limits and current signatures
33
+ * @param {SplitAggregateSignatureParams<TAccount>} args - the arguments for the split
34
+ * @param {Hex} args.aggregateSignature - the aggregated signature to split
35
+ * @param {number} args.threshold - the threshold for the signature
36
+ * @param {SmartContractAccount} args.account - the account which the signature is valid for
37
+ * @param {UserOperationRequest<TEntryPointVersion>} args.request - the user operation request that the signature is for
38
+ * @returns {Promise<SplitAggregateSignatureResult>} the signature split into its upper limits and current signatures
31
39
  */
32
40
  export const splitAggregatedSignature = async <
33
41
  TAccount extends SmartContractAccount | undefined =
@@ -35,12 +43,7 @@ export const splitAggregatedSignature = async <
35
43
  | undefined
36
44
  >(
37
45
  args: SplitAggregateSignatureParams<TAccount>
38
- ): Promise<{
39
- upperLimitPvg: Hex;
40
- upperLimitMaxFeePerGas: Hex;
41
- upperLimitMaxPriorityFeePerGas: Hex;
42
- signatures: Signature[];
43
- }> => {
46
+ ): Promise<SplitAggregateSignatureResult> => {
44
47
  const { aggregatedSignature, threshold, account, request } = args;
45
48
  if (aggregatedSignature.length < 192 + (65 * threshold - 1)) {
46
49
  throw new InvalidAggregatedSignatureError();
@@ -70,46 +70,192 @@ export class SessionKeyPermissionsBuilder {
70
70
  private _gasSpendLimit?: GasSpendLimit;
71
71
  private _requiredPaymaster?: Address;
72
72
 
73
+ /**
74
+ * Sets the access control type for the contract and returns the current instance for method chaining.
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * import { SessionKeyPermissionsBuilder } from "@account-kit/smart-contracts";
79
+ *
80
+ * const builder = new SessionKeyPermissionsBuilder();
81
+ * builder.setContractAccessControlType(SessionKeyAccessListType.ALLOWLIST);
82
+ * ```
83
+ *
84
+ * @param {SessionKeyAccessListType} aclType The access control type for the session key
85
+ * @returns {SessionKeyPermissionsBuilder} The current instance for method chaining
86
+ */
73
87
  public setContractAccessControlType(aclType: SessionKeyAccessListType) {
74
88
  this._contractAccessControlType = aclType;
75
89
  return this;
76
90
  }
77
91
 
92
+ /**
93
+ * Adds a contract access entry to the internal list of contract address access entries.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * import { SessionKeyPermissionsBuilder } from "@account-kit/smart-contracts";
98
+ *
99
+ * const builder = new SessionKeyPermissionsBuilder();
100
+ * builder.addContractAddressAccessEntry({
101
+ * contractAddress: "0x1234",
102
+ * isOnList: true,
103
+ * checkSelectors: true,
104
+ * });
105
+ * ```
106
+ *
107
+ * @param {ContractAccessEntry} entry the contract access entry to be added
108
+ * @returns {SessionKeyPermissionsBuilder} the instance of the current class for chaining
109
+ */
78
110
  public addContractAddressAccessEntry(entry: ContractAccessEntry) {
79
111
  this._contractAddressAccessEntrys.push(entry);
80
112
  return this;
81
113
  }
82
114
 
115
+ /**
116
+ * Adds a contract method entry to the `_contractMethodAccessEntrys` array.
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * import { SessionKeyPermissionsBuilder } from "@account-kit/smart-contracts";
121
+ *
122
+ * const builder = new SessionKeyPermissionsBuilder();
123
+ * builder.addContractAddressAccessEntry({
124
+ * contractAddress: "0x1234",
125
+ * methodSelector: "0x45678",
126
+ * isOnList: true,
127
+ * });
128
+ * ```
129
+ *
130
+ * @param {ContractMethodEntry} entry The contract method entry to be added
131
+ * @returns {SessionKeyPermissionsBuilder} The instance of the class for method chaining
132
+ */
83
133
  public addContractFunctionAccessEntry(entry: ContractMethodEntry) {
84
134
  this._contractMethodAccessEntrys.push(entry);
85
135
  return this;
86
136
  }
87
137
 
138
+ /**
139
+ * Sets the time range for an object and returns the object itself for chaining.
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * import { SessionKeyPermissionsBuilder } from "@account-kit/smart-contracts";
144
+ *
145
+ * const builder = new SessionKeyPermissionsBuilder();
146
+ * builder.setTimeRange({
147
+ * validFrom: Date.now(),
148
+ * validUntil: Date.now() + (15 * 60 * 1000),
149
+ * });
150
+ * ```
151
+ *
152
+ * @param {TimeRange} timeRange The time range to be set
153
+ * @returns {SessionKeyPermissionsBuilder} The current object for method chaining
154
+ */
88
155
  public setTimeRange(timeRange: TimeRange) {
89
156
  this._timeRange = timeRange;
90
157
  return this;
91
158
  }
92
159
 
160
+ /**
161
+ * Sets the native token spend limit and returns the instance for chaining.
162
+ *
163
+ * @example
164
+ * ```ts
165
+ * import { SessionKeyPermissionsBuilder } from "@account-kit/smart-contracts";
166
+ *
167
+ * const builder = new SessionKeyPermissionsBuilder();
168
+ * builder.setNativeTokenSpendLimit({
169
+ * spendLimit: 1000000000000000000n,
170
+ * refreshInterval: 3600,
171
+ * });
172
+ * ```
173
+ *
174
+ * @param {NativeTokenLimit} limit The limit to set for native token spending
175
+ * @returns {SessionKeyPermissionsBuilder} The instance for chaining
176
+ */
93
177
  public setNativeTokenSpendLimit(limit: NativeTokenLimit) {
94
178
  this._nativeTokenSpendLimit = limit;
95
179
  return this;
96
180
  }
97
181
 
182
+ /**
183
+ * Adds an ERC20 token spend limit to the list of limits and returns the updated object.
184
+ *
185
+ * @example
186
+ * ```ts
187
+ * import { SessionKeyPermissionsBuilder } from "@account-kit/smart-contracts";
188
+ *
189
+ * const builder = new SessionKeyPermissionsBuilder();
190
+ * builder.addErc20TokenSpendLimit({
191
+ * tokenAddress: "0x1234",
192
+ * spendLimit: 1000000000000000000n,
193
+ * refreshInterval: 3600,
194
+ * });
195
+ * ```
196
+ *
197
+ * @param {Erc20TokenLimit} limit The ERC20 token spend limit to be added
198
+ * @returns {object} The updated object with the new ERC20 token spend limit
199
+ */
98
200
  public addErc20TokenSpendLimit(limit: Erc20TokenLimit) {
99
201
  this._erc20TokenSpendLimits.push(limit);
100
202
  return this;
101
203
  }
102
204
 
103
- public setGasSpendLimit(limit: GasSpendLimit) {
205
+ /**
206
+ * Sets the gas spend limit and returns the current instance for method chaining.
207
+ *
208
+ * @example
209
+ * ```ts
210
+ * import { SessionKeyPermissionsBuilder } from "@account-kit/smart-contracts";
211
+ *
212
+ * const builder = new SessionKeyPermissionsBuilder();
213
+ * builder.setGasSpendLimit({
214
+ * spendLimit: 1000000000000000000n,
215
+ * refreshInterval: 3600,
216
+ * });
217
+ * ```
218
+ *
219
+ * @param {GasSpendLimit} limit - The gas spend limit to be set
220
+ * @returns {SessionKeyPermissionsBuilder} The current instance for chaining
221
+ */ public setGasSpendLimit(limit: GasSpendLimit) {
104
222
  this._gasSpendLimit = limit;
105
223
  return this;
106
224
  }
107
225
 
226
+ /**
227
+ * Sets the required paymaster address.
228
+ *
229
+ * @example
230
+ * ```ts
231
+ * import { SessionKeyPermissionsBuilder } from "@account-kit/smart-contracts";
232
+ *
233
+ * const builder = new SessionKeyPermissionsBuilder();
234
+ * builder.setRequiredPaymaster("0x1234");
235
+ * ```
236
+ *
237
+ * @param {Address} paymaster the address of the paymaster to be set
238
+ * @returns {SessionKeyPermissionsBuilder} the current instance for method chaining
239
+ */
108
240
  public setRequiredPaymaster(paymaster: Address) {
109
241
  this._requiredPaymaster = paymaster;
110
242
  return this;
111
243
  }
112
244
 
245
+ /**
246
+ * Encodes various function calls into an array of hexadecimal strings based on the provided permissions and limits.
247
+ *
248
+ * @example
249
+ * ```ts
250
+ * import { SessionKeyPermissionsBuilder } from "@account-kit/smart-contracts";
251
+ *
252
+ * const builder = new SessionKeyPermissionsBuilder();
253
+ * builder.setRequiredPaymaster("0x1234");
254
+ * const encoded = builder.encode();
255
+ * ```
256
+ *
257
+ * @returns {Hex[]} An array of encoded hexadecimal strings representing the function calls for setting access control, permissions, and limits.
258
+ */
113
259
  public encode(): Hex[] {
114
260
  return [
115
261
  encodeFunctionData({
@@ -33,6 +33,18 @@ export class SessionKeySigner
33
33
  private storageType: "local-storage" | "session-storage" | Storage;
34
34
  private storageKey: string;
35
35
 
36
+ /**
37
+ * Initializes a new instance of a session key signer with the provided configuration. This will set the `signerType`, `storageKey`, and `storageType`. It will also manage the session key, either fetching it from storage or generating a new one if it doesn't exist.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * import { SessionKeySigner } from "@account-kit/smart-contracts";
42
+ *
43
+ * const signer = new SessionKeySigner();
44
+ * ```
45
+ *
46
+ * @param {SessionKeySignerConfig} config_ the configuration for initializing the session key signer
47
+ */
36
48
  constructor(config_: SessionKeySignerConfig = {}) {
37
49
  const config = SessionKeySignerSchema.parse(config_);
38
50
  this.signerType = `${SESSION_KEY_SIGNER_TYPE_PFX}`;
@@ -60,16 +72,66 @@ export class SessionKeySigner
60
72
  this.inner = LocalAccountSigner.privateKeyToAccountSigner(sessionKey);
61
73
  }
62
74
 
75
+ /**
76
+ * An async function that retrieves the address using the inner object's `getAddress` method.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * import { SessionKeySigner } from "@account-kit/smart-contracts";
81
+ *
82
+ * const signer = new SessionKeySigner();
83
+ * const sessionKeyAddress = await signer.getAddress();
84
+ * ```
85
+ *
86
+ * @returns {Promise<string>} A promise that resolves to the address as a string
87
+ */
63
88
  getAddress: () => Promise<`0x${string}`> = async () => {
64
89
  return this.inner.getAddress();
65
90
  };
66
91
 
92
+ /**
93
+ * Signs a message using the inner signer.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * import { SessionKeySigner } from "@account-kit/smart-contracts";
98
+ *
99
+ * const signer = new SessionKeySigner();
100
+ * const sessionKeyAddress = await signer.signMessage("hello");
101
+ * ```
102
+ *
103
+ * @param {SignableMessage} msg The message to sign
104
+ * @returns {Promise<Hex>} A promise that resolves to the signed message
105
+ */
67
106
  signMessage: (msg: SignableMessage) => Promise<`0x${string}`> = async (
68
107
  msg
69
108
  ) => {
70
109
  return this.inner.signMessage(msg);
71
110
  };
72
111
 
112
+ /**
113
+ * Signs the provided typed data using the inner signer.
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * import { SessionKeySigner } from "@account-kit/smart-contracts";
118
+ *
119
+ * const signer = new SessionKeySigner();
120
+ * console.log(await signer.signTypedData({
121
+ * types: {
122
+ * "Message": [{ name: "content", type: "string" }]
123
+ * },
124
+ * primaryType: "Message",
125
+ * message: { content: "Hello" },
126
+ * }));
127
+ * ```
128
+ *
129
+ * @template TTypedData - The typed data type, which extends `TypedData` or a record of unknown keys to unknown values.
130
+ * @template TPrimaryType - The primary type of the typed data.
131
+ *
132
+ * @param {TypedDataDefinition<TTypedData, TPrimaryType>} params The parameters containing the typed data definition and primary type.
133
+ * @returns {Promise<string>} A promise that resolves to the signed typed data as a string.
134
+ */
73
135
  signTypedData = async <
74
136
  const TTypedData extends TypedData | { [key: string]: unknown },
75
137
  TPrimaryType extends string = string
@@ -82,7 +144,15 @@ export class SessionKeySigner
82
144
  /**
83
145
  * Generates a new private key and stores it in the storage.
84
146
  *
85
- * @returns The public address of the new key.
147
+ * @example
148
+ * ```ts
149
+ * import { SessionKeySigner } from "@account-kit/smart-contracts";
150
+ *
151
+ * const signer = new SessionKeySigner();
152
+ * const newSessionKey = signer.generateNewKey();
153
+ * ```
154
+ *
155
+ * @returns {Address} The public address of the new key.
86
156
  */
87
157
  generateNewKey = () => {
88
158
  const storage =
package/src/msca/utils.ts CHANGED
@@ -1,6 +1,14 @@
1
1
  import {
2
2
  AccountNotFoundError,
3
3
  ChainNotFoundError,
4
+ type GetAccountParameter,
5
+ type SmartAccountClient,
6
+ type SmartAccountSigner,
7
+ type SmartContractAccount,
8
+ type SmartContractAccountWithSigner,
9
+ type UpgradeToData,
10
+ } from "@aa-sdk/core";
11
+ import {
4
12
  arbitrum,
5
13
  arbitrumSepolia,
6
14
  base,
@@ -11,13 +19,7 @@ import {
11
19
  polygon,
12
20
  polygonAmoy,
13
21
  sepolia,
14
- type GetAccountParameter,
15
- type SmartAccountClient,
16
- type SmartAccountSigner,
17
- type SmartContractAccount,
18
- type SmartContractAccountWithSigner,
19
- type UpgradeToData,
20
- } from "@aa-sdk/core";
22
+ } from "@account-kit/infra";
21
23
  import type { Address, Chain, Transport } from "viem";
22
24
  import {
23
25
  custom,
@@ -37,10 +39,10 @@ import {
37
39
  import { MultiOwnerPlugin } from "./plugins/multi-owner/plugin.js";
38
40
 
39
41
  /**
40
- * Utility method returning the default multi sig msca factory address given a {@link Chain} object
42
+ * Utility method returning the default multi sig msca factory address given a chain
41
43
  *
42
- * @param chain a {@link Chain} object
43
- * @returns a {@link Address} for the given chain
44
+ * @param {Chain} chain the chain object for which to get the address
45
+ * @returns {Address} the address for the given chain
44
46
  * @throws if the chain doesn't have an address currently deployed
45
47
  */
46
48
  export const getDefaultMultisigModularAccountFactoryAddress = (
@@ -63,10 +65,10 @@ export const getDefaultMultisigModularAccountFactoryAddress = (
63
65
  };
64
66
 
65
67
  /**
66
- * Utility method returning the default multi owner msca factory address given a {@link Chain} object
68
+ * Utility method returning the default multi owner msca factory address given a chain
67
69
  *
68
- * @param chain - a {@link Chain} object
69
- * @returns a {@link Address} for the given chain
70
+ * @param {Chain} chain the chain object for which to get the address
71
+ * @returns {Address} the address for the given chain
70
72
  * @throws if the chain doesn't have an address currently deployed
71
73
  */
72
74
  export const getDefaultMultiOwnerModularAccountFactoryAddress = (
@@ -1,6 +0,0 @@
1
- export declare const API_KEY: string;
2
- export declare const API_KEY_STAGING: string;
3
- export declare const PAYMASTER_POLICY_ID: string;
4
- export declare const PAYMASTER_POLICY_ID_STAGING: string;
5
- export declare const UNDEPLOYED_OWNER_MNEMONIC: string;
6
- export declare const LIGHT_ACCOUNT_OWNER_MNEMONIC: string;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LIGHT_ACCOUNT_OWNER_MNEMONIC = exports.UNDEPLOYED_OWNER_MNEMONIC = exports.PAYMASTER_POLICY_ID_STAGING = exports.PAYMASTER_POLICY_ID = exports.API_KEY_STAGING = exports.API_KEY = void 0;
4
- exports.API_KEY = process.env.API_KEY;
5
- exports.API_KEY_STAGING = process.env.API_KEY_STAGING;
6
- exports.PAYMASTER_POLICY_ID = process.env.PAYMASTER_POLICY_ID;
7
- exports.PAYMASTER_POLICY_ID_STAGING = process.env.PAYMASTER_POLICY_ID_STAGING;
8
- exports.UNDEPLOYED_OWNER_MNEMONIC = process.env.UNDEPLOYED_OWNER_MNEMONIC;
9
- exports.LIGHT_ACCOUNT_OWNER_MNEMONIC = process.env.LIGHT_ACCOUNT_OWNER_MNEMONIC;
10
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/light-account/e2e-tests/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAQ,CAAC;AAC/B,QAAA,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,eAAgB,CAAC;AAC/C,QAAA,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAoB,CAAC;AACvD,QAAA,2BAA2B,GACtC,OAAO,CAAC,GAAG,CAAC,2BAA4B,CAAC;AAC9B,QAAA,yBAAyB,GAAG,OAAO,CAAC,GAAG,CAAC,yBAA0B,CAAC;AACnE,QAAA,4BAA4B,GACvC,OAAO,CAAC,GAAG,CAAC,4BAA6B,CAAC","sourcesContent":["export const API_KEY = process.env.API_KEY!;\nexport const API_KEY_STAGING = process.env.API_KEY_STAGING!;\nexport const PAYMASTER_POLICY_ID = process.env.PAYMASTER_POLICY_ID!;\nexport const PAYMASTER_POLICY_ID_STAGING =\n process.env.PAYMASTER_POLICY_ID_STAGING!;\nexport const UNDEPLOYED_OWNER_MNEMONIC = process.env.UNDEPLOYED_OWNER_MNEMONIC!;\nexport const LIGHT_ACCOUNT_OWNER_MNEMONIC =\n process.env.LIGHT_ACCOUNT_OWNER_MNEMONIC!;\n"]}
@@ -1,21 +0,0 @@
1
- import { z } from "zod";
2
- import type { LightAccountVersion } from "./types.js";
3
- export declare const LightAccountFactoryConfigSchema: z.ZodObject<{
4
- signer: z.ZodType<import("@aa-sdk/core").SmartAccountSigner<any>, z.ZodTypeDef, import("@aa-sdk/core").SmartAccountSigner<any>>;
5
- accountAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
6
- initCode: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
7
- factoryAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
8
- version: z.ZodOptional<z.ZodEffects<z.ZodString, LightAccountVersion, string>>;
9
- }, "strip", z.ZodTypeAny, {
10
- signer: import("@aa-sdk/core").SmartAccountSigner<any>;
11
- accountAddress?: `0x${string}` | undefined;
12
- initCode?: `0x${string}` | undefined;
13
- factoryAddress?: `0x${string}` | undefined;
14
- version?: LightAccountVersion | undefined;
15
- }, {
16
- signer: import("@aa-sdk/core").SmartAccountSigner<any>;
17
- accountAddress?: string | undefined;
18
- initCode?: string | undefined;
19
- factoryAddress?: string | undefined;
20
- version?: string | undefined;
21
- }>;