@aa-sdk/core 4.0.0-alpha.9 → 4.0.0-beta.0

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 (416) hide show
  1. package/dist/esm/abis/EntryPointAbi_v7.js +1 -0
  2. package/dist/esm/abis/EntryPointAbi_v7.js.map +1 -1
  3. package/dist/esm/account/smartContractAccount.d.ts +50 -1
  4. package/dist/esm/account/smartContractAccount.js +111 -2
  5. package/dist/esm/account/smartContractAccount.js.map +1 -1
  6. package/dist/esm/actions/smartAccount/buildUserOperation.d.ts +23 -0
  7. package/dist/esm/actions/smartAccount/buildUserOperation.js +23 -0
  8. package/dist/esm/actions/smartAccount/buildUserOperation.js.map +1 -1
  9. package/dist/esm/actions/smartAccount/buildUserOperationFromTx.d.ts +39 -0
  10. package/dist/esm/actions/smartAccount/buildUserOperationFromTx.js +39 -0
  11. package/dist/esm/actions/smartAccount/buildUserOperationFromTx.js.map +1 -1
  12. package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.d.ts +54 -0
  13. package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.js +55 -0
  14. package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.js.map +1 -1
  15. package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.d.ts +28 -0
  16. package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.js +28 -0
  17. package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
  18. package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.d.ts +22 -0
  19. package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.js +27 -6
  20. package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.js.map +1 -1
  21. package/dist/esm/actions/smartAccount/estimateUserOperationGas.d.ts +13 -0
  22. package/dist/esm/actions/smartAccount/estimateUserOperationGas.js +13 -0
  23. package/dist/esm/actions/smartAccount/estimateUserOperationGas.js.map +1 -1
  24. package/dist/esm/actions/smartAccount/internal/initUserOperation.d.ts +13 -0
  25. package/dist/esm/actions/smartAccount/internal/initUserOperation.js +14 -1
  26. package/dist/esm/actions/smartAccount/internal/initUserOperation.js.map +1 -1
  27. package/dist/esm/actions/smartAccount/internal/runMiddlewareStack.js +2 -1
  28. package/dist/esm/actions/smartAccount/internal/runMiddlewareStack.js.map +1 -1
  29. package/dist/esm/actions/smartAccount/sendTransaction.d.ts +24 -0
  30. package/dist/esm/actions/smartAccount/sendTransaction.js +24 -0
  31. package/dist/esm/actions/smartAccount/sendTransaction.js.map +1 -1
  32. package/dist/esm/actions/smartAccount/sendTransactions.d.ts +23 -0
  33. package/dist/esm/actions/smartAccount/sendTransactions.js +23 -0
  34. package/dist/esm/actions/smartAccount/sendTransactions.js.map +1 -1
  35. package/dist/esm/actions/smartAccount/sendUserOperation.d.ts +21 -0
  36. package/dist/esm/actions/smartAccount/sendUserOperation.js +21 -0
  37. package/dist/esm/actions/smartAccount/sendUserOperation.js.map +1 -1
  38. package/dist/esm/actions/smartAccount/types.d.ts +14 -0
  39. package/dist/esm/actions/smartAccount/types.js +1 -0
  40. package/dist/esm/actions/smartAccount/types.js.map +1 -1
  41. package/dist/esm/actions/smartAccount/waitForUserOperationTransacation.d.ts +24 -0
  42. package/dist/esm/actions/smartAccount/waitForUserOperationTransacation.js +24 -0
  43. package/dist/esm/actions/smartAccount/waitForUserOperationTransacation.js.map +1 -1
  44. package/dist/esm/client/bundlerClient.d.ts +21 -0
  45. package/dist/esm/client/bundlerClient.js +32 -0
  46. package/dist/esm/client/bundlerClient.js.map +1 -1
  47. package/dist/esm/client/decorators/bundlerClient.d.ts +41 -0
  48. package/dist/esm/client/decorators/bundlerClient.js +10 -0
  49. package/dist/esm/client/decorators/bundlerClient.js.map +1 -1
  50. package/dist/esm/client/decorators/smartAccountClient.d.ts +8 -0
  51. package/dist/esm/client/decorators/smartAccountClient.js +12 -1
  52. package/dist/esm/client/decorators/smartAccountClient.js.map +1 -1
  53. package/dist/esm/client/isSmartAccountClient.d.ts +16 -0
  54. package/dist/esm/client/isSmartAccountClient.js +16 -0
  55. package/dist/esm/client/isSmartAccountClient.js.map +1 -1
  56. package/dist/esm/client/schema.d.ts +12 -0
  57. package/dist/esm/client/schema.js +14 -0
  58. package/dist/esm/client/schema.js.map +1 -1
  59. package/dist/esm/client/smartAccountClient.js +53 -0
  60. package/dist/esm/client/smartAccountClient.js.map +1 -1
  61. package/dist/esm/client/types.js +1 -0
  62. package/dist/esm/client/types.js.map +1 -1
  63. package/dist/esm/ens/utils.d.ts +45 -0
  64. package/dist/esm/ens/utils.js +49 -0
  65. package/dist/esm/ens/utils.js.map +1 -1
  66. package/dist/esm/entrypoint/index.d.ts +14 -0
  67. package/dist/esm/entrypoint/index.js +30 -0
  68. package/dist/esm/entrypoint/index.js.map +1 -1
  69. package/dist/esm/entrypoint/types.d.ts +17 -0
  70. package/dist/esm/errors/account.d.ts +87 -4
  71. package/dist/esm/errors/account.js +88 -4
  72. package/dist/esm/errors/account.js.map +1 -1
  73. package/dist/esm/errors/base.d.ts +5 -0
  74. package/dist/esm/errors/base.js +5 -0
  75. package/dist/esm/errors/base.js.map +1 -1
  76. package/dist/esm/errors/client.d.ts +24 -0
  77. package/dist/esm/errors/client.js +24 -0
  78. package/dist/esm/errors/client.js.map +1 -1
  79. package/dist/esm/errors/entrypoint.d.ts +18 -0
  80. package/dist/esm/errors/entrypoint.js +18 -0
  81. package/dist/esm/errors/entrypoint.js.map +1 -1
  82. package/dist/esm/errors/signer.d.ts +8 -0
  83. package/dist/esm/errors/signer.js +8 -0
  84. package/dist/esm/errors/signer.js.map +1 -1
  85. package/dist/esm/errors/transaction.d.ts +14 -1
  86. package/dist/esm/errors/transaction.js +14 -1
  87. package/dist/esm/errors/transaction.js.map +1 -1
  88. package/dist/esm/errors/useroperation.d.ts +25 -0
  89. package/dist/esm/errors/useroperation.js +26 -0
  90. package/dist/esm/errors/useroperation.js.map +1 -1
  91. package/dist/esm/index.d.ts +0 -1
  92. package/dist/esm/index.js +0 -1
  93. package/dist/esm/index.js.map +1 -1
  94. package/dist/esm/logger.d.ts +91 -0
  95. package/dist/esm/logger.js +91 -0
  96. package/dist/esm/logger.js.map +1 -1
  97. package/dist/esm/middleware/actions.d.ts +14 -0
  98. package/dist/esm/middleware/actions.js +7 -0
  99. package/dist/esm/middleware/actions.js.map +1 -1
  100. package/dist/esm/middleware/defaults/feeEstimator.d.ts +20 -0
  101. package/dist/esm/middleware/defaults/feeEstimator.js +28 -0
  102. package/dist/esm/middleware/defaults/feeEstimator.js.map +1 -1
  103. package/dist/esm/middleware/defaults/gasEstimator.d.ts +8 -0
  104. package/dist/esm/middleware/defaults/gasEstimator.js +8 -0
  105. package/dist/esm/middleware/defaults/gasEstimator.js.map +1 -1
  106. package/dist/esm/middleware/defaults/paymasterAndData.d.ts +8 -0
  107. package/dist/esm/middleware/defaults/paymasterAndData.js +8 -0
  108. package/dist/esm/middleware/defaults/paymasterAndData.js.map +1 -1
  109. package/dist/esm/middleware/defaults/userOpSigner.d.ts +10 -0
  110. package/dist/esm/middleware/defaults/userOpSigner.js +10 -0
  111. package/dist/esm/middleware/defaults/userOpSigner.js.map +1 -1
  112. package/dist/esm/middleware/erc7677middleware.d.ts +21 -0
  113. package/dist/esm/middleware/erc7677middleware.js +23 -0
  114. package/dist/esm/middleware/erc7677middleware.js.map +1 -1
  115. package/dist/esm/middleware/noopMiddleware.d.ts +6 -0
  116. package/dist/esm/middleware/noopMiddleware.js +6 -0
  117. package/dist/esm/middleware/noopMiddleware.js.map +1 -1
  118. package/dist/esm/middleware/types.js +1 -0
  119. package/dist/esm/middleware/types.js.map +1 -1
  120. package/dist/esm/signer/local-account.d.ts +96 -1
  121. package/dist/esm/signer/local-account.js +97 -2
  122. package/dist/esm/signer/local-account.js.map +1 -1
  123. package/dist/esm/signer/schema.d.ts +14 -0
  124. package/dist/esm/signer/schema.js +14 -0
  125. package/dist/esm/signer/schema.js.map +1 -1
  126. package/dist/esm/signer/types.d.ts +12 -0
  127. package/dist/esm/signer/types.js +1 -0
  128. package/dist/esm/signer/types.js.map +1 -1
  129. package/dist/esm/signer/utils.d.ts +20 -0
  130. package/dist/esm/signer/utils.js +27 -0
  131. package/dist/esm/signer/utils.js.map +1 -1
  132. package/dist/esm/signer/wallet-client.d.ts +92 -0
  133. package/dist/esm/signer/wallet-client.js +92 -0
  134. package/dist/esm/signer/wallet-client.js.map +1 -1
  135. package/dist/esm/transport/split.d.ts +32 -0
  136. package/dist/esm/transport/split.js +32 -0
  137. package/dist/esm/transport/split.js.map +1 -1
  138. package/dist/esm/types.d.ts +17 -0
  139. package/dist/esm/types.js +1 -0
  140. package/dist/esm/types.js.map +1 -1
  141. package/dist/esm/utils/bigint.d.ts +45 -0
  142. package/dist/esm/utils/bigint.js +46 -0
  143. package/dist/esm/utils/bigint.js.map +1 -1
  144. package/dist/esm/utils/bytes.d.ts +9 -0
  145. package/dist/esm/utils/bytes.js +10 -1
  146. package/dist/esm/utils/bytes.js.map +1 -1
  147. package/dist/esm/utils/index.d.ts +86 -0
  148. package/dist/esm/utils/index.js +86 -0
  149. package/dist/esm/utils/index.js.map +1 -1
  150. package/dist/esm/utils/schema.d.ts +3 -0
  151. package/dist/esm/utils/schema.js +9 -0
  152. package/dist/esm/utils/schema.js.map +1 -1
  153. package/dist/esm/utils/stateOverride.js +2 -0
  154. package/dist/esm/utils/stateOverride.js.map +1 -1
  155. package/dist/esm/utils/types.d.ts +22 -0
  156. package/dist/esm/utils/types.js +1 -0
  157. package/dist/esm/utils/types.js.map +1 -1
  158. package/dist/esm/utils/userop.d.ts +79 -0
  159. package/dist/esm/utils/userop.js +83 -0
  160. package/dist/esm/utils/userop.js.map +1 -1
  161. package/dist/esm/version.d.ts +1 -1
  162. package/dist/esm/version.js +3 -1
  163. package/dist/esm/version.js.map +1 -1
  164. package/dist/types/account/smartContractAccount.d.ts +1 -1
  165. package/dist/types/account/smartContractAccount.d.ts.map +1 -1
  166. package/dist/types/actions/smartAccount/dropAndReplaceUserOperation.d.ts.map +1 -1
  167. package/dist/types/client/smartAccountClient.d.ts.map +1 -1
  168. package/dist/types/index.d.ts +0 -1
  169. package/dist/types/index.d.ts.map +1 -1
  170. package/dist/types/transport/split.d.ts +1 -1
  171. package/dist/types/version.d.ts +1 -1
  172. package/dist/types/version.d.ts.map +1 -1
  173. package/package.json +10 -11
  174. package/src/account/smartContractAccount.ts +3 -3
  175. package/src/actions/smartAccount/dropAndReplaceUserOperation.ts +10 -10
  176. package/src/actions/smartAccount/internal/initUserOperation.ts +1 -1
  177. package/src/client/smartAccountClient.ts +7 -0
  178. package/src/index.ts +0 -1
  179. package/src/transport/split.ts +1 -1
  180. package/src/version.ts +1 -1
  181. package/dist/cjs/abis/EntryPointAbi_v6.d.ts +0 -1018
  182. package/dist/cjs/abis/EntryPointAbi_v6.js +0 -1313
  183. package/dist/cjs/abis/EntryPointAbi_v6.js.map +0 -1
  184. package/dist/cjs/abis/EntryPointAbi_v7.d.ts +0 -775
  185. package/dist/cjs/abis/EntryPointAbi_v7.js +0 -661
  186. package/dist/cjs/abis/EntryPointAbi_v7.js.map +0 -1
  187. package/dist/cjs/abis/SimpleAccountAbi_v6.d.ts +0 -405
  188. package/dist/cjs/abis/SimpleAccountAbi_v6.js +0 -528
  189. package/dist/cjs/abis/SimpleAccountAbi_v6.js.map +0 -1
  190. package/dist/cjs/abis/SimpleAccountAbi_v7.d.ts +0 -410
  191. package/dist/cjs/abis/SimpleAccountAbi_v7.js +0 -538
  192. package/dist/cjs/abis/SimpleAccountAbi_v7.js.map +0 -1
  193. package/dist/cjs/abis/SimpleAccountFactoryAbi.d.ts +0 -55
  194. package/dist/cjs/abis/SimpleAccountFactoryAbi.js +0 -78
  195. package/dist/cjs/abis/SimpleAccountFactoryAbi.js.map +0 -1
  196. package/dist/cjs/account/smartContractAccount.d.ts +0 -74
  197. package/dist/cjs/account/smartContractAccount.js +0 -180
  198. package/dist/cjs/account/smartContractAccount.js.map +0 -1
  199. package/dist/cjs/actions/bundler/estimateUserOperationGas.d.ts +0 -8
  200. package/dist/cjs/actions/bundler/estimateUserOperationGas.js +0 -18
  201. package/dist/cjs/actions/bundler/estimateUserOperationGas.js.map +0 -1
  202. package/dist/cjs/actions/bundler/getSupportedEntryPoints.d.ts +0 -3
  203. package/dist/cjs/actions/bundler/getSupportedEntryPoints.js +0 -11
  204. package/dist/cjs/actions/bundler/getSupportedEntryPoints.js.map +0 -1
  205. package/dist/cjs/actions/bundler/getUserOperationByHash.d.ts +0 -6
  206. package/dist/cjs/actions/bundler/getUserOperationByHash.js +0 -11
  207. package/dist/cjs/actions/bundler/getUserOperationByHash.js.map +0 -1
  208. package/dist/cjs/actions/bundler/getUserOperationReceipt.d.ts +0 -6
  209. package/dist/cjs/actions/bundler/getUserOperationReceipt.js +0 -11
  210. package/dist/cjs/actions/bundler/getUserOperationReceipt.js.map +0 -1
  211. package/dist/cjs/actions/bundler/sendRawUserOperation.d.ts +0 -7
  212. package/dist/cjs/actions/bundler/sendRawUserOperation.js +0 -11
  213. package/dist/cjs/actions/bundler/sendRawUserOperation.js.map +0 -1
  214. package/dist/cjs/actions/smartAccount/buildUserOperation.d.ts +0 -5
  215. package/dist/cjs/actions/smartAccount/buildUserOperation.js +0 -25
  216. package/dist/cjs/actions/smartAccount/buildUserOperation.js.map +0 -1
  217. package/dist/cjs/actions/smartAccount/buildUserOperationFromTx.d.ts +0 -5
  218. package/dist/cjs/actions/smartAccount/buildUserOperationFromTx.js +0 -39
  219. package/dist/cjs/actions/smartAccount/buildUserOperationFromTx.js.map +0 -1
  220. package/dist/cjs/actions/smartAccount/buildUserOperationFromTxs.d.ts +0 -4
  221. package/dist/cjs/actions/smartAccount/buildUserOperationFromTxs.js +0 -62
  222. package/dist/cjs/actions/smartAccount/buildUserOperationFromTxs.js.map +0 -1
  223. package/dist/cjs/actions/smartAccount/checkGasSponsorshipEligibility.d.ts +0 -4
  224. package/dist/cjs/actions/smartAccount/checkGasSponsorshipEligibility.js +0 -34
  225. package/dist/cjs/actions/smartAccount/checkGasSponsorshipEligibility.js.map +0 -1
  226. package/dist/cjs/actions/smartAccount/dropAndReplaceUserOperation.d.ts +0 -5
  227. package/dist/cjs/actions/smartAccount/dropAndReplaceUserOperation.js +0 -64
  228. package/dist/cjs/actions/smartAccount/dropAndReplaceUserOperation.js.map +0 -1
  229. package/dist/cjs/actions/smartAccount/estimateUserOperationGas.d.ts +0 -5
  230. package/dist/cjs/actions/smartAccount/estimateUserOperationGas.js +0 -23
  231. package/dist/cjs/actions/smartAccount/estimateUserOperationGas.js.map +0 -1
  232. package/dist/cjs/actions/smartAccount/getAddress.d.ts +0 -4
  233. package/dist/cjs/actions/smartAccount/getAddress.js +0 -13
  234. package/dist/cjs/actions/smartAccount/getAddress.js.map +0 -1
  235. package/dist/cjs/actions/smartAccount/internal/initUserOperation.d.ts +0 -7
  236. package/dist/cjs/actions/smartAccount/internal/initUserOperation.js +0 -42
  237. package/dist/cjs/actions/smartAccount/internal/initUserOperation.js.map +0 -1
  238. package/dist/cjs/actions/smartAccount/internal/runMiddlewareStack.d.ts +0 -10
  239. package/dist/cjs/actions/smartAccount/internal/runMiddlewareStack.js +0 -47
  240. package/dist/cjs/actions/smartAccount/internal/runMiddlewareStack.js.map +0 -1
  241. package/dist/cjs/actions/smartAccount/internal/sendUserOperation.d.ts +0 -10
  242. package/dist/cjs/actions/smartAccount/internal/sendUserOperation.js +0 -28
  243. package/dist/cjs/actions/smartAccount/internal/sendUserOperation.js.map +0 -1
  244. package/dist/cjs/actions/smartAccount/sendTransaction.d.ts +0 -5
  245. package/dist/cjs/actions/smartAccount/sendTransaction.js +0 -35
  246. package/dist/cjs/actions/smartAccount/sendTransaction.js.map +0 -1
  247. package/dist/cjs/actions/smartAccount/sendTransactions.d.ts +0 -4
  248. package/dist/cjs/actions/smartAccount/sendTransactions.js +0 -36
  249. package/dist/cjs/actions/smartAccount/sendTransactions.js.map +0 -1
  250. package/dist/cjs/actions/smartAccount/sendUserOperation.d.ts +0 -5
  251. package/dist/cjs/actions/smartAccount/sendUserOperation.js +0 -31
  252. package/dist/cjs/actions/smartAccount/sendUserOperation.js.map +0 -1
  253. package/dist/cjs/actions/smartAccount/signMessage.d.ts +0 -6
  254. package/dist/cjs/actions/smartAccount/signMessage.js +0 -12
  255. package/dist/cjs/actions/smartAccount/signMessage.js.map +0 -1
  256. package/dist/cjs/actions/smartAccount/signMessageWith6492.d.ts +0 -4
  257. package/dist/cjs/actions/smartAccount/signMessageWith6492.js +0 -12
  258. package/dist/cjs/actions/smartAccount/signMessageWith6492.js.map +0 -1
  259. package/dist/cjs/actions/smartAccount/signTypedData.d.ts +0 -10
  260. package/dist/cjs/actions/smartAccount/signTypedData.js +0 -12
  261. package/dist/cjs/actions/smartAccount/signTypedData.js.map +0 -1
  262. package/dist/cjs/actions/smartAccount/signTypedDataWith6492.d.ts +0 -6
  263. package/dist/cjs/actions/smartAccount/signTypedDataWith6492.js +0 -12
  264. package/dist/cjs/actions/smartAccount/signTypedDataWith6492.js.map +0 -1
  265. package/dist/cjs/actions/smartAccount/signUserOperation.d.ts +0 -5
  266. package/dist/cjs/actions/smartAccount/signUserOperation.js +0 -30
  267. package/dist/cjs/actions/smartAccount/signUserOperation.js.map +0 -1
  268. package/dist/cjs/actions/smartAccount/types.d.ts +0 -42
  269. package/dist/cjs/actions/smartAccount/types.js +0 -3
  270. package/dist/cjs/actions/smartAccount/types.js.map +0 -1
  271. package/dist/cjs/actions/smartAccount/upgradeAccount.d.ts +0 -4
  272. package/dist/cjs/actions/smartAccount/upgradeAccount.js +0 -38
  273. package/dist/cjs/actions/smartAccount/upgradeAccount.js.map +0 -1
  274. package/dist/cjs/actions/smartAccount/waitForUserOperationTransacation.d.ts +0 -3
  275. package/dist/cjs/actions/smartAccount/waitForUserOperationTransacation.js +0 -36
  276. package/dist/cjs/actions/smartAccount/waitForUserOperationTransacation.js.map +0 -1
  277. package/dist/cjs/client/bundlerClient.d.ts +0 -10
  278. package/dist/cjs/client/bundlerClient.js +0 -51
  279. package/dist/cjs/client/bundlerClient.js.map +0 -1
  280. package/dist/cjs/client/decorators/bundlerClient.d.ts +0 -41
  281. package/dist/cjs/client/decorators/bundlerClient.js +0 -17
  282. package/dist/cjs/client/decorators/bundlerClient.js.map +0 -1
  283. package/dist/cjs/client/decorators/smartAccountClient.d.ts +0 -35
  284. package/dist/cjs/client/decorators/smartAccountClient.js +0 -43
  285. package/dist/cjs/client/decorators/smartAccountClient.js.map +0 -1
  286. package/dist/cjs/client/isSmartAccountClient.d.ts +0 -5
  287. package/dist/cjs/client/isSmartAccountClient.js +0 -18
  288. package/dist/cjs/client/isSmartAccountClient.js.map +0 -1
  289. package/dist/cjs/client/schema.d.ts +0 -767
  290. package/dist/cjs/client/schema.js +0 -63
  291. package/dist/cjs/client/schema.js.map +0 -1
  292. package/dist/cjs/client/smartAccountClient.d.ts +0 -33
  293. package/dist/cjs/client/smartAccountClient.js +0 -93
  294. package/dist/cjs/client/smartAccountClient.js.map +0 -1
  295. package/dist/cjs/client/types.d.ts +0 -21
  296. package/dist/cjs/client/types.js +0 -3
  297. package/dist/cjs/client/types.js.map +0 -1
  298. package/dist/cjs/ens/utils.d.ts +0 -6
  299. package/dist/cjs/ens/utils.js +0 -53
  300. package/dist/cjs/ens/utils.js.map +0 -1
  301. package/dist/cjs/entrypoint/0.6.d.ts +0 -1029
  302. package/dist/cjs/entrypoint/0.6.js +0 -49
  303. package/dist/cjs/entrypoint/0.6.js.map +0 -1
  304. package/dist/cjs/entrypoint/0.7.d.ts +0 -792
  305. package/dist/cjs/entrypoint/0.7.js +0 -88
  306. package/dist/cjs/entrypoint/0.7.js.map +0 -1
  307. package/dist/cjs/entrypoint/index.d.ts +0 -8
  308. package/dist/cjs/entrypoint/index.js +0 -53
  309. package/dist/cjs/entrypoint/index.js.map +0 -1
  310. package/dist/cjs/entrypoint/types.d.ts +0 -46
  311. package/dist/cjs/entrypoint/types.js +0 -3
  312. package/dist/cjs/entrypoint/types.js.map +0 -1
  313. package/dist/cjs/errors/account.d.ts +0 -47
  314. package/dist/cjs/errors/account.js +0 -140
  315. package/dist/cjs/errors/account.js.map +0 -1
  316. package/dist/cjs/errors/base.d.ts +0 -18
  317. package/dist/cjs/errors/base.js +0 -39
  318. package/dist/cjs/errors/base.js.map +0 -1
  319. package/dist/cjs/errors/client.d.ts +0 -14
  320. package/dist/cjs/errors/client.js +0 -44
  321. package/dist/cjs/errors/client.js.map +0 -1
  322. package/dist/cjs/errors/entrypoint.d.ts +0 -10
  323. package/dist/cjs/errors/entrypoint.js +0 -32
  324. package/dist/cjs/errors/entrypoint.js.map +0 -1
  325. package/dist/cjs/errors/signer.d.ts +0 -5
  326. package/dist/cjs/errors/signer.js +0 -20
  327. package/dist/cjs/errors/signer.js.map +0 -1
  328. package/dist/cjs/errors/transaction.d.ts +0 -10
  329. package/dist/cjs/errors/transaction.js +0 -29
  330. package/dist/cjs/errors/transaction.js.map +0 -1
  331. package/dist/cjs/errors/useroperation.d.ts +0 -10
  332. package/dist/cjs/errors/useroperation.js +0 -34
  333. package/dist/cjs/errors/useroperation.js.map +0 -1
  334. package/dist/cjs/index.d.ts +0 -60
  335. package/dist/cjs/index.js +0 -170
  336. package/dist/cjs/index.js.map +0 -1
  337. package/dist/cjs/logger.d.ts +0 -20
  338. package/dist/cjs/logger.js +0 -60
  339. package/dist/cjs/logger.js.map +0 -1
  340. package/dist/cjs/middleware/actions.d.ts +0 -12
  341. package/dist/cjs/middleware/actions.js +0 -21
  342. package/dist/cjs/middleware/actions.js.map +0 -1
  343. package/dist/cjs/middleware/defaults/feeEstimator.d.ts +0 -3
  344. package/dist/cjs/middleware/defaults/feeEstimator.js +0 -23
  345. package/dist/cjs/middleware/defaults/feeEstimator.js.map +0 -1
  346. package/dist/cjs/middleware/defaults/gasEstimator.d.ts +0 -3
  347. package/dist/cjs/middleware/defaults/gasEstimator.js +0 -28
  348. package/dist/cjs/middleware/defaults/gasEstimator.js.map +0 -1
  349. package/dist/cjs/middleware/defaults/paymasterAndData.d.ts +0 -2
  350. package/dist/cjs/middleware/defaults/paymasterAndData.js +0 -12
  351. package/dist/cjs/middleware/defaults/paymasterAndData.js.map +0 -1
  352. package/dist/cjs/middleware/defaults/userOpSigner.d.ts +0 -2
  353. package/dist/cjs/middleware/defaults/userOpSigner.js +0 -26
  354. package/dist/cjs/middleware/defaults/userOpSigner.js.map +0 -1
  355. package/dist/cjs/middleware/erc7677middleware.d.ts +0 -40
  356. package/dist/cjs/middleware/erc7677middleware.js +0 -77
  357. package/dist/cjs/middleware/erc7677middleware.js.map +0 -1
  358. package/dist/cjs/middleware/noopMiddleware.d.ts +0 -3
  359. package/dist/cjs/middleware/noopMiddleware.js +0 -8
  360. package/dist/cjs/middleware/noopMiddleware.js.map +0 -1
  361. package/dist/cjs/middleware/types.d.ts +0 -22
  362. package/dist/cjs/middleware/types.js +0 -3
  363. package/dist/cjs/middleware/types.js.map +0 -1
  364. package/dist/cjs/package.json +0 -1
  365. package/dist/cjs/signer/local-account.d.ts +0 -219
  366. package/dist/cjs/signer/local-account.js +0 -56
  367. package/dist/cjs/signer/local-account.js.map +0 -1
  368. package/dist/cjs/signer/schema.d.ts +0 -4
  369. package/dist/cjs/signer/schema.js +0 -16
  370. package/dist/cjs/signer/schema.js.map +0 -1
  371. package/dist/cjs/signer/types.d.ts +0 -15
  372. package/dist/cjs/signer/types.js +0 -3
  373. package/dist/cjs/signer/types.js.map +0 -1
  374. package/dist/cjs/signer/utils.d.ts +0 -7
  375. package/dist/cjs/signer/utils.js +0 -16
  376. package/dist/cjs/signer/utils.js.map +0 -1
  377. package/dist/cjs/signer/wallet-client.d.ts +0 -217
  378. package/dist/cjs/signer/wallet-client.js +0 -58
  379. package/dist/cjs/signer/wallet-client.js.map +0 -1
  380. package/dist/cjs/transport/split.d.ts +0 -9
  381. package/dist/cjs/transport/split.js +0 -26
  382. package/dist/cjs/transport/split.js.map +0 -1
  383. package/dist/cjs/types.d.ts +0 -158
  384. package/dist/cjs/types.js +0 -3
  385. package/dist/cjs/types.js.map +0 -1
  386. package/dist/cjs/utils/bigint.d.ts +0 -10
  387. package/dist/cjs/utils/bigint.js +0 -55
  388. package/dist/cjs/utils/bigint.js.map +0 -1
  389. package/dist/cjs/utils/bytes.d.ts +0 -7
  390. package/dist/cjs/utils/bytes.js +0 -11
  391. package/dist/cjs/utils/bytes.js.map +0 -1
  392. package/dist/cjs/utils/defaults.d.ts +0 -4
  393. package/dist/cjs/utils/defaults.js +0 -19
  394. package/dist/cjs/utils/defaults.js.map +0 -1
  395. package/dist/cjs/utils/index.d.ts +0 -19
  396. package/dist/cjs/utils/index.js +0 -95
  397. package/dist/cjs/utils/index.js.map +0 -1
  398. package/dist/cjs/utils/schema.d.ts +0 -25
  399. package/dist/cjs/utils/schema.js +0 -35
  400. package/dist/cjs/utils/schema.js.map +0 -1
  401. package/dist/cjs/utils/stateOverride.d.ts +0 -4
  402. package/dist/cjs/utils/stateOverride.js +0 -52
  403. package/dist/cjs/utils/stateOverride.js.map +0 -1
  404. package/dist/cjs/utils/testUtils.d.ts +0 -6
  405. package/dist/cjs/utils/testUtils.js +0 -33
  406. package/dist/cjs/utils/testUtils.js.map +0 -1
  407. package/dist/cjs/utils/types.d.ts +0 -16
  408. package/dist/cjs/utils/types.js +0 -3
  409. package/dist/cjs/utils/types.js.map +0 -1
  410. package/dist/cjs/utils/userop.d.ts +0 -49
  411. package/dist/cjs/utils/userop.js +0 -75
  412. package/dist/cjs/utils/userop.js.map +0 -1
  413. package/dist/cjs/version.d.ts +0 -1
  414. package/dist/cjs/version.js +0 -5
  415. package/dist/cjs/version.js.map +0 -1
  416. package/dist/esm/package.json +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"buildUserOperation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperation.ts"],"names":[],"mappings":"AACA,OAAO,EAGN,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AA6BvE,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAWtC,MAA4C,EAC5C,IAA0E;IAE1E,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,oBAAoB,EACpB,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CACnD,mBAAmB,CAAC,MAAM,EAAE;QAC1B,EAAE,EAAE,GAAG;QACP,SAAS;QACT,OAAO;QACP,OAAO;KACR,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport {\n type GetEntryPointFromAccount,\n type SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type { UserOperationStruct } from \"../../types.js\";\nimport { _initUserOperation } from \"./internal/initUserOperation.js\";\nimport { _runMiddlewareStack } from \"./internal/runMiddlewareStack.js\";\nimport type {\n BuildUserOperationParameters,\n UserOperationContext,\n} from \"./types\";\n\n/**\n * Builds a user operation using the provided client and operation parameters. Ensures that the account exists and the client is compatible.\n *\n * @example\n * ```ts\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * // smart account client is already extended with buildUserOperation\n * const client = createSmartAccountClient(...);\n * const result = await client.buildUserOperation({\n * uo: {\n * target: \"0x...\",\n * data: \"0x...\", // or \"0x\",\n * value: 0n, // optional\n * },\n * account, // only required if the client above is not connected to an account\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client the client instance used to build the user operation\n * @param {BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>} args the parameters required to build the user operation, including account, overrides, and context\n * @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a promise that resolves to a `UserOperationStruct` object containing the built user operation details\n */\nexport async function buildUserOperation<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>\n): Promise<UserOperationStruct<TEntryPointVersion>> {\n const { account = client.account, overrides, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"buildUserOperation\",\n client\n );\n }\n\n return _initUserOperation(client, args).then((_uo) =>\n _runMiddlewareStack(client, {\n uo: _uo,\n overrides,\n account,\n context,\n })\n );\n}\n"]}
