@aa-sdk/core 4.0.0-alpha.1 → 4.0.0-alpha.10

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 (263) 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/ens/utils.d.ts +1 -1
  18. package/dist/cjs/ens/utils.js +3 -3
  19. package/dist/cjs/ens/utils.js.map +1 -1
  20. package/dist/cjs/errors/account.js.map +1 -1
  21. package/dist/cjs/errors/client.js.map +1 -1
  22. package/dist/cjs/errors/entrypoint.js.map +1 -1
  23. package/dist/cjs/errors/signer.js.map +1 -1
  24. package/dist/cjs/errors/transaction.js.map +1 -1
  25. package/dist/cjs/errors/useroperation.js.map +1 -1
  26. package/dist/cjs/index.d.ts +3 -6
  27. package/dist/cjs/index.js +38 -64
  28. package/dist/cjs/index.js.map +1 -1
  29. package/dist/cjs/logger.js.map +1 -1
  30. package/dist/cjs/middleware/actions.js +2 -18
  31. package/dist/cjs/middleware/actions.js.map +1 -1
  32. package/dist/cjs/middleware/defaults/gasEstimator.js +4 -2
  33. package/dist/cjs/middleware/defaults/gasEstimator.js.map +1 -1
  34. package/dist/cjs/middleware/erc7677middleware.d.ts +40 -0
  35. package/dist/cjs/middleware/erc7677middleware.js +77 -0
  36. package/dist/cjs/middleware/erc7677middleware.js.map +1 -0
  37. package/dist/cjs/middleware/noopMiddleware.d.ts +2 -1
  38. package/dist/cjs/middleware/noopMiddleware.js.map +1 -1
  39. package/dist/cjs/middleware/types.d.ts +3 -2
  40. package/dist/cjs/middleware/types.js.map +1 -1
  41. package/dist/cjs/signer/local-account.d.ts +44 -44
  42. package/dist/cjs/signer/local-account.js.map +1 -1
  43. package/dist/cjs/signer/wallet-client.d.ts +44 -44
  44. package/dist/cjs/signer/wallet-client.js.map +1 -1
  45. package/dist/cjs/transport/split.js.map +1 -1
  46. package/dist/cjs/utils/bigint.js.map +1 -1
  47. package/dist/cjs/utils/bytes.js.map +1 -1
  48. package/dist/cjs/utils/defaults.d.ts +2 -4
  49. package/dist/cjs/utils/defaults.js +5 -45
  50. package/dist/cjs/utils/defaults.js.map +1 -1
  51. package/dist/cjs/utils/index.d.ts +0 -3
  52. package/dist/cjs/utils/index.js +1 -25
  53. package/dist/cjs/utils/index.js.map +1 -1
  54. package/dist/cjs/utils/types.js.map +1 -1
  55. package/dist/cjs/utils/userop.js.map +1 -1
  56. package/dist/cjs/version.d.ts +1 -1
  57. package/dist/cjs/version.js +1 -1
  58. package/dist/cjs/version.js.map +1 -1
  59. package/dist/esm/account/smartContractAccount.d.ts +9 -3
  60. package/dist/esm/account/smartContractAccount.js +6 -1
  61. package/dist/esm/account/smartContractAccount.js.map +1 -1
  62. package/dist/esm/actions/smartAccount/buildUserOperationFromTx.js.map +1 -1
  63. package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.js.map +1 -1
  64. package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
  65. package/dist/esm/actions/smartAccount/estimateUserOperationGas.js.map +1 -1
  66. package/dist/esm/actions/smartAccount/internal/initUserOperation.js.map +1 -1
  67. package/dist/esm/actions/smartAccount/internal/runMiddlewareStack.js.map +1 -1
  68. package/dist/esm/actions/smartAccount/internal/sendUserOperation.js.map +1 -1
  69. package/dist/esm/actions/smartAccount/sendUserOperation.js.map +1 -1
  70. package/dist/esm/client/bundlerClient.js.map +1 -1
  71. package/dist/esm/client/decorators/bundlerClient.js.map +1 -1
  72. package/dist/esm/client/isSmartAccountClient.js.map +1 -1
  73. package/dist/esm/client/types.d.ts +2 -7
  74. package/dist/esm/client/types.js.map +1 -1
  75. package/dist/esm/ens/utils.d.ts +1 -1
  76. package/dist/esm/ens/utils.js +1 -1
  77. package/dist/esm/ens/utils.js.map +1 -1
  78. package/dist/esm/errors/account.js.map +1 -1
  79. package/dist/esm/errors/client.js.map +1 -1
  80. package/dist/esm/errors/entrypoint.js.map +1 -1
  81. package/dist/esm/errors/signer.js.map +1 -1
  82. package/dist/esm/errors/transaction.js.map +1 -1
  83. package/dist/esm/errors/useroperation.js.map +1 -1
  84. package/dist/esm/index.d.ts +3 -6
  85. package/dist/esm/index.js +2 -4
  86. package/dist/esm/index.js.map +1 -1
  87. package/dist/esm/logger.js.map +1 -1
  88. package/dist/esm/middleware/actions.js +3 -18
  89. package/dist/esm/middleware/actions.js.map +1 -1
  90. package/dist/esm/middleware/defaults/gasEstimator.js +4 -2
  91. package/dist/esm/middleware/defaults/gasEstimator.js.map +1 -1
  92. package/dist/esm/middleware/erc7677middleware.d.ts +40 -0
  93. package/dist/esm/middleware/erc7677middleware.js +73 -0
  94. package/dist/esm/middleware/erc7677middleware.js.map +1 -0
  95. package/dist/esm/middleware/noopMiddleware.d.ts +2 -1
  96. package/dist/esm/middleware/noopMiddleware.js.map +1 -1
  97. package/dist/esm/middleware/types.d.ts +3 -2
  98. package/dist/esm/middleware/types.js.map +1 -1
  99. package/dist/esm/signer/local-account.d.ts +44 -44
  100. package/dist/esm/signer/local-account.js.map +1 -1
  101. package/dist/esm/signer/wallet-client.d.ts +44 -44
  102. package/dist/esm/signer/wallet-client.js.map +1 -1
  103. package/dist/esm/transport/split.js.map +1 -1
  104. package/dist/esm/utils/bigint.js.map +1 -1
  105. package/dist/esm/utils/bytes.js.map +1 -1
  106. package/dist/esm/utils/defaults.d.ts +2 -4
  107. package/dist/esm/utils/defaults.js +1 -40
  108. package/dist/esm/utils/defaults.js.map +1 -1
  109. package/dist/esm/utils/index.d.ts +0 -3
  110. package/dist/esm/utils/index.js +0 -11
  111. package/dist/esm/utils/index.js.map +1 -1
  112. package/dist/esm/utils/types.js.map +1 -1
  113. package/dist/esm/utils/userop.js.map +1 -1
  114. package/dist/esm/version.d.ts +1 -1
  115. package/dist/esm/version.js +1 -1
  116. package/dist/esm/version.js.map +1 -1
  117. package/dist/types/account/smartContractAccount.d.ts +17 -11
  118. package/dist/types/account/smartContractAccount.d.ts.map +1 -1
  119. package/dist/types/actions/smartAccount/buildUserOperationFromTx.d.ts +33 -33
  120. package/dist/types/actions/smartAccount/buildUserOperationFromTxs.d.ts +43 -59
  121. package/dist/types/actions/smartAccount/buildUserOperationFromTxs.d.ts.map +1 -1
  122. package/dist/types/actions/smartAccount/checkGasSponsorshipEligibility.d.ts +18 -18
  123. package/dist/types/actions/smartAccount/estimateUserOperationGas.d.ts +3 -3
  124. package/dist/types/actions/smartAccount/internal/initUserOperation.d.ts +3 -4
  125. package/dist/types/actions/smartAccount/internal/initUserOperation.d.ts.map +1 -1
  126. package/dist/types/actions/smartAccount/internal/runMiddlewareStack.d.ts +0 -14
  127. package/dist/types/actions/smartAccount/internal/runMiddlewareStack.d.ts.map +1 -1
  128. package/dist/types/actions/smartAccount/internal/sendUserOperation.d.ts +0 -7
  129. package/dist/types/actions/smartAccount/internal/sendUserOperation.d.ts.map +1 -1
  130. package/dist/types/actions/smartAccount/sendUserOperation.d.ts +17 -3
  131. package/dist/types/actions/smartAccount/sendUserOperation.d.ts.map +1 -1
  132. package/dist/types/client/bundlerClient.d.ts +2 -2
  133. package/dist/types/client/decorators/bundlerClient.d.ts +8 -8
  134. package/dist/types/client/isSmartAccountClient.d.ts +4 -4
  135. package/dist/types/client/types.d.ts +2 -7
  136. package/dist/types/client/types.d.ts.map +1 -1
  137. package/dist/types/ens/utils.d.ts +1 -1
  138. package/dist/types/ens/utils.d.ts.map +1 -1
  139. package/dist/types/errors/account.d.ts +53 -4
  140. package/dist/types/errors/account.d.ts.map +1 -1
  141. package/dist/types/errors/client.d.ts +15 -0
  142. package/dist/types/errors/client.d.ts.map +1 -1
  143. package/dist/types/errors/entrypoint.d.ts +12 -0
  144. package/dist/types/errors/entrypoint.d.ts.map +1 -1
  145. package/dist/types/errors/signer.d.ts +5 -0
  146. package/dist/types/errors/signer.d.ts.map +1 -1
  147. package/dist/types/errors/transaction.d.ts +8 -1
  148. package/dist/types/errors/transaction.d.ts.map +1 -1
  149. package/dist/types/errors/useroperation.d.ts +5 -5
  150. package/dist/types/errors/useroperation.d.ts.map +1 -1
  151. package/dist/types/index.d.ts +3 -6
  152. package/dist/types/index.d.ts.map +1 -1
  153. package/dist/types/logger.d.ts +88 -0
  154. package/dist/types/logger.d.ts.map +1 -1
  155. package/dist/types/middleware/actions.d.ts +3 -3
  156. package/dist/types/middleware/actions.d.ts.map +1 -1
  157. package/dist/types/middleware/defaults/gasEstimator.d.ts +2 -2
  158. package/dist/types/middleware/defaults/gasEstimator.d.ts.map +1 -1
  159. package/dist/types/middleware/erc7677middleware.d.ts +62 -0
  160. package/dist/types/middleware/erc7677middleware.d.ts.map +1 -0
  161. package/dist/types/middleware/noopMiddleware.d.ts +4 -4
  162. package/dist/types/middleware/noopMiddleware.d.ts.map +1 -1
  163. package/dist/types/middleware/types.d.ts +3 -2
  164. package/dist/types/middleware/types.d.ts.map +1 -1
  165. package/dist/types/signer/local-account.d.ts +137 -45
  166. package/dist/types/signer/local-account.d.ts.map +1 -1
  167. package/dist/types/signer/wallet-client.d.ts +133 -44
  168. package/dist/types/signer/wallet-client.d.ts.map +1 -1
  169. package/dist/types/transport/split.d.ts +2 -2
  170. package/dist/types/utils/bigint.d.ts +14 -14
  171. package/dist/types/utils/bigint.d.ts.map +1 -1
  172. package/dist/types/utils/bytes.d.ts +5 -5
  173. package/dist/types/utils/defaults.d.ts +2 -12
  174. package/dist/types/utils/defaults.d.ts.map +1 -1
  175. package/dist/types/utils/index.d.ts +12 -22
  176. package/dist/types/utils/index.d.ts.map +1 -1
  177. package/dist/types/utils/types.d.ts +2 -2
  178. package/dist/types/utils/userop.d.ts +33 -33
  179. package/dist/types/version.d.ts +1 -1
  180. package/dist/types/version.d.ts.map +1 -1
  181. package/package.json +4 -3
  182. package/src/account/smartContractAccount.ts +19 -13
  183. package/src/actions/smartAccount/buildUserOperationFromTx.ts +35 -35
  184. package/src/actions/smartAccount/buildUserOperationFromTxs.ts +44 -60
  185. package/src/actions/smartAccount/checkGasSponsorshipEligibility.ts +19 -19
  186. package/src/actions/smartAccount/estimateUserOperationGas.ts +3 -3
  187. package/src/actions/smartAccount/internal/initUserOperation.ts +3 -4
  188. package/src/actions/smartAccount/internal/runMiddlewareStack.ts +0 -22
  189. package/src/actions/smartAccount/internal/sendUserOperation.ts +0 -7
  190. package/src/actions/smartAccount/sendUserOperation.ts +17 -3
  191. package/src/client/bundlerClient.ts +2 -2
  192. package/src/client/decorators/bundlerClient.ts +8 -8
  193. package/src/client/isSmartAccountClient.ts +4 -4
  194. package/src/client/types.ts +2 -15
  195. package/src/ens/utils.ts +1 -2
  196. package/src/errors/account.ts +64 -4
  197. package/src/errors/client.ts +18 -0
  198. package/src/errors/entrypoint.ts +12 -0
  199. package/src/errors/signer.ts +6 -0
  200. package/src/errors/transaction.ts +10 -1
  201. package/src/errors/useroperation.ts +5 -6
  202. package/src/index.ts +2 -31
  203. package/src/logger.ts +88 -0
  204. package/src/middleware/actions.ts +6 -27
  205. package/src/middleware/defaults/gasEstimator.ts +9 -5
  206. package/src/middleware/erc7677middleware.ts +201 -0
  207. package/src/middleware/noopMiddleware.ts +6 -4
  208. package/src/middleware/types.ts +16 -7
  209. package/src/signer/local-account.ts +94 -2
  210. package/src/signer/wallet-client.ts +89 -0
  211. package/src/transport/split.ts +2 -2
  212. package/src/utils/bigint.ts +15 -15
  213. package/src/utils/bytes.ts +5 -5
  214. package/src/utils/defaults.ts +3 -76
  215. package/src/utils/index.ts +12 -35
  216. package/src/utils/types.ts +2 -2
  217. package/src/utils/userop.ts +33 -33
  218. package/src/version.ts +1 -1
  219. package/dist/cjs/account/base.d.ts +0 -49
  220. package/dist/cjs/account/base.js +0 -257
  221. package/dist/cjs/account/base.js.map +0 -1
  222. package/dist/cjs/account/schema.d.ts +0 -100
  223. package/dist/cjs/account/schema.js +0 -43
  224. package/dist/cjs/account/schema.js.map +0 -1
  225. package/dist/cjs/account/simple.d.ts +0 -14
  226. package/dist/cjs/account/simple.js +0 -119
  227. package/dist/cjs/account/simple.js.map +0 -1
  228. package/dist/cjs/account/types.d.ts +0 -30
  229. package/dist/cjs/account/types.js +0 -3
  230. package/dist/cjs/account/types.js.map +0 -1
  231. package/dist/cjs/chains/index.d.ts +0 -20
  232. package/dist/cjs/chains/index.js +0 -169
  233. package/dist/cjs/chains/index.js.map +0 -1
  234. package/dist/esm/account/base.d.ts +0 -49
  235. package/dist/esm/account/base.js +0 -253
  236. package/dist/esm/account/base.js.map +0 -1
  237. package/dist/esm/account/schema.d.ts +0 -100
  238. package/dist/esm/account/schema.js +0 -35
  239. package/dist/esm/account/schema.js.map +0 -1
  240. package/dist/esm/account/simple.d.ts +0 -14
  241. package/dist/esm/account/simple.js +0 -115
  242. package/dist/esm/account/simple.js.map +0 -1
  243. package/dist/esm/account/types.d.ts +0 -30
  244. package/dist/esm/account/types.js +0 -2
  245. package/dist/esm/account/types.js.map +0 -1
  246. package/dist/esm/chains/index.d.ts +0 -20
  247. package/dist/esm/chains/index.js +0 -166
  248. package/dist/esm/chains/index.js.map +0 -1
  249. package/dist/types/account/base.d.ts +0 -128
  250. package/dist/types/account/base.d.ts.map +0 -1
  251. package/dist/types/account/schema.d.ts +0 -101
  252. package/dist/types/account/schema.d.ts.map +0 -1
  253. package/dist/types/account/simple.d.ts +0 -15
  254. package/dist/types/account/simple.d.ts.map +0 -1
  255. package/dist/types/account/types.d.ts +0 -144
  256. package/dist/types/account/types.d.ts.map +0 -1
  257. package/dist/types/chains/index.d.ts +0 -21
  258. package/dist/types/chains/index.d.ts.map +0 -1
  259. package/src/account/base.ts +0 -415
  260. package/src/account/schema.ts +0 -51
  261. package/src/account/simple.ts +0 -221
  262. package/src/account/types.ts +0 -184
  263. package/src/chains/index.ts +0 -194
