permissionless 0.0.11 → 0.0.13

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 (306) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/_cjs/accounts/index.js +14 -0
  3. package/_cjs/accounts/index.js.map +1 -0
  4. package/_cjs/accounts/privateKeyToSafeSmartAccount.js +24 -0
  5. package/_cjs/accounts/privateKeyToSafeSmartAccount.js.map +1 -0
  6. package/_cjs/accounts/privateKeyToSimpleSmartAccount.js +16 -0
  7. package/_cjs/accounts/privateKeyToSimpleSmartAccount.js.map +1 -0
  8. package/_cjs/accounts/signerToSafeSmartAccount.js +492 -0
  9. package/_cjs/accounts/signerToSafeSmartAccount.js.map +1 -0
  10. package/_cjs/accounts/signerToSimpleSmartAccount.js +190 -0
  11. package/_cjs/accounts/signerToSimpleSmartAccount.js.map +1 -0
  12. package/_cjs/accounts/types.js +23 -0
  13. package/_cjs/accounts/types.js.map +1 -0
  14. package/_cjs/actions/bundler/chainId.js.map +1 -1
  15. package/_cjs/actions/bundler/estimateUserOperationGas.js +4 -1
  16. package/_cjs/actions/bundler/estimateUserOperationGas.js.map +1 -1
  17. package/_cjs/actions/bundler/getUserOperationByHash.js.map +1 -1
  18. package/_cjs/actions/bundler/getUserOperationReceipt.js.map +1 -1
  19. package/_cjs/actions/bundler/sendUserOperation.js +4 -1
  20. package/_cjs/actions/bundler/sendUserOperation.js.map +1 -1
  21. package/_cjs/actions/bundler/supportedEntryPoints.js.map +1 -1
  22. package/_cjs/actions/bundler/waitForUserOperationReceipt.js +7 -2
  23. package/_cjs/actions/bundler/waitForUserOperationReceipt.js.map +1 -1
  24. package/_cjs/actions/index.js.map +1 -1
  25. package/_cjs/actions/pimlico/getUserOperationGasPrice.js.map +1 -1
  26. package/_cjs/actions/pimlico/getUserOperationStatus.js.map +1 -1
  27. package/_cjs/actions/pimlico/sponsorUserOperation.js +4 -1
  28. package/_cjs/actions/pimlico/sponsorUserOperation.js.map +1 -1
  29. package/_cjs/actions/pimlico.js.map +1 -1
  30. package/_cjs/actions/public/getAccountNonce.js +4 -2
  31. package/_cjs/actions/public/getAccountNonce.js.map +1 -1
  32. package/_cjs/actions/public/getSenderAddress.js +7 -3
  33. package/_cjs/actions/public/getSenderAddress.js.map +1 -1
  34. package/_cjs/actions/smartAccount/deployContract.js +38 -0
  35. package/_cjs/actions/smartAccount/deployContract.js.map +1 -0
  36. package/_cjs/actions/smartAccount/prepareUserOperationRequest.js +73 -0
  37. package/_cjs/actions/smartAccount/prepareUserOperationRequest.js.map +1 -0
  38. package/_cjs/actions/smartAccount/sendTransaction.js +44 -0
  39. package/_cjs/actions/smartAccount/sendTransaction.js.map +1 -0
  40. package/_cjs/actions/smartAccount/sendTransactions.js +46 -0
  41. package/_cjs/actions/smartAccount/sendTransactions.js.map +1 -0
  42. package/_cjs/actions/smartAccount/sendUserOperation.js +22 -0
  43. package/_cjs/actions/smartAccount/sendUserOperation.js.map +1 -0
  44. package/_cjs/actions/smartAccount/signMessage.js +16 -0
  45. package/_cjs/actions/smartAccount/signMessage.js.map +1 -0
  46. package/_cjs/actions/smartAccount/signTypedData.js +34 -0
  47. package/_cjs/actions/smartAccount/signTypedData.js.map +1 -0
  48. package/_cjs/actions/smartAccount/writeContract.js +21 -0
  49. package/_cjs/actions/smartAccount/writeContract.js.map +1 -0
  50. package/_cjs/actions/smartAccount.js +18 -0
  51. package/_cjs/actions/smartAccount.js.map +1 -0
  52. package/_cjs/actions/stackup/sponsorUserOperation.js +5 -1
  53. package/_cjs/actions/stackup/sponsorUserOperation.js.map +1 -1
  54. package/_cjs/clients/{bundler.js → createBundlerClient.js} +1 -1
  55. package/_cjs/clients/createBundlerClient.js.map +1 -0
  56. package/_cjs/clients/createSmartAccountClient.js +20 -0
  57. package/_cjs/clients/createSmartAccountClient.js.map +1 -0
  58. package/_cjs/clients/decorators/bundler.js.map +1 -1
  59. package/_cjs/clients/decorators/pimlico.js.map +1 -1
  60. package/_cjs/clients/decorators/smartAccount.js +33 -0
  61. package/_cjs/clients/decorators/smartAccount.js.map +1 -0
  62. package/_cjs/clients/decorators/stackup.js.map +1 -1
  63. package/_cjs/clients/pimlico.js.map +1 -1
  64. package/_cjs/clients/stackup.js.map +1 -1
  65. package/_cjs/index.js +9 -5
  66. package/_cjs/index.js.map +1 -1
  67. package/_cjs/utils/deepHexlify.js +4 -4
  68. package/_cjs/utils/deepHexlify.js.map +1 -1
  69. package/_cjs/utils/getAction.js +8 -0
  70. package/_cjs/utils/getAction.js.map +1 -0
  71. package/_cjs/utils/getUserOperationHash.js.map +1 -1
  72. package/_cjs/utils/index.js +7 -1
  73. package/_cjs/utils/index.js.map +1 -1
  74. package/_cjs/utils/observe.js +7 -2
  75. package/_cjs/utils/observe.js.map +1 -1
  76. package/_cjs/utils/signUserOperationHashWithECDSA.js +7 -7
  77. package/_cjs/utils/signUserOperationHashWithECDSA.js.map +1 -1
  78. package/_esm/accounts/index.js +7 -0
  79. package/_esm/accounts/index.js.map +1 -0
  80. package/_esm/accounts/privateKeyToSafeSmartAccount.js +26 -0
  81. package/_esm/accounts/privateKeyToSafeSmartAccount.js.map +1 -0
  82. package/_esm/accounts/privateKeyToSimpleSmartAccount.js +18 -0
  83. package/_esm/accounts/privateKeyToSimpleSmartAccount.js.map +1 -0
  84. package/_esm/accounts/signerToSafeSmartAccount.js +499 -0
  85. package/_esm/accounts/signerToSafeSmartAccount.js.map +1 -0
  86. package/_esm/accounts/signerToSimpleSmartAccount.js +191 -0
  87. package/_esm/accounts/signerToSimpleSmartAccount.js.map +1 -0
  88. package/_esm/accounts/types.js +20 -0
  89. package/_esm/accounts/types.js.map +1 -0
  90. package/_esm/actions/bundler/chainId.js.map +1 -1
  91. package/_esm/actions/bundler/estimateUserOperationGas.js +4 -1
  92. package/_esm/actions/bundler/estimateUserOperationGas.js.map +1 -1
  93. package/_esm/actions/bundler/getUserOperationByHash.js.map +1 -1
  94. package/_esm/actions/bundler/getUserOperationReceipt.js.map +1 -1
  95. package/_esm/actions/bundler/sendUserOperation.js +4 -3
  96. package/_esm/actions/bundler/sendUserOperation.js.map +1 -1
  97. package/_esm/actions/bundler/supportedEntryPoints.js.map +1 -1
  98. package/_esm/actions/bundler/waitForUserOperationReceipt.js +7 -2
  99. package/_esm/actions/bundler/waitForUserOperationReceipt.js.map +1 -1
  100. package/_esm/actions/index.js.map +1 -1
  101. package/_esm/actions/pimlico/getUserOperationGasPrice.js +2 -2
  102. package/_esm/actions/pimlico/getUserOperationGasPrice.js.map +1 -1
  103. package/_esm/actions/pimlico/getUserOperationStatus.js +1 -1
  104. package/_esm/actions/pimlico/getUserOperationStatus.js.map +1 -1
  105. package/_esm/actions/pimlico/sponsorUserOperation.js +4 -1
  106. package/_esm/actions/pimlico/sponsorUserOperation.js.map +1 -1
  107. package/_esm/actions/pimlico.js.map +1 -1
  108. package/_esm/actions/public/getAccountNonce.js +7 -5
  109. package/_esm/actions/public/getAccountNonce.js.map +1 -1
  110. package/_esm/actions/public/getSenderAddress.js +8 -5
  111. package/_esm/actions/public/getSenderAddress.js.map +1 -1
  112. package/_esm/actions/smartAccount/deployContract.js +64 -0
  113. package/_esm/actions/smartAccount/deployContract.js.map +1 -0
  114. package/_esm/actions/smartAccount/prepareUserOperationRequest.js +69 -0
  115. package/_esm/actions/smartAccount/prepareUserOperationRequest.js.map +1 -0
  116. package/_esm/actions/smartAccount/sendTransaction.js +88 -0
  117. package/_esm/actions/smartAccount/sendTransaction.js.map +1 -0
  118. package/_esm/actions/smartAccount/sendTransactions.js +90 -0
  119. package/_esm/actions/smartAccount/sendTransactions.js.map +1 -0
  120. package/_esm/actions/smartAccount/sendUserOperation.js +18 -0
  121. package/_esm/actions/smartAccount/sendUserOperation.js.map +1 -0
  122. package/_esm/actions/smartAccount/signMessage.js +59 -0
  123. package/_esm/actions/smartAccount/signMessage.js.map +1 -0
  124. package/_esm/actions/smartAccount/signTypedData.js +129 -0
  125. package/_esm/actions/smartAccount/signTypedData.js.map +1 -0
  126. package/_esm/actions/smartAccount/writeContract.js +19 -0
  127. package/_esm/actions/smartAccount/writeContract.js.map +1 -0
  128. package/_esm/actions/smartAccount.js +9 -0
  129. package/_esm/actions/smartAccount.js.map +1 -0
  130. package/_esm/actions/stackup/accounts.js +1 -1
  131. package/_esm/actions/stackup/sponsorUserOperation.js +6 -2
  132. package/_esm/actions/stackup/sponsorUserOperation.js.map +1 -1
  133. package/_esm/clients/{bundler.js → createBundlerClient.js} +1 -1
  134. package/_esm/clients/createBundlerClient.js.map +1 -0
  135. package/_esm/clients/createSmartAccountClient.js +38 -0
  136. package/_esm/clients/createSmartAccountClient.js.map +1 -0
  137. package/_esm/clients/decorators/bundler.js.map +1 -1
  138. package/_esm/clients/decorators/pimlico.js +1 -1
  139. package/_esm/clients/decorators/pimlico.js.map +1 -1
  140. package/_esm/clients/decorators/smartAccount.js +29 -0
  141. package/_esm/clients/decorators/smartAccount.js.map +1 -0
  142. package/_esm/clients/decorators/stackup.js.map +1 -1
  143. package/_esm/clients/pimlico.js +1 -1
  144. package/_esm/clients/pimlico.js.map +1 -1
  145. package/_esm/clients/stackup.js +1 -1
  146. package/_esm/clients/stackup.js.map +1 -1
  147. package/_esm/index.js +5 -2
  148. package/_esm/index.js.map +1 -1
  149. package/_esm/utils/deepHexlify.js +6 -4
  150. package/_esm/utils/deepHexlify.js.map +1 -1
  151. package/_esm/utils/getAction.js +6 -0
  152. package/_esm/utils/getAction.js.map +1 -0
  153. package/_esm/utils/getUserOperationHash.js.map +1 -1
  154. package/_esm/utils/index.js +5 -0
  155. package/_esm/utils/index.js.map +1 -1
  156. package/_esm/utils/observe.js +7 -2
  157. package/_esm/utils/observe.js.map +1 -1
  158. package/_esm/utils/signUserOperationHashWithECDSA.js +7 -6
  159. package/_esm/utils/signUserOperationHashWithECDSA.js.map +1 -1
  160. package/_types/accounts/index.d.ts +7 -0
  161. package/_types/accounts/index.d.ts.map +1 -0
  162. package/_types/accounts/privateKeyToSafeSmartAccount.d.ts +26 -0
  163. package/_types/accounts/privateKeyToSafeSmartAccount.d.ts.map +1 -0
  164. package/_types/accounts/privateKeyToSimpleSmartAccount.d.ts +14 -0
  165. package/_types/accounts/privateKeyToSimpleSmartAccount.d.ts.map +1 -0
  166. package/_types/accounts/signerToSafeSmartAccount.d.ts +28 -0
  167. package/_types/accounts/signerToSafeSmartAccount.d.ts.map +1 -0
  168. package/_types/accounts/signerToSimpleSmartAccount.d.ts +15 -0
  169. package/_types/accounts/signerToSimpleSmartAccount.d.ts.map +1 -0
  170. package/_types/accounts/types.d.ts +32 -0
  171. package/_types/accounts/types.d.ts.map +1 -0
  172. package/_types/actions/bundler/chainId.d.ts +3 -2
  173. package/_types/actions/bundler/chainId.d.ts.map +1 -1
  174. package/_types/actions/bundler/estimateUserOperationGas.d.ts +3 -3
  175. package/_types/actions/bundler/estimateUserOperationGas.d.ts.map +1 -1
  176. package/_types/actions/bundler/getUserOperationByHash.d.ts +3 -3
  177. package/_types/actions/bundler/getUserOperationByHash.d.ts.map +1 -1
  178. package/_types/actions/bundler/getUserOperationReceipt.d.ts +3 -3
  179. package/_types/actions/bundler/getUserOperationReceipt.d.ts.map +1 -1
  180. package/_types/actions/bundler/sendUserOperation.d.ts +3 -5
  181. package/_types/actions/bundler/sendUserOperation.d.ts.map +1 -1
  182. package/_types/actions/bundler/supportedEntryPoints.d.ts +3 -3
  183. package/_types/actions/bundler/supportedEntryPoints.d.ts.map +1 -1
  184. package/_types/actions/bundler/waitForUserOperationReceipt.d.ts +2 -3
  185. package/_types/actions/bundler/waitForUserOperationReceipt.d.ts.map +1 -1
  186. package/_types/actions/index.d.ts.map +1 -1
  187. package/_types/actions/pimlico/getUserOperationGasPrice.d.ts +5 -4
  188. package/_types/actions/pimlico/getUserOperationGasPrice.d.ts.map +1 -1
  189. package/_types/actions/pimlico/getUserOperationStatus.d.ts +4 -5
  190. package/_types/actions/pimlico/getUserOperationStatus.d.ts.map +1 -1
  191. package/_types/actions/pimlico/sponsorUserOperation.d.ts +3 -3
  192. package/_types/actions/pimlico/sponsorUserOperation.d.ts.map +1 -1
  193. package/_types/actions/pimlico.d.ts.map +1 -1
  194. package/_types/actions/public/getAccountNonce.d.ts +5 -5
  195. package/_types/actions/public/getAccountNonce.d.ts.map +1 -1
  196. package/_types/actions/public/getSenderAddress.d.ts +3 -4
  197. package/_types/actions/public/getSenderAddress.d.ts.map +1 -1
  198. package/_types/actions/smartAccount/deployContract.d.ts +34 -0
  199. package/_types/actions/smartAccount/deployContract.d.ts.map +1 -0
  200. package/_types/actions/smartAccount/prepareUserOperationRequest.d.ts +20 -0
  201. package/_types/actions/smartAccount/prepareUserOperationRequest.d.ts.map +1 -0
  202. package/_types/actions/smartAccount/sendTransaction.d.ts +52 -0
  203. package/_types/actions/smartAccount/sendTransaction.d.ts.map +1 -0
  204. package/_types/actions/smartAccount/sendTransactions.d.ts +63 -0
  205. package/_types/actions/smartAccount/sendTransactions.d.ts.map +1 -0
  206. package/_types/actions/smartAccount/sendUserOperation.d.ts +10 -0
  207. package/_types/actions/smartAccount/sendUserOperation.d.ts.map +1 -0
  208. package/_types/actions/smartAccount/signMessage.d.ts +50 -0
  209. package/_types/actions/smartAccount/signMessage.d.ts.map +1 -0
  210. package/_types/actions/smartAccount/signTypedData.d.ts +104 -0
  211. package/_types/actions/smartAccount/signTypedData.d.ts.map +1 -0
  212. package/_types/actions/smartAccount/writeContract.d.ts +57 -0
  213. package/_types/actions/smartAccount/writeContract.d.ts.map +1 -0
  214. package/_types/actions/smartAccount.d.ts +9 -0
  215. package/_types/actions/smartAccount.d.ts.map +1 -0
  216. package/_types/actions/stackup/accounts.d.ts +1 -1
  217. package/_types/actions/stackup/sponsorUserOperation.d.ts +1 -1
  218. package/_types/actions/stackup/sponsorUserOperation.d.ts.map +1 -1
  219. package/_types/clients/{bundler.d.ts → createBundlerClient.d.ts} +1 -1
  220. package/_types/clients/createBundlerClient.d.ts.map +1 -0
  221. package/_types/clients/createSmartAccountClient.d.ts +282 -0
  222. package/_types/clients/createSmartAccountClient.d.ts.map +1 -0
  223. package/_types/clients/decorators/bundler.d.ts +1 -1
  224. package/_types/clients/decorators/bundler.d.ts.map +1 -1
  225. package/_types/clients/decorators/pimlico.d.ts +3 -3
  226. package/_types/clients/decorators/pimlico.d.ts.map +1 -1
  227. package/_types/clients/decorators/smartAccount.d.ts +327 -0
  228. package/_types/clients/decorators/smartAccount.d.ts.map +1 -0
  229. package/_types/clients/decorators/stackup.d.ts.map +1 -1
  230. package/_types/clients/pimlico.d.ts +1 -1
  231. package/_types/clients/pimlico.d.ts.map +1 -1
  232. package/_types/clients/stackup.d.ts +1 -1
  233. package/_types/clients/stackup.d.ts.map +1 -1
  234. package/_types/index.d.ts +6 -3
  235. package/_types/index.d.ts.map +1 -1
  236. package/_types/types/bundler.d.ts +4 -1
  237. package/_types/types/bundler.d.ts.map +1 -1
  238. package/_types/types/index.d.ts +20 -0
  239. package/_types/types/index.d.ts.map +1 -1
  240. package/_types/types/pimlico.d.ts.map +1 -1
  241. package/_types/types/stackup.d.ts.map +1 -1
  242. package/_types/utils/deepHexlify.d.ts.map +1 -1
  243. package/_types/utils/getAction.d.ts +3 -0
  244. package/_types/utils/getAction.d.ts.map +1 -0
  245. package/_types/utils/getUserOperationHash.d.ts.map +1 -1
  246. package/_types/utils/index.d.ts +2 -0
  247. package/_types/utils/index.d.ts.map +1 -1
  248. package/_types/utils/observe.d.ts.map +1 -1
  249. package/_types/utils/signUserOperationHashWithECDSA.d.ts +3 -11
  250. package/_types/utils/signUserOperationHashWithECDSA.d.ts.map +1 -1
  251. package/accounts/index.ts +33 -0
  252. package/accounts/privateKeyToSafeSmartAccount.ts +73 -0
  253. package/accounts/privateKeyToSimpleSmartAccount.ts +44 -0
  254. package/accounts/signerToSafeSmartAccount.ts +775 -0
  255. package/accounts/signerToSimpleSmartAccount.ts +267 -0
  256. package/accounts/types.ts +64 -0
  257. package/actions/bundler/chainId.ts +10 -2
  258. package/actions/bundler/estimateUserOperationGas.ts +17 -6
  259. package/actions/bundler/getUserOperationByHash.ts +16 -5
  260. package/actions/bundler/getUserOperationReceipt.ts +17 -4
  261. package/actions/bundler/sendUserOperation.ts +19 -7
  262. package/actions/bundler/supportedEntryPoints.ts +10 -3
  263. package/actions/bundler/waitForUserOperationReceipt.ts +64 -26
  264. package/actions/index.ts +4 -1
  265. package/actions/pimlico/getUserOperationGasPrice.ts +13 -6
  266. package/actions/pimlico/getUserOperationStatus.ts +12 -5
  267. package/actions/pimlico/sponsorUserOperation.ts +20 -7
  268. package/actions/pimlico.ts +8 -2
  269. package/actions/public/getAccountNonce.ts +20 -8
  270. package/actions/public/getSenderAddress.ts +25 -8
  271. package/actions/smartAccount/deployContract.ts +110 -0
  272. package/actions/smartAccount/prepareUserOperationRequest.ts +140 -0
  273. package/actions/smartAccount/sendTransaction.ts +138 -0
  274. package/actions/smartAccount/sendTransactions.ts +141 -0
  275. package/actions/smartAccount/sendUserOperation.ts +70 -0
  276. package/actions/smartAccount/signMessage.ts +79 -0
  277. package/actions/smartAccount/signTypedData.ts +161 -0
  278. package/actions/smartAccount/writeContract.ts +126 -0
  279. package/actions/smartAccount.ts +49 -0
  280. package/actions/stackup/accounts.ts +1 -1
  281. package/actions/stackup/sponsorUserOperation.ts +14 -4
  282. package/clients/{bundler.ts → createBundlerClient.ts} +14 -3
  283. package/clients/createSmartAccountClient.ts +95 -0
  284. package/clients/decorators/bundler.ts +20 -10
  285. package/clients/decorators/pimlico.ts +21 -9
  286. package/clients/decorators/smartAccount.ts +451 -0
  287. package/clients/decorators/stackup.ts +12 -4
  288. package/clients/pimlico.ts +20 -5
  289. package/clients/stackup.ts +17 -4
  290. package/index.ts +20 -3
  291. package/package.json +12 -2
  292. package/types/bundler.ts +4 -1
  293. package/types/index.ts +29 -0
  294. package/types/pimlico.ts +12 -2
  295. package/types/stackup.ts +4 -1
  296. package/utils/deepHexlify.test.ts +13 -7
  297. package/utils/deepHexlify.ts +5 -4
  298. package/utils/getAction.ts +15 -0
  299. package/utils/getUserOperationHash.ts +10 -2
  300. package/utils/index.ts +15 -2
  301. package/utils/observe.ts +18 -5
  302. package/utils/signUserOperationHashWithECDSA.ts +17 -20
  303. package/_cjs/clients/bundler.js.map +0 -1
  304. package/_esm/clients/bundler.js.map +0 -1
  305. package/_types/clients/bundler.d.ts.map +0 -1
  306. package/tsconfig.build.tsbuildinfo +0 -1
