@aa-sdk/core 4.0.0-alpha.5 → 4.0.0-alpha.6

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 (239) hide show
  1. package/dist/cjs/account/smartContractAccount.d.ts +9 -3
  2. package/dist/cjs/account/smartContractAccount.js +11 -6
  3. package/dist/cjs/account/smartContractAccount.js.map +1 -1
  4. package/dist/cjs/actions/smartAccount/buildUserOperationFromTx.js.map +1 -1
  5. package/dist/cjs/actions/smartAccount/buildUserOperationFromTxs.js.map +1 -1
  6. package/dist/cjs/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
  7. package/dist/cjs/actions/smartAccount/estimateUserOperationGas.js.map +1 -1
  8. package/dist/cjs/actions/smartAccount/internal/initUserOperation.js.map +1 -1
  9. package/dist/cjs/actions/smartAccount/internal/runMiddlewareStack.js.map +1 -1
  10. package/dist/cjs/actions/smartAccount/internal/sendUserOperation.js.map +1 -1
  11. package/dist/cjs/actions/smartAccount/sendUserOperation.js.map +1 -1
  12. package/dist/cjs/client/bundlerClient.js.map +1 -1
  13. package/dist/cjs/client/decorators/bundlerClient.js.map +1 -1
  14. package/dist/cjs/client/isSmartAccountClient.js.map +1 -1
  15. package/dist/cjs/client/types.d.ts +2 -7
  16. package/dist/cjs/client/types.js.map +1 -1
  17. package/dist/cjs/errors/account.js.map +1 -1
  18. package/dist/cjs/errors/client.js.map +1 -1
  19. package/dist/cjs/errors/entrypoint.js.map +1 -1
  20. package/dist/cjs/errors/signer.js.map +1 -1
  21. package/dist/cjs/errors/transaction.js.map +1 -1
  22. package/dist/cjs/errors/useroperation.js.map +1 -1
  23. package/dist/cjs/index.d.ts +3 -5
  24. package/dist/cjs/index.js +6 -9
  25. package/dist/cjs/index.js.map +1 -1
  26. package/dist/cjs/logger.js.map +1 -1
  27. package/dist/cjs/middleware/actions.js +2 -18
  28. package/dist/cjs/middleware/actions.js.map +1 -1
  29. package/dist/cjs/middleware/defaults/gasEstimator.js +3 -2
  30. package/dist/cjs/middleware/defaults/gasEstimator.js.map +1 -1
  31. package/dist/cjs/middleware/erc7677middleware.d.ts +40 -0
  32. package/dist/cjs/middleware/erc7677middleware.js +77 -0
  33. package/dist/cjs/middleware/erc7677middleware.js.map +1 -0
  34. package/dist/cjs/middleware/noopMiddleware.d.ts +2 -1
  35. package/dist/cjs/middleware/noopMiddleware.js.map +1 -1
  36. package/dist/cjs/middleware/types.d.ts +3 -2
  37. package/dist/cjs/middleware/types.js.map +1 -1
  38. package/dist/cjs/signer/local-account.d.ts +46 -46
  39. package/dist/cjs/signer/local-account.js.map +1 -1
  40. package/dist/cjs/signer/wallet-client.d.ts +46 -46
  41. package/dist/cjs/signer/wallet-client.js.map +1 -1
  42. package/dist/cjs/transport/split.js.map +1 -1
  43. package/dist/cjs/utils/bigint.js.map +1 -1
  44. package/dist/cjs/utils/bytes.js.map +1 -1
  45. package/dist/cjs/utils/defaults.d.ts +1 -3
  46. package/dist/cjs/utils/defaults.js +1 -41
  47. package/dist/cjs/utils/defaults.js.map +1 -1
  48. package/dist/cjs/utils/index.js.map +1 -1
  49. package/dist/cjs/utils/types.js.map +1 -1
  50. package/dist/cjs/utils/userop.js.map +1 -1
  51. package/dist/cjs/version.d.ts +1 -1
  52. package/dist/cjs/version.js +1 -1
  53. package/dist/cjs/version.js.map +1 -1
  54. package/dist/esm/account/smartContractAccount.d.ts +9 -3
  55. package/dist/esm/account/smartContractAccount.js +6 -1
  56. package/dist/esm/account/smartContractAccount.js.map +1 -1
  57. package/dist/esm/actions/smartAccount/buildUserOperationFromTx.js.map +1 -1
  58. package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.js.map +1 -1
  59. package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
  60. package/dist/esm/actions/smartAccount/estimateUserOperationGas.js.map +1 -1
  61. package/dist/esm/actions/smartAccount/internal/initUserOperation.js.map +1 -1
  62. package/dist/esm/actions/smartAccount/internal/runMiddlewareStack.js.map +1 -1
  63. package/dist/esm/actions/smartAccount/internal/sendUserOperation.js.map +1 -1
  64. package/dist/esm/actions/smartAccount/sendUserOperation.js.map +1 -1
  65. package/dist/esm/client/bundlerClient.js.map +1 -1
  66. package/dist/esm/client/decorators/bundlerClient.js.map +1 -1
  67. package/dist/esm/client/isSmartAccountClient.js.map +1 -1
  68. package/dist/esm/client/types.d.ts +2 -7
  69. package/dist/esm/client/types.js.map +1 -1
  70. package/dist/esm/errors/account.js.map +1 -1
  71. package/dist/esm/errors/client.js.map +1 -1
  72. package/dist/esm/errors/entrypoint.js.map +1 -1
  73. package/dist/esm/errors/signer.js.map +1 -1
  74. package/dist/esm/errors/transaction.js.map +1 -1
  75. package/dist/esm/errors/useroperation.js.map +1 -1
  76. package/dist/esm/index.d.ts +3 -5
  77. package/dist/esm/index.js +2 -3
  78. package/dist/esm/index.js.map +1 -1
  79. package/dist/esm/logger.js.map +1 -1
  80. package/dist/esm/middleware/actions.js +3 -18
  81. package/dist/esm/middleware/actions.js.map +1 -1
  82. package/dist/esm/middleware/defaults/gasEstimator.js +3 -2
  83. package/dist/esm/middleware/defaults/gasEstimator.js.map +1 -1
  84. package/dist/esm/middleware/erc7677middleware.d.ts +40 -0
  85. package/dist/esm/middleware/erc7677middleware.js +73 -0
  86. package/dist/esm/middleware/erc7677middleware.js.map +1 -0
  87. package/dist/esm/middleware/noopMiddleware.d.ts +2 -1
  88. package/dist/esm/middleware/noopMiddleware.js.map +1 -1
  89. package/dist/esm/middleware/types.d.ts +3 -2
  90. package/dist/esm/middleware/types.js.map +1 -1
  91. package/dist/esm/signer/local-account.d.ts +46 -46
  92. package/dist/esm/signer/local-account.js.map +1 -1
  93. package/dist/esm/signer/wallet-client.d.ts +46 -46
  94. package/dist/esm/signer/wallet-client.js.map +1 -1
  95. package/dist/esm/transport/split.js.map +1 -1
  96. package/dist/esm/utils/bigint.js.map +1 -1
  97. package/dist/esm/utils/bytes.js.map +1 -1
  98. package/dist/esm/utils/defaults.d.ts +1 -3
  99. package/dist/esm/utils/defaults.js +1 -40
  100. package/dist/esm/utils/defaults.js.map +1 -1
  101. package/dist/esm/utils/index.js.map +1 -1
  102. package/dist/esm/utils/types.js.map +1 -1
  103. package/dist/esm/utils/userop.js.map +1 -1
  104. package/dist/esm/version.d.ts +1 -1
  105. package/dist/esm/version.js +1 -1
  106. package/dist/esm/version.js.map +1 -1
  107. package/dist/types/account/smartContractAccount.d.ts +17 -11
  108. package/dist/types/account/smartContractAccount.d.ts.map +1 -1
  109. package/dist/types/actions/smartAccount/buildUserOperationFromTx.d.ts +33 -33
  110. package/dist/types/actions/smartAccount/buildUserOperationFromTxs.d.ts +43 -59
  111. package/dist/types/actions/smartAccount/buildUserOperationFromTxs.d.ts.map +1 -1
  112. package/dist/types/actions/smartAccount/checkGasSponsorshipEligibility.d.ts +18 -18
  113. package/dist/types/actions/smartAccount/estimateUserOperationGas.d.ts +3 -3
  114. package/dist/types/actions/smartAccount/internal/initUserOperation.d.ts +3 -4
  115. package/dist/types/actions/smartAccount/internal/initUserOperation.d.ts.map +1 -1
  116. package/dist/types/actions/smartAccount/internal/runMiddlewareStack.d.ts +0 -14
  117. package/dist/types/actions/smartAccount/internal/runMiddlewareStack.d.ts.map +1 -1
  118. package/dist/types/actions/smartAccount/internal/sendUserOperation.d.ts +0 -7
  119. package/dist/types/actions/smartAccount/internal/sendUserOperation.d.ts.map +1 -1
  120. package/dist/types/actions/smartAccount/sendUserOperation.d.ts +17 -3
  121. package/dist/types/actions/smartAccount/sendUserOperation.d.ts.map +1 -1
  122. package/dist/types/client/bundlerClient.d.ts +2 -2
  123. package/dist/types/client/decorators/bundlerClient.d.ts +8 -8
  124. package/dist/types/client/isSmartAccountClient.d.ts +4 -4
  125. package/dist/types/client/types.d.ts +2 -7
  126. package/dist/types/client/types.d.ts.map +1 -1
  127. package/dist/types/errors/account.d.ts +53 -4
  128. package/dist/types/errors/account.d.ts.map +1 -1
  129. package/dist/types/errors/client.d.ts +15 -0
  130. package/dist/types/errors/client.d.ts.map +1 -1
  131. package/dist/types/errors/entrypoint.d.ts +12 -0
  132. package/dist/types/errors/entrypoint.d.ts.map +1 -1
  133. package/dist/types/errors/signer.d.ts +5 -0
  134. package/dist/types/errors/signer.d.ts.map +1 -1
  135. package/dist/types/errors/transaction.d.ts +8 -1
  136. package/dist/types/errors/transaction.d.ts.map +1 -1
  137. package/dist/types/errors/useroperation.d.ts +5 -5
  138. package/dist/types/errors/useroperation.d.ts.map +1 -1
  139. package/dist/types/index.d.ts +3 -5
  140. package/dist/types/index.d.ts.map +1 -1
  141. package/dist/types/logger.d.ts +88 -0
  142. package/dist/types/logger.d.ts.map +1 -1
  143. package/dist/types/middleware/actions.d.ts +3 -3
  144. package/dist/types/middleware/actions.d.ts.map +1 -1
  145. package/dist/types/middleware/defaults/gasEstimator.d.ts +2 -2
  146. package/dist/types/middleware/defaults/gasEstimator.d.ts.map +1 -1
  147. package/dist/types/middleware/erc7677middleware.d.ts +62 -0
  148. package/dist/types/middleware/erc7677middleware.d.ts.map +1 -0
  149. package/dist/types/middleware/noopMiddleware.d.ts +4 -4
  150. package/dist/types/middleware/noopMiddleware.d.ts.map +1 -1
  151. package/dist/types/middleware/types.d.ts +3 -2
  152. package/dist/types/middleware/types.d.ts.map +1 -1
  153. package/dist/types/signer/local-account.d.ts +139 -47
  154. package/dist/types/signer/local-account.d.ts.map +1 -1
  155. package/dist/types/signer/wallet-client.d.ts +135 -46
  156. package/dist/types/signer/wallet-client.d.ts.map +1 -1
  157. package/dist/types/transport/split.d.ts +2 -2
  158. package/dist/types/utils/bigint.d.ts +14 -14
  159. package/dist/types/utils/bigint.d.ts.map +1 -1
  160. package/dist/types/utils/bytes.d.ts +5 -5
  161. package/dist/types/utils/defaults.d.ts +1 -11
  162. package/dist/types/utils/defaults.d.ts.map +1 -1
  163. package/dist/types/utils/index.d.ts +12 -12
  164. package/dist/types/utils/types.d.ts +2 -2
  165. package/dist/types/utils/userop.d.ts +33 -33
  166. package/dist/types/version.d.ts +1 -1
  167. package/package.json +3 -2
  168. package/src/account/smartContractAccount.ts +19 -12
  169. package/src/actions/smartAccount/buildUserOperationFromTx.ts +35 -35
  170. package/src/actions/smartAccount/buildUserOperationFromTxs.ts +44 -60
  171. package/src/actions/smartAccount/checkGasSponsorshipEligibility.ts +19 -19
  172. package/src/actions/smartAccount/estimateUserOperationGas.ts +3 -3
  173. package/src/actions/smartAccount/internal/initUserOperation.ts +3 -4
  174. package/src/actions/smartAccount/internal/runMiddlewareStack.ts +0 -22
  175. package/src/actions/smartAccount/internal/sendUserOperation.ts +0 -7
  176. package/src/actions/smartAccount/sendUserOperation.ts +17 -3
  177. package/src/client/bundlerClient.ts +2 -2
  178. package/src/client/decorators/bundlerClient.ts +8 -8
  179. package/src/client/isSmartAccountClient.ts +4 -4
  180. package/src/client/types.ts +2 -15
  181. package/src/errors/account.ts +64 -4
  182. package/src/errors/client.ts +18 -0
  183. package/src/errors/entrypoint.ts +12 -0
  184. package/src/errors/signer.ts +6 -0
  185. package/src/errors/transaction.ts +10 -1
  186. package/src/errors/useroperation.ts +5 -6
  187. package/src/index.ts +2 -8
  188. package/src/logger.ts +88 -0
  189. package/src/middleware/actions.ts +6 -27
  190. package/src/middleware/defaults/gasEstimator.ts +8 -5
  191. package/src/middleware/erc7677middleware.ts +201 -0
  192. package/src/middleware/noopMiddleware.ts +6 -4
  193. package/src/middleware/types.ts +16 -7
  194. package/src/signer/local-account.ts +94 -2
  195. package/src/signer/wallet-client.ts +89 -0
  196. package/src/transport/split.ts +2 -2
  197. package/src/utils/bigint.ts +15 -15
  198. package/src/utils/bytes.ts +5 -5
  199. package/src/utils/defaults.ts +2 -74
  200. package/src/utils/index.ts +12 -12
  201. package/src/utils/types.ts +2 -2
  202. package/src/utils/userop.ts +33 -33
  203. package/src/version.ts +1 -1
  204. package/dist/cjs/account/base.d.ts +0 -49
  205. package/dist/cjs/account/base.js +0 -257
  206. package/dist/cjs/account/base.js.map +0 -1
  207. package/dist/cjs/account/schema.d.ts +0 -100
  208. package/dist/cjs/account/schema.js +0 -43
  209. package/dist/cjs/account/schema.js.map +0 -1
  210. package/dist/cjs/account/simple.d.ts +0 -14
  211. package/dist/cjs/account/simple.js +0 -119
  212. package/dist/cjs/account/simple.js.map +0 -1
  213. package/dist/cjs/account/types.d.ts +0 -30
  214. package/dist/cjs/account/types.js +0 -3
  215. package/dist/cjs/account/types.js.map +0 -1
  216. package/dist/esm/account/base.d.ts +0 -49
  217. package/dist/esm/account/base.js +0 -253
  218. package/dist/esm/account/base.js.map +0 -1
  219. package/dist/esm/account/schema.d.ts +0 -100
  220. package/dist/esm/account/schema.js +0 -35
  221. package/dist/esm/account/schema.js.map +0 -1
  222. package/dist/esm/account/simple.d.ts +0 -14
  223. package/dist/esm/account/simple.js +0 -115
  224. package/dist/esm/account/simple.js.map +0 -1
  225. package/dist/esm/account/types.d.ts +0 -30
  226. package/dist/esm/account/types.js +0 -2
  227. package/dist/esm/account/types.js.map +0 -1
  228. package/dist/types/account/base.d.ts +0 -128
  229. package/dist/types/account/base.d.ts.map +0 -1
  230. package/dist/types/account/schema.d.ts +0 -101
  231. package/dist/types/account/schema.d.ts.map +0 -1
  232. package/dist/types/account/simple.d.ts +0 -15
  233. package/dist/types/account/simple.d.ts.map +0 -1
  234. package/dist/types/account/types.d.ts +0 -144
  235. package/dist/types/account/types.d.ts.map +0 -1
  236. package/src/account/base.ts +0 -415
  237. package/src/account/schema.ts +0 -51
  238. package/src/account/simple.ts +0 -221
  239. package/src/account/types.ts +0 -184