1
+ {"version":3,"file":"buildUserOperation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperation.ts"],"names":[],"mappings":"AACA,OAAO,EAGN,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAMvE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAWtC,MAA4C,EAC5C,IAA0E;IAE1E,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,oBAAoB,EACpB,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CACnD,mBAAmB,CAAC,MAAM,EAAE;QAC1B,EAAE,EAAE,GAAG;QACP,SAAS;QACT,OAAO;QACP,OAAO;KACR,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport {\n type GetEntryPointFromAccount,\n type SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type { UserOperationStruct } from \"../../types.js\";\nimport { _initUserOperation } from \"./internal/initUserOperation.js\";\nimport { _runMiddlewareStack } from \"./internal/runMiddlewareStack.js\";\nimport type {\n BuildUserOperationParameters,\n UserOperationContext,\n} from \"./types\";\n\n/**\n * Builds a user operation using the provided client and operation parameters. Ensures that the account exists and the client is compatible.\n *\n * @example\n * ```ts\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * // smart account client is already extended with buildUserOperation\n * const client = createSmartAccountClient(...);\n * const result = await client.buildUserOperation({\n * uo: {\n * target: \"0x...\",\n * data: \"0x...\", // or \"0x\",\n * value: 0n, // optional\n * },\n * account, // only required if the client above is not connected to an account\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client the client instance used to build the user operation\n * @param {BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>} args the parameters required to build the user operation, including account, overrides, and context\n * @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a promise that resolves to a `UserOperationStruct` object containing the built user operation details\n */\nexport async function buildUserOperation<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>\n): Promise<UserOperationStruct<TEntryPointVersion>> {\n const { account = client.account, overrides, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"buildUserOperation\",\n client\n );\n }\n\n return _initUserOperation(client, args).then((_uo) =>\n _runMiddlewareStack(client, {\n uo: _uo,\n overrides,\n account,\n context,\n })\n );\n}\n"]}
@@ -2,4 +2,43 @@ import { type Chain, type Client, type SendTransactionParameters, type Transport
2
2
  import type { GetEntryPointFromAccount, SmartContractAccount } from "../../account/smartContractAccount.js";
3
3
  import type { UserOperationOverrides, UserOperationStruct } from "../../types.js";
4
4
  import type { UserOperationContext } from "./types.js";
5
+ /**
6
+ * 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`
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import type { RpcTransactionRequest } from "viem";
11
+ * import { smartAccountClient } from "./smartAccountClient";
12
+ * // [!code focus:99]
13
+ * // buildUserOperationFromTx converts a traditional Ethereum transaction and returns
14
+ * // the unsigned user operation struct after constructing the user operation struct
15
+ * // through the middleware pipeline
16
+ * const tx: RpcTransactionRequest = {
17
+ * from, // ignored
18
+ * to,
19
+ * data: encodeFunctionData({
20
+ * abi: ContractABI.abi,
21
+ * functionName: "func",
22
+ * args: [arg1, arg2, ...],
23
+ * }),
24
+ * };
25
+ * const uoStruct = await smartAccountClient.buildUserOperationFromTx(tx);
26
+ *
27
+ * // signUserOperation signs the above unsigned user operation struct built
28
+ * // using the account connected to the smart account client
29
+ * const request = await smartAccountClient.signUserOperation({ uoStruct });
30
+ *
31
+ * // You can use the BundlerAction `sendRawUserOperation` (packages/core/src/actions/bundler/sendRawUserOperation.ts)
32
+ * // to send the signed user operation request to the bundler, requesting the bundler to send the signed uo to the
33
+ * // EntryPoint contract pointed at by the entryPoint address parameter
34
+ * const entryPointAddress = client.account.getEntryPoint().address;
35
+ * const uoHash = await smartAccountClient.sendRawUserOperation({ request, entryPoint: entryPointAddress });
36
+ * ```
37
+ *
38
+ * @param {Client<Transport, TChain, TAccount>} client the smart account client to use for RPC requests
39
+ * @param {SendTransactionParameters} args the send tx parameters
40
+ * @param {UserOperationOverrides} overrides optional overrides to use for any of the fields
41
+ * @param {TContext} context if the smart account client requires additinoal context for building UOs
42
+ * @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a Promise containing the built user operation
43
+ */
5
44
  export declare function buildUserOperationFromTx<TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TChainOverride extends Chain | undefined = Chain | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined, TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>>(client: Client<Transport, TChain, TAccount>, args: SendTransactionParameters<TChain, TAccount, TChainOverride>, overrides?: UserOperationOverrides<TEntryPointVersion>, context?: TContext): Promise<UserOperationStruct<TEntryPointVersion>>;
@@ -4,6 +4,45 @@ import { AccountNotFoundError } from "../../errors/account.js";
4
4
  import { IncompatibleClientError } from "../../errors/client.js";
5
5
  import { TransactionMissingToParamError } from "../../errors/transaction.js";
6
6
  import { buildUserOperation } from "./buildUserOperation.js";
7
+ /**
8
+ * 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`
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import type { RpcTransactionRequest } from "viem";
13
+ * import { smartAccountClient } from "./smartAccountClient";
14
+ * // [!code focus:99]
15
+ * // buildUserOperationFromTx converts a traditional Ethereum transaction and returns
16
+ * // the unsigned user operation struct after constructing the user operation struct
17
+ * // through the middleware pipeline
18
+ * const tx: RpcTransactionRequest = {
19
+ * from, // ignored
20
+ * to,
21
+ * data: encodeFunctionData({
22
+ * abi: ContractABI.abi,
23
+ * functionName: "func",
24
+ * args: [arg1, arg2, ...],
25
+ * }),
26
+ * };
27
+ * const uoStruct = await smartAccountClient.buildUserOperationFromTx(tx);
28
+ *
29
+ * // signUserOperation signs the above unsigned user operation struct built
30
+ * // using the account connected to the smart account client
31
+ * const request = await smartAccountClient.signUserOperation({ uoStruct });
32
+ *
33
+ * // You can use the BundlerAction `sendRawUserOperation` (packages/core/src/actions/bundler/sendRawUserOperation.ts)
34
+ * // to send the signed user operation request to the bundler, requesting the bundler to send the signed uo to the
35
+ * // EntryPoint contract pointed at by the entryPoint address parameter
36
+ * const entryPointAddress = client.account.getEntryPoint().address;
37
+ * const uoHash = await smartAccountClient.sendRawUserOperation({ request, entryPoint: entryPointAddress });
38
+ * ```
39
+ *
40
+ * @param {Client<Transport, TChain, TAccount>} client the smart account client to use for RPC requests
41
+ * @param {SendTransactionParameters} args the send tx parameters
42
+ * @param {UserOperationOverrides} overrides optional overrides to use for any of the fields
43
+ * @param {TContext} context if the smart account client requires additinoal context for building UOs
44
+ * @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a Promise containing the built user operation
45
+ */
7
46
  export async function buildUserOperationFromTx(client, args, overrides, context) {
8
47
  const { account = client.account, ...request } = args;
9
48
  if (!account || typeof account === "string") {
@@ -1 +1 @@
1
- {"version":3,"file":"buildUserOperationFromTx.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperationFromTx.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,MAAM,MAAM,CAAC;AAKd,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAK7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AA0C7D,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAW5C,MAA2C,EAC3C,IAAiE,EACjE,SAAsD,EACtD,OAAkB;IAElB,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC;IACtD,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;QAChB,MAAM,IAAI,8BAA8B,EAAE,CAAC;IAC7C,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,0BAA0B,EAC1B,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG;QACjB,GAAG,SAAS;QACZ,YAAY,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;QACrE,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;YAChD,CAAC,CAAC,OAAO,CAAC,oBAAoB;YAC9B,CAAC,CAAC,SAAS;KACgC,CAAC;IAEhD,OAAO,kBAAkB,CAAC,MAAM,EAAE;QAChC,EAAE,EAAE;YACF,MAAM,EAAE,OAAO,CAAC,EAAE;YAClB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,IAAI;YAC1B,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;SAC1C;QACD,OAAO,EAAE,OAA+B;QACxC,OAAO;QACP,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n type Chain,\n type Client,\n type SendTransactionParameters,\n type Transport,\n} from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { TransactionMissingToParamError } from \"../../errors/transaction.js\";\nimport type {\n UserOperationOverrides,\n UserOperationStruct,\n} from \"../../types.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type { UserOperationContext } from \"./types.js\";\n\n/**\n * 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`\n *\n * @example\n * ```ts\n * import type { RpcTransactionRequest } from \"viem\";\n * import { smartAccountClient } from \"./smartAccountClient\";\n * // [!code focus:99]\n * // buildUserOperationFromTx converts a traditional Ethereum transaction and returns\n * // the unsigned user operation struct after constructing the user operation struct\n * // through the middleware pipeline\n * const tx: RpcTransactionRequest = {\n * from, // ignored\n * to,\n * data: encodeFunctionData({\n * abi: ContractABI.abi,\n * functionName: \"func\",\n * args: [arg1, arg2, ...],\n * }),\n * };\n * const uoStruct = await smartAccountClient.buildUserOperationFromTx(tx);\n *\n * // signUserOperation signs the above unsigned user operation struct built\n * // using the account connected to the smart account client\n * const request = await smartAccountClient.signUserOperation({ uoStruct });\n *\n * // You can use the BundlerAction `sendRawUserOperation` (packages/core/src/actions/bundler/sendRawUserOperation.ts)\n * // to send the signed user operation request to the bundler, requesting the bundler to send the signed uo to the\n * // EntryPoint contract pointed at by the entryPoint address parameter\n * const entryPointAddress = client.account.getEntryPoint().address;\n * const uoHash = await smartAccountClient.sendRawUserOperation({ request, entryPoint: entryPointAddress });\n * ```\n *\n * @param {Client<Transport, TChain, TAccount>} client the smart account client to use for RPC requests\n * @param {SendTransactionParameters} args the send tx parameters\n * @param {UserOperationOverrides} overrides optional overrides to use for any of the fields\n * @param {TContext} context if the smart account client requires additinoal context for building UOs\n * @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a Promise containing the built user operation\n */\nexport async function buildUserOperationFromTx<\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TChainOverride extends Chain | undefined = Chain | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client: Client<Transport, TChain, TAccount>,\n args: SendTransactionParameters<TChain, TAccount, TChainOverride>,\n overrides?: UserOperationOverrides<TEntryPointVersion>,\n context?: TContext\n): Promise<UserOperationStruct<TEntryPointVersion>> {\n const { account = client.account, ...request } = args;\n if (!account || typeof account === \"string\") {\n throw new AccountNotFoundError();\n }\n\n if (!request.to) {\n throw new TransactionMissingToParamError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"buildUserOperationFromTx\",\n client\n );\n }\n\n const _overrides = {\n ...overrides,\n maxFeePerGas: request.maxFeePerGas ? request.maxFeePerGas : undefined,\n maxPriorityFeePerGas: request.maxPriorityFeePerGas\n ? request.maxPriorityFeePerGas\n : undefined,\n } as UserOperationOverrides<TEntryPointVersion>;\n\n return buildUserOperation(client, {\n uo: {\n target: request.to,\n data: request.data ?? \"0x\",\n value: request.value ? request.value : 0n,\n },\n account: account as SmartContractAccount,\n context,\n overrides: _overrides,\n });\n}\n"]}
1
+ {"version":3,"file":"buildUserOperationFromTx.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperationFromTx.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,MAAM,MAAM,CAAC;AAKd,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAK7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAW5C,MAA2C,EAC3C,IAAiE,EACjE,SAAsD,EACtD,OAAkB;IAElB,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC;IACtD,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;QAChB,MAAM,IAAI,8BAA8B,EAAE,CAAC;IAC7C,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,0BAA0B,EAC1B,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG;QACjB,GAAG,SAAS;QACZ,YAAY,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;QACrE,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;YAChD,CAAC,CAAC,OAAO,CAAC,oBAAoB;YAC9B,CAAC,CAAC,SAAS;KACgC,CAAC;IAEhD,OAAO,kBAAkB,CAAC,MAAM,EAAE;QAChC,EAAE,EAAE;YACF,MAAM,EAAE,OAAO,CAAC,EAAE;YAClB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,IAAI;YAC1B,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;SAC1C;QACD,OAAO,EAAE,OAA+B;QACxC,OAAO;QACP,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n type Chain,\n type Client,\n type SendTransactionParameters,\n type Transport,\n} from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { TransactionMissingToParamError } from \"../../errors/transaction.js\";\nimport type {\n UserOperationOverrides,\n UserOperationStruct,\n} from \"../../types.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type { UserOperationContext } from \"./types.js\";\n\n/**\n * 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`\n *\n * @example\n * ```ts\n * import type { RpcTransactionRequest } from \"viem\";\n * import { smartAccountClient } from \"./smartAccountClient\";\n * // [!code focus:99]\n * // buildUserOperationFromTx converts a traditional Ethereum transaction and returns\n * // the unsigned user operation struct after constructing the user operation struct\n * // through the middleware pipeline\n * const tx: RpcTransactionRequest = {\n * from, // ignored\n * to,\n * data: encodeFunctionData({\n * abi: ContractABI.abi,\n * functionName: \"func\",\n * args: [arg1, arg2, ...],\n * }),\n * };\n * const uoStruct = await smartAccountClient.buildUserOperationFromTx(tx);\n *\n * // signUserOperation signs the above unsigned user operation struct built\n * // using the account connected to the smart account client\n * const request = await smartAccountClient.signUserOperation({ uoStruct });\n *\n * // You can use the BundlerAction `sendRawUserOperation` (packages/core/src/actions/bundler/sendRawUserOperation.ts)\n * // to send the signed user operation request to the bundler, requesting the bundler to send the signed uo to the\n * // EntryPoint contract pointed at by the entryPoint address parameter\n * const entryPointAddress = client.account.getEntryPoint().address;\n * const uoHash = await smartAccountClient.sendRawUserOperation({ request, entryPoint: entryPointAddress });\n * ```\n *\n * @param {Client<Transport, TChain, TAccount>} client the smart account client to use for RPC requests\n * @param {SendTransactionParameters} args the send tx parameters\n * @param {UserOperationOverrides} overrides optional overrides to use for any of the fields\n * @param {TContext} context if the smart account client requires additinoal context for building UOs\n * @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a Promise containing the built user operation\n */\nexport async function buildUserOperationFromTx<\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TChainOverride extends Chain | undefined = Chain | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client: Client<Transport, TChain, TAccount>,\n args: SendTransactionParameters<TChain, TAccount, TChainOverride>,\n overrides?: UserOperationOverrides<TEntryPointVersion>,\n context?: TContext\n): Promise<UserOperationStruct<TEntryPointVersion>> {\n const { account = client.account, ...request } = args;\n if (!account || typeof account === \"string\") {\n throw new AccountNotFoundError();\n }\n\n if (!request.to) {\n throw new TransactionMissingToParamError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"buildUserOperationFromTx\",\n client\n );\n }\n\n const _overrides = {\n ...overrides,\n maxFeePerGas: request.maxFeePerGas ? request.maxFeePerGas : undefined,\n maxPriorityFeePerGas: request.maxPriorityFeePerGas\n ? request.maxPriorityFeePerGas\n : undefined,\n } as UserOperationOverrides<TEntryPointVersion>;\n\n return buildUserOperation(client, {\n uo: {\n target: request.to,\n data: request.data ?? \"0x\",\n value: request.value ? request.value : 0n,\n },\n account: account as SmartContractAccount,\n context,\n overrides: _overrides,\n });\n}\n"]}
@@ -1,4 +1,58 @@
1
1
  import { type Chain, type Client, type Transport } from "viem";
2
2
  import type { GetEntryPointFromAccount, SmartContractAccount } from "../../account/smartContractAccount";
3
3
  import type { BuildTransactionParameters, BuildUserOperationFromTransactionsResult, UserOperationContext } from "./types";
4
+ /**
5
+ * Performs `buildUserOperationFromTx` in batch and builds into a single,
6
+ * yet to be signed `UserOperation` (UO) struct. The output user operation struct
7
+ * will be filled with all gas fields (and paymaster data if a paymaster is used)
8
+ * based on the transactions data (`to`, `data`, `value`, `maxFeePerGas`,
9
+ * `maxPriorityFeePerGas`) computed using the configured ClientMiddlewares on the SmartAccountClient.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import type { RpcTransactionRequest } from "viem";
14
+ * import { smartAccountClient } from "./smartAccountClient";
15
+ *
16
+ * const requests: RpcTransactionRequest[] = [
17
+ * {
18
+ * from, // ignored
19
+ * to,
20
+ * data: encodeFunctionData({
21
+ * abi: ContractABI.abi,
22
+ * functionName: "func",
23
+ * args: [arg1, arg2, ...],
24
+ * }),
25
+ * },
26
+ * {
27
+ * from, // ignored
28
+ * to,
29
+ * data: encodeFunctionData({
30
+ * abi: ContractABI.abi,
31
+ * functionName: "func",
32
+ * args: [arg1, arg2, ...],
33
+ * }),
34
+ * },
35
+ * ];
36
+ * const uoStruct = await smartAccountClient.buildUserOperationFromTxs({
37
+ * requests,
38
+ * });
39
+ *
40
+ * // signUserOperation signs the above unsigned user operation struct built
41
+ * // using the account connected to the smart account client
42
+ * const request = await smartAccountClient.signUserOperation({ uoStruct });
43
+ *
44
+ * // You can use the BundlerAction `sendRawUserOperation` (packages/core/src/actions/bundler/sendRawUserOperation.ts)
45
+ * // to send the signed user operation request to the bundler, requesting the bundler to send the signed uo to the
46
+ * // EntryPoint contract pointed at by the entryPoint address parameter
47
+ * const entryPointAddress = client.account.getEntryPoint().address;
48
+ * const uoHash = await smartAccountClient.sendRawUserOperation({
49
+ * request,
50
+ * entryPoint: entryPointAddress,
51
+ * });
52
+ * ```
53
+ *
54
+ * @param {Client<TTransport, TChain, TAccount>} client the smart account client to use to make RPC calls
55
+ * @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
56
+ * @returns {Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>} a Promise containing the built user operation
57
+ */
4
58
  export declare function buildUserOperationFromTxs<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(client: Client<TTransport, TChain, TAccount>, args: BuildTransactionParameters<TAccount, TContext, TEntryPointVersion>): Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>;
@@ -5,6 +5,60 @@ import { IncompatibleClientError } from "../../errors/client.js";
5
5
  import { TransactionMissingToParamError } from "../../errors/transaction.js";
6
6
  import { bigIntMax } from "../../utils/index.js";
7
7
  import { buildUserOperation } from "./buildUserOperation.js";
8
+ /**
9
+ * Performs `buildUserOperationFromTx` in batch and builds into a single,
10
+ * yet to be signed `UserOperation` (UO) struct. The output user operation struct
11
+ * will be filled with all gas fields (and paymaster data if a paymaster is used)
12
+ * based on the transactions data (`to`, `data`, `value`, `maxFeePerGas`,
13
+ * `maxPriorityFeePerGas`) computed using the configured ClientMiddlewares on the SmartAccountClient.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import type { RpcTransactionRequest } from "viem";
18
+ * import { smartAccountClient } from "./smartAccountClient";
19
+ *
20
+ * const requests: RpcTransactionRequest[] = [
21
+ * {
22
+ * from, // ignored
23
+ * to,
24
+ * data: encodeFunctionData({
25
+ * abi: ContractABI.abi,
26
+ * functionName: "func",
27
+ * args: [arg1, arg2, ...],
28
+ * }),
29
+ * },
30
+ * {
31
+ * from, // ignored
32
+ * to,
33
+ * data: encodeFunctionData({
34
+ * abi: ContractABI.abi,
35
+ * functionName: "func",
36
+ * args: [arg1, arg2, ...],
37
+ * }),
38
+ * },
39
+ * ];
40
+ * const uoStruct = await smartAccountClient.buildUserOperationFromTxs({
41
+ * requests,
42
+ * });
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({
53
+ * request,
54
+ * entryPoint: entryPointAddress,
55
+ * });
56
+ * ```
57
+ *
58
+ * @param {Client<TTransport, TChain, TAccount>} client the smart account client to use to make RPC calls
59
+ * @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
60
+ * @returns {Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>} a Promise containing the built user operation
61
+ */
8
62
  export async function buildUserOperationFromTxs(client, args) {
9
63
  const { account = client.account, requests, overrides, context } = args;
10
64
  if (!account) {
@@ -51,6 +105,7 @@ export async function buildUserOperationFromTxs(client, args) {
51
105
  });
52
106
  return {
53
107
  uoStruct,
108
+ // TODO: in v4 major version update, remove these as below parameters are not needed
54
109
  batch,
55
110
  overrides: _overrides,
56
111
  };
@@ -1 +1 @@
1
- {"version":3,"file":"buildUserOperationFromTxs.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperationFromTxs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2C,MAAM,MAAM,CAAC;AAKxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAE7E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AA6D7D,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAW7C,MAA4C,EAC5C,IAAwE;IAExE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACxE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,2BAA2B,EAC3B,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACrC,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;YAChB,MAAM,IAAI,8BAA8B,EAAE,CAAC;QAC7C,CAAC;QAED,OAAO;YACL,MAAM,EAAE,OAAO,CAAC,EAAE;YAClB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,IAAI;YAC1B,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE;SAC7D,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAAG,GAAG,EAAE,CAC7B,QAAQ;SACL,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,IAAI,IAAI,CAAC;SACrC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,YAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;IACpD,MAAM,YAAY,GAChB,SAAS,EAAE,YAAY,IAAI,IAAI;QAC7B,CAAC,CAAC,SAAS,EAAE,YAAY;QACzB,CAAC,CAAC,iBAAiB,EAAE,CAAC,MAAM,GAAG,CAAC;YAChC,CAAC,CAAC,SAAS,CAAC,GAAG,iBAAiB,EAAE,CAAC;YACnC,CAAC,CAAC,SAAS,CAAC;IAEhB,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAC9B,QAAQ;SACL,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,oBAAoB,IAAI,IAAI,CAAC;SAC7C,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAqB,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC5D,MAAM,oBAAoB,GACxB,SAAS,EAAE,oBAAoB,IAAI,IAAI;QACrC,CAAC,CAAC,SAAS,EAAE,oBAAoB;QACjC,CAAC,CAAC,kBAAkB,EAAE,CAAC,MAAM,GAAG,CAAC;YACjC,CAAC,CAAC,SAAS,CAAC,GAAG,kBAAkB,EAAE,CAAC;YACpC,CAAC,CAAC,SAAS,CAAC;IAEhB,MAAM,UAAU,GAAG;QACjB,YAAY;QACZ,oBAAoB;KACyB,CAAC;IAEhD,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE;QAChD,EAAE,EAAE,KAAK;QACT,OAAO;QACP,OAAO;QACP,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ;QAER,KAAK;QACL,SAAS,EAAE,UAAU;KACtB,CAAC;AACJ,CAAC","sourcesContent":["import { fromHex, type Chain, type Client, type Transport } from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { TransactionMissingToParamError } from \"../../errors/transaction.js\";\nimport type { UserOperationOverrides } from \"../../types\";\nimport { bigIntMax } from \"../../utils/index.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type {\n BuildTransactionParameters,\n BuildUserOperationFromTransactionsResult,\n UserOperationContext,\n} from \"./types\";\n\n/**\n * Performs `buildUserOperationFromTx` in batch and builds into a single,\n * yet to be signed `UserOperation` (UO) struct. The output user operation struct\n * will be filled with all gas fields (and paymaster data if a paymaster is used)\n * based on the transactions data (`to`, `data`, `value`, `maxFeePerGas`,\n * `maxPriorityFeePerGas`) computed using the configured ClientMiddlewares on the SmartAccountClient.\n *\n * @example\n * ```ts\n * import type { RpcTransactionRequest } from \"viem\";\n * import { smartAccountClient } from \"./smartAccountClient\";\n *\n * const requests: RpcTransactionRequest[] = [\n * {\n * from, // ignored\n * to,\n * data: encodeFunctionData({\n * abi: ContractABI.abi,\n * functionName: \"func\",\n * args: [arg1, arg2, ...],\n * }),\n * },\n * {\n * from, // ignored\n * to,\n * data: encodeFunctionData({\n * abi: ContractABI.abi,\n * functionName: \"func\",\n * args: [arg1, arg2, ...],\n * }),\n * },\n * ];\n * const uoStruct = await smartAccountClient.buildUserOperationFromTxs({\n * requests,\n * });\n *\n * // signUserOperation signs the above unsigned user operation struct built\n * // using the account connected to the smart account client\n * const request = await smartAccountClient.signUserOperation({ uoStruct });\n *\n * // You can use the BundlerAction `sendRawUserOperation` (packages/core/src/actions/bundler/sendRawUserOperation.ts)\n * // to send the signed user operation request to the bundler, requesting the bundler to send the signed uo to the\n * // EntryPoint contract pointed at by the entryPoint address parameter\n * const entryPointAddress = client.account.getEntryPoint().address;\n * const uoHash = await smartAccountClient.sendRawUserOperation({\n * request,\n * entryPoint: entryPointAddress,\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client the smart account client to use to make RPC calls\n * @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\n * @returns {Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>} a Promise containing the built user operation\n */\nexport async function buildUserOperationFromTxs<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: BuildTransactionParameters<TAccount, TContext, TEntryPointVersion>\n): Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>> {\n const { account = client.account, requests, overrides, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"buildUserOperationFromTxs\",\n client\n );\n }\n\n const batch = requests.map((request) => {\n if (!request.to) {\n throw new TransactionMissingToParamError();\n }\n\n return {\n target: request.to,\n data: request.data ?? \"0x\",\n value: request.value ? fromHex(request.value, \"bigint\") : 0n,\n };\n });\n\n const mfpgOverridesInTx = () =>\n requests\n .filter((x) => x.maxFeePerGas != null)\n .map((x) => fromHex(x.maxFeePerGas!, \"bigint\"));\n const maxFeePerGas =\n overrides?.maxFeePerGas != null\n ? overrides?.maxFeePerGas\n : mfpgOverridesInTx().length > 0\n ? bigIntMax(...mfpgOverridesInTx())\n : undefined;\n\n const mpfpgOverridesInTx = () =>\n requests\n .filter((x) => x.maxPriorityFeePerGas != null)\n .map((x) => fromHex(x.maxPriorityFeePerGas!, \"bigint\"));\n const maxPriorityFeePerGas =\n overrides?.maxPriorityFeePerGas != null\n ? overrides?.maxPriorityFeePerGas\n : mpfpgOverridesInTx().length > 0\n ? bigIntMax(...mpfpgOverridesInTx())\n : undefined;\n\n const _overrides = {\n maxFeePerGas,\n maxPriorityFeePerGas,\n } as UserOperationOverrides<TEntryPointVersion>;\n\n const uoStruct = await buildUserOperation(client, {\n uo: batch,\n account,\n context,\n overrides: _overrides,\n });\n\n return {\n uoStruct,\n // TODO: in v4 major version update, remove these as below parameters are not needed\n batch,\n overrides: _overrides,\n };\n}\n"]}
1
+ {"version":3,"file":"buildUserOperationFromTxs.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperationFromTxs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2C,MAAM,MAAM,CAAC;AAKxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAE7E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAO7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAW7C,MAA4C,EAC5C,IAAwE;IAExE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACxE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,2BAA2B,EAC3B,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACrC,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;YAChB,MAAM,IAAI,8BAA8B,EAAE,CAAC;QAC7C,CAAC;QAED,OAAO;YACL,MAAM,EAAE,OAAO,CAAC,EAAE;YAClB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,IAAI;YAC1B,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE;SAC7D,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAAG,GAAG,EAAE,CAC7B,QAAQ;SACL,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,IAAI,IAAI,CAAC;SACrC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,YAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;IACpD,MAAM,YAAY,GAChB,SAAS,EAAE,YAAY,IAAI,IAAI;QAC7B,CAAC,CAAC,SAAS,EAAE,YAAY;QACzB,CAAC,CAAC,iBAAiB,EAAE,CAAC,MAAM,GAAG,CAAC;YAChC,CAAC,CAAC,SAAS,CAAC,GAAG,iBAAiB,EAAE,CAAC;YACnC,CAAC,CAAC,SAAS,CAAC;IAEhB,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAC9B,QAAQ;SACL,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,oBAAoB,IAAI,IAAI,CAAC;SAC7C,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAqB,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC5D,MAAM,oBAAoB,GACxB,SAAS,EAAE,oBAAoB,IAAI,IAAI;QACrC,CAAC,CAAC,SAAS,EAAE,oBAAoB;QACjC,CAAC,CAAC,kBAAkB,EAAE,CAAC,MAAM,GAAG,CAAC;YACjC,CAAC,CAAC,SAAS,CAAC,GAAG,kBAAkB,EAAE,CAAC;YACpC,CAAC,CAAC,SAAS,CAAC;IAEhB,MAAM,UAAU,GAAG;QACjB,YAAY;QACZ,oBAAoB;KACyB,CAAC;IAEhD,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE;QAChD,EAAE,EAAE,KAAK;QACT,OAAO;QACP,OAAO;QACP,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ;QACR,oFAAoF;QACpF,KAAK;QACL,SAAS,EAAE,UAAU;KACtB,CAAC;AACJ,CAAC","sourcesContent":["import { fromHex, type Chain, type Client, type Transport } from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { TransactionMissingToParamError } from \"../../errors/transaction.js\";\nimport type { UserOperationOverrides } from \"../../types\";\nimport { bigIntMax } from \"../../utils/index.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type {\n BuildTransactionParameters,\n BuildUserOperationFromTransactionsResult,\n UserOperationContext,\n} from \"./types\";\n\n/**\n * Performs `buildUserOperationFromTx` in batch and builds into a single,\n * yet to be signed `UserOperation` (UO) struct. The output user operation struct\n * will be filled with all gas fields (and paymaster data if a paymaster is used)\n * based on the transactions data (`to`, `data`, `value`, `maxFeePerGas`,\n * `maxPriorityFeePerGas`) computed using the configured ClientMiddlewares on the SmartAccountClient.\n *\n * @example\n * ```ts\n * import type { RpcTransactionRequest } from \"viem\";\n * import { smartAccountClient } from \"./smartAccountClient\";\n *\n * const requests: RpcTransactionRequest[] = [\n * {\n * from, // ignored\n * to,\n * data: encodeFunctionData({\n * abi: ContractABI.abi,\n * functionName: \"func\",\n * args: [arg1, arg2, ...],\n * }),\n * },\n * {\n * from, // ignored\n * to,\n * data: encodeFunctionData({\n * abi: ContractABI.abi,\n * functionName: \"func\",\n * args: [arg1, arg2, ...],\n * }),\n * },\n * ];\n * const uoStruct = await smartAccountClient.buildUserOperationFromTxs({\n * requests,\n * });\n *\n * // signUserOperation signs the above unsigned user operation struct built\n * // using the account connected to the smart account client\n * const request = await smartAccountClient.signUserOperation({ uoStruct });\n *\n * // You can use the BundlerAction `sendRawUserOperation` (packages/core/src/actions/bundler/sendRawUserOperation.ts)\n * // to send the signed user operation request to the bundler, requesting the bundler to send the signed uo to the\n * // EntryPoint contract pointed at by the entryPoint address parameter\n * const entryPointAddress = client.account.getEntryPoint().address;\n * const uoHash = await smartAccountClient.sendRawUserOperation({\n * request,\n * entryPoint: entryPointAddress,\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client the smart account client to use to make RPC calls\n * @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\n * @returns {Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>} a Promise containing the built user operation\n */\nexport async function buildUserOperationFromTxs<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: BuildTransactionParameters<TAccount, TContext, TEntryPointVersion>\n): Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>> {\n const { account = client.account, requests, overrides, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"buildUserOperationFromTxs\",\n client\n );\n }\n\n const batch = requests.map((request) => {\n if (!request.to) {\n throw new TransactionMissingToParamError();\n }\n\n return {\n target: request.to,\n data: request.data ?? \"0x\",\n value: request.value ? fromHex(request.value, \"bigint\") : 0n,\n };\n });\n\n const mfpgOverridesInTx = () =>\n requests\n .filter((x) => x.maxFeePerGas != null)\n .map((x) => fromHex(x.maxFeePerGas!, \"bigint\"));\n const maxFeePerGas =\n overrides?.maxFeePerGas != null\n ? overrides?.maxFeePerGas\n : mfpgOverridesInTx().length > 0\n ? bigIntMax(...mfpgOverridesInTx())\n : undefined;\n\n const mpfpgOverridesInTx = () =>\n requests\n .filter((x) => x.maxPriorityFeePerGas != null)\n .map((x) => fromHex(x.maxPriorityFeePerGas!, \"bigint\"));\n const maxPriorityFeePerGas =\n overrides?.maxPriorityFeePerGas != null\n ? overrides?.maxPriorityFeePerGas\n : mpfpgOverridesInTx().length > 0\n ? bigIntMax(...mpfpgOverridesInTx())\n : undefined;\n\n const _overrides = {\n maxFeePerGas,\n maxPriorityFeePerGas,\n } as UserOperationOverrides<TEntryPointVersion>;\n\n const uoStruct = await buildUserOperation(client, {\n uo: batch,\n account,\n context,\n overrides: _overrides,\n });\n\n return {\n uoStruct,\n // TODO: in v4 major version update, remove these as below parameters are not needed\n batch,\n overrides: _overrides,\n };\n}\n"]}
@@ -1,4 +1,32 @@
1
1
  import type { Chain, Client, Transport } from "viem";
2
2
  import type { SmartContractAccount } from "../../account/smartContractAccount.js";
3
3
  import type { SendUserOperationParameters, UserOperationContext } from "./types";
4
+ /**
5
+ * This function verifies the eligibility of the connected account for gas sponsorship concerning the upcoming `UserOperation` (UO) that is intended to be sent.
6
+ * 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.
7
+ * 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.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { smartAccountClient } from "./smartAccountClient";
12
+ * // [!code focus:99]
13
+ * const eligible = await smartAccountClient.checkGasSponsorshipEligibility({
14
+ * uo: {
15
+ * data: "0xCalldata",
16
+ * target: "0xTarget",
17
+ * value: 0n,
18
+ * },
19
+ * });
20
+ *
21
+ * console.log(
22
+ * `User Operation is ${
23
+ * eligible ? "eligible" : "ineligible"
24
+ * } for gas sponsorship.`
25
+ * );
26
+ * ```
27
+ *
28
+ * @param {Client<TTransport, TChain, TAccount>} client the smart account client to use for making RPC calls
29
+ * @param {SendUserOperationParameters} args containing the user operation, account, context, and overrides
30
+ * @returns {Promise<boolean>} a Promise containing a boolean indicating if the account is elgibile for sponsorship
31
+ */
4
32
  export declare function checkGasSponsorshipEligibility<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(client: Client<TTransport, TChain, TAccount>, args: SendUserOperationParameters<TAccount, TContext>): Promise<boolean>;
@@ -2,6 +2,34 @@ import { isBaseSmartAccountClient } from "../../client/isSmartAccountClient.js";
2
2
  import { AccountNotFoundError } from "../../errors/account.js";
3
3
  import { IncompatibleClientError } from "../../errors/client.js";
4
4
  import { buildUserOperation } from "./buildUserOperation.js";
5
+ /**
6
+ * This function verifies the eligibility of the connected account for gas sponsorship concerning the upcoming `UserOperation` (UO) that is intended to be sent.
7
+ * 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.
8
+ * 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.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { smartAccountClient } from "./smartAccountClient";
13
+ * // [!code focus:99]
14
+ * const eligible = await smartAccountClient.checkGasSponsorshipEligibility({
15
+ * uo: {
16
+ * data: "0xCalldata",
17
+ * target: "0xTarget",
18
+ * value: 0n,
19
+ * },
20
+ * });
21
+ *
22
+ * console.log(
23
+ * `User Operation is ${
24
+ * eligible ? "eligible" : "ineligible"
25
+ * } for gas sponsorship.`
26
+ * );
27
+ * ```
28
+ *
29
+ * @param {Client<TTransport, TChain, TAccount>} client the smart account client to use for making RPC calls
30
+ * @param {SendUserOperationParameters} args containing the user operation, account, context, and overrides
31
+ * @returns {Promise<boolean>} a Promise containing a boolean indicating if the account is elgibile for sponsorship
32
+ */
5
33
  export function checkGasSponsorshipEligibility(client, args) {
6
34
  const { account = client.account, overrides, context } = args;
7
35
  if (!account) {
@@ -1 +1 @@
1
- {"version":3,"file":"checkGasSponsorshipEligibility.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/checkGasSponsorshipEligibility.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAkC7D,MAAM,UAAU,8BAA8B,CAU5C,MAA4C,EAC5C,IAAqD;IAErD,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAE9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,gCAAgC,EAChC,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,EAAE;QAChC,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,OAAO;QACP,SAAS;QACT,OAAO;KACR,CAAC;SACC,IAAI,CAAC,CAAC,mBAAmB,EAAE,EAAE,CAC5B,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,KAAK,OAAO;QACzC,CAAC,CAAE,mBAAoD;aAClD,gBAAgB,KAAK,IAAI;YAC3B,mBAAoD;iBAClD,gBAAgB,KAAK,IAAI;QAC9B,CAAC,CAAE,mBAAoD;aAClD,aAAa,KAAK,IAAI;YACxB,mBAAoD;iBAClD,aAAa,KAAK,IAAI,CAC9B;SACA,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport type { SmartContractAccount } from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type { UserOperationStruct } from \"../../types.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type {\n SendUserOperationParameters,\n UserOperationContext,\n} from \"./types\";\n\n/**\n * This function verifies the eligibility of the connected account for gas sponsorship concerning the upcoming `UserOperation` (UO) that is intended to be sent.\n * 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.\n * 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.\n *\n * @example\n * ```ts\n * import { smartAccountClient } from \"./smartAccountClient\";\n * // [!code focus:99]\n * const eligible = await smartAccountClient.checkGasSponsorshipEligibility({\n * uo: {\n * data: \"0xCalldata\",\n * target: \"0xTarget\",\n * value: 0n,\n * },\n * });\n *\n * console.log(\n * `User Operation is ${\n * eligible ? \"eligible\" : \"ineligible\"\n * } for gas sponsorship.`\n * );\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client the smart account client to use for making RPC calls\n * @param {SendUserOperationParameters} args containing the user operation, account, context, and overrides\n * @returns {Promise<boolean>} a Promise containing a boolean indicating if the account is elgibile for sponsorship\n */\nexport function checkGasSponsorshipEligibility<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: SendUserOperationParameters<TAccount, TContext>\n): Promise<boolean> {\n const { account = client.account, overrides, context } = args;\n\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"checkGasSponsorshipEligibility\",\n client\n );\n }\n\n return buildUserOperation(client, {\n uo: args.uo,\n account,\n overrides,\n context,\n })\n .then((userOperationStruct) =>\n account.getEntryPoint().version === \"0.6.0\"\n ? (userOperationStruct as UserOperationStruct<\"0.6.0\">)\n .paymasterAndData !== \"0x\" &&\n (userOperationStruct as UserOperationStruct<\"0.6.0\">)\n .paymasterAndData !== null\n : (userOperationStruct as UserOperationStruct<\"0.7.0\">)\n .paymasterData !== \"0x\" &&\n (userOperationStruct as UserOperationStruct<\"0.7.0\">)\n .paymasterData !== null\n )\n .catch(() => false);\n}\n"]}
1
+ {"version":3,"file":"checkGasSponsorshipEligibility.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/checkGasSponsorshipEligibility.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAM7D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,8BAA8B,CAU5C,MAA4C,EAC5C,IAAqD;IAErD,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAE9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,gCAAgC,EAChC,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,EAAE;QAChC,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,OAAO;QACP,SAAS;QACT,OAAO;KACR,CAAC;SACC,IAAI,CAAC,CAAC,mBAAmB,EAAE,EAAE,CAC5B,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,KAAK,OAAO;QACzC,CAAC,CAAE,mBAAoD;aAClD,gBAAgB,KAAK,IAAI;YAC3B,mBAAoD;iBAClD,gBAAgB,KAAK,IAAI;QAC9B,CAAC,CAAE,mBAAoD;aAClD,aAAa,KAAK,IAAI;YACxB,mBAAoD;iBAClD,aAAa,KAAK,IAAI,CAC9B;SACA,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport type { SmartContractAccount } from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type { UserOperationStruct } from \"../../types.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type {\n SendUserOperationParameters,\n UserOperationContext,\n} from \"./types\";\n\n/**\n * This function verifies the eligibility of the connected account for gas sponsorship concerning the upcoming `UserOperation` (UO) that is intended to be sent.\n * 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.\n * 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.\n *\n * @example\n * ```ts\n * import { smartAccountClient } from \"./smartAccountClient\";\n * // [!code focus:99]\n * const eligible = await smartAccountClient.checkGasSponsorshipEligibility({\n * uo: {\n * data: \"0xCalldata\",\n * target: \"0xTarget\",\n * value: 0n,\n * },\n * });\n *\n * console.log(\n * `User Operation is ${\n * eligible ? \"eligible\" : \"ineligible\"\n * } for gas sponsorship.`\n * );\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client the smart account client to use for making RPC calls\n * @param {SendUserOperationParameters} args containing the user operation, account, context, and overrides\n * @returns {Promise<boolean>} a Promise containing a boolean indicating if the account is elgibile for sponsorship\n */\nexport function checkGasSponsorshipEligibility<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: SendUserOperationParameters<TAccount, TContext>\n): Promise<boolean> {\n const { account = client.account, overrides, context } = args;\n\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"checkGasSponsorshipEligibility\",\n client\n );\n }\n\n return buildUserOperation(client, {\n uo: args.uo,\n account,\n overrides,\n context,\n })\n .then((userOperationStruct) =>\n account.getEntryPoint().version === \"0.6.0\"\n ? (userOperationStruct as UserOperationStruct<\"0.6.0\">)\n .paymasterAndData !== \"0x\" &&\n (userOperationStruct as UserOperationStruct<\"0.6.0\">)\n .paymasterAndData !== null\n : (userOperationStruct as UserOperationStruct<\"0.7.0\">)\n .paymasterData !== \"0x\" &&\n (userOperationStruct as UserOperationStruct<\"0.7.0\">)\n .paymasterData !== null\n )\n .catch(() => false);\n}\n"]}
@@ -2,4 +2,26 @@ import type { Chain, Client, Transport } from "viem";
2
2
  import type { GetEntryPointFromAccount, SmartContractAccount } from "../../account/smartContractAccount";
3
3
  import type { SendUserOperationResult } from "../../client/types";
4
4
  import type { DropAndReplaceUserOperationParameters, UserOperationContext } from "./types";
5
+ /**
6
+ * Drops an existing user operation and replaces it with a new one while ensuring the appropriate fees and overrides are applied.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import {
11
+ * createSmartAccountClient,
12
+ * } from "@aa-sdk/core";
13
+ *
14
+ * // smart account client is already extended with dropAndReplaceUserOperation
15
+ * const client = createSmartAccountClient(...);
16
+ * const { request } = await client.sendUserOperation(...);
17
+ * const result = await client.dropAndReplaceUserOperation({
18
+ * uoToDrop: request,
19
+ * account, // only required if the client above is not connected to an account
20
+ * });
21
+ * ```
22
+ *
23
+ * @param {Client<TTransport, TChain, TAccount>} client The client instance with the transport, chain, and account information
24
+ * @param {DropAndReplaceUserOperationParameters<TAccount, TContext>} args The parameters required for dropping and replacing the user operation including the account, operation to drop, overrides, and context
25
+ * @returns {Promise<SendUserOperationResult<TEntryPointVersion>>} A promise that resolves to the result of sending the new user operation
26
+ */
5
27
  export declare function dropAndReplaceUserOperation<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined, TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>>(client: Client<TTransport, TChain, TAccount>, args: DropAndReplaceUserOperationParameters<TAccount, TContext>): Promise<SendUserOperationResult<TEntryPointVersion>>;
@@ -1,9 +1,31 @@
1
1
  import { isBaseSmartAccountClient } from "../../client/isSmartAccountClient.js";
2
2
  import { AccountNotFoundError } from "../../errors/account.js";
3
3
  import { IncompatibleClientError } from "../../errors/client.js";
4
- import { bigIntMax, bigIntMultiply } from "../../utils/index.js";
4
+ import { bigIntMax, bigIntMultiply, resolveProperties, } from "../../utils/index.js";
5
5
  import { _runMiddlewareStack } from "./internal/runMiddlewareStack.js";
6
6
  import { _sendUserOperation } from "./internal/sendUserOperation.js";
7
+ /**
8
+ * Drops an existing user operation and replaces it with a new one while ensuring the appropriate fees and overrides are applied.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import {
13
+ * createSmartAccountClient,
14
+ * } from "@aa-sdk/core";
15
+ *
16
+ * // smart account client is already extended with dropAndReplaceUserOperation
17
+ * const client = createSmartAccountClient(...);
18
+ * const { request } = await client.sendUserOperation(...);
19
+ * const result = await client.dropAndReplaceUserOperation({
20
+ * uoToDrop: request,
21
+ * account, // only required if the client above is not connected to an account
22
+ * });
23
+ * ```
24
+ *
25
+ * @param {Client<TTransport, TChain, TAccount>} client The client instance with the transport, chain, and account information
26
+ * @param {DropAndReplaceUserOperationParameters<TAccount, TContext>} args The parameters required for dropping and replacing the user operation including the account, operation to drop, overrides, and context
27
+ * @returns {Promise<SendUserOperationResult<TEntryPointVersion>>} A promise that resolves to the result of sending the new user operation
28
+ */
7
29
  export async function dropAndReplaceUserOperation(client, args) {
8
30
  const { account = client.account, uoToDrop, overrides, context } = args;
9
31
  if (!account) {
@@ -35,11 +57,10 @@ export async function dropAndReplaceUserOperation(client, args) {
35
57
  callData: uoToDrop.callData,
36
58
  signature: await account.getDummySignature(),
37
59
  });
38
- const { maxFeePerGas, maxPriorityFeePerGas } = await _runMiddlewareStack(client, {
39
- uo: uoToSubmit,
40
- overrides,
41
- account,
42
- });
60
+ // If the fee estimator is not the one estimating fees, then this won't work
61
+ // however, we have migrated to using erc7677middleware for alchemy paymaster flows
62
+ // and most of the other paymasters we've seen don't do fee estimation
63
+ const { maxFeePerGas, maxPriorityFeePerGas } = await resolveProperties(await client.middleware.feeEstimator(uoToSubmit, { account, client }));
43
64
  const _overrides = {
44
65
  ...overrides,
45
66
  maxFeePerGas: bigIntMax(BigInt(maxFeePerGas ?? 0n), bigIntMultiply(uoToDrop.maxFeePerGas, 1.1)),
@@ -1 +1 @@
1
- {"version":3,"file":"dropAndReplaceUserOperation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/dropAndReplaceUserOperation.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAMjE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AA4BrE,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAW/C,MAA4C,EAC5C,IAA+D;IAE/D,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACxE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IACD,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,6BAA6B,EAC7B,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAE3C,MAAM,UAAU,GAAG,CACjB,UAAU,CAAC,OAAO,KAAK,OAAO;QAC5B,CAAC,CAAC;YACE,QAAQ,EAAG,QAA0C,CAAC,QAAQ;YAC9D,MAAM,EAAG,QAA0C,CAAC,MAAM;YAC1D,KAAK,EAAG,QAA0C,CAAC,KAAK;YACxD,QAAQ,EAAG,QAA0C,CAAC,QAAQ;YAC9D,SAAS,EAAE,MAAM,OAAO,CAAC,iBAAiB,EAAE;SAC7C;QACH,CAAC,CAAC;YACE,GAAG,CAAE,QAA0C,CAAC,OAAO;gBACtD,QAA0C,CAAC,WAAW;gBACrD,CAAC,CAAC;oBACE,OAAO,EAAG,QAA0C,CAAC,OAAO;oBAC5D,WAAW,EAAG,QAA0C;yBACrD,WAAW;iBACf;gBACH,CAAC,CAAC,EAAE,CAAC;YACP,MAAM,EAAG,QAA0C,CAAC,MAAM;YAC1D,KAAK,EAAG,QAA0C,CAAC,KAAK;YACxD,QAAQ,EAAG,QAA0C,CAAC,QAAQ;YAC9D,SAAS,EAAE,MAAM,OAAO,CAAC,iBAAiB,EAAE;SAC7C,CACqC,CAAC;IAI7C,MAAM,EAAE,YAAY,EAAE,oBAAoB,EAAE,GAAG,MAAM,mBAAmB,CACtE,MAAM,EACN;QACE,EAAE,EAAE,UAAU;QACd,SAAS;QACT,OAAO;KACR,CACF,CAAC;IAEF,MAAM,UAAU,GAAG;QACjB,GAAG,SAAS;QACZ,YAAY,EAAE,SAAS,CACrB,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC,EAC1B,cAAc,CAAC,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC,CAC3C;QACD,oBAAoB,EAAE,SAAS,CAC7B,MAAM,CAAC,oBAAoB,IAAI,EAAE,CAAC,EAClC,cAAc,CAAC,QAAQ,CAAC,oBAAoB,EAAE,GAAG,CAAC,CACnD;KAC4C,CAAC;IAEhD,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,MAAM,EAAE;QACjD,EAAE,EAAE,UAAU;QACd,SAAS,EAAE,UAAU;QACrB,OAAO;KACR,CAAC,CAAC;IAEH,OAAO,kBAAkB,CAAC,MAAM,EAAE;QAChC,QAAQ,EAAE,QAAQ;QAClB,OAAO;QACP,OAAO;QACP,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport type { SendUserOperationResult } from \"../../client/types\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type {\n UserOperationOverrides,\n UserOperationRequest,\n UserOperationStruct,\n} from \"../../types\";\nimport { bigIntMax, bigIntMultiply } from \"../../utils/index.js\";\nimport { _runMiddlewareStack } from \"./internal/runMiddlewareStack.js\";\nimport { _sendUserOperation } from \"./internal/sendUserOperation.js\";\nimport type {\n DropAndReplaceUserOperationParameters,\n UserOperationContext,\n} from \"./types\";\n\n/**\n * Drops an existing user operation and replaces it with a new one while ensuring the appropriate fees and overrides are applied.\n *\n * @example\n * ```ts\n * import {\n * createSmartAccountClient,\n * } from \"@aa-sdk/core\";\n *\n * // smart account client is already extended with dropAndReplaceUserOperation\n * const client = createSmartAccountClient(...);\n * const { request } = await client.sendUserOperation(...);\n * const result = await client.dropAndReplaceUserOperation({\n * uoToDrop: request,\n * account, // only required if the client above is not connected to an account\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client The client instance with the transport, chain, and account information\n * @param {DropAndReplaceUserOperationParameters<TAccount, TContext>} args The parameters required for dropping and replacing the user operation including the account, operation to drop, overrides, and context\n * @returns {Promise<SendUserOperationResult<TEntryPointVersion>>} A promise that resolves to the result of sending the new user operation\n */\nexport async function dropAndReplaceUserOperation<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: DropAndReplaceUserOperationParameters<TAccount, TContext>\n): Promise<SendUserOperationResult<TEntryPointVersion>> {\n const { account = client.account, uoToDrop, overrides, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"dropAndReplaceUserOperation\",\n client\n );\n }\n\n const entryPoint = account.getEntryPoint();\n\n const uoToSubmit = (\n entryPoint.version === \"0.6.0\"\n ? {\n initCode: (uoToDrop as UserOperationRequest<\"0.6.0\">).initCode,\n sender: (uoToDrop as UserOperationRequest<\"0.6.0\">).sender,\n nonce: (uoToDrop as UserOperationRequest<\"0.6.0\">).nonce,\n callData: (uoToDrop as UserOperationRequest<\"0.6.0\">).callData,\n signature: await account.getDummySignature(),\n }\n : {\n ...((uoToDrop as UserOperationRequest<\"0.7.0\">).factory &&\n (uoToDrop as UserOperationRequest<\"0.7.0\">).factoryData\n ? {\n factory: (uoToDrop as UserOperationRequest<\"0.7.0\">).factory,\n factoryData: (uoToDrop as UserOperationRequest<\"0.7.0\">)\n .factoryData,\n }\n : {}),\n sender: (uoToDrop as UserOperationRequest<\"0.7.0\">).sender,\n nonce: (uoToDrop as UserOperationRequest<\"0.7.0\">).nonce,\n callData: (uoToDrop as UserOperationRequest<\"0.7.0\">).callData,\n signature: await account.getDummySignature(),\n }\n ) as UserOperationStruct<TEntryPointVersion>;\n\n // Run once to get the fee estimates\n // This can happen at any part of the middleware stack, so we want to run it all\n const { maxFeePerGas, maxPriorityFeePerGas } = await _runMiddlewareStack(\n client,\n {\n uo: uoToSubmit,\n overrides,\n account,\n }\n );\n\n const _overrides = {\n ...overrides,\n maxFeePerGas: bigIntMax(\n BigInt(maxFeePerGas ?? 0n),\n bigIntMultiply(uoToDrop.maxFeePerGas, 1.1)\n ),\n maxPriorityFeePerGas: bigIntMax(\n BigInt(maxPriorityFeePerGas ?? 0n),\n bigIntMultiply(uoToDrop.maxPriorityFeePerGas, 1.1)\n ),\n } as UserOperationOverrides<TEntryPointVersion>;\n\n const uoToSend = await _runMiddlewareStack(client, {\n uo: uoToSubmit,\n overrides: _overrides,\n account,\n });\n\n return _sendUserOperation(client, {\n uoStruct: uoToSend,\n account,\n context,\n overrides: _overrides,\n });\n}\n"]}
1
+ {"version":3,"file":"dropAndReplaceUserOperation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/dropAndReplaceUserOperation.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAMjE,OAAO,EACL,SAAS,EACT,cAAc,EACd,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAMrE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAW/C,MAA4C,EAC5C,IAA+D;IAE/D,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACxE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IACD,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,6BAA6B,EAC7B,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAE3C,MAAM,UAAU,GAAG,CACjB,UAAU,CAAC,OAAO,KAAK,OAAO;QAC5B,CAAC,CAAC;YACE,QAAQ,EAAG,QAA0C,CAAC,QAAQ;YAC9D,MAAM,EAAG,QAA0C,CAAC,MAAM;YAC1D,KAAK,EAAG,QAA0C,CAAC,KAAK;YACxD,QAAQ,EAAG,QAA0C,CAAC,QAAQ;YAC9D,SAAS,EAAE,MAAM,OAAO,CAAC,iBAAiB,EAAE;SAC7C;QACH,CAAC,CAAC;YACE,GAAG,CAAE,QAA0C,CAAC,OAAO;gBACtD,QAA0C,CAAC,WAAW;gBACrD,CAAC,CAAC;oBACE,OAAO,EAAG,QAA0C,CAAC,OAAO;oBAC5D,WAAW,EAAG,QAA0C;yBACrD,WAAW;iBACf;gBACH,CAAC,CAAC,EAAE,CAAC;YACP,MAAM,EAAG,QAA0C,CAAC,MAAM;YAC1D,KAAK,EAAG,QAA0C,CAAC,KAAK;YACxD,QAAQ,EAAG,QAA0C,CAAC,QAAQ;YAC9D,SAAS,EAAE,MAAM,OAAO,CAAC,iBAAiB,EAAE;SAC7C,CACqC,CAAC;IAE7C,4EAA4E;IAC5E,mFAAmF;IACnF,sEAAsE;IACtE,MAAM,EAAE,YAAY,EAAE,oBAAoB,EAAE,GAAG,MAAM,iBAAiB,CACpE,MAAM,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CACtE,CAAC;IAEF,MAAM,UAAU,GAAG;QACjB,GAAG,SAAS;QACZ,YAAY,EAAE,SAAS,CACrB,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC,EAC1B,cAAc,CAAC,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC,CAC3C;QACD,oBAAoB,EAAE,SAAS,CAC7B,MAAM,CAAC,oBAAoB,IAAI,EAAE,CAAC,EAClC,cAAc,CAAC,QAAQ,CAAC,oBAAoB,EAAE,GAAG,CAAC,CACnD;KAC4C,CAAC;IAEhD,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,MAAM,EAAE;QACjD,EAAE,EAAE,UAAU;QACd,SAAS,EAAE,UAAU;QACrB,OAAO;KACR,CAAC,CAAC;IAEH,OAAO,kBAAkB,CAAC,MAAM,EAAE;QAChC,QAAQ,EAAE,QAAQ;QAClB,OAAO;QACP,OAAO;QACP,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport type { SendUserOperationResult } from \"../../client/types\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type {\n UserOperationOverrides,\n UserOperationRequest,\n UserOperationStruct,\n} from \"../../types\";\nimport {\n bigIntMax,\n bigIntMultiply,\n resolveProperties,\n} from \"../../utils/index.js\";\nimport { _runMiddlewareStack } from \"./internal/runMiddlewareStack.js\";\nimport { _sendUserOperation } from \"./internal/sendUserOperation.js\";\nimport type {\n DropAndReplaceUserOperationParameters,\n UserOperationContext,\n} from \"./types\";\n\n/**\n * Drops an existing user operation and replaces it with a new one while ensuring the appropriate fees and overrides are applied.\n *\n * @example\n * ```ts\n * import {\n * createSmartAccountClient,\n * } from \"@aa-sdk/core\";\n *\n * // smart account client is already extended with dropAndReplaceUserOperation\n * const client = createSmartAccountClient(...);\n * const { request } = await client.sendUserOperation(...);\n * const result = await client.dropAndReplaceUserOperation({\n * uoToDrop: request,\n * account, // only required if the client above is not connected to an account\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client The client instance with the transport, chain, and account information\n * @param {DropAndReplaceUserOperationParameters<TAccount, TContext>} args The parameters required for dropping and replacing the user operation including the account, operation to drop, overrides, and context\n * @returns {Promise<SendUserOperationResult<TEntryPointVersion>>} A promise that resolves to the result of sending the new user operation\n */\nexport async function dropAndReplaceUserOperation<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: DropAndReplaceUserOperationParameters<TAccount, TContext>\n): Promise<SendUserOperationResult<TEntryPointVersion>> {\n const { account = client.account, uoToDrop, overrides, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"dropAndReplaceUserOperation\",\n client\n );\n }\n\n const entryPoint = account.getEntryPoint();\n\n const uoToSubmit = (\n entryPoint.version === \"0.6.0\"\n ? {\n initCode: (uoToDrop as UserOperationRequest<\"0.6.0\">).initCode,\n sender: (uoToDrop as UserOperationRequest<\"0.6.0\">).sender,\n nonce: (uoToDrop as UserOperationRequest<\"0.6.0\">).nonce,\n callData: (uoToDrop as UserOperationRequest<\"0.6.0\">).callData,\n signature: await account.getDummySignature(),\n }\n : {\n ...((uoToDrop as UserOperationRequest<\"0.7.0\">).factory &&\n (uoToDrop as UserOperationRequest<\"0.7.0\">).factoryData\n ? {\n factory: (uoToDrop as UserOperationRequest<\"0.7.0\">).factory,\n factoryData: (uoToDrop as UserOperationRequest<\"0.7.0\">)\n .factoryData,\n }\n : {}),\n sender: (uoToDrop as UserOperationRequest<\"0.7.0\">).sender,\n nonce: (uoToDrop as UserOperationRequest<\"0.7.0\">).nonce,\n callData: (uoToDrop as UserOperationRequest<\"0.7.0\">).callData,\n signature: await account.getDummySignature(),\n }\n ) as UserOperationStruct<TEntryPointVersion>;\n\n // If the fee estimator is not the one estimating fees, then this won't work\n // however, we have migrated to using erc7677middleware for alchemy paymaster flows\n // and most of the other paymasters we've seen don't do fee estimation\n const { maxFeePerGas, maxPriorityFeePerGas } = await resolveProperties(\n await client.middleware.feeEstimator(uoToSubmit, { account, client })\n );\n\n const _overrides = {\n ...overrides,\n maxFeePerGas: bigIntMax(\n BigInt(maxFeePerGas ?? 0n),\n bigIntMultiply(uoToDrop.maxFeePerGas, 1.1)\n ),\n maxPriorityFeePerGas: bigIntMax(\n BigInt(maxPriorityFeePerGas ?? 0n),\n bigIntMultiply(uoToDrop.maxPriorityFeePerGas, 1.1)\n ),\n } as UserOperationOverrides<TEntryPointVersion>;\n\n const uoToSend = await _runMiddlewareStack(client, {\n uo: uoToSubmit,\n overrides: _overrides,\n account,\n });\n\n return _sendUserOperation(client, {\n uoStruct: uoToSend,\n account,\n context,\n overrides: _overrides,\n });\n}\n"]}
@@ -2,4 +2,17 @@ import type { Chain, Client, Transport } from "viem";
2
2
  import { type GetEntryPointFromAccount, type SmartContractAccount } from "../../account/smartContractAccount.js";
3
3
  import type { UserOperationEstimateGasResponse } from "../../types.js";
4
4
  import type { SendUserOperationParameters, UserOperationContext } from "./types.js";
5
+ /**
6
+ * Description SmartAccountClientAction for estimating the gas cost of a user operation
7
+ *
8
+ * @async
9
+ * @template {Transport} TTransport
10
+ * @template {Chain | undefined} TChain
11
+ * @template {SmartContractAccount | undefined} TAccount
12
+ * @template {UserOperationContext | undefined} TContext
13
+ * @template {GetEntryPointFromAccount<TAccount>} TEntryPointVersion
14
+ * @param {Client<TTransport, TChain, TAccount>} client smart account client
15
+ * @param {SendUserOperationParameters<TAccount, TContext>} args send user operation parameters
16
+ * @returns {Promise<UserOperationEstimateGasResponse<TEntryPointVersion>>}user operation gas estimate response
17
+ */
5
18
  export declare function estimateUserOperationGas<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined, TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>>(client: Client<TTransport, TChain, TAccount>, args: SendUserOperationParameters<TAccount, TContext>): Promise<UserOperationEstimateGasResponse<TEntryPointVersion>>;
@@ -4,6 +4,19 @@ import { AccountNotFoundError } from "../../errors/account.js";
4
4
  import { IncompatibleClientError } from "../../errors/client.js";
5
5
  import { deepHexlify, resolveProperties } from "../../utils/index.js";
6
6
  import { _initUserOperation } from "./internal/initUserOperation.js";
7
+ /**
8
+ * Description SmartAccountClientAction for estimating the gas cost of a user operation
9
+ *
10
+ * @async
11
+ * @template {Transport} TTransport
12
+ * @template {Chain | undefined} TChain
13
+ * @template {SmartContractAccount | undefined} TAccount
14
+ * @template {UserOperationContext | undefined} TContext
15
+ * @template {GetEntryPointFromAccount<TAccount>} TEntryPointVersion
16
+ * @param {Client<TTransport, TChain, TAccount>} client smart account client
17
+ * @param {SendUserOperationParameters<TAccount, TContext>} args send user operation parameters
18
+ * @returns {Promise<UserOperationEstimateGasResponse<TEntryPointVersion>>}user operation gas estimate response
19
+ */
7
20
  export async function estimateUserOperationGas(client, args) {
8
21
  const { account = client.account, overrides } = args;
9
22
  if (!account) {
@@ -1 +1 @@
1
- {"version":3,"file":"estimateUserOperationGas.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/estimateUserOperationGas.ts"],"names":[],"mappings":"AACA,OAAO,EAGN,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAmBrE,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAW5C,MAA4C,EAC5C,IAAqD;IAErD,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACrD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,0BAA0B,EAC1B,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC5D,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7D,OAAO,MAAM,CAAC,wBAAwB,CACpC,OAAO,EACP,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,EAC/B,SAAS,EAAE,aAAa,CACzB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport {\n type GetEntryPointFromAccount,\n type SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type { UserOperationEstimateGasResponse } from \"../../types.js\";\nimport { deepHexlify, resolveProperties } from \"../../utils/index.js\";\nimport { _initUserOperation } from \"./internal/initUserOperation.js\";\nimport type {\n SendUserOperationParameters,\n UserOperationContext,\n} from \"./types.js\";\n\n/**\n * Description SmartAccountClientAction for estimating the gas cost of a user operation\n *\n * @async\n * @template {Transport} TTransport\n * @template {Chain | undefined} TChain\n * @template {SmartContractAccount | undefined} TAccount\n * @template {UserOperationContext | undefined} TContext\n * @template {GetEntryPointFromAccount<TAccount>} TEntryPointVersion\n * @param {Client<TTransport, TChain, TAccount>} client smart account client\n * @param {SendUserOperationParameters<TAccount, TContext>} args send user operation parameters\n * @returns {Promise<UserOperationEstimateGasResponse<TEntryPointVersion>>}user operation gas estimate response\n */\nexport async function estimateUserOperationGas<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: SendUserOperationParameters<TAccount, TContext>\n): Promise<UserOperationEstimateGasResponse<TEntryPointVersion>> {\n const { account = client.account, overrides } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"estimateUserOperationGas\",\n client\n );\n }\n\n return _initUserOperation(client, args).then(async (struct) => {\n const request = deepHexlify(await resolveProperties(struct));\n return client.estimateUserOperationGas(\n request,\n account.getEntryPoint().address,\n overrides?.stateOverride\n );\n });\n}\n"]}
1
+ {"version":3,"file":"estimateUserOperationGas.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/estimateUserOperationGas.ts"],"names":[],"mappings":"AACA,OAAO,EAGN,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAMrE;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAW5C,MAA4C,EAC5C,IAAqD;IAErD,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACrD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,0BAA0B,EAC1B,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC5D,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7D,OAAO,MAAM,CAAC,wBAAwB,CACpC,OAAO,EACP,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,EAC/B,SAAS,EAAE,aAAa,CACzB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport {\n type GetEntryPointFromAccount,\n type SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type { UserOperationEstimateGasResponse } from \"../../types.js\";\nimport { deepHexlify, resolveProperties } from \"../../utils/index.js\";\nimport { _initUserOperation } from \"./internal/initUserOperation.js\";\nimport type {\n SendUserOperationParameters,\n UserOperationContext,\n} from \"./types.js\";\n\n/**\n * Description SmartAccountClientAction for estimating the gas cost of a user operation\n *\n * @async\n * @template {Transport} TTransport\n * @template {Chain | undefined} TChain\n * @template {SmartContractAccount | undefined} TAccount\n * @template {UserOperationContext | undefined} TContext\n * @template {GetEntryPointFromAccount<TAccount>} TEntryPointVersion\n * @param {Client<TTransport, TChain, TAccount>} client smart account client\n * @param {SendUserOperationParameters<TAccount, TContext>} args send user operation parameters\n * @returns {Promise<UserOperationEstimateGasResponse<TEntryPointVersion>>}user operation gas estimate response\n */\nexport async function estimateUserOperationGas<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: SendUserOperationParameters<TAccount, TContext>\n): Promise<UserOperationEstimateGasResponse<TEntryPointVersion>> {\n const { account = client.account, overrides } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"estimateUserOperationGas\",\n client\n );\n }\n\n return _initUserOperation(client, args).then(async (struct) => {\n const request = deepHexlify(await resolveProperties(struct));\n return client.estimateUserOperationGas(\n request,\n account.getEntryPoint().address,\n overrides?.stateOverride\n );\n });\n}\n"]}
@@ -4,4 +4,17 @@ import type { BaseSmartAccountClient } from "../../../client/smartAccountClient.
4
4
  import type { UserOperationStruct } from "../../../types.js";