@@ -1,4 +1,5 @@
1
- import type { PimlicoBundlerClient } from "../../clients/pimlico.js"
1
+ import type { Account, Chain, Client, Transport } from "viem"
2
+ import type { PimlicoBundlerRpcSchema } from "../../types/pimlico.js"
2
3
 
3
4
  export type GetUserOperationGasPriceReturnType = {
4
5
  slow: {
@@ -20,7 +21,7 @@ export type GetUserOperationGasPriceReturnType = {
20
21
  *
21
22
  * - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-bundler-actions/getUserOperationGasPrice
22
23
  *
23
- * @param client {@link PimlicoBundlerClient} that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler.
24
+ * @param client that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler.
24
25
  * @returns slow, standard & fast values for maxFeePerGas & maxPriorityFeePerGas
25
26
  *
26
27
  *
@@ -30,14 +31,18 @@ export type GetUserOperationGasPriceReturnType = {
30
31
  *
31
32
  * const bundlerClient = createClient({
32
33
  * chain: goerli,
33
- * transport: http("https://api.pimlico.io/v1/goerli/rpc?apikey=YOUR_API_KEY_HERE")
34
+ * transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE")
34
35
  * })
35
36
  *
36
37
  * await getUserOperationGasPrice(bundlerClient)
37
38
  *
38
39
  */
39
- export const getUserOperationGasPrice = async (
40
- client: PimlicoBundlerClient
40
+ export const getUserOperationGasPrice = async <
41
+ TTransport extends Transport = Transport,
42
+ TChain extends Chain | undefined = Chain | undefined,
43
+ TAccount extends Account | undefined = Account | undefined
44
+ >(
45
+ client: Client<TTransport, TChain, TAccount, PimlicoBundlerRpcSchema>
41
46
  ): Promise<GetUserOperationGasPriceReturnType> => {
42
47
  const gasPrices = await client.request({
43
48
  method: "pimlico_getUserOperationGasPrice",
@@ -51,7 +56,9 @@ export const getUserOperationGasPrice = async (
51
56
  },
52
57
  standard: {
53
58
  maxFeePerGas: BigInt(gasPrices.standard.maxFeePerGas),
54
- maxPriorityFeePerGas: BigInt(gasPrices.standard.maxPriorityFeePerGas)
59
+ maxPriorityFeePerGas: BigInt(
60
+ gasPrices.standard.maxPriorityFeePerGas
61
+ )
55
62
  },
56
63
  fast: {
57
64
  maxFeePerGas: BigInt(gasPrices.fast.maxFeePerGas),
@@ -1,6 +1,9 @@
1
- import type { Hash } from "viem"
1
+ import type { Account, Chain, Client, Hash, Transport } from "viem"
2
2
  import type { PimlicoBundlerClient } from "../../clients/pimlico.js"
3
- import type { PimlicoUserOperationStatus } from "../../types/pimlico.js"
3
+ import type {
4
+ PimlicoBundlerRpcSchema,
5
+ PimlicoUserOperationStatus
6
+ } from "../../types/pimlico.js"
4
7
 
5
8
  export type GetUserOperationStatusParameters = {
6
9
  hash: Hash
@@ -24,14 +27,18 @@ export type GetUserOperationStatusReturnType = PimlicoUserOperationStatus
24
27
  *
25
28
  * const bundlerClient = createClient({
26
29
  * chain: goerli,
27
- * transport: http("https://api.pimlico.io/v1/goerli/rpc?apikey=YOUR_API_KEY_HERE")
30
+ * transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE")
28
31
  * })
29
32
  *
30
33
  * await getUserOperationStatus(bundlerClient, { hash: userOpHash })
31
34
  *
32
35
  */
33
- export const getUserOperationStatus = async (
34
- client: PimlicoBundlerClient,
36
+ export const getUserOperationStatus = async <
37
+ TTransport extends Transport = Transport,
38
+ TChain extends Chain | undefined = Chain | undefined,
39
+ TAccount extends Account | undefined = Account | undefined
40
+ >(
41
+ client: Client<TTransport, TChain, TAccount, PimlicoBundlerRpcSchema>,
35
42
  { hash }: GetUserOperationStatusParameters
36
43
  ): Promise<GetUserOperationStatusReturnType> => {
37
44
  return client.request({
@@ -1,13 +1,19 @@
1
- import type { Address, Hex } from "viem"
1
+ import type { Account, Address, Chain, Client, Hex, Transport } from "viem"
2
2
  import type { PartialBy } from "viem/types/utils"
3
- import type { PimlicoPaymasterClient } from "../../clients/pimlico.js"
4
- import type { UserOperation, UserOperationWithBigIntAsHex } from "../../types/userOperation.js"
3
+ import type { PimlicoPaymasterRpcSchema } from "../../types/pimlico.js"
4
+ import type {
5
+ UserOperation,
6
+ UserOperationWithBigIntAsHex
7
+ } from "../../types/userOperation.js"
5
8
  import { deepHexlify } from "../../utils/deepHexlify.js"
6
9
 
7
10
  export type SponsorUserOperationParameters = {
8
11
  userOperation: PartialBy<
9
12
  UserOperation,
10
- "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "paymasterAndData"
13
+ | "callGasLimit"
14
+ | "preVerificationGas"
15
+ | "verificationGasLimit"
16
+ | "paymasterAndData"
11
17
  >
12
18
  entryPoint: Address
13
19
  }
@@ -44,13 +50,20 @@ export type SponsorUserOperationReturnType = {
44
50
  * }})
45
51
  *
46
52
  */
47
- export const sponsorUserOperation = async (
48
- client: PimlicoPaymasterClient,
53
+ export const sponsorUserOperation = async <
54
+ TTransport extends Transport = Transport,
55
+ TChain extends Chain | undefined = Chain | undefined,
56
+ TAccount extends Account | undefined = Account | undefined
57
+ >(
58
+ client: Client<TTransport, TChain, TAccount, PimlicoPaymasterRpcSchema>,
49
59
  args: SponsorUserOperationParameters
50
60
  ): Promise<SponsorUserOperationReturnType> => {
51
61
  const response = await client.request({
52
62
  method: "pm_sponsorUserOperation",
53
- params: [deepHexlify(args.userOperation) as UserOperationWithBigIntAsHex, args.entryPoint]
63
+ params: [
64
+ deepHexlify(args.userOperation) as UserOperationWithBigIntAsHex,
65
+ args.entryPoint
66
+ ]
54
67
  })
55
68
 
56
69
  return {
@@ -13,8 +13,14 @@ import {
13
13
  sponsorUserOperation
14
14
  } from "./pimlico/sponsorUserOperation.js"
15
15
 
16
- import type { PimlicoBundlerActions, PimlicoPaymasterClientActions } from "../clients/decorators/pimlico.js"
17
- import { pimlicoBundlerActions, pimlicoPaymasterActions } from "../clients/decorators/pimlico.js"
16
+ import type {
17
+ PimlicoBundlerActions,
18
+ PimlicoPaymasterClientActions
19
+ } from "../clients/decorators/pimlico.js"
20
+ import {
21
+ pimlicoBundlerActions,
22
+ pimlicoPaymasterActions
23
+ } from "../clients/decorators/pimlico.js"
18
24
 
19
25
  export type {
20
26
  GetUserOperationGasPriceReturnType,
@@ -1,13 +1,19 @@
1
- import type { Address, PublicClient } from "viem"
1
+ import type { Address, Chain, Client, Transport } from "viem"
2
+ import { readContract } from "viem/actions"
3
+ import { getAction } from "../../utils/getAction.js"
2
4
 
3
- export type GetAccountNonceParams = { sender: Address; entryPoint: Address; key?: bigint }
5
+ export type GetAccountNonceParams = {
6
+ sender: Address
7
+ entryPoint: Address
8
+ key?: bigint
9
+ }
4
10
 
5
11
  /**
6
12
  * Returns the nonce of the account with the entry point.
7
13
  *
8
14
  * - Docs: https://docs.pimlico.io/permissionless/reference/public-actions/getAccountNonce
9
15
  *
10
- * @param publicClient {@link PublicClient} that you created using viem's createPublicClient.
16
+ * @param client {@link client} that you created using viem's createPublicClient.
11
17
  * @param args {@link GetAccountNonceParams} address, entryPoint & key
12
18
  * @returns bigint nonce
13
19
  *
@@ -15,12 +21,12 @@ export type GetAccountNonceParams = { sender: Address; entryPoint: Address; key?
15
21
  * import { createPublicClient } from "viem"
16
22
  * import { getAccountNonce } from "permissionless/actions"
17
23
  *
18
- * const publicClient = createPublicClient({
24
+ * const client = createPublicClient({
19
25
  * chain: goerli,
20
26
  * transport: http("https://goerli.infura.io/v3/your-infura-key")
21
27
  * })
22
28
  *
23
- * const nonce = await getAccountNonce(publicClient, {
29
+ * const nonce = await getAccountNonce(client, {
24
30
  * address,
25
31
  * entryPoint,
26
32
  * key
@@ -28,11 +34,17 @@ export type GetAccountNonceParams = { sender: Address; entryPoint: Address; key?
28
34
  *
29
35
  * // Return 0n
30
36
  */
31
- export const getAccountNonce = async (
32
- publicClient: PublicClient,
37
+ export const getAccountNonce = async <
38
+ TTransport extends Transport = Transport,
39
+ TChain extends Chain | undefined = Chain | undefined
40
+ >(
41
+ client: Client<TTransport, TChain>,
33
42
  { sender, entryPoint, key = BigInt(0) }: GetAccountNonceParams
34
43
  ): Promise<bigint> => {
35
- return await publicClient.readContract({
44
+ return await getAction(
45
+ client,
46
+ readContract
47
+ )({
36
48
  address: entryPoint,
37
49
  abi: [
38
50
  {
@@ -1,18 +1,26 @@
1
1
  import {
2
2
  type Address,
3
3
  BaseError,
4
+ type Chain,
5
+ type Client,
4
6
  type ContractFunctionExecutionErrorType,
5
7
  type ContractFunctionRevertedErrorType,
6
8
  type Hex,
7
- type PublicClient
9
+ type Transport
8
10
  } from "viem"
9
11
 
12
+ import { simulateContract } from "viem/actions"
13
+ import { getAction } from "../../utils/getAction.js"
14
+
10
15
  export type GetSenderAddressParams = { initCode: Hex; entryPoint: Address }
11
16
 
12
17
  export class InvalidEntryPointError extends BaseError {
13
18
  override name = "InvalidEntryPointError"
14
19
 
15
- constructor({ cause, entryPoint }: { cause?: BaseError; entryPoint?: Address } = {}) {
20
+ constructor({
21
+ cause,
22
+ entryPoint
23
+ }: { cause?: BaseError; entryPoint?: Address } = {}) {
16
24
  super(
17
25
  `The entry point address (\`entryPoint\`${
18
26
  entryPoint ? ` = ${entryPoint}` : ""
@@ -29,8 +37,7 @@ export class InvalidEntryPointError extends BaseError {
29
37
  *
30
38
  * - Docs: https://docs.pimlico.io/permissionless/reference/public-actions/getSenderAddress
31
39
  *
32
- *
33
- * @param publicClient {@link PublicClient} that you created using viem's createPublicClient.
40
+ * @param client {@link Client} that you created using viem's createPublicClient.
34
41
  * @param args {@link GetSenderAddressParams} initCode & entryPoint
35
42
  * @returns Sender's Address
36
43
  *
@@ -50,12 +57,18 @@ export class InvalidEntryPointError extends BaseError {
50
57
  *
51
58
  * // Return '0x7a88a206ba40b37a8c07a2b5688cf8b287318b63'
52
59
  */
53
- export const getSenderAddress = async (
54
- publicClient: PublicClient,
60
+ export const getSenderAddress = async <
61
+ TTransport extends Transport = Transport,
62
+ TChain extends Chain | undefined = Chain | undefined
63
+ >(
64
+ client: Client<TTransport, TChain>,
55
65
  { initCode, entryPoint }: GetSenderAddressParams
56
66
  ): Promise<Address> => {
57
67
  try {
58
- await publicClient.simulateContract({
68
+ await getAction(
69
+ client,
70
+ simulateContract
71
+ )({
59
72
  address: entryPoint,
60
73
  abi: [
61
74
  {
@@ -92,7 +105,11 @@ export const getSenderAddress = async (
92
105
  if (err.cause.name === "ContractFunctionRevertedError") {
93
106
  const revertError = err.cause as ContractFunctionRevertedErrorType
94
107
  const errorName = revertError.data?.errorName ?? ""
95
- if (errorName === "SenderAddressResult" && revertError.data?.args && revertError.data?.args[0]) {
108
+ if (
109
+ errorName === "SenderAddressResult" &&
110
+ revertError.data?.args &&
111
+ revertError.data?.args[0]
112
+ ) {
96
113
  return revertError.data?.args[0] as Address
97
114
  }
98
115
  }
@@ -0,0 +1,110 @@
1
+ import {
2
+ type Abi,
3
+ type Chain,
4
+ type Client,
5
+ type DeployContractParameters,
6
+ type DeployContractReturnType,
7
+ type Transport
8
+ } from "viem"
9
+ import type { SmartAccount } from "../../accounts/types.js"
10
+ import { getAction } from "../../utils/getAction.js"
11
+ import { parseAccount } from "../../utils/index.js"
12
+ import { AccountOrClientNotFoundError } from "../../utils/signUserOperationHashWithECDSA.js"
13
+ import { waitForUserOperationReceipt } from "../bundler/waitForUserOperationReceipt.js"
14
+ import { type SponsorUserOperationMiddleware } from "./prepareUserOperationRequest.js"
15
+ import { sendUserOperation } from "./sendUserOperation.js"
16
+
17
+ export type DeployContractParametersWithPaymaster<
18
+ TAbi extends Abi | readonly unknown[] = Abi | readonly unknown[],
19
+ TChain extends Chain | undefined = Chain | undefined,
20
+ TAccount extends SmartAccount | undefined = SmartAccount | undefined,
21
+ TChainOverride extends Chain | undefined = Chain | undefined
22
+ > = DeployContractParameters<TAbi, TChain, TAccount, TChainOverride> &
23
+ SponsorUserOperationMiddleware
24
+
25
+ /**
26
+ * Deploys a contract to the network, given bytecode and constructor arguments.
27
+ * This function also allows you to sponsor this transaction if sender is a smartAccount
28
+ *
29
+ * - Docs: https://viem.sh/docs/contract/deployContract.html
30
+ * - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts
31
+ *
32
+ * @param client - Client to use
33
+ * @param parameters - {@link DeployContractParameters}
34
+ * @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash. {@link DeployContractReturnType}
35
+ *
36
+ * @example
37
+ * import { createWalletClient, http } from 'viem'
38
+ * import { privateKeyToAccount } from 'viem/accounts'
39
+ * import { mainnet } from 'viem/chains'
40
+ * import { deployContract } from 'viem/contract'
41
+ *
42
+ * const client = createWalletClient({
43
+ * account: privateKeyToAccount('0x…'),
44
+ * chain: mainnet,
45
+ * transport: http(),
46
+ * })
47
+ * const hash = await deployContract(client, {
48
+ * abi: [],
49
+ * account: '0x…,
50
+ * bytecode: '0x608060405260405161083e38038061083e833981016040819052610...',
51
+ * })
52
+ */
53
+ export async function deployContract<
54
+ const TAbi extends Abi | readonly unknown[],
55
+ TChain extends Chain | undefined,
56
+ TAccount extends SmartAccount | undefined,
57
+ TChainOverride extends Chain | undefined
58
+ >(
59
+ client: Client<Transport, TChain, TAccount>,
60
+ {
61
+ abi,
62
+ args,
63
+ bytecode,
64
+ sponsorUserOperation,
65
+ ...request
66
+ }: DeployContractParametersWithPaymaster
67
+ ): Promise<DeployContractReturnType> {
68
+ const { account: account_ = client.account } = request
69
+
70
+ if (!account_) {
71
+ throw new AccountOrClientNotFoundError({
72
+ docsPath: "/docs/actions/wallet/sendTransaction"
73
+ })
74
+ }
75
+
76
+ const account = parseAccount(account_) as SmartAccount
77
+
78
+ const userOpHash = await getAction(
79
+ client,
80
+ sendUserOperation
81
+ )({
82
+ userOperation: {
83
+ sender: account.address,
84
+ paymasterAndData: "0x",
85
+ maxFeePerGas: request.maxFeePerGas || 0n,
86
+ maxPriorityFeePerGas: request.maxPriorityFeePerGas || 0n,
87
+ callData: await account.encodeDeployCallData({
88
+ abi,
89
+ args,
90
+ bytecode
91
+ } as unknown as DeployContractParameters<
92
+ TAbi,
93
+ TChain,
94
+ TAccount,
95
+ TChainOverride
96
+ >)
97
+ },
98
+ account: account,
99
+ sponsorUserOperation
100
+ })
101
+
102
+ const userOperationReceipt = await getAction(
103
+ client,
104
+ waitForUserOperationReceipt
105
+ )({
106
+ hash: userOpHash
107
+ })
108
+
109
+ return userOperationReceipt?.receipt.transactionHash
110
+ }
@@ -0,0 +1,140 @@
1
+ import type { Address, Chain, Client, Hex, Transport } from "viem"
2
+ import { estimateFeesPerGas } from "viem/actions"
3
+ import type { SmartAccount } from "../../accounts/types.js"
4
+ import type {
5
+ GetAccountParameter,
6
+ PartialBy,
7
+ UserOperation
8
+ } from "../../types/index.js"
9
+ import { getAction } from "../../utils/getAction.js"
10
+ import {
11
+ AccountOrClientNotFoundError,
12
+ parseAccount
13
+ } from "../../utils/index.js"
14
+ import { estimateUserOperationGas } from "../bundler/estimateUserOperationGas.js"
15
+
16
+ export type SponsorUserOperationMiddleware = {
17
+ sponsorUserOperation?: (args: {
18
+ userOperation: UserOperation
19
+ entryPoint: Address
20
+ }) => Promise<{
21
+ paymasterAndData: Hex
22
+ preVerificationGas: bigint
23
+ verificationGasLimit: bigint
24
+ callGasLimit: bigint
25
+ }>
26
+ }
27
+
28
+ export type PrepareUserOperationRequestParameters<
29
+ TAccount extends SmartAccount | undefined = SmartAccount | undefined,
30
+ > = {
31
+ userOperation: PartialBy<
32
+ UserOperation,
33
+ | "nonce"
34
+ | "sender"
35
+ | "initCode"
36
+ | "callGasLimit"
37
+ | "verificationGasLimit"
38
+ | "preVerificationGas"
39
+ | "maxFeePerGas"
40
+ | "maxPriorityFeePerGas"
41
+ | "paymasterAndData"
42
+ | "signature"
43
+ >
44
+ } & GetAccountParameter<TAccount> &
45
+ SponsorUserOperationMiddleware
46
+
47
+ export type PrepareUserOperationRequestReturnType = UserOperation
48
+
49
+ export async function prepareUserOperationRequest<
50
+ TTransport extends Transport = Transport,
51
+ TChain extends Chain | undefined = Chain | undefined,
52
+ TAccount extends SmartAccount | undefined = SmartAccount | undefined
53
+ >(
54
+ client: Client<TTransport, TChain, TAccount>,
55
+ args: PrepareUserOperationRequestParameters<TAccount>
56
+ ): Promise<PrepareUserOperationRequestReturnType> {
57
+ const {
58
+ account: account_ = client.account,
59
+ userOperation: partialUserOperation,
60
+ sponsorUserOperation
61
+ } = args
62
+ if (!account_) throw new AccountOrClientNotFoundError()
63
+
64
+ const account = parseAccount(account_) as SmartAccount
65
+
66
+ const [sender, nonce, initCode, signature, callData, gasEstimation] =
67
+ await Promise.all([
68
+ partialUserOperation.sender || account.address,
69
+ partialUserOperation.nonce || account.getNonce(),
70
+ partialUserOperation.initCode || account.getInitCode(),
71
+ partialUserOperation.signature || account.getDummySignature(),
72
+ partialUserOperation.callData,
73
+ !partialUserOperation.maxFeePerGas ||
74
+ !partialUserOperation.maxPriorityFeePerGas
75
+ ? estimateFeesPerGas(account.client)
76
+ : undefined
77
+ ])
78
+
79
+ const userOperation: UserOperation = {
80
+ sender,
81
+ nonce,
82
+ initCode,
83
+ signature,
84
+ callData,
85
+ paymasterAndData: "0x",
86
+ maxFeePerGas:
87
+ partialUserOperation.maxFeePerGas ||
88
+ gasEstimation?.maxFeePerGas ||
89
+ 0n,
90
+ maxPriorityFeePerGas:
91
+ partialUserOperation.maxPriorityFeePerGas ||
92
+ gasEstimation?.maxPriorityFeePerGas ||
93
+ 0n,
94
+ callGasLimit: partialUserOperation.callGasLimit || 0n,
95
+ verificationGasLimit: partialUserOperation.verificationGasLimit || 0n,
96
+ preVerificationGas: partialUserOperation.preVerificationGas || 0n
97
+ }
98
+
99
+ if (sponsorUserOperation) {
100
+ const {
101
+ callGasLimit,
102
+ verificationGasLimit,
103
+ preVerificationGas,
104
+ paymasterAndData
105
+ } = await sponsorUserOperation({
106
+ userOperation,
107
+ entryPoint: account.entryPoint
108
+ })
109
+ userOperation.paymasterAndData = paymasterAndData
110
+ userOperation.callGasLimit = userOperation.callGasLimit || callGasLimit
111
+ userOperation.verificationGasLimit =
112
+ userOperation.verificationGasLimit || verificationGasLimit
113
+ userOperation.preVerificationGas =
114
+ userOperation.preVerificationGas || preVerificationGas
115
+ } else if (
116
+ !userOperation.callGasLimit ||
117
+ !userOperation.verificationGasLimit ||
118
+ !userOperation.preVerificationGas
119
+ ) {
120
+ const gasParameters = await getAction(
121
+ client,
122
+ estimateUserOperationGas
123
+ )({
124
+ userOperation: {
125
+ ...userOperation
126
+ },
127
+ entryPoint: account.entryPoint
128
+ })
129
+
130
+ userOperation.callGasLimit =
131
+ userOperation.callGasLimit || gasParameters.callGasLimit
132
+ userOperation.verificationGasLimit =
133
+ userOperation.verificationGasLimit ||
134
+ gasParameters.verificationGasLimit
135
+ userOperation.preVerificationGas =
136
+ userOperation.preVerificationGas || gasParameters.preVerificationGas
137
+ }
138
+
139
+ return userOperation
140
+ }
@@ -0,0 +1,138 @@
1
+ import type {
2
+ Chain,
3
+ Client,
4
+ SendTransactionParameters,
5
+ SendTransactionReturnType,
6
+ Transport
7
+ } from "viem"
8
+ import { type SmartAccount } from "../../accounts/types.js"
9
+ import { getAction } from "../../utils/getAction.js"
10
+ import {
11
+ AccountOrClientNotFoundError,
12
+ parseAccount
13
+ } from "../../utils/index.js"
14
+ import { waitForUserOperationReceipt } from "../bundler/waitForUserOperationReceipt.js"
15
+ import { type SponsorUserOperationMiddleware } from "./prepareUserOperationRequest.js"
16
+ import { sendUserOperation } from "./sendUserOperation.js"
17
+
18
+ export type SendTransactionWithPaymasterParameters<
19
+ TChain extends Chain | undefined = Chain | undefined,
20
+ TAccount extends SmartAccount | undefined = SmartAccount | undefined,
21
+ TChainOverride extends Chain | undefined = Chain | undefined
22
+ > = SendTransactionParameters<TChain, TAccount, TChainOverride> &
23
+ SponsorUserOperationMiddleware
24
+
25
+ /**
26
+ * Creates, signs, and sends a new transaction to the network.
27
+ * This function also allows you to sponsor this transaction if sender is a smartAccount
28
+ *
29
+ * - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html
30
+ * - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions
31
+ * - JSON-RPC Methods:
32
+ * - JSON-RPC Accounts: [`eth_sendTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendtransaction)
33
+ * - Local Accounts: [`eth_sendRawTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction)
34
+ *
35
+ * @param client - Client to use
36
+ * @param parameters - {@link SendTransactionParameters}
37
+ * @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash. {@link SendTransactionReturnType}
38
+ *
39
+ * @example
40
+ * import { createWalletClient, custom } from 'viem'
41
+ * import { mainnet } from 'viem/chains'
42
+ * import { sendTransaction } from 'viem/wallet'
43
+ *
44
+ * const client = createWalletClient({
45
+ * chain: mainnet,
46
+ * transport: custom(window.ethereum),
47
+ * })
48
+ * const hash = await sendTransaction(client, {
49
+ * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
50
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
51
+ * value: 1000000000000000000n,
52
+ * })
53
+ *
54
+ * @example
55
+ * // Account Hoisting
56
+ * import { createWalletClient, http } from 'viem'
57
+ * import { privateKeyToAccount } from 'viem/accounts'
58
+ * import { mainnet } from 'viem/chains'
59
+ * import { sendTransaction } from 'viem/wallet'
60
+ *
61
+ * const client = createWalletClient({
62
+ * account: privateKeyToAccount('0x…'),
63
+ * chain: mainnet,
64
+ * transport: http(),
65
+ * })
66
+ * const hash = await sendTransaction(client, {
67
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
68
+ * value: 1000000000000000000n,
69
+ * })
70
+ */
71
+ export async function sendTransaction<
72
+ TChain extends Chain | undefined,
73
+ TAccount extends SmartAccount | undefined,
74
+ TChainOverride extends Chain | undefined
75
+ >(
76
+ client: Client<Transport, TChain, TAccount>,
77
+ args: SendTransactionWithPaymasterParameters<
78
+ TChain,
79
+ TAccount,
80
+ TChainOverride
81
+ >
82
+ ): Promise<SendTransactionReturnType> {
83
+ const {
84
+ account: account_ = client.account,
85
+ data,
86
+ maxFeePerGas,
87
+ maxPriorityFeePerGas,
88
+ to,
89
+ value,
90
+ nonce,
91
+ sponsorUserOperation
92
+ } = args
93
+
94
+ if (!account_) {
95
+ throw new AccountOrClientNotFoundError({
96
+ docsPath: "/docs/actions/wallet/sendTransaction"
97
+ })
98
+ }
99
+
100
+ const account = parseAccount(account_) as SmartAccount
101
+
102
+ if (!to) throw new Error("Missing to address")
103
+
104
+ if (account.type !== "local") {
105
+ throw new Error("RPC account type not supported")
106
+ }
107
+
108
+ const callData = await account.encodeCallData({
109
+ to,
110
+ value: value || 0n,
111
+ data: data || "0x"
112
+ })
113
+
114
+ const userOpHash = await getAction(
115
+ client,
116
+ sendUserOperation
117
+ )({
118
+ userOperation: {
119
+ sender: account.address,
120
+ paymasterAndData: "0x",
121
+ maxFeePerGas: maxFeePerGas || 0n,
122
+ maxPriorityFeePerGas: maxPriorityFeePerGas || 0n,
123
+ callData: callData,
124
+ nonce: nonce ? BigInt(nonce) : undefined
125
+ },
126
+ account: account,
127
+ sponsorUserOperation
128
+ })
129
+
130
+ const userOperationReceipt = await getAction(
131
+ client,
132
+ waitForUserOperationReceipt
133
+ )({
134
+ hash: userOpHash
135
+ })
136
+
137
+ return userOperationReceipt?.receipt.transactionHash
138
+ }