@@ -1,100 +0,0 @@
1
- import { type Transport } from "viem";
2
- import z from "zod";
3
- import type { SmartAccountSigner } from "../signer/types.js";
4
- export declare const createBaseSmartAccountParamsSchema: <TTransport extends Transport = Transport, TSigner extends SmartAccountSigner<any> = SmartAccountSigner<any>>() => z.ZodObject<{
5
- rpcClient: z.ZodUnion<[z.ZodString, z.ZodType<import("../index.js").BundlerClient<TTransport>, z.ZodTypeDef, import("../index.js").BundlerClient<TTransport>>]>;
6
- factoryAddress: z.ZodEffects<z.ZodString, `0x${string}`, string>;
7
- signer: z.ZodType<TSigner, z.ZodTypeDef, TSigner>;
8
- entryPointAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
9
- chain: z.ZodType<import("viem").Chain, z.ZodTypeDef, import("viem").Chain>;
10
- accountAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
11
- initCode: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
12
- entryPointVersion: z.ZodOptional<z.ZodType<keyof import("../entrypoint/types.js").EntryPointRegistryBase<unknown>, z.ZodTypeDef, keyof import("../entrypoint/types.js").EntryPointRegistryBase<unknown>>>;
13
- }, "strip", z.ZodTypeAny, { [k_1 in keyof z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
14
- rpcClient: z.ZodUnion<[z.ZodString, z.ZodType<import("../index.js").BundlerClient<TTransport>, z.ZodTypeDef, import("../index.js").BundlerClient<TTransport>>]>;
15
- factoryAddress: z.ZodEffects<z.ZodString, `0x${string}`, string>;
16
- signer: z.ZodType<TSigner, z.ZodTypeDef, TSigner>;
17
- entryPointAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
18
- chain: z.ZodType<import("viem").Chain, z.ZodTypeDef, import("viem").Chain>;
19
- accountAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
20
- initCode: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
21
- entryPointVersion: z.ZodOptional<z.ZodType<keyof import("../entrypoint/types.js").EntryPointRegistryBase<unknown>, z.ZodTypeDef, keyof import("../entrypoint/types.js").EntryPointRegistryBase<unknown>>>;
22
- }>, "chain" | "factoryAddress" | "rpcClient" | (undefined extends TSigner ? never : "signer")>]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
23
- rpcClient: z.ZodUnion<[z.ZodString, z.ZodType<import("../index.js").BundlerClient<TTransport>, z.ZodTypeDef, import("../index.js").BundlerClient<TTransport>>]>;
24
- factoryAddress: z.ZodEffects<z.ZodString, `0x${string}`, string>;
25
- signer: z.ZodType<TSigner, z.ZodTypeDef, TSigner>;
26
- entryPointAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
27
- chain: z.ZodType<import("viem").Chain, z.ZodTypeDef, import("viem").Chain>;
28
- accountAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
29
- initCode: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
30
- entryPointVersion: z.ZodOptional<z.ZodType<keyof import("../entrypoint/types.js").EntryPointRegistryBase<unknown>, z.ZodTypeDef, keyof import("../entrypoint/types.js").EntryPointRegistryBase<unknown>>>;
31
- }>, "chain" | "factoryAddress" | "rpcClient" | (undefined extends TSigner ? never : "signer")>[k_1]; }, { [k_2 in keyof z.baseObjectInputType<{
32
- rpcClient: z.ZodUnion<[z.ZodString, z.ZodType<import("../index.js").BundlerClient<TTransport>, z.ZodTypeDef, import("../index.js").BundlerClient<TTransport>>]>;
33
- factoryAddress: z.ZodEffects<z.ZodString, `0x${string}`, string>;
34
- signer: z.ZodType<TSigner, z.ZodTypeDef, TSigner>;
35
- entryPointAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
36
- chain: z.ZodType<import("viem").Chain, z.ZodTypeDef, import("viem").Chain>;
37
- accountAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
38
- initCode: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
39
- entryPointVersion: z.ZodOptional<z.ZodType<keyof import("../entrypoint/types.js").EntryPointRegistryBase<unknown>, z.ZodTypeDef, keyof import("../entrypoint/types.js").EntryPointRegistryBase<unknown>>>;
40
- }>]: z.baseObjectInputType<{
41
- rpcClient: z.ZodUnion<[z.ZodString, z.ZodType<import("../index.js").BundlerClient<TTransport>, z.ZodTypeDef, import("../index.js").BundlerClient<TTransport>>]>;
42
- factoryAddress: z.ZodEffects<z.ZodString, `0x${string}`, string>;
43
- signer: z.ZodType<TSigner, z.ZodTypeDef, TSigner>;
44
- entryPointAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
45
- chain: z.ZodType<import("viem").Chain, z.ZodTypeDef, import("viem").Chain>;
46
- accountAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
47
- initCode: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
48
- entryPointVersion: z.ZodOptional<z.ZodType<keyof import("../entrypoint/types.js").EntryPointRegistryBase<unknown>, z.ZodTypeDef, keyof import("../entrypoint/types.js").EntryPointRegistryBase<unknown>>>;
49
- }>[k_2]; }>;
50
- export declare const SimpleSmartAccountParamsSchema: <TTransport extends Transport = Transport, TSigner extends SmartAccountSigner<any> = SmartAccountSigner<any>>() => z.ZodObject<{
51
- initCode: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
52
- chain: z.ZodType<import("viem").Chain, z.ZodTypeDef, import("viem").Chain>;
53
- factoryAddress: z.ZodEffects<z.ZodString, `0x${string}`, string>;
54
- signer: z.ZodType<TSigner, z.ZodTypeDef, TSigner>;
55
- entryPointAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
56
- accountAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
57
- entryPointVersion: z.ZodOptional<z.ZodType<keyof import("../entrypoint/types.js").EntryPointRegistryBase<unknown>, z.ZodTypeDef, keyof import("../entrypoint/types.js").EntryPointRegistryBase<unknown>>>;
58
- transport: z.ZodType<TTransport, z.ZodTypeDef, TTransport>;
59
- salt: z.ZodOptional<z.ZodBigInt>;
60
- }, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
61
- initCode: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
62
- chain: z.ZodType<import("viem").Chain, z.ZodTypeDef, import("viem").Chain>;
63
- factoryAddress: z.ZodEffects<z.ZodString, `0x${string}`, string>;
64
- signer: z.ZodType<TSigner, z.ZodTypeDef, TSigner>;
65
- entryPointAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
66
- accountAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
67
- entryPointVersion: z.ZodOptional<z.ZodType<keyof import("../entrypoint/types.js").EntryPointRegistryBase<unknown>, z.ZodTypeDef, keyof import("../entrypoint/types.js").EntryPointRegistryBase<unknown>>>;
68
- transport: z.ZodType<TTransport, z.ZodTypeDef, TTransport>;
69
- salt: z.ZodOptional<z.ZodBigInt>;
70
- }>, "chain" | "factoryAddress" | (undefined extends TTransport ? never : "transport") | (undefined extends TSigner ? never : "signer")> extends infer T ? { [k in keyof T]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
71
- initCode: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
72
- chain: z.ZodType<import("viem").Chain, z.ZodTypeDef, import("viem").Chain>;
73
- factoryAddress: z.ZodEffects<z.ZodString, `0x${string}`, string>;
74
- signer: z.ZodType<TSigner, z.ZodTypeDef, TSigner>;
75
- entryPointAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
76
- accountAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
77
- entryPointVersion: z.ZodOptional<z.ZodType<keyof import("../entrypoint/types.js").EntryPointRegistryBase<unknown>, z.ZodTypeDef, keyof import("../entrypoint/types.js").EntryPointRegistryBase<unknown>>>;
78
- transport: z.ZodType<TTransport, z.ZodTypeDef, TTransport>;
79
- salt: z.ZodOptional<z.ZodBigInt>;
80
- }>, "chain" | "factoryAddress" | (undefined extends TTransport ? never : "transport") | (undefined extends TSigner ? never : "signer")>[k]; } : never, z.baseObjectInputType<{
81
- initCode: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
82
- chain: z.ZodType<import("viem").Chain, z.ZodTypeDef, import("viem").Chain>;
83
- factoryAddress: z.ZodEffects<z.ZodString, `0x${string}`, string>;
84
- signer: z.ZodType<TSigner, z.ZodTypeDef, TSigner>;
85
- entryPointAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
86
- accountAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
87
- entryPointVersion: z.ZodOptional<z.ZodType<keyof import("../entrypoint/types.js").EntryPointRegistryBase<unknown>, z.ZodTypeDef, keyof import("../entrypoint/types.js").EntryPointRegistryBase<unknown>>>;
88
- transport: z.ZodType<TTransport, z.ZodTypeDef, TTransport>;
89
- salt: z.ZodOptional<z.ZodBigInt>;
90
- }> extends infer T_1 ? { [k_1 in keyof T_1]: z.baseObjectInputType<{
91
- initCode: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
92
- chain: z.ZodType<import("viem").Chain, z.ZodTypeDef, import("viem").Chain>;
93
- factoryAddress: z.ZodEffects<z.ZodString, `0x${string}`, string>;
94
- signer: z.ZodType<TSigner, z.ZodTypeDef, TSigner>;
95
- entryPointAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
96
- accountAddress: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
97
- entryPointVersion: z.ZodOptional<z.ZodType<keyof import("../entrypoint/types.js").EntryPointRegistryBase<unknown>, z.ZodTypeDef, keyof import("../entrypoint/types.js").EntryPointRegistryBase<unknown>>>;
98
- transport: z.ZodType<TTransport, z.ZodTypeDef, TTransport>;
99
- salt: z.ZodOptional<z.ZodBigInt>;
100
- }>[k_1]; } : never>;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SimpleSmartAccountParamsSchema = exports.createBaseSmartAccountParamsSchema = void 0;
7
- const zod_1 = require("abitype/zod");
8
- const viem_1 = require("viem");
9
- const zod_2 = __importDefault(require("zod"));
10
- const schema_js_1 = require("../client/schema.js");
11
- const index_js_1 = require("../entrypoint/index.js");
12
- const schema_js_2 = require("../signer/schema.js");
13
- const index_js_2 = require("../utils/index.js");
14
- const createBaseSmartAccountParamsSchema = () => zod_2.default.object({
15
- rpcClient: zod_2.default.union([
16
- zod_2.default.string(),
17
- (0, schema_js_1.createPublicErc4337ClientSchema)(),
18
- ]),
19
- factoryAddress: zod_1.Address,
20
- signer: zod_2.default.custom(schema_js_2.isSigner),
21
- entryPointAddress: zod_1.Address.optional(),
22
- chain: index_js_2.ChainSchema,
23
- accountAddress: zod_1.Address.optional().describe("Optional override for the account address."),
24
- initCode: zod_2.default
25
- .string()
26
- .refine((x) => (0, viem_1.isHex)(x, { strict: true }), "initCode must be a valid hex.")
27
- .optional()
28
- .describe("Optional override for the account init code."),
29
- entryPointVersion: zod_2.default
30
- .custom(index_js_1.isEntryPointVersion)
31
- .optional(),
32
- });
33
- exports.createBaseSmartAccountParamsSchema = createBaseSmartAccountParamsSchema;
34
- const SimpleSmartAccountParamsSchema = () => (0, exports.createBaseSmartAccountParamsSchema)()
35
- .omit({
36
- rpcClient: true,
37
- })
38
- .extend({
39
- transport: zod_2.default.custom(),
40
- salt: zod_2.default.bigint().optional(),
41
- });
42
- exports.SimpleSmartAccountParamsSchema = SimpleSmartAccountParamsSchema;
43
- //# sourceMappingURL=schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/account/schema.ts"],"names":[],"mappings":";;;;;;AAAA,qCAAsC;AACtC,+BAA6C;AAC7C,8CAAoB;AACpB,mDAAsE;AACtE,qDAA6D;AAE7D,mDAA+C;AAE/C,gDAAgD;AAEzC,MAAM,kCAAkC,GAAG,GAG9C,EAAE,CACJ,aAAC,CAAC,MAAM,CAAC;IACP,SAAS,EAAE,aAAC,CAAC,KAAK,CAAC;QACjB,aAAC,CAAC,MAAM,EAAE;QACV,IAAA,2CAA+B,GAAc;KAC9C,CAAC;IACF,cAAc,EAAE,aAAO;IACvB,MAAM,EAAE,aAAC,CAAC,MAAM,CAAU,oBAAQ,CAAC;IACnC,iBAAiB,EAAE,aAAO,CAAC,QAAQ,EAAE;IACrC,KAAK,EAAE,sBAAW;IAClB,cAAc,EAAE,aAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,CACzC,4CAA4C,CAC7C;IACD,QAAQ,EAAE,aAAC;SACR,MAAM,EAAE;SACR,MAAM,CACL,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,YAAK,EAAC,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EACjC,+BAA+B,CAChC;SACA,QAAQ,EAAE;SACV,QAAQ,CAAC,8CAA8C,CAAC;IAC3D,iBAAiB,EAAE,aAAC;SACjB,MAAM,CAAoB,8BAAmB,CAAC;SAC9C,QAAQ,EAAE;CACd,CAAC,CAAC;AA3BQ,QAAA,kCAAkC,sCA2B1C;AAEE,MAAM,8BAA8B,GAAG,GAG1C,EAAE,CACJ,IAAA,0CAAkC,GAAuB;KACtD,IAAI,CAAC;IACJ,SAAS,EAAE,IAAI;CAChB,CAAC;KACD,MAAM,CAAC;IACN,SAAS,EAAE,aAAC,CAAC,MAAM,EAAc;IACjC,IAAI,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC5B,CAAC,CAAC;AAXM,QAAA,8BAA8B,kCAWpC","sourcesContent":["import { Address } from \"abitype/zod\";\nimport { isHex, type Transport } from \"viem\";\nimport z from \"zod\";\nimport { createPublicErc4337ClientSchema } from \"../client/schema.js\";\nimport { isEntryPointVersion } from \"../entrypoint/index.js\";\nimport type { EntryPointVersion } from \"../entrypoint/types.js\";\nimport { isSigner } from \"../signer/schema.js\";\nimport type { SmartAccountSigner } from \"../signer/types.js\";\nimport { ChainSchema } from \"../utils/index.js\";\n\nexport const createBaseSmartAccountParamsSchema = <\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>() =>\n z.object({\n rpcClient: z.union([\n z.string(),\n createPublicErc4337ClientSchema<TTransport>(),\n ]),\n factoryAddress: Address,\n signer: z.custom<TSigner>(isSigner),\n entryPointAddress: Address.optional(),\n chain: ChainSchema,\n accountAddress: Address.optional().describe(\n \"Optional override for the account address.\"\n ),\n initCode: z\n .string()\n .refine(\n (x) => isHex(x, { strict: true }),\n \"initCode must be a valid hex.\"\n )\n .optional()\n .describe(\"Optional override for the account init code.\"),\n entryPointVersion: z\n .custom<EntryPointVersion>(isEntryPointVersion)\n .optional(),\n });\n\nexport const SimpleSmartAccountParamsSchema = <\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>() =>\n createBaseSmartAccountParamsSchema<TTransport, TSigner>()\n .omit({\n rpcClient: true,\n })\n .extend({\n transport: z.custom<TTransport>(),\n salt: z.bigint().optional(),\n });\n"]}
@@ -1,14 +0,0 @@
1
- import type { Address } from "abitype";
2
- import { type Chain, type Hex, type Transport } from "viem";
3
- import type { DefaultEntryPointVersion, EntryPointParameter, EntryPointVersion } from "../entrypoint/types.js";
4
- import type { SmartAccountSigner } from "../signer/types.js";
5
- import { type SmartContractAccountWithSigner, type ToSmartContractAccountParams } from "./smartContractAccount.js";
6
- export type SimpleSmartAccount<TSigner extends SmartAccountSigner = SmartAccountSigner, TEntryPointVersion extends EntryPointVersion = EntryPointVersion> = SmartContractAccountWithSigner<"SimpleAccount", TSigner, TEntryPointVersion>;
7
- export type CreateSimpleAccountParams<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner, TEntryPointVersion extends EntryPointVersion = DefaultEntryPointVersion> = Pick<ToSmartContractAccountParams<"SimpleAccount", TTransport, Chain, TEntryPointVersion>, "chain" | "transport"> & {
8
- signer: TSigner;
9
- salt?: bigint;
10
- accountAddress?: Address;
11
- factoryAddress?: Address;
12
- initCode?: Hex;
13
- } & EntryPointParameter<TEntryPointVersion, Chain>;
14
- export declare function createSimpleSmartAccount<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner, TEntryPointVersion extends EntryPointVersion = DefaultEntryPointVersion>(config: CreateSimpleAccountParams<TTransport, TSigner, TEntryPointVersion>): Promise<SimpleSmartAccount<TSigner, TEntryPointVersion>>;
@@ -1,119 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSimpleSmartAccount = void 0;
4
- const viem_1 = require("viem");
5
- const SimpleAccountAbi_v6_js_1 = require("../abis/SimpleAccountAbi_v6.js");
6
- const SimpleAccountAbi_v7_js_1 = require("../abis/SimpleAccountAbi_v7.js");
7
- const SimpleAccountFactoryAbi_js_1 = require("../abis/SimpleAccountFactoryAbi.js");
8
- const bundlerClient_js_1 = require("../client/bundlerClient.js");
9
- const index_js_1 = require("../entrypoint/index.js");
10
- const account_js_1 = require("../errors/account.js");
11
- const defaults_js_1 = require("../utils/defaults.js");
12
- const base_js_1 = require("./base.js");
13
- const schema_js_1 = require("./schema.js");
14
- const smartContractAccount_js_1 = require("./smartContractAccount.js");
15
- class SimpleSmartContractAccount extends base_js_1.BaseSmartContractAccount {
16
- constructor(params) {
17
- (0, schema_js_1.SimpleSmartAccountParamsSchema)().parse(params);
18
- const client = (0, bundlerClient_js_1.createBundlerClient)({
19
- transport: params.transport,
20
- chain: params.chain,
21
- });
22
- super({ ...params, rpcClient: client });
23
- Object.defineProperty(this, "index", {
24
- enumerable: true,
25
- configurable: true,
26
- writable: true,
27
- value: void 0
28
- });
29
- Object.defineProperty(this, "entryPointVersion", {
30
- enumerable: true,
31
- configurable: true,
32
- writable: true,
33
- value: void 0
34
- });
35
- this.signer = params.signer;
36
- this.index = params.salt ?? 0n;
37
- this.entryPointVersion =
38
- params.entryPointVersion ?? index_js_1.defaultEntryPointVersion;
39
- }
40
- getDummySignature() {
41
- return "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
42
- }
43
- async encodeExecute(target, value, data) {
44
- return (0, viem_1.encodeFunctionData)({
45
- abi: this.entryPointVersion === "0.6.0"
46
- ? SimpleAccountAbi_v6_js_1.SimpleAccountAbi_v6
47
- : SimpleAccountAbi_v7_js_1.SimpleAccountAbi_v7,
48
- functionName: "execute",
49
- args: [target, value, data],
50
- });
51
- }
52
- async encodeBatchExecute(txs) {
53
- const [targets, datas] = txs.reduce((accum, curr) => {
54
- accum[0].push(curr.target);
55
- accum[1].push(curr.data);
56
- return accum;
57
- }, [[], []]);
58
- return (0, viem_1.encodeFunctionData)({
59
- abi: this.entryPointVersion === "0.6.0"
60
- ? SimpleAccountAbi_v6_js_1.SimpleAccountAbi_v6
61
- : SimpleAccountAbi_v7_js_1.SimpleAccountAbi_v7,
62
- functionName: "executeBatch",
63
- args: [targets, datas],
64
- });
65
- }
66
- signMessage(msg) {
67
- return this.signer.signMessage(typeof msg === "string" && !(0, viem_1.isHex)(msg) ? msg : { raw: msg });
68
- }
69
- async getAccountInitCode() {
70
- return (0, viem_1.concatHex)([
71
- this.factoryAddress,
72
- (0, viem_1.encodeFunctionData)({
73
- abi: SimpleAccountFactoryAbi_js_1.SimpleAccountFactoryAbi,
74
- functionName: "createAccount",
75
- args: [await this.signer.getAddress(), this.index],
76
- }),
77
- ]);
78
- }
79
- }
80
- async function createSimpleSmartAccount({ chain, entryPoint = (0, index_js_1.getEntryPoint)(chain), factoryAddress = (0, defaults_js_1.getDefaultSimpleAccountFactoryAddress)(chain, entryPoint.version), ...params }) {
81
- if (!params.signer)
82
- throw new account_js_1.AccountRequiresOwnerError("SimpleAccount");
83
- const simpleAccount = new SimpleSmartContractAccount((0, schema_js_1.SimpleSmartAccountParamsSchema)().parse({
84
- chain,
85
- entryPointAddress: entryPoint.address,
86
- factoryAddress,
87
- ...params,
88
- }));
89
- const parsedParams = (0, schema_js_1.SimpleSmartAccountParamsSchema)().parse({
90
- chain,
91
- entryPointAddress: entryPoint.address,
92
- entryPointVersion: entryPoint.version,
93
- factoryAddress,
94
- ...params,
95
- });
96
- const base = await (0, smartContractAccount_js_1.toSmartContractAccount)({
97
- source: "SimpleAccount",
98
- transport: params.transport,
99
- chain,
100
- encodeBatchExecute: simpleAccount.encodeBatchExecute.bind(simpleAccount),
101
- encodeExecute: (tx) => simpleAccount.encodeExecute.bind(simpleAccount)(tx.target, tx.value ?? 0n, tx.data),
102
- entryPoint,
103
- getAccountInitCode: async () => {
104
- if (parsedParams.initCode)
105
- return parsedParams.initCode;
106
- return simpleAccount.getAccountInitCode();
107
- },
108
- getDummySignature: simpleAccount.getDummySignature.bind(simpleAccount),
109
- signMessage: ({ message }) => simpleAccount.signMessage(typeof message === "string" ? message : message.raw),
110
- signTypedData: simpleAccount.signTypedData.bind(simpleAccount),
111
- accountAddress: parsedParams.accountAddress,
112
- });
113
- return {
114
- ...base,
115
- getSigner: () => simpleAccount.getSigner(),
116
- };
117
- }
118
- exports.createSimpleSmartAccount = createSimpleSmartAccount;
119
- //# sourceMappingURL=simple.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"simple.js","sourceRoot":"","sources":["../../../src/account/simple.ts"],"names":[],"mappings":"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","sourcesContent":["import type { Address } from \"abitype\";\nimport {\n concatHex,\n encodeFunctionData,\n isHex,\n type Chain,\n type FallbackTransport,\n type Hex,\n type Transport,\n} from \"viem\";\nimport { SimpleAccountAbi_v6 } from \"../abis/SimpleAccountAbi_v6.js\";\nimport { SimpleAccountAbi_v7 } from \"../abis/SimpleAccountAbi_v7.js\";\nimport { SimpleAccountFactoryAbi } from \"../abis/SimpleAccountFactoryAbi.js\";\nimport { createBundlerClient } from \"../client/bundlerClient.js\";\nimport {\n defaultEntryPointVersion,\n getEntryPoint,\n} from \"../entrypoint/index.js\";\nimport type {\n DefaultEntryPointVersion,\n EntryPointParameter,\n EntryPointVersion,\n} from \"../entrypoint/types.js\";\nimport { AccountRequiresOwnerError } from \"../errors/account.js\";\nimport type { SmartAccountSigner } from \"../signer/types.js\";\nimport type { BatchUserOperationCallData } from \"../types.js\";\nimport { getDefaultSimpleAccountFactoryAddress } from \"../utils/defaults.js\";\nimport { BaseSmartContractAccount } from \"./base.js\";\nimport { SimpleSmartAccountParamsSchema } from \"./schema.js\";\nimport {\n toSmartContractAccount,\n type SmartContractAccountWithSigner,\n type ToSmartContractAccountParams,\n} from \"./smartContractAccount.js\";\nimport type { SimpleSmartAccountParams } from \"./types.js\";\n\nclass SimpleSmartContractAccount<\n TTransport extends Transport | FallbackTransport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> extends BaseSmartContractAccount<TTransport, TSigner> {\n protected index: bigint;\n protected entryPointVersion: EntryPointVersion;\n\n constructor(params: SimpleSmartAccountParams<TTransport, TSigner>) {\n SimpleSmartAccountParamsSchema().parse(params);\n\n // This is a hack for now, we should kill the SimpleSmart Account when we kill Base Account\n const client = createBundlerClient({\n transport: params.transport as TTransport,\n chain: params.chain,\n });\n\n // @ts-expect-error zod custom type not recognized as required params for signers\n super({ ...params, rpcClient: client });\n this.signer = params.signer as TSigner;\n this.index = params.salt ?? 0n;\n this.entryPointVersion =\n params.entryPointVersion ?? defaultEntryPointVersion;\n }\n\n getDummySignature(): `0x${string}` {\n return \"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\";\n }\n\n async encodeExecute(\n target: Hex,\n value: bigint,\n data: Hex\n ): Promise<`0x${string}`> {\n return encodeFunctionData({\n abi:\n this.entryPointVersion === \"0.6.0\"\n ? SimpleAccountAbi_v6\n : SimpleAccountAbi_v7,\n functionName: \"execute\",\n args: [target, value, data],\n });\n }\n\n override async encodeBatchExecute(\n txs: BatchUserOperationCallData\n ): Promise<`0x${string}`> {\n const [targets, datas] = txs.reduce(\n (accum, curr) => {\n accum[0].push(curr.target);\n accum[1].push(curr.data);\n\n return accum;\n },\n [[], []] as [Address[], Hex[]]\n );\n\n return encodeFunctionData({\n abi:\n this.entryPointVersion === \"0.6.0\"\n ? SimpleAccountAbi_v6\n : SimpleAccountAbi_v7,\n functionName: \"executeBatch\",\n args: [targets, datas],\n });\n }\n\n signMessage(msg: Uint8Array | string): Promise<`0x${string}`> {\n return this.signer.signMessage(\n typeof msg === \"string\" && !isHex(msg) ? msg : { raw: msg }\n );\n }\n\n public async getAccountInitCode(): Promise<`0x${string}`> {\n return concatHex([\n this.factoryAddress,\n encodeFunctionData({\n abi: SimpleAccountFactoryAbi,\n functionName: \"createAccount\",\n args: [await this.signer.getAddress(), this.index],\n }),\n ]);\n }\n}\n\nexport type SimpleSmartAccount<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = SmartContractAccountWithSigner<\n \"SimpleAccount\",\n TSigner,\n TEntryPointVersion\n>;\n\nexport type CreateSimpleAccountParams<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TEntryPointVersion extends EntryPointVersion = DefaultEntryPointVersion\n> = Pick<\n ToSmartContractAccountParams<\n \"SimpleAccount\",\n TTransport,\n Chain,\n TEntryPointVersion\n >,\n \"chain\" | \"transport\"\n> & {\n signer: TSigner;\n salt?: bigint;\n accountAddress?: Address;\n factoryAddress?: Address;\n initCode?: Hex;\n} & EntryPointParameter<TEntryPointVersion, Chain>;\n\nexport async function createSimpleSmartAccount<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TEntryPointVersion extends EntryPointVersion = DefaultEntryPointVersion\n>(\n config: CreateSimpleAccountParams<TTransport, TSigner, TEntryPointVersion>\n): Promise<SimpleSmartAccount<TSigner, TEntryPointVersion>>;\n\n/**\n * Creates a simple smart account using the provided parameters, including chain, entry point, factory address, and additional parameters. This function also ensures that a signer is provided.\n *\n * @param {CreateSimpleAccountParams} config The parameters for creating a simple smart account\n * @returns {Promise<SimpleSmartAccount>} A promise that resolves to a `SimpleSmartAccount` object containing the created account information and methods\n */\nexport async function createSimpleSmartAccount({\n chain,\n entryPoint = getEntryPoint(chain),\n factoryAddress = getDefaultSimpleAccountFactoryAddress(\n chain,\n entryPoint.version\n ),\n ...params\n}: CreateSimpleAccountParams): Promise<SimpleSmartAccount> {\n if (!params.signer) throw new AccountRequiresOwnerError(\"SimpleAccount\");\n const simpleAccount = new SimpleSmartContractAccount(\n SimpleSmartAccountParamsSchema().parse({\n chain,\n entryPointAddress: entryPoint.address,\n factoryAddress,\n ...params,\n })\n );\n\n const parsedParams = SimpleSmartAccountParamsSchema().parse({\n chain,\n entryPointAddress: entryPoint.address,\n entryPointVersion: entryPoint.version,\n factoryAddress,\n ...params,\n });\n\n const base = await toSmartContractAccount({\n source: \"SimpleAccount\",\n transport: params.transport,\n chain,\n encodeBatchExecute: simpleAccount.encodeBatchExecute.bind(simpleAccount),\n encodeExecute: (tx) =>\n simpleAccount.encodeExecute.bind(simpleAccount)(\n tx.target,\n tx.value ?? 0n,\n tx.data\n ),\n entryPoint,\n getAccountInitCode: async () => {\n if (parsedParams.initCode) return parsedParams.initCode as Hex;\n return simpleAccount.getAccountInitCode();\n },\n getDummySignature: simpleAccount.getDummySignature.bind(simpleAccount),\n signMessage: ({ message }) =>\n simpleAccount.signMessage(\n typeof message === \"string\" ? message : message.raw\n ),\n // @ts-expect-error these types still represent the same thing, but they are just a little off in there definitions\n signTypedData: simpleAccount.signTypedData.bind(simpleAccount),\n accountAddress: parsedParams.accountAddress,\n });\n\n return {\n ...base,\n getSigner: () => simpleAccount.getSigner(),\n };\n}\n"]}
@@ -1,30 +0,0 @@
1
- import type { Address } from "abitype";
2
- import type { Hash, Hex, HttpTransport, Transport } from "viem";
3
- import type { SignTypedDataParameters } from "viem/accounts";
4
- import type { z } from "zod";
5
- import type { BundlerClient } from "../client/bundlerClient";
6
- import type { SmartAccountSigner } from "../signer/types";
7
- import type { BatchUserOperationCallData } from "../types";
8
- import type { SimpleSmartAccountParamsSchema, createBaseSmartAccountParamsSchema } from "./schema";
9
- export type SignTypedDataParams = Omit<SignTypedDataParameters, "privateKey">;
10
- export type BaseSmartAccountParams<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner> = z.input<ReturnType<typeof createBaseSmartAccountParamsSchema<TTransport, TSigner>>>;
11
- export type SimpleSmartAccountParams<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner> = z.input<ReturnType<typeof SimpleSmartAccountParamsSchema<TTransport, TSigner>>>;
12
- export interface ISmartContractAccount<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner> {
13
- readonly rpcProvider: BundlerClient<TTransport> | BundlerClient<HttpTransport>;
14
- getInitCode(): Promise<Hex>;
15
- getDummySignature(): Hex | Promise<Hex>;
16
- encodeExecute(target: string, value: bigint, data: string): Promise<Hex>;
17
- encodeBatchExecute(txs: BatchUserOperationCallData): Promise<Hex>;
18
- getNonce(): Promise<bigint>;
19
- signUserOperationHash(uoHash: Hash): Promise<Hash>;
20
- signMessage(msg: string | Uint8Array | Hex): Promise<Hex>;
21
- signTypedData(params: SignTypedDataParams): Promise<Hash>;
22
- signMessageWith6492(msg: string | Uint8Array | Hex): Promise<Hex>;
23
- signTypedDataWith6492(params: SignTypedDataParams): Promise<Hash>;
24
- getAddress(): Promise<Address>;
25
- getSigner(): TSigner;
26
- getFactoryAddress(): Address;
27
- getEntryPointAddress(): Address;
28
- extend: <R>(extendFn: (self: this) => R) => this & R;
29
- encodeUpgradeToAndCall: (upgradeToImplAddress: Address, upgradeToInitData: Hex) => Promise<Hex>;
30
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/account/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Address } from \"abitype\";\nimport type { Hash, Hex, HttpTransport, Transport } from \"viem\";\nimport type { SignTypedDataParameters } from \"viem/accounts\";\nimport type { z } from \"zod\";\nimport type { BundlerClient } from \"../client/bundlerClient\";\nimport type { SmartAccountSigner } from \"../signer/types\";\nimport type { BatchUserOperationCallData } from \"../types\";\nimport type {\n SimpleSmartAccountParamsSchema,\n createBaseSmartAccountParamsSchema,\n} from \"./schema\";\n\n/** @deprecated */\nexport type SignTypedDataParams = Omit<SignTypedDataParameters, \"privateKey\">;\n\n/**\n * @deprecated don't use base smart account anymore, migrate to using toSmartContractAccount instead\n */\nexport type BaseSmartAccountParams<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = z.input<\n ReturnType<typeof createBaseSmartAccountParamsSchema<TTransport, TSigner>>\n>;\n\nexport type SimpleSmartAccountParams<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = z.input<\n ReturnType<typeof SimpleSmartAccountParamsSchema<TTransport, TSigner>>\n>;\n\n/**\n * @deprecated use `toSmartContractAccount` instead for creating instances of smart accounts\n */\nexport interface ISmartContractAccount<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> {\n /**\n * The RPC provider the account uses to make RPC calls\n */\n readonly rpcProvider:\n | BundlerClient<TTransport>\n | BundlerClient<HttpTransport>;\n\n /**\n * @returns the init code for the account\n */\n getInitCode(): Promise<Hex>;\n\n /**\n * This is useful for estimating gas costs. It should return a signature that doesn't cause the account to revert\n * when validation is run during estimation.\n *\n * @returns a dummy signature that doesn't cause the account to revert during estimation\n */\n getDummySignature(): Hex | Promise<Hex>;\n\n /**\n * Encodes a call to the account's execute function.\n *\n * @param target - the address receiving the call data\n * @param value - optionally the amount of native token to send\n * @param data - the call data or \"0x\" if empty\n */\n encodeExecute(target: string, value: bigint, data: string): Promise<Hex>;\n\n /**\n * Encodes a batch of transactions to the account's batch execute function.\n * NOTE: not all accounts support batching.\n *\n * @param txs - An Array of objects containing the target, value, and data for each transaction\n * @returns the encoded callData for a UserOperation\n */\n encodeBatchExecute(txs: BatchUserOperationCallData): Promise<Hex>;\n\n /**\n * @returns the nonce of the account\n */\n getNonce(): Promise<bigint>;\n\n /**\n * If your account handles 1271 signatures of personal_sign differently\n * than it does UserOperations, you can implement two different approaches to signing\n *\n * @param uoHash -- The hash of the UserOperation to sign\n * @returns the signature of the UserOperation\n */\n signUserOperationHash(uoHash: Hash): Promise<Hash>;\n\n /**\n * Returns a signed and prefixed message.\n *\n * @param msg - the message to sign\n * @returns the signature of the message\n */\n signMessage(msg: string | Uint8Array | Hex): Promise<Hex>;\n\n /**\n * Signs a typed data object as per ERC-712\n *\n * @param params - {@link SignTypedDataParams}\n * @returns the signed hash for the message passed\n */\n signTypedData(params: SignTypedDataParams): Promise<Hash>;\n\n /**\n * If the account is not deployed, it will sign the message and then wrap it in 6492 format\n *\n * @param msg - the message to sign\n * @returns ths signature wrapped in 6492 format\n */\n signMessageWith6492(msg: string | Uint8Array | Hex): Promise<Hex>;\n\n /**\n * If the account is not deployed, it will sign the typed data blob and then wrap it in 6492 format\n *\n * @param params - {@link SignTypedDataParams}\n * @returns the signed hash for the params passed in wrapped in 6492 format\n */\n signTypedDataWith6492(params: SignTypedDataParams): Promise<Hash>;\n\n /**\n * @returns the address of the account\n */\n getAddress(): Promise<Address>;\n\n /**\n * @returns the current account signer instance that the smart account client\n * operations are being signed with.\n *\n * The signer is expected to be the owner or one of the owners of the account\n * for the signatures to be valid for the acting account.\n */\n getSigner(): TSigner;\n\n /**\n * The factory address of the smart account created by the factory\n *\n * @returns the address of the factory contract for the smart account\n */\n getFactoryAddress(): Address;\n\n /**\n * The entrypoint address is the address ERC 4337 entrypoint singleton contract\n * that this smart account and the connected bundler client use\n *\n * @returns the address of the entry point contract for the smart account\n */\n getEntryPointAddress(): Address;\n\n /**\n * Allows you to add additional functionality and utility methods to this account\n * via a decorator pattern.\n *\n * NOTE: this method does not allow you to override existing methods on the account.\n *\n * @example\n * ```ts\n * const account = new BaseSmartCobntractAccount(...).extend((account) => ({\n * readAccountState: async (...args) => {\n * return this.rpcProvider.readContract({\n * address: await this.getAddress(),\n * abi: ThisContractsAbi\n * args: args\n * });\n * }\n * }));\n *\n * account.debugSendUserOperation(...);\n * ```\n *\n * @param extendFn -- this function gives you access to the created account instance and returns an object\n * with the extension methods\n * @returns -- the account with the extension methods added\n */\n extend: <R>(extendFn: (self: this) => R) => this & R;\n\n encodeUpgradeToAndCall: (\n upgradeToImplAddress: Address,\n upgradeToInitData: Hex\n ) => Promise<Hex>;\n}\n"]}
@@ -1,49 +0,0 @@
1
- import type { Address } from "abitype";
2
- import { type GetContractReturnType, type Hash, type Hex, type HttpTransport, type PublicClient, type Transport } from "viem";
3
- import { EntryPointAbi_v6 as EntryPointAbi } from "../abis/EntryPointAbi_v6.js";
4
- import { type BundlerClient } from "../client/bundlerClient.js";
5
- import type { SmartAccountSigner } from "../signer/types.js";
6
- import type { BatchUserOperationCallData, NullAddress } from "../types.js";
7
- import type { BaseSmartAccountParams, ISmartContractAccount, SignTypedDataParams } from "./types.js";
8
- export declare enum DeploymentState {
9
- UNDEFINED = "0x0",
10
- NOT_DEPLOYED = "0x1",
11
- DEPLOYED = "0x2"
12
- }
13
- export declare abstract class BaseSmartContractAccount<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner> implements ISmartContractAccount<TTransport, TSigner> {
14
- protected factoryAddress: Address;
15
- protected deploymentState: DeploymentState;
16
- protected accountAddress?: Address;
17
- protected accountInitCode?: Hex;
18
- protected signer: TSigner;
19
- protected entryPoint: GetContractReturnType<typeof EntryPointAbi, PublicClient>;
20
- protected entryPointAddress: Address;
21
- readonly rpcProvider: BundlerClient<TTransport> | BundlerClient<HttpTransport>;
22
- constructor(params_: BaseSmartAccountParams<TTransport, TSigner>);
23
- abstract getDummySignature(): Hex | Promise<Hex>;
24
- abstract encodeExecute(target: string, value: bigint, data: string): Promise<Hash>;
25
- abstract signMessage(msg: string | Uint8Array): Promise<Hash>;
26
- protected abstract getAccountInitCode(): Promise<Hash>;
27
- signUserOperationHash(uoHash: Hash): Promise<Hash>;
28
- signTypedData(_params: SignTypedDataParams): Promise<`0x${string}`>;
29
- signMessageWith6492(msg: string | Uint8Array): Promise<`0x${string}`>;
30
- signTypedDataWith6492(params: SignTypedDataParams): Promise<`0x${string}`>;
31
- encodeBatchExecute(_txs: BatchUserOperationCallData): Promise<`0x${string}`>;
32
- encodeUpgradeToAndCall: (_upgradeToImplAddress: Address, _upgradeToInitData: Hex) => Promise<Hex>;
33
- getNonce(): Promise<bigint>;
34
- getInitCode(): Promise<Hex>;
35
- getAddress(): Promise<Address>;
36
- extend: <R>(fn: (self: this) => R) => this & R;
37
- getSigner(): TSigner;
38
- getFactoryAddress(): Address;
39
- getEntryPointAddress(): Address;
40
- isAccountDeployed(): Promise<boolean>;
41
- getDeploymentState(): Promise<DeploymentState>;
42
- protected parseFactoryAddressFromAccountInitCode(): Promise<[
43
- Address,
44
- Hex
45
- ]>;
46
- protected getImplementationAddress(): Promise<NullAddress | Address>;
47
- private _getAccountInitCode;
48
- private create6492Signature;
49
- }