5
5
  import { type Deferrable } from "../../../utils/index.js";
6
6
  import type { BuildUserOperationParameters, SendUserOperationParameters, UserOperationContext } from "../types.js";
7
+ /**
8
+ * Description internal action function of SmartAccountClient for initializing
9
+ * a user operation for the sender account
10
+ *
11
+ * @template {Transport} TTransport
12
+ * @template {Chain | undefined} TChain
13
+ * @template {SmartContractAccount | undefined} TAccount
14
+ * @template {UserOperationContext | undefined} TContext
15
+ * @template {GetEntryPointFromAccount} TEntryPointVersion
16
+ * @param {BaseSmartAccountClient<TTransport, TChain, TAccount>} client smart account client
17
+ * @param {SendUserOperationParameters<TAccount, TContext, TEntryPointVersion> | BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>} args send user operation parameters
18
+ * @returns {Promise<Deferrable<UserOperationStruct<TEntryPointVersion>>>} initialized user operation struct
19
+ */
7
20
  export declare function _initUserOperation<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined, TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>>(client: BaseSmartAccountClient<TTransport, TChain, TAccount>, args: SendUserOperationParameters<TAccount, TContext, TEntryPointVersion> | BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>): Promise<Deferrable<UserOperationStruct<TEntryPointVersion>>>;