@aa-sdk/core 4.0.0-alpha.0 → 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 (342) hide show
  1. package/dist/cjs/account/smartContractAccount.d.ts +9 -3
  2. package/dist/cjs/account/smartContractAccount.js +13 -7
  3. package/dist/cjs/account/smartContractAccount.js.map +1 -1
  4. package/dist/cjs/actions/smartAccount/buildUserOperation.js.map +1 -1
  5. package/dist/cjs/actions/smartAccount/buildUserOperationFromTx.js.map +1 -1
  6. package/dist/cjs/actions/smartAccount/buildUserOperationFromTxs.js.map +1 -1
  7. package/dist/cjs/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
  8. package/dist/cjs/actions/smartAccount/dropAndReplaceUserOperation.js.map +1 -1
  9. package/dist/cjs/actions/smartAccount/estimateUserOperationGas.js.map +1 -1
  10. package/dist/cjs/actions/smartAccount/internal/initUserOperation.js.map +1 -1
  11. package/dist/cjs/actions/smartAccount/internal/runMiddlewareStack.js.map +1 -1
  12. package/dist/cjs/actions/smartAccount/internal/sendUserOperation.js.map +1 -1
  13. package/dist/cjs/actions/smartAccount/sendTransaction.js.map +1 -1
  14. package/dist/cjs/actions/smartAccount/sendTransactions.js.map +1 -1
  15. package/dist/cjs/actions/smartAccount/sendUserOperation.js.map +1 -1
  16. package/dist/cjs/actions/smartAccount/waitForUserOperationTransacation.js.map +1 -1
  17. package/dist/cjs/client/bundlerClient.js.map +1 -1
  18. package/dist/cjs/client/decorators/bundlerClient.js.map +1 -1
  19. package/dist/cjs/client/decorators/smartAccountClient.js.map +1 -1
  20. package/dist/cjs/client/isSmartAccountClient.js.map +1 -1
  21. package/dist/cjs/client/smartAccountClient.js.map +1 -1
  22. package/dist/cjs/client/types.d.ts +2 -7
  23. package/dist/cjs/client/types.js.map +1 -1
  24. package/dist/cjs/ens/utils.d.ts +1 -1
  25. package/dist/cjs/ens/utils.js +3 -3
  26. package/dist/cjs/ens/utils.js.map +1 -1
  27. package/dist/cjs/entrypoint/index.js.map +1 -1
  28. package/dist/cjs/errors/account.js.map +1 -1
  29. package/dist/cjs/errors/base.js.map +1 -1
  30. package/dist/cjs/errors/client.js.map +1 -1
  31. package/dist/cjs/errors/entrypoint.js.map +1 -1
  32. package/dist/cjs/errors/signer.js.map +1 -1
  33. package/dist/cjs/errors/transaction.js.map +1 -1
  34. package/dist/cjs/errors/useroperation.js.map +1 -1
  35. package/dist/cjs/index.d.ts +4 -7
  36. package/dist/cjs/index.js +38 -66
  37. package/dist/cjs/index.js.map +1 -1
  38. package/dist/cjs/logger.js.map +1 -1
  39. package/dist/cjs/middleware/actions.js +2 -18
  40. package/dist/cjs/middleware/actions.js.map +1 -1
  41. package/dist/cjs/middleware/defaults/feeEstimator.d.ts +1 -1
  42. package/dist/cjs/middleware/defaults/feeEstimator.js +17 -15
  43. package/dist/cjs/middleware/defaults/feeEstimator.js.map +1 -1
  44. package/dist/cjs/middleware/defaults/gasEstimator.js +4 -2
  45. package/dist/cjs/middleware/defaults/gasEstimator.js.map +1 -1
  46. package/dist/cjs/middleware/defaults/paymasterAndData.js.map +1 -1
  47. package/dist/cjs/middleware/defaults/userOpSigner.js.map +1 -1
  48. package/dist/cjs/middleware/erc7677middleware.d.ts +40 -0
  49. package/dist/cjs/middleware/erc7677middleware.js +77 -0
  50. package/dist/cjs/middleware/erc7677middleware.js.map +1 -0
  51. package/dist/cjs/middleware/noopMiddleware.d.ts +2 -1
  52. package/dist/cjs/middleware/noopMiddleware.js.map +1 -1
  53. package/dist/cjs/middleware/types.d.ts +3 -2
  54. package/dist/cjs/middleware/types.js.map +1 -1
  55. package/dist/cjs/signer/local-account.d.ts +44 -44
  56. package/dist/cjs/signer/local-account.js.map +1 -1
  57. package/dist/cjs/signer/schema.js.map +1 -1
  58. package/dist/cjs/signer/utils.d.ts +1 -9
  59. package/dist/cjs/signer/utils.js +1 -16
  60. package/dist/cjs/signer/utils.js.map +1 -1
  61. package/dist/cjs/signer/wallet-client.d.ts +44 -44
  62. package/dist/cjs/signer/wallet-client.js.map +1 -1
  63. package/dist/cjs/transport/split.js.map +1 -1
  64. package/dist/cjs/utils/bigint.js.map +1 -1
  65. package/dist/cjs/utils/bytes.js.map +1 -1
  66. package/dist/cjs/utils/defaults.d.ts +2 -4
  67. package/dist/cjs/utils/defaults.js +5 -45
  68. package/dist/cjs/utils/defaults.js.map +1 -1
  69. package/dist/cjs/utils/index.d.ts +0 -4
  70. package/dist/cjs/utils/index.js +1 -33
  71. package/dist/cjs/utils/index.js.map +1 -1
  72. package/dist/cjs/utils/types.js.map +1 -1
  73. package/dist/cjs/utils/userop.js.map +1 -1
  74. package/dist/cjs/version.d.ts +1 -1
  75. package/dist/cjs/version.js +1 -1
  76. package/dist/cjs/version.js.map +1 -1
  77. package/dist/esm/account/smartContractAccount.d.ts +9 -3
  78. package/dist/esm/account/smartContractAccount.js +8 -2
  79. package/dist/esm/account/smartContractAccount.js.map +1 -1
  80. package/dist/esm/actions/smartAccount/buildUserOperation.js.map +1 -1
  81. package/dist/esm/actions/smartAccount/buildUserOperationFromTx.js.map +1 -1
  82. package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.js.map +1 -1
  83. package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
  84. package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.js.map +1 -1
  85. package/dist/esm/actions/smartAccount/estimateUserOperationGas.js.map +1 -1
  86. package/dist/esm/actions/smartAccount/internal/initUserOperation.js.map +1 -1
  87. package/dist/esm/actions/smartAccount/internal/runMiddlewareStack.js.map +1 -1
  88. package/dist/esm/actions/smartAccount/internal/sendUserOperation.js.map +1 -1
  89. package/dist/esm/actions/smartAccount/sendTransaction.js.map +1 -1
  90. package/dist/esm/actions/smartAccount/sendTransactions.js.map +1 -1
  91. package/dist/esm/actions/smartAccount/sendUserOperation.js.map +1 -1
  92. package/dist/esm/actions/smartAccount/waitForUserOperationTransacation.js.map +1 -1
  93. package/dist/esm/client/bundlerClient.js.map +1 -1
  94. package/dist/esm/client/decorators/bundlerClient.js.map +1 -1
  95. package/dist/esm/client/decorators/smartAccountClient.js.map +1 -1
  96. package/dist/esm/client/isSmartAccountClient.js.map +1 -1
  97. package/dist/esm/client/smartAccountClient.js.map +1 -1
  98. package/dist/esm/client/types.d.ts +2 -7
  99. package/dist/esm/client/types.js.map +1 -1
  100. package/dist/esm/ens/utils.d.ts +1 -1
  101. package/dist/esm/ens/utils.js +1 -1
  102. package/dist/esm/ens/utils.js.map +1 -1
  103. package/dist/esm/entrypoint/index.js.map +1 -1
  104. package/dist/esm/errors/account.js.map +1 -1
  105. package/dist/esm/errors/base.js.map +1 -1
  106. package/dist/esm/errors/client.js.map +1 -1
  107. package/dist/esm/errors/entrypoint.js.map +1 -1
  108. package/dist/esm/errors/signer.js.map +1 -1
  109. package/dist/esm/errors/transaction.js.map +1 -1
  110. package/dist/esm/errors/useroperation.js.map +1 -1
  111. package/dist/esm/index.d.ts +4 -7
  112. package/dist/esm/index.js +3 -5
  113. package/dist/esm/index.js.map +1 -1
  114. package/dist/esm/logger.js.map +1 -1
  115. package/dist/esm/middleware/actions.js +3 -18
  116. package/dist/esm/middleware/actions.js.map +1 -1
  117. package/dist/esm/middleware/defaults/feeEstimator.d.ts +1 -1
  118. package/dist/esm/middleware/defaults/feeEstimator.js +17 -15
  119. package/dist/esm/middleware/defaults/feeEstimator.js.map +1 -1
  120. package/dist/esm/middleware/defaults/gasEstimator.js +4 -2
  121. package/dist/esm/middleware/defaults/gasEstimator.js.map +1 -1
  122. package/dist/esm/middleware/defaults/paymasterAndData.js.map +1 -1
  123. package/dist/esm/middleware/defaults/userOpSigner.js.map +1 -1
  124. package/dist/esm/middleware/erc7677middleware.d.ts +40 -0
  125. package/dist/esm/middleware/erc7677middleware.js +73 -0
  126. package/dist/esm/middleware/erc7677middleware.js.map +1 -0
  127. package/dist/esm/middleware/noopMiddleware.d.ts +2 -1
  128. package/dist/esm/middleware/noopMiddleware.js.map +1 -1
  129. package/dist/esm/middleware/types.d.ts +3 -2
  130. package/dist/esm/middleware/types.js.map +1 -1
  131. package/dist/esm/signer/local-account.d.ts +44 -44
  132. package/dist/esm/signer/local-account.js.map +1 -1
  133. package/dist/esm/signer/schema.js.map +1 -1
  134. package/dist/esm/signer/utils.d.ts +1 -9
  135. package/dist/esm/signer/utils.js +0 -14
  136. package/dist/esm/signer/utils.js.map +1 -1
  137. package/dist/esm/signer/wallet-client.d.ts +44 -44
  138. package/dist/esm/signer/wallet-client.js.map +1 -1
  139. package/dist/esm/transport/split.js.map +1 -1
  140. package/dist/esm/utils/bigint.js.map +1 -1
  141. package/dist/esm/utils/bytes.js.map +1 -1
  142. package/dist/esm/utils/defaults.d.ts +2 -4
  143. package/dist/esm/utils/defaults.js +1 -40
  144. package/dist/esm/utils/defaults.js.map +1 -1
  145. package/dist/esm/utils/index.d.ts +0 -4
  146. package/dist/esm/utils/index.js +0 -18
  147. package/dist/esm/utils/index.js.map +1 -1
  148. package/dist/esm/utils/types.js.map +1 -1
  149. package/dist/esm/utils/userop.js.map +1 -1
  150. package/dist/esm/version.d.ts +1 -1
  151. package/dist/esm/version.js +1 -1
  152. package/dist/esm/version.js.map +1 -1
  153. package/dist/types/account/smartContractAccount.d.ts +58 -3
  154. package/dist/types/account/smartContractAccount.d.ts.map +1 -1
  155. package/dist/types/actions/smartAccount/buildUserOperation.d.ts +23 -0
  156. package/dist/types/actions/smartAccount/buildUserOperation.d.ts.map +1 -1
  157. package/dist/types/actions/smartAccount/buildUserOperationFromTx.d.ts +33 -33
  158. package/dist/types/actions/smartAccount/buildUserOperationFromTxs.d.ts +43 -59
  159. package/dist/types/actions/smartAccount/buildUserOperationFromTxs.d.ts.map +1 -1
  160. package/dist/types/actions/smartAccount/checkGasSponsorshipEligibility.d.ts +18 -18
  161. package/dist/types/actions/smartAccount/dropAndReplaceUserOperation.d.ts +22 -0
  162. package/dist/types/actions/smartAccount/dropAndReplaceUserOperation.d.ts.map +1 -1
  163. package/dist/types/actions/smartAccount/estimateUserOperationGas.d.ts +3 -3
  164. package/dist/types/actions/smartAccount/internal/initUserOperation.d.ts +3 -4
  165. package/dist/types/actions/smartAccount/internal/initUserOperation.d.ts.map +1 -1
  166. package/dist/types/actions/smartAccount/internal/runMiddlewareStack.d.ts +0 -14
  167. package/dist/types/actions/smartAccount/internal/runMiddlewareStack.d.ts.map +1 -1
  168. package/dist/types/actions/smartAccount/internal/sendUserOperation.d.ts +0 -7
  169. package/dist/types/actions/smartAccount/internal/sendUserOperation.d.ts.map +1 -1
  170. package/dist/types/actions/smartAccount/sendTransaction.d.ts +24 -0
  171. package/dist/types/actions/smartAccount/sendTransaction.d.ts.map +1 -1
  172. package/dist/types/actions/smartAccount/sendTransactions.d.ts +23 -0
  173. package/dist/types/actions/smartAccount/sendTransactions.d.ts.map +1 -1
  174. package/dist/types/actions/smartAccount/sendUserOperation.d.ts +17 -3
  175. package/dist/types/actions/smartAccount/sendUserOperation.d.ts.map +1 -1
  176. package/dist/types/actions/smartAccount/waitForUserOperationTransacation.d.ts +24 -0
  177. package/dist/types/actions/smartAccount/waitForUserOperationTransacation.d.ts.map +1 -1
  178. package/dist/types/client/bundlerClient.d.ts +17 -2
  179. package/dist/types/client/bundlerClient.d.ts.map +1 -1
  180. package/dist/types/client/decorators/bundlerClient.d.ts +17 -8
  181. package/dist/types/client/decorators/bundlerClient.d.ts.map +1 -1
  182. package/dist/types/client/decorators/smartAccountClient.d.ts +8 -0
  183. package/dist/types/client/decorators/smartAccountClient.d.ts.map +1 -1
  184. package/dist/types/client/isSmartAccountClient.d.ts +4 -4
  185. package/dist/types/client/smartAccountClient.d.ts.map +1 -1
  186. package/dist/types/client/types.d.ts +2 -7
  187. package/dist/types/client/types.d.ts.map +1 -1
  188. package/dist/types/ens/utils.d.ts +46 -1
  189. package/dist/types/ens/utils.d.ts.map +1 -1
  190. package/dist/types/entrypoint/index.d.ts +14 -0
  191. package/dist/types/entrypoint/index.d.ts.map +1 -1
  192. package/dist/types/errors/account.d.ts +87 -4
  193. package/dist/types/errors/account.d.ts.map +1 -1
  194. package/dist/types/errors/base.d.ts +5 -0
  195. package/dist/types/errors/base.d.ts.map +1 -1
  196. package/dist/types/errors/client.d.ts +24 -0
  197. package/dist/types/errors/client.d.ts.map +1 -1
  198. package/dist/types/errors/entrypoint.d.ts +18 -0
  199. package/dist/types/errors/entrypoint.d.ts.map +1 -1
  200. package/dist/types/errors/signer.d.ts +8 -0
  201. package/dist/types/errors/signer.d.ts.map +1 -1
  202. package/dist/types/errors/transaction.d.ts +14 -1
  203. package/dist/types/errors/transaction.d.ts.map +1 -1
  204. package/dist/types/errors/useroperation.d.ts +5 -5
  205. package/dist/types/errors/useroperation.d.ts.map +1 -1
  206. package/dist/types/index.d.ts +4 -7
  207. package/dist/types/index.d.ts.map +1 -1
  208. package/dist/types/logger.d.ts +91 -0
  209. package/dist/types/logger.d.ts.map +1 -1
  210. package/dist/types/middleware/actions.d.ts +3 -3
  211. package/dist/types/middleware/actions.d.ts.map +1 -1
  212. package/dist/types/middleware/defaults/feeEstimator.d.ts +21 -1
  213. package/dist/types/middleware/defaults/feeEstimator.d.ts.map +1 -1
  214. package/dist/types/middleware/defaults/gasEstimator.d.ts +2 -2
  215. package/dist/types/middleware/defaults/gasEstimator.d.ts.map +1 -1
  216. package/dist/types/middleware/defaults/paymasterAndData.d.ts +8 -0
  217. package/dist/types/middleware/defaults/paymasterAndData.d.ts.map +1 -1
  218. package/dist/types/middleware/defaults/userOpSigner.d.ts +10 -0
  219. package/dist/types/middleware/defaults/userOpSigner.d.ts.map +1 -1
  220. package/dist/types/middleware/erc7677middleware.d.ts +62 -0
  221. package/dist/types/middleware/erc7677middleware.d.ts.map +1 -0
  222. package/dist/types/middleware/noopMiddleware.d.ts +4 -4
  223. package/dist/types/middleware/noopMiddleware.d.ts.map +1 -1
  224. package/dist/types/middleware/types.d.ts +3 -2
  225. package/dist/types/middleware/types.d.ts.map +1 -1
  226. package/dist/types/signer/local-account.d.ts +140 -45
  227. package/dist/types/signer/local-account.d.ts.map +1 -1
  228. package/dist/types/signer/schema.d.ts +14 -0
  229. package/dist/types/signer/schema.d.ts.map +1 -1
  230. package/dist/types/signer/utils.d.ts +21 -9
  231. package/dist/types/signer/utils.d.ts.map +1 -1
  232. package/dist/types/signer/wallet-client.d.ts +136 -44
  233. package/dist/types/signer/wallet-client.d.ts.map +1 -1
  234. package/dist/types/transport/split.d.ts +2 -2
  235. package/dist/types/utils/bigint.d.ts +14 -14
  236. package/dist/types/utils/bigint.d.ts.map +1 -1
  237. package/dist/types/utils/bytes.d.ts +5 -5
  238. package/dist/types/utils/defaults.d.ts +2 -12
  239. package/dist/types/utils/defaults.d.ts.map +1 -1
  240. package/dist/types/utils/index.d.ts +66 -23
  241. package/dist/types/utils/index.d.ts.map +1 -1
  242. package/dist/types/utils/types.d.ts +2 -2
  243. package/dist/types/utils/userop.d.ts +33 -33
  244. package/dist/types/version.d.ts +1 -1
  245. package/dist/types/version.d.ts.map +1 -1
  246. package/package.json +4 -3
  247. package/src/account/smartContractAccount.ts +134 -23
  248. package/src/actions/smartAccount/buildUserOperation.ts +23 -0
  249. package/src/actions/smartAccount/buildUserOperationFromTx.ts +35 -35
  250. package/src/actions/smartAccount/buildUserOperationFromTxs.ts +44 -60
  251. package/src/actions/smartAccount/checkGasSponsorshipEligibility.ts +19 -19
  252. package/src/actions/smartAccount/dropAndReplaceUserOperation.ts +22 -0
  253. package/src/actions/smartAccount/estimateUserOperationGas.ts +3 -3
  254. package/src/actions/smartAccount/internal/initUserOperation.ts +3 -4
  255. package/src/actions/smartAccount/internal/runMiddlewareStack.ts +0 -22
  256. package/src/actions/smartAccount/internal/sendUserOperation.ts +0 -7
  257. package/src/actions/smartAccount/sendTransaction.ts +24 -0
  258. package/src/actions/smartAccount/sendTransactions.ts +23 -0
  259. package/src/actions/smartAccount/sendUserOperation.ts +17 -3
  260. package/src/actions/smartAccount/waitForUserOperationTransacation.ts +24 -0
  261. package/src/client/bundlerClient.ts +34 -2
  262. package/src/client/decorators/bundlerClient.ts +17 -8
  263. package/src/client/decorators/smartAccountClient.ts +8 -0
  264. package/src/client/isSmartAccountClient.ts +4 -4
  265. package/src/client/smartAccountClient.ts +41 -0
  266. package/src/client/types.ts +2 -15
  267. package/src/ens/utils.ts +46 -2
  268. package/src/entrypoint/index.ts +30 -62
  269. package/src/errors/account.ts +98 -4
  270. package/src/errors/base.ts +5 -2
  271. package/src/errors/client.ts +27 -0
  272. package/src/errors/entrypoint.ts +18 -0
  273. package/src/errors/signer.ts +9 -0
  274. package/src/errors/transaction.ts +16 -1
  275. package/src/errors/useroperation.ts +5 -6
  276. package/src/index.ts +3 -36
  277. package/src/logger.ts +91 -0
  278. package/src/middleware/actions.ts +6 -27
  279. package/src/middleware/defaults/feeEstimator.ts +24 -4
  280. package/src/middleware/defaults/gasEstimator.ts +9 -5
  281. package/src/middleware/defaults/paymasterAndData.ts +8 -0
  282. package/src/middleware/defaults/userOpSigner.ts +10 -0
  283. package/src/middleware/erc7677middleware.ts +201 -0
  284. package/src/middleware/noopMiddleware.ts +6 -4
  285. package/src/middleware/types.ts +16 -7
  286. package/src/signer/local-account.ts +97 -2
  287. package/src/signer/schema.ts +14 -0
  288. package/src/signer/utils.ts +20 -32
  289. package/src/signer/wallet-client.ts +92 -0
  290. package/src/transport/split.ts +2 -2
  291. package/src/utils/bigint.ts +15 -15
  292. package/src/utils/bytes.ts +5 -5
  293. package/src/utils/defaults.ts +3 -76
  294. package/src/utils/index.ts +66 -48
  295. package/src/utils/types.ts +2 -2
  296. package/src/utils/userop.ts +33 -33
  297. package/src/version.ts +1 -1
  298. package/dist/cjs/account/base.d.ts +0 -49
  299. package/dist/cjs/account/base.js +0 -257
  300. package/dist/cjs/account/base.js.map +0 -1
  301. package/dist/cjs/account/schema.d.ts +0 -100
  302. package/dist/cjs/account/schema.js +0 -43
  303. package/dist/cjs/account/schema.js.map +0 -1
  304. package/dist/cjs/account/simple.d.ts +0 -14
  305. package/dist/cjs/account/simple.js +0 -119
  306. package/dist/cjs/account/simple.js.map +0 -1
  307. package/dist/cjs/account/types.d.ts +0 -30
  308. package/dist/cjs/account/types.js +0 -3
  309. package/dist/cjs/account/types.js.map +0 -1
  310. package/dist/cjs/chains/index.d.ts +0 -20
  311. package/dist/cjs/chains/index.js +0 -169
  312. package/dist/cjs/chains/index.js.map +0 -1
  313. package/dist/esm/account/base.d.ts +0 -49
  314. package/dist/esm/account/base.js +0 -253
  315. package/dist/esm/account/base.js.map +0 -1
  316. package/dist/esm/account/schema.d.ts +0 -100
  317. package/dist/esm/account/schema.js +0 -35
  318. package/dist/esm/account/schema.js.map +0 -1
  319. package/dist/esm/account/simple.d.ts +0 -14
  320. package/dist/esm/account/simple.js +0 -115
  321. package/dist/esm/account/simple.js.map +0 -1
  322. package/dist/esm/account/types.d.ts +0 -30
  323. package/dist/esm/account/types.js +0 -2
  324. package/dist/esm/account/types.js.map +0 -1
  325. package/dist/esm/chains/index.d.ts +0 -20
  326. package/dist/esm/chains/index.js +0 -166
  327. package/dist/esm/chains/index.js.map +0 -1
  328. package/dist/types/account/base.d.ts +0 -128
  329. package/dist/types/account/base.d.ts.map +0 -1
  330. package/dist/types/account/schema.d.ts +0 -101
  331. package/dist/types/account/schema.d.ts.map +0 -1
  332. package/dist/types/account/simple.d.ts +0 -15
  333. package/dist/types/account/simple.d.ts.map +0 -1
  334. package/dist/types/account/types.d.ts +0 -144
  335. package/dist/types/account/types.d.ts.map +0 -1
  336. package/dist/types/chains/index.d.ts +0 -21
  337. package/dist/types/chains/index.d.ts.map +0 -1
  338. package/src/account/base.ts +0 -415
  339. package/src/account/schema.ts +0 -51
  340. package/src/account/simple.ts +0 -215
  341. package/src/account/types.ts +0 -184
  342. package/src/chains/index.ts +0 -194
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aa-sdk/core",
3
3
  "license": "MIT",