@@ -17,74 +17,58 @@ import type {
17
17
  } from "./types";
18
18
 
19
19
  /**
20
- * Performs {@link buildUserOperationFromTx} in batch and builds into a single,
20
+ * Performs `buildUserOperationFromTx` in batch and builds into a single,
21
21
  * yet to be signed `UserOperation` (UO) struct. The output user operation struct
22
22
  * will be filled with all gas fields (and paymaster data if a paymaster is used)
23
23
  * based on the transactions data (`to`, `data`, `value`, `maxFeePerGas`,
24
- * `maxPriorityFeePerGas`) computed using the configured
25
- * [`ClientMiddlewares`](/packages/aa-core/smart-account-client/middleware/index) on the `SmartAccountClient`
26
- *
24
+ * `maxPriorityFeePerGas`) computed using the configured ClientMiddlewares on the SmartAccountClient.
25
+ *
27
26
  * @example
28
27
  * ```ts
29
28
  * import type { RpcTransactionRequest } from "viem";
30
- import { smartAccountClient } from "./smartAccountClient";
31
- // [!code focus:99]
32
- // buildUserOperationFromTxs converts traditional Ethereum transactions in batch and returns
33
- // the unsigned user operation struct after constructing the user operation struct
34
- // through the middleware pipeline
35
- const requests: RpcTransactionRequest[] = [
36
- {
37
- from, // ignored
38
- to,
39
- data: encodeFunctionData({
40
- abi: ContractABI.abi,
41
- functionName: "func",
42
- args: [arg1, arg2, ...],
43
- }),
44
- },
45
- {
46
- from, // ignored
47
- to,
48
- data: encodeFunctionData({
49
- abi: ContractABI.abi,
50
- functionName: "func",
51
- args: [arg1, arg2, ...],
52
- }),
53
- },
54
- ...
55
- {
56
- from, // ignored
57
- to,
58
- data: encodeFunctionData({
59
- abi: ContractABI.abi,
60
- functionName: "func",
61
- args: [arg1, arg2, ...],
62
- }),
63
- },
64
- ];
65
- const uoStruct = await smartAccountClient.buildUserOperationFromTxs({
66
- requests,
67
- });
68
-
69
- // signUserOperation signs the above unsigned user operation struct built
70
- // using the account connected to the smart account client
71
- const request = await smartAccountClient.signUserOperation({ uoStruct });
72
-
73
- // You can use the BundlerAction `sendRawUserOperation` (packages/core/src/actions/bundler/sendRawUserOperation.ts)
74
- // to send the signed user operation request to the bundler, requesting the bundler to send the signed uo to the
75
- // EntryPoint contract pointed at by the entryPoint address parameter
76
- const entryPointAddress = client.account.getEntryPoint().address;
77
- const uoHash = await smartAccountClient.sendRawUserOperation({
78
- request,
79
- entryPoint: entryPointAddress,
80
- });
29
+ * import { smartAccountClient } from "./smartAccountClient";
30
+ *
31
+ * const requests: RpcTransactionRequest[] = [
32
+ * {
33
+ * from, // ignored
34
+ * to,
35
+ * data: encodeFunctionData({
36
+ * abi: ContractABI.abi,
37
+ * functionName: "func",
38
+ * args: [arg1, arg2, ...],
39
+ * }),
40
+ * },
41
+ * {
42
+ * from, // ignored
43
+ * to,
44
+ * data: encodeFunctionData({
45
+ * abi: ContractABI.abi,
46
+ * functionName: "func",
47
+ * args: [arg1, arg2, ...],
48
+ * }),
49
+ * },
50
+ * ];
51
+ * const uoStruct = await smartAccountClient.buildUserOperationFromTxs({
52
+ * requests,
53
+ * });
54
+ *
55
+ * // signUserOperation signs the above unsigned user operation struct built
56
+ * // using the account connected to the smart account client
57
+ * const request = await smartAccountClient.signUserOperation({ uoStruct });
58
+ *
59
+ * // You can use the BundlerAction `sendRawUserOperation` (packages/core/src/actions/bundler/sendRawUserOperation.ts)
60
+ * // to send the signed user operation request to the bundler, requesting the bundler to send the signed uo to the
61
+ * // EntryPoint contract pointed at by the entryPoint address parameter
62
+ * const entryPointAddress = client.account.getEntryPoint().address;
63
+ * const uoHash = await smartAccountClient.sendRawUserOperation({
64
+ * request,
65
+ * entryPoint: entryPointAddress,
66
+ * });
81
67
  * ```
82
68
  *
83
- * @param client the smart account client to use to make RPC calls
84
- * @param args {@link BuildTransactionParameters} an object containing the requests
85
- * to build as well as, the account if not hoisted, the context, the overrides, and
86
- * optionally a flag to enable signing of the UO via the underlying middleware
87
- * @returns a Promise containing the built user operation
69
+ * @param {Client<TTransport, TChain, TAccount>} client the smart account client to use to make RPC calls
70
+ * @param {BuildTransactionParameters} args an object containing the requests to build as well as, the account if not hoisted, the context, the overrides, and optionally a flag to enable signing of the UO via the underlying middleware
71
+ * @returns {Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>} a Promise containing the built user operation
88
72
  */
89
73
  export async function buildUserOperationFromTxs<
90
74
  TTransport extends Transport = Transport,
@@ -12,31 +12,31 @@ import type {
12
12
 
13
13
  /**
14
14
  * This function verifies the eligibility of the connected account for gas sponsorship concerning the upcoming `UserOperation` (UO) that is intended to be sent.
15
- * Internally, this method invokes [`buildUserOperation`](./buildUserOperation.md), which navigates through the middleware pipeline, including the `PaymasterMiddleware`. Its purpose is to construct the UO struct meant for transmission to the bundler. Following the construction of the UO struct, this function verifies if the resulting structure contains a non-empty `paymasterAndData` field.
15
+ * Internally, this method invokes `buildUserOperation`, which navigates through the middleware pipeline, including the `PaymasterMiddleware`. Its purpose is to construct the UO struct meant for transmission to the bundler. Following the construction of the UO struct, this function verifies if the resulting structure contains a non-empty `paymasterAndData` field.
16
16
  * You can utilize this method before sending the user operation to confirm its eligibility for gas sponsorship. Depending on the outcome, it allows you to tailor the user experience accordingly, based on eligibility.
17
17
  *
18
18
  * @example
19
19
  * ```ts
20
20
  * import { smartAccountClient } from "./smartAccountClient";
21
- // [!code focus:99]
22
- const eligible = await smartAccountClient.checkGasSponsorshipEligibility({
23
- uo: {
24
- data: "0xCalldata",
25
- target: "0xTarget",
26
- value: 0n,
27
- },
28
- });
29
-
30
- console.log(
31
- `User Operation is ${
32
- eligible ? "eligible" : "ineligible"
33
- } for gas sponsorship.`
34
- );
21
+ * // [!code focus:99]
22
+ * const eligible = await smartAccountClient.checkGasSponsorshipEligibility({
23
+ * uo: {
24
+ * data: "0xCalldata",
25
+ * target: "0xTarget",
26
+ * value: 0n,
27
+ * },
28
+ * });
29
+ *
30
+ * console.log(
31
+ * `User Operation is ${
32
+ * eligible ? "eligible" : "ineligible"
33
+ * } for gas sponsorship.`
34
+ * );
35
35
  * ```
36
- *
37
- * @param client the smart account client to use for making RPC calls
38
- * @param args {@link SendUserOperationParameters} containing the user operation, account, context, and overrides
39
- * @returns a Promise containing a boolean indicating if the account is elgibile for sponsorship
36
+ *
37
+ * @param {Client<TTransport, TChain, TAccount>} client the smart account client to use for making RPC calls
38
+ * @param {SendUserOperationParameters} args containing the user operation, account, context, and overrides
39
+ * @returns {Promise<boolean>} a Promise containing a boolean indicating if the account is elgibile for sponsorship
40
40
  */
41
41
  export function checkGasSponsorshipEligibility<
42
42
  TTransport extends Transport = Transport,
@@ -23,9 +23,9 @@ import type {
23
23
  * @template {SmartContractAccount | undefined} TAccount
24
24
  * @template {UserOperationContext | undefined} TContext
25
25
  * @template {GetEntryPointFromAccount<TAccount>} TEntryPointVersion
26
- * @param client smart account client
27
- * @param args send user operation parameters
28
- * @returns user operation gas estimate response
26
+ * @param {Client<TTransport, TChain, TAccount>} client smart account client
27
+ * @param {SendUserOperationParameters<TAccount, TContext>} args send user operation parameters
28
+ * @returns {Promise<UserOperationEstimateGasResponse<TEntryPointVersion>>}user operation gas estimate response
29
29
  */
30
30
  export async function estimateUserOperationGas<
31
31
  TTransport extends Transport = Transport,
@@ -18,15 +18,14 @@ import type {
18
18
  * Description internal action function of SmartAccountClient for initializing
19
19
  * a user operation for the sender account
20
20
  *
21
- * @async
22
21
  * @template {Transport} TTransport
23
22
  * @template {Chain | undefined} TChain
24
23
  * @template {SmartContractAccount | undefined} TAccount
25
24
  * @template {UserOperationContext | undefined} TContext
26
25
  * @template {GetEntryPointFromAccount} TEntryPointVersion
27
- * @param client smart account client
28
- * @param args send user operation parameters
29
- * @returns initialized user operation struct
26
+ * @param {BaseSmartAccountClient<TTransport, TChain, TAccount>} client smart account client
27
+ * @param {SendUserOperationParameters<TAccount, TContext, TEntryPointVersion> | BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>} args send user operation parameters
28
+ * @returns {Promise<Deferrable<UserOperationStruct<TEntryPointVersion>>>} initialized user operation struct
30
29
  */
31
30
  export async function _initUserOperation<
32
31
  TTransport extends Transport = Transport,
@@ -19,14 +19,6 @@ import {
19
19
  } from "../../../utils/index.js";
20
20
  import type { UserOperationContext } from "../types";
21
21
 
22
- /**
23
- * Utility method for running a sequence of async functions as a pipeline
24
- *
25
- * @template S
26
- * @template Opts
27
- * @param fns async functions to run in a pipeline sequence
28
- * @returns a function that runs the async functions in a pipeline sequence
29
- */
30
22
  const asyncPipe =
31
23
  <S, Opts>(...fns: ((s: S, opts: Opts) => Promise<S>)[]) =>
32
24
  async (s: S, opts: Opts) => {
@@ -37,20 +29,6 @@ const asyncPipe =
37
29
  return result;
38
30
  };
39
31
 
40
- /**
41
- * Internal method of {@link SmartAccountClient} running the middleware stack for a user operation
42
- *
43
- * @async
44
- * @template TTransport
45
- * @template TChain
46
- * @template TAccount
47
- * @template TContext the {@link UserOperationContext} passed to the middleware
48
- * @template TEntryPointVersion
49
- * @param client the smart account client instance that runs the middleware pipeline with
50
- * @param args the Deferrable {@link UserOperationStruct} to run the middleware pipeline on
51
- *
52
- * @returns the resolved {@link UserOperationStruct} after running the middleware pipeline
53
- */
54
32
  export async function _runMiddlewareStack<
55
33
  TTransport extends Transport = Transport,
56
34
  TChain extends Chain | undefined = Chain | undefined,
@@ -15,13 +15,6 @@ import type {
15
15
  import { signUserOperation } from "../signUserOperation.js";
16
16
  import type { GetContextParameter, UserOperationContext } from "../types";
17
17
 
18
- /**
19
- * Used internally to send a user operation that has **already** been signed
20
- *
21
- * @param client a base smart account client instance with middleware configured
22
- * @param args user operation struct, overrides, account, and context to be used in sending
23
- * @returns A Promise containing the send user operation result {@link SendUserOperationResult}
24
- */
25
18
  export async function _sendUserOperation<
26
19
  TTransport extends Transport = Transport,
27
20
  TChain extends Chain | undefined = Chain | undefined,
@@ -17,9 +17,23 @@ import type {
17
17
  /**
18
18
  * Sends a user operation or batch of user operations using the connected account. Before executing, sendUserOperation will run the user operation through the middleware pipeline.
19
19
  *
20
- * @param client the smart account client to use for RPC requests
21
- * @param args {@link SendUserOperationParameters} containg the UO or batch to send, context, overrides, and account if not hoisted on the client
22
- * @returns a Promise containing the {@link SendUserOperationResult}
20
+ * @example
21
+ * ```ts
22
+ * import { createSmartAccountClient, toSmartContractAccount } from "@aa-sdk/core";
23
+ *
24
+ * const account = await toSmartContractAccount(...);
25
+ * const result = await createSmartAccountClient(...).sendUserOperation({
26
+ * uo: {
27
+ * target: "0x...",
28
+ * data: "0x...", // or "0x",
29
+ * value: 0n, // optional
30
+ * }
31
+ * });
32
+ * ```
33
+ *
34
+ * @param {Client<TTransport, TChain, TAccount>} client the smart account client to use for RPC requests
35
+ * @param {SendUserOperationParameters<TAccount, TContext>} args contains the UO or batch to send, context, overrides, and account if not hoisted on the client
36
+ * @returns {Promise<SendUserOperationResult<TEntryPointVersion>>} a Promise containing the result of the user operation
23
37
  */
24
38
  export async function sendUserOperation<
25
39
  TTransport extends Transport = Transport,
@@ -58,8 +58,8 @@ export const createBundlerClientFromExisting: <
58
58
  /**
59
59
  * Creates a PublicClient with methods for calling Bundler RPC methods
60
60
  *
61
- * @param args - configuration for the client
62
- * @returns a PublicClient with methods for calling Bundler RPC methods
61
+ * @param {PublicClientConfig<TTransport, Chain> & { type?: string }} args - configuration for the client
62
+ * @returns {BundlerClient<TTransport>} a PublicClient with methods for calling Bundler RPC methods
63
63
  */
64
64
  export function createBundlerClient<TTransport extends Transport>(
65
65
  args: PublicClientConfig<TTransport, Chain> & { type?: string }
@@ -55,10 +55,10 @@ export type BundlerActions = {
55
55
  /**
56
56
  * calls `eth_estimateUserOperationGas` and returns the result
57
57
  *
58
- * @param request - the {@link UserOperationRequest} to estimate gas for
58
+ * @param request - the UserOperationRequest to estimate gas for
59
59
  * @param entryPoint - the entry point address the op will be sent to
60
60
  * @param stateOverride - the state override to use for the estimation
61
- * @returns the gas estimates for the given response (see: {@link UserOperationEstimateGasResponse})
61
+ * @returns the gas estimates for the given response
62
62
  */
63
63
  estimateUserOperationGas<
64
64
  TEntryPointVersion extends EntryPointVersion = EntryPointVersion
@@ -71,7 +71,7 @@ export type BundlerActions = {
71
71
  /**
72
72
  * calls `eth_sendUserOperation` and returns the hash of the sent UserOperation
73
73
  *
74
- * @param request - the {@link UserOperationRequest} to send
74
+ * @param request - the UserOperationRequest to send
75
75
  * @param entryPoint - the entry point address the op will be sent to
76
76
  * @returns the hash of the sent UserOperation
77
77
  */
@@ -83,25 +83,25 @@ export type BundlerActions = {
83
83
  ): Promise<Hash>;
84
84
 
85
85
  /**
86
- * calls `eth_getUserOperationByHash` and returns the {@link UserOperationResponse}
86
+ * calls `eth_getUserOperationByHash` and returns the UserOperationResponse
87
87
  *
88
88
  * @param hash - the hash of the UserOperation to fetch
89
- * @returns - {@link UserOperationResponse}
89
+ * @returns - the user operation if found or null
90
90
  */
91
91
  getUserOperationByHash(hash: Hash): Promise<UserOperationResponse | null>;
92
92
 
93
93
  /**
94
- * calls `eth_getUserOperationReceipt` and returns the {@link UserOperationReceipt}
94
+ * calls `eth_getUserOperationReceipt` and returns the UserOperationReceipt
95
95
  *
96
96
  * @param hash - the hash of the UserOperation to get the receipt for
97
- * @returns - {@link UserOperationReceipt}
97
+ * @returns - a user operation receipt or null if not found
98
98
  */
99
99
  getUserOperationReceipt(hash: Hash): Promise<UserOperationReceipt | null>;
100
100
 
101
101
  /**
102
102
  * calls `eth_supportedEntryPoints` and returns the entry points the RPC supports
103
103
  *
104
- * @returns - {@link Address}[]
104
+ * @returns - an array of the entrypoint addresses supported
105
105
  */
106
106
  getSupportedEntryPoints(): Promise<Address[]>;
107
107
  };
@@ -11,8 +11,8 @@ import type {
11
11
  * Useful for narrowing the type of the client down when used within the
12
12
  * smart account client decorators
13
13
  *
14
- * @param client a viem client
15
- * @returns true if the client is a SmartAccountClient
14
+ * @param {Client<TTransport, TChain, TAccount>} client a viem client
15
+ * @returns {boolean} true if the client is a SmartAccountClient
16
16
  */
17
17
  export function isSmartAccountClient<
18
18
  TTransport extends Transport = Transport,
@@ -37,8 +37,8 @@ export function isSmartAccountClient<
37
37
  * Useful for narrowing the type of the client down when used within the
38
38
  * smart account action decorators
39
39
  *
40
- * @param client a viem client
41
- * @returns true if the account is a BaseSmartAccountClient
40
+ * @param {Client<TTransport, TChain, TAccount>} client a viem client
41
+ * @returns {boolean} true if the account is a BaseSmartAccountClient
42
42
  */
43
43
  export function isBaseSmartAccountClient<
44
44
  TTransport extends Transport = Transport,
@@ -3,10 +3,7 @@ import type { Hash, Hex } from "viem";
3
3
  import type { z } from "zod";
4
4
  import type { UserOperationContext } from "../actions/smartAccount/types.js";
5
5
  import type { EntryPointVersion } from "../entrypoint/types.js";
6
- import type {
7
- ClientMiddleware,
8
- ClientMiddlewareFn,
9
- } from "../middleware/types.js";
6
+ import type { ClientMiddleware } from "../middleware/types.js";
10
7
  import type { UserOperationRequest } from "../types.js";
11
8
  import type { ConnectionConfigSchema } from "./schema.js";
12
9
 
@@ -37,15 +34,5 @@ export type ClientMiddlewareConfig<
37
34
  TContext extends UserOperationContext | undefined =
38
35
  | UserOperationContext
39
36
  | undefined
40
- > = Omit<
41
- Partial<ClientMiddleware<TContext>>,
42
- "dummyPaymasterAndData" | "paymasterAndData"
43
- > & {
44
- paymasterAndData?: {
45
- dummyPaymasterAndData: () =>
46
- | UserOperationRequest<"0.6.0">["paymasterAndData"]
47
- | Pick<UserOperationRequest<"0.7.0">, "paymaster" | "paymasterData">;
48
- paymasterAndData: ClientMiddlewareFn<TContext>;
49
- };
50
- };
37
+ > = Partial<ClientMiddleware<TContext>>;
51
38
  // [!endregion ClientMiddlewareConfig]
package/src/ens/utils.ts CHANGED
@@ -1,6 +1,5 @@
1
- import type { Chain } from "viem/chains";
2
1
  import * as chains from "viem/chains";
3
- import { mainnet } from "../chains/index.js";
2
+ import { mainnet, type Chain } from "viem/chains";
4
3
 
5
4
  export const ChainsById: Map<number, chains.Chain> = new Map(
6
5
  Object.values(chains).map((x) => [x.id, x])
@@ -9,7 +9,10 @@ export class AccountNotFoundError extends BaseError {
9
9
  override name = "AccountNotFoundError";
10
10
 
11
11
  // TODO: extend this further using docs path as well
12
- constructor() {
12
+
13
+ /**
14
+ * Constructor for initializing an error message indicating that an account could not be found to execute the specified action.
15
+ */ constructor() {
13
16
  super("Could not find an Account to execute with this Action.");
14
17
  }
15
18
  }
@@ -20,6 +23,14 @@ export class AccountNotFoundError extends BaseError {
20
23
  */
21
24
  export class DefaultFactoryNotDefinedError extends BaseError {
22
25
  override name = "DefaultFactoryNotDefinedError";
26
+
27
+ /**
28
+ * Constructs an error message indicating that no default factory was found for the given account type, chain, and entry point version.
29
+ *
30
+ * @param {string} accountType the type of account
31
+ * @param {Chain} chain the blockchain chain
32
+ * @param {EntryPointVersion} version the entry point version
33
+ */
23
34
  constructor(accountType: string, chain: Chain, version: EntryPointVersion) {
24
35
  super(
25
36
  [
@@ -35,7 +46,10 @@ export class DefaultFactoryNotDefinedError extends BaseError {
35
46
  */
36
47
  export class GetCounterFactualAddressError extends BaseError {
37
48
  override name = "GetCounterFactualAddressError";
38
- constructor() {
49
+
50
+ /**
51
+ * Constructor for initializing an error message indicating the failure of fetching the counter-factual address.
52
+ */ constructor() {
39
53
  super("getCounterFactualAddress failed");
40
54
  }
41
55
  }
@@ -45,6 +59,12 @@ export class GetCounterFactualAddressError extends BaseError {
45
59
  */
46
60
  export class UpgradesNotSupportedError extends BaseError {
47
61
  override name = "UpgradesNotSupported";
62
+
63
+ /**
64
+ * Error constructor for indicating that upgrades are not supported by the given account type.
65
+ *
66
+ * @param {string} accountType The type of account that does not support upgrades
67
+ */
48
68
  constructor(accountType: string) {
49
69
  super(`Upgrades are not supported by ${accountType}`);
50
70
  }
@@ -55,7 +75,12 @@ export class UpgradesNotSupportedError extends BaseError {
55
75
  */
56
76
  export class SignTransactionNotSupportedError extends BaseError {
57
77
  override name = "SignTransactionNotSupported";
58
- constructor() {
78
+
79
+ /**
80
+ * Throws an error indicating that signing a transaction is not supported by smart contracts.
81
+ *
82
+
83
+ */ constructor() {
59
84
  super(`SignTransaction is not supported by smart contracts`);
60
85
  }
61
86
  }
@@ -65,6 +90,13 @@ export class SignTransactionNotSupportedError extends BaseError {
65
90
  */
66
91
  export class FailedToGetStorageSlotError extends BaseError {
67
92
  override name = "FailedToGetStorageSlotError";
93
+
94
+ /**
95
+ * Custom error message constructor for failing to get a specific storage slot.
96
+ *
97
+ * @param {string} slot The storage slot that failed to be accessed or retrieved
98
+ * @param {string} slotDescriptor A description of the storage slot, for additional context in the error message
99
+ */
68
100
  constructor(slot: string, slotDescriptor: string) {
69
101
  super(`Failed to get storage slot ${slot} (${slotDescriptor})`);
70
102
  }
@@ -75,6 +107,12 @@ export class FailedToGetStorageSlotError extends BaseError {
75
107
  */
76
108
  export class BatchExecutionNotSupportedError extends BaseError {
77
109
  override name = "BatchExecutionNotSupportedError";
110
+
111
+ /**
112
+ * Constructs an error message indicating that batch execution is not supported by the specified account type.
113
+ *
114
+ * @param {string} accountType the type of account that does not support batch execution
115
+ */
78
116
  constructor(accountType: string) {
79
117
  super(`Batch execution is not supported by ${accountType}`);
80
118
  }
@@ -85,6 +123,12 @@ export class BatchExecutionNotSupportedError extends BaseError {
85
123
  */
86
124
  export class AccountRequiresOwnerError extends BaseError {
87
125
  override name = "AccountRequiresOwnerError";
126
+
127
+ /**
128
+ * Constructs an error indicating that an account of the specified type requires an owner to execute.
129
+ *
130
+ * @param {string} accountType The type of account that requires an owner
131
+ */
88
132
  constructor(accountType: string) {
89
133
  super(`Account of type ${accountType} requires an owner to execute`);
90
134
  }
@@ -95,6 +139,12 @@ export class AccountRequiresOwnerError extends BaseError {
95
139
  */
96
140
  export class UpgradeToAndCallNotSupportedError extends BaseError {
97
141
  override name = "UpgradeToAndCallNotSupportedError";
142
+
143
+ /**
144
+ * Constructs an error message indicating that `UpgradeToAndCall` is not supported by the specified account type.
145
+ *
146
+ * @param {string} accountType The type of account that does not support `UpgradeToAndCall`
147
+ */
98
148
  constructor(accountType: string) {
99
149
  super(`UpgradeToAndCall is not supported by ${accountType}`);
100
150
  }
@@ -105,6 +155,13 @@ export class UpgradeToAndCallNotSupportedError extends BaseError {
105
155
  */
106
156
  export class IncorrectAccountType extends BaseError {
107
157
  override name = "IncorrectAccountTypeError";
158
+
159
+ /**
160
+ * Constructs an error object indicating that the expected account type does not match the actual account type.
161
+ *
162
+ * @param {string} expected the expected account type
163
+ * @param {string} actual the actual account type that was received
164
+ */
108
165
  constructor(expected: string, actual: string) {
109
166
  super(`Expected account type ${expected}, got ${actual}`);
110
167
  }
@@ -115,7 +172,10 @@ export class IncorrectAccountType extends BaseError {
115
172
  */
116
173
  export class SmartAccountWithSignerRequiredError extends BaseError {
117
174
  override name = "SmartAccountWithSignerRequiredError";
118
- constructor() {
175
+
176
+ /**
177
+ * Initializes a new instance of the error class with a predefined error message indicating that a smart account requires a signer.
178
+ */ constructor() {
119
179
  super("Smart account requires a signer");
120
180
  }
121
181
  }
@@ -6,6 +6,14 @@ import { BaseError } from "./base.js";
6
6
  */
7
7
  export class IncompatibleClientError extends BaseError {
8
8
  override name = "IncompatibleClientError";
9
+
10
+ /**
11
+ * Throws an error when the client type does not match the expected client type.
12
+ *
13
+ * @param {string} expectedClient The expected type of the client.
14
+ * @param {string} method The method that was called.
15
+ * @param {Client} client The client instance.
16
+ */
9
17
  constructor(expectedClient: string, method: string, client: Client) {
10
18
  super(
11
19
  [
@@ -21,6 +29,12 @@ export class IncompatibleClientError extends BaseError {
21
29
  */
22
30
  export class InvalidRpcUrlError extends BaseError {
23
31
  override name = "InvalidRpcUrlError";
32
+
33
+ /**
34
+ * Creates an instance of an error with a message indicating an invalid RPC URL.
35
+ *
36
+ * @param {string} [rpcUrl] The invalid RPC URL that caused the error
37
+ */
24
38
  constructor(rpcUrl?: string) {
25
39
  super(`Invalid RPC URL ${rpcUrl}`);
26
40
  }
@@ -31,6 +45,10 @@ export class InvalidRpcUrlError extends BaseError {
31
45
  */
32
46
  export class ChainNotFoundError extends BaseError {
33
47
  override name = "ChainNotFoundError";
48
+
49
+ /**
50
+ * Initializes a new instance of the error message with a default message indicating that no chain was supplied to the client.
51
+ */
34
52
  constructor() {
35
53
  super("No chain supplied to the client");
36
54
  }
@@ -7,6 +7,12 @@ import { BaseError } from "./base.js";
7
7
  export class EntryPointNotFoundError extends BaseError {
8
8
  override name = "EntryPointNotFoundError";
9
9
 
10
+ /**
11
+ * Constructs an error message indicating that no default entry point exists for the given chain and entry point version.
12
+ *
13
+ * @param {Chain} chain The blockchain network for which the entry point is being queried
14
+ * @param {any} entryPointVersion The version of the entry point for which no default exists
15
+ */
10
16
  constructor(chain: Chain, entryPointVersion: any) {
11
17
  super(
12
18
  [
@@ -23,6 +29,12 @@ export class EntryPointNotFoundError extends BaseError {
23
29
  export class InvalidEntryPointError extends BaseError {
24
30
  override name = "InvalidEntryPointError";
25
31
 
32
+ /**
33
+ * Constructs an error indicating an invalid entry point version for a specific chain.
34
+ *
35
+ * @param {Chain} chain The chain object containing information about the blockchain
36
+ * @param {any} entryPointVersion The entry point version that is invalid
37
+ */
26
38
  constructor(chain: Chain, entryPointVersion: any) {
27
39
  super(
28
40
  `Invalid entry point: unexpected version ${entryPointVersion} for ${chain.name}.`
@@ -5,6 +5,12 @@ import { BaseError } from "./base.js";
5
5
  */
6
6
  export class InvalidSignerTypeError extends BaseError {
7
7
  override name = "InvalidSignerTypeError";
8
+
9
+ /**
10
+ * Constructs an error message when an invalid signer type is passed to SmartAccountSigner.
11
+ *
12
+ * @param {string} [signerType] An optional parameter specifying the signer type. If not provided, a default error message will be used.
13
+ */
8
14
  constructor(signerType?: string) {
9
15
  super(
10
16
  [
@@ -6,7 +6,10 @@ import { BaseError } from "./base.js";
6
6
  */
7
7
  export class TransactionMissingToParamError extends BaseError {
8
8
  override name = "TransactionMissingToParamError";
9
- constructor() {
9
+
10
+ /**
11
+ * Throws an error indicating that a transaction is missing the `to` address in the request.
12
+ */ constructor() {
10
13
  super("Transaction is missing `to` address set on request");
11
14
  }
12
15
  }
@@ -16,6 +19,12 @@ export class TransactionMissingToParamError extends BaseError {
16
19
  */
17
20
  export class FailedToFindTransactionError extends BaseError {
18
21
  override name = "FailedToFindTransactionError";
22
+
23
+ /**
24
+ * Constructs a new error message indicating a failure to find the transaction for the specified user operation hash.
25
+ *
26
+ * @param {Hex} hash The hexadecimal value representing the user operation hash.
27
+ */
19
28
  constructor(hash: Hex) {
20
29
  super(`Failed to find transaction for user operation ${hash}`);
21
30
  }