4
- "version": "4.0.0-alpha.0",
4
+ "version": "4.0.0-alpha.10",
5
5
  "description": "viem based SDK that enables interactions with ERC-4337 Smart Accounts. ABIs are based off the definitions generated in @account-abstraction/contracts",
6
6
  "author": "Alchemy",
7
7
  "type": "module",
@@ -37,6 +37,7 @@
37
37
  "build:cjs": "tsc --project tsconfig.build.json --module commonjs --outDir ./dist/cjs --removeComments --verbatimModuleSyntax false && echo > ./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
38
38
  "build:esm": "tsc --project tsconfig.build.json --module es2020 --outDir ./dist/esm --removeComments && echo > ./dist/esm/package.json '{\"type\":\"module\"}'",
39
39
  "build:types": "tsc --project tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
40
+ "docs:gen": "npx ak-docgen generate --in ./src/index.ts --out ../../site/pages/reference/aa-sdk/core",
40
41
  "clean": "rm -rf ./dist",
41
42
  "test": "vitest",
42
43
  "test:run": "vitest run",
@@ -47,7 +48,7 @@
47
48
  "ts-node": "^10.9.1",
48
49
  "typescript": "^5.0.4",
49
50
  "typescript-template": "*",
50
- "vitest": "^0.31.0"
51
+ "vitest": "^2.0.4"
51
52
  },
52
53
  "dependencies": {
53
54
  "abitype": "^0.8.3",
@@ -66,5 +67,5 @@
66
67
  "url": "https://github.com/alchemyplatform/aa-sdk/issues"
67
68
  },
68
69
  "homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
69
- "gitHead": "bd1788c2bd7f28ba762a06c649f30b544f8bade9"
70
+ "gitHead": "e3446b95cdee38c248f336857b24f78a32694076"
70
71
  }
@@ -34,7 +34,6 @@ import type { SmartAccountSigner } from "../signer/types.js";
34
34
  import { wrapSignatureWith6492 } from "../signer/utils.js";
35
35
  import type { NullAddress } from "../types.js";
36
36
  import type { IsUndefined } from "../utils/types.js";
37
- import { DeploymentState } from "./base.js";
38
37
 
39
38
  export type AccountOp = {
40
39
  target: Address;
@@ -42,6 +41,12 @@ export type AccountOp = {
42
41
  data: Hex | "0x";
43
42
  };
44
43
 
44
+ export enum DeploymentState {
45
+ UNDEFINED = "0x0",
46
+ NOT_DEPLOYED = "0x1",
47
+ DEPLOYED = "0x2",
48
+ }
49
+
45
50
  export type GetEntryPointFromAccount<
46
51
  TAccount extends SmartContractAccount | undefined,
47
52
  TAccountOverride extends SmartContractAccount = SmartContractAccount
@@ -74,6 +79,21 @@ export type SmartContractAccountWithSigner<
74
79
  getSigner: () => TSigner;
75
80
  };
76
81
 
82
+ /**
83
+ * Determines if the given SmartContractAccount has a signer associated with it.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * import { toSmartContractAccount } from "@aa-sdk/core";
88
+ *
89
+ * const account = await toSmartContractAccount(...);
90
+ *
91
+ * console.log(isSmartAccountWithSigner(account)); // false: the base account does not have a publicly accessible signer
92
+ * ```
93
+ *
94
+ * @param {SmartContractAccount} account The account to check.
95
+ * @returns {boolean} true if the account has a signer, otherwise false.
96
+ */
77
97
  export const isSmartAccountWithSigner = (
78
98
  account: SmartContractAccount
79
99
  ): account is SmartContractAccountWithSigner => {
@@ -138,6 +158,19 @@ export type ToSmartContractAccountParams<
138
158
  } & Omit<CustomSource, "signTransaction" | "address">;
139
159
  // [!endregion ToSmartContractAccountParams]
140
160
 
161
+ /**
162
+ * Parses the factory address and factory calldata from the provided account initialization code (initCode).
163
+ *
164
+ * @example
165
+ * ```ts
166
+ * import { parseFactoryAddressFromAccountInitCode } from "@aa-sdk/core";
167
+ *
168
+ * const [address, calldata] = parseFactoryAddressFromAccountInitCode("0xAddressCalldata");
169
+ * ```
170
+ *
171
+ * @param {Hex} initCode The initialization code from which to parse the factory address and calldata
172
+ * @returns {[Address, Hex]} A tuple containing the parsed factory address and factory calldata
173
+ */
141
174
  export const parseFactoryAddressFromAccountInitCode = (
142
175
  initCode: Hex
143
176
  ): [Address, Hex] => {
@@ -146,17 +179,40 @@ export const parseFactoryAddressFromAccountInitCode = (
146
179
  return [factoryAddress, factoryCalldata];
147
180
  };
148
181
 
182
+ export type GetAccountAddressParams = {
183
+ client: PublicClient;
184
+ entryPoint: EntryPointDef;
185
+ accountAddress?: Address;
186
+ getAccountInitCode: () => Promise<Hex>;
187
+ };
188
+
189
+ /**
190
+ * Retrieves the account address. Uses a provided `accountAddress` if available; otherwise, it computes the address using the entry point contract and the initial code.
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * import { getEntryPoint, getAccountAddress } from "@aa-sdk/core";
195
+ *
196
+ * const accountAddress = await getAccountAddress({
197
+ * client,
198
+ * entryPoint: getEntryPoint(chain),
199
+ * getAccountInitCode: async () => "0x{factoryAddress}{factoryCallData}",
200
+ * });
201
+ * ```
202
+ *
203
+ * @param {GetAccountAddressParams} params The configuration object
204
+ * @param {PublicClient} params.client A public client instance to interact with the blockchain
205
+ * @param {EntryPointDef} params.entryPoint The entry point definition which includes the address and ABI
206
+ * @param {Address} params.accountAddress Optional existing account address
207
+ * @param {() => Promise<Hex>} params.getAccountInitCode A function that returns a Promise resolving to a Hex string representing the initial code of the account
208
+ * @returns {Promise<Address>} A promise that resolves to the account address
209
+ */
149
210
  export const getAccountAddress = async ({
150
211
  client,
151
212
  entryPoint,
152
213
  accountAddress,
153
214
  getAccountInitCode,
154
- }: {
155
- client: PublicClient;
156
- entryPoint: EntryPointDef;
157
- accountAddress?: Address;
158
- getAccountInitCode: () => Promise<Hex>;
159
- }) => {
215
+ }: GetAccountAddressParams) => {
160
216
  if (accountAddress) return accountAddress;
161
217
 
162
218
  const entryPointContract = getContract({
@@ -220,21 +276,77 @@ export async function toSmartContractAccount<
220
276
  >): Promise<SmartContractAccount<Name, TEntryPointVersion>>;
221
277
  // [!endregion toSmartContractAccount]
222
278
 
223
- export async function toSmartContractAccount({
224
- transport,
225
- chain,
226
- entryPoint,
227
- source,
228
- accountAddress,
229
- getAccountInitCode,
230
- signMessage,
231
- signTypedData,
232
- encodeBatchExecute,
233
- encodeExecute,
234
- getDummySignature,
235
- signUserOperationHash,
236
- encodeUpgradeToAndCall,
237
- }: ToSmartContractAccountParams): Promise<SmartContractAccount> {
279
+ /**
280
+ * Converts an account to a smart contract account and sets up various account-related methods using the provided parameters like transport, chain, entry point, and other utilities.
281
+ *
282
+ * @example
283
+ * ```ts
284
+ * import { http, type SignableMessage } from "viem";
285
+ * import { sepolia } from "viem/chains";
286
+ *
287
+ * const myAccount = await toSmartContractAccount({
288
+ * /// REQUIRED PARAMS ///
289
+ * source: "MyAccount",
290
+ * transport: http("RPC_URL"),
291
+ * chain: sepolia,
292
+ * // The EntryPointDef that your account is com"patible with
293
+ * entryPoint: getEntryPoint(sepolia, { version: "0.6.0" }),
294
+ * // This should return a concatenation of your `factoryAddress` and the `callData` for your factory's create account method
295
+ * getAccountInitCode: async () => "0x{factoryAddress}{callData}",
296
+ * // an invalid signature that doesn't cause your account to revert during validation
297
+ * getDummySignature: () => "0x1234...",
298
+ * // given a UO in the form of {target, data, value} should output the calldata for calling your contract's execution method
299
+ * encodeExecute: async (uo) => "0xcalldata",
300
+ * signMessage: async ({ message }: { message: SignableMessage }) => "0x...",
301
+ * signTypedData: async (typedData) => "0x000",
302
+ *
303
+ * /// OPTIONAL PARAMS ///
304
+ * // if you already know your account's address, pass that in here to avoid generating a new counterfactual
305
+ * accountAddress: "0xaddressoverride",
306
+ * // if your account supports batching, this should take an array of UOs and return the calldata for calling your contract's batchExecute method
307
+ * encodeBatchExecute: async (uos) => "0x...",
308
+ * // if your contract expects a different signing scheme than the default signMessage scheme, you can override that here
309
+ * signUserOperationHash: async (hash) => "0x...",
310
+ * // allows you to define the calldata for upgrading your account
311
+ * encodeUpgradeToAndCall: async (params) => "0x...",
312
+ * });
313
+ * ```
314
+ *
315
+ * @param {ToSmartContractAccountParams} params the parameters required for converting to a smart contract account
316
+ * @param {Transport} params.transport the transport mechanism used for communication
317
+ * @param {Chain} params.chain the blockchain chain used in the account
318
+ * @param {EntryPoint} params.entryPoint the entry point of the smart contract
319
+ * @param {string} params.source the source identifier for the account
320
+ * @param {Address} [params.accountAddress] the address of the account
321
+ * @param {() => Promise<Hex>} params.getAccountInitCode a function to get the initial state code of the account
322
+ * @param {(message: { message: SignableMessage }) => Promise<Hex>} params.signMessage a function to sign a message
323
+ * @param {(typedDataDefinition: TypedDataDefinition<typedData, primaryType>) => Promise<Hex>} params.signTypedData a function to sign typed data
324
+ * @param {(transactions: Transaction[]) => Hex} [params.encodeBatchExecute] a function to encode batch transactions
325
+ * @param {(tx: Transaction) => Hex} params.encodeExecute a function to encode a single transaction
326
+ * @param {() => Promise<Hex>} params.getDummySignature a function to get a dummy signature
327
+ * @param {(uoHash: Hex) => Promise<Hex>} [params.signUserOperationHash] a function to sign user operations
328
+ * @param {(implementationAddress: Address, implementationCallData: Hex) => Hex} [params.encodeUpgradeToAndCall] a function to encode upgrade call
329
+ * @returns {Promise<SmartContractAccount>} a promise that resolves to a SmartContractAccount object with methods and properties for interacting with the smart contract account
330
+ */
331
+ export async function toSmartContractAccount(
332
+ params: ToSmartContractAccountParams
333
+ ): Promise<SmartContractAccount> {
334
+ const {
335
+ transport,
336
+ chain,
337
+ entryPoint,
338
+ source,
339
+ accountAddress,
340
+ getAccountInitCode,
341
+ signMessage,
342
+ signTypedData,
343
+ encodeBatchExecute,
344
+ encodeExecute,
345
+ getDummySignature,
346
+ signUserOperationHash,
347
+ encodeUpgradeToAndCall,
348
+ } = params;
349
+
238
350
  const client = createBundlerClient({
239
351
  // we set the retry count to 0 so that viem doesn't retry during
240
352
  // getting the address. That call always reverts and without this
@@ -262,7 +374,6 @@ export async function toSmartContractAccount({
262
374
  if (deploymentState === DeploymentState.DEPLOYED) {
263
375
  return "0x";
264
376
  }
265
-
266
377
  const contractCode = await client.getBytecode({
267
378
  address: accountAddress_,
268
379
  });
@@ -14,6 +14,29 @@ import type {
14
14
  UserOperationContext,
15
15
  } from "./types";
16
16
 
17
+ /**
18
+ * Builds a user operation using the provided client and operation parameters. Ensures that the account exists and the client is compatible.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { createSmartAccountClient } from "@aa-sdk/core";
23
+ *
24
+ * // smart account client is already extended with buildUserOperation
25
+ * const client = createSmartAccountClient(...);
26
+ * const result = await client.buildUserOperation({
27
+ * uo: {
28
+ * target: "0x...",
29
+ * data: "0x...", // or "0x",
30
+ * value: 0n, // optional
31
+ * },
32
+ * account, // only required if the client above is not connected to an account
33
+ * });
34
+ * ```
35
+ *
36
+ * @param {Client<TTransport, TChain, TAccount>} client the client instance used to build the user operation
37
+ * @param {BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>} args the parameters required to build the user operation, including account, overrides, and context
38
+ * @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a promise that resolves to a `UserOperationStruct` object containing the built user operation details
39
+ */
17
40
  export async function buildUserOperation<
18
41
  TTransport extends Transport = Transport,
19
42
  TChain extends Chain | undefined = Chain | undefined,
@@ -20,43 +20,43 @@ import { buildUserOperation } from "./buildUserOperation.js";
20
20
  import type { UserOperationContext } from "./types.js";
21
21
 
22
22
  /**
23
- * Performs [`buildUserOperationFromTx`](./buildUserOperationFromTx.md) in batch and builds into a single, yet to be signed `UserOperation` (UO) struct. The output user operation struct will be filled with all gas fields (and paymaster data if a paymaster is used) based on the transactions data (`to`, `data`, `value`, `maxFeePerGas`, `maxPriorityFeePerGas`) computed using the configured [`ClientMiddlewares`](/packages/aa-core/smart-account-client/middleware/index) on the `SmartAccountClient`
24
- *
23
+ * Performs `buildUserOperationFromTx` in batch and builds into a single, yet to be signed `UserOperation` (UO) struct. The output user operation struct will be filled with all gas fields (and paymaster data if a paymaster is used) based on the transactions data (`to`, `data`, `value`, `maxFeePerGas`, `maxPriorityFeePerGas`) computed using the configured `ClientMiddlewares` on the `SmartAccountClient`
24
+ *
25
25
  * @example
26
26
  * ```ts
27
- import type { RpcTransactionRequest } from "viem";
28
- import { smartAccountClient } from "./smartAccountClient";
29
- // [!code focus:99]
30
- // buildUserOperationFromTx converts a traditional Ethereum transaction and returns
31
- // the unsigned user operation struct after constructing the user operation struct
32
- // through the middleware pipeline
33
- const tx: RpcTransactionRequest = {
34
- from, // ignored
35
- to,
36
- data: encodeFunctionData({
37
- abi: ContractABI.abi,
38
- functionName: "func",
39
- args: [arg1, arg2, ...],
40
- }),
41
- };
42
- const uoStruct = await smartAccountClient.buildUserOperationFromTx(tx);
43
-
44
- // signUserOperation signs the above unsigned user operation struct built
45
- // using the account connected to the smart account client
46
- const request = await smartAccountClient.signUserOperation({ uoStruct });
47
-
48
- // You can use the BundlerAction `sendRawUserOperation` (packages/core/src/actions/bundler/sendRawUserOperation.ts)
49
- // to send the signed user operation request to the bundler, requesting the bundler to send the signed uo to the
50
- // EntryPoint contract pointed at by the entryPoint address parameter
51
- const entryPointAddress = client.account.getEntryPoint().address;
52
- const uoHash = await smartAccountClient.sendRawUserOperation({ request, entryPoint: entryPointAddress });
53
- ```
54
- *
55
- * @param client the smart account client to use for RPC requests
56
- * @param args {@link SendTransactionParameters}
57
- * @param overrides optional {@link UserOperationOverrides} to use for any of the fields
58
- * @param context if the smart account client requires additinoal context for building UOs
59
- * @returns a Promise containing the built user operation
27
+ * import type { RpcTransactionRequest } from "viem";
28
+ * import { smartAccountClient } from "./smartAccountClient";
29
+ * // [!code focus:99]
30
+ * // buildUserOperationFromTx converts a traditional Ethereum transaction and returns
31
+ * // the unsigned user operation struct after constructing the user operation struct
32
+ * // through the middleware pipeline
33
+ * const tx: RpcTransactionRequest = {
34
+ * from, // ignored
35
+ * to,
36
+ * data: encodeFunctionData({
37
+ * abi: ContractABI.abi,
38
+ * functionName: "func",
39
+ * args: [arg1, arg2, ...],
40
+ * }),
41
+ * };
42
+ * const uoStruct = await smartAccountClient.buildUserOperationFromTx(tx);
43
+ *
44
+ * // signUserOperation signs the above unsigned user operation struct built
45
+ * // using the account connected to the smart account client
46
+ * const request = await smartAccountClient.signUserOperation({ uoStruct });
47
+ *
48
+ * // You can use the BundlerAction `sendRawUserOperation` (packages/core/src/actions/bundler/sendRawUserOperation.ts)
49
+ * // to send the signed user operation request to the bundler, requesting the bundler to send the signed uo to the
50
+ * // EntryPoint contract pointed at by the entryPoint address parameter
51
+ * const entryPointAddress = client.account.getEntryPoint().address;
52
+ * const uoHash = await smartAccountClient.sendRawUserOperation({ request, entryPoint: entryPointAddress });
53
+ * ```
54
+ *
55
+ * @param {Client<Transport, TChain, TAccount>} client the smart account client to use for RPC requests
56
+ * @param {SendTransactionParameters} args the send tx parameters
57
+ * @param {UserOperationOverrides} overrides optional overrides to use for any of the fields
58
+ * @param {TContext} context if the smart account client requires additinoal context for building UOs
59
+ * @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a Promise containing the built user operation
60
60
  */
61
61
  export async function buildUserOperationFromTx<
62
62
  TChain extends Chain | undefined = Chain | undefined,
@@ -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,
@@ -20,6 +20,28 @@ import type {
20
20
  UserOperationContext,
21
21
  } from "./types";
22
22
 
23
+ /**
24
+ * Drops an existing user operation and replaces it with a new one while ensuring the appropriate fees and overrides are applied.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import {
29
+ * createSmartAccountClient,
30
+ * } from "@aa-sdk/core";
31
+ *
32
+ * // smart account client is already extended with dropAndReplaceUserOperation
33
+ * const client = createSmartAccountClient(...);
34
+ * const { request } = await client.sendUserOperation(...);
35
+ * const result = await client.dropAndReplaceUserOperation({
36
+ * uoToDrop: request,
37
+ * account, // only required if the client above is not connected to an account
38
+ * });
39
+ * ```
40
+ *
41
+ * @param {Client<TTransport, TChain, TAccount>} client The client instance with the transport, chain, and account information
42
+ * @param {DropAndReplaceUserOperationParameters<TAccount, TContext>} args The parameters required for dropping and replacing the user operation including the account, operation to drop, overrides, and context
43
+ * @returns {Promise<SendUserOperationResult<TEntryPointVersion>>} A promise that resolves to the result of sending the new user operation
44
+ */
23
45
  export async function dropAndReplaceUserOperation<
24
46
  TTransport extends Transport = Transport,
25
47
  TChain extends Chain | undefined = Chain | undefined,
@@ -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,