permissionless 0.0.35 → 0.1.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 (325) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/_cjs/accounts/biconomy/privateKeyToBiconomySmartAccount.js.map +1 -1
  3. package/_cjs/accounts/biconomy/signerToBiconomySmartAccount.js +32 -15
  4. package/_cjs/accounts/biconomy/signerToBiconomySmartAccount.js.map +1 -1
  5. package/_cjs/accounts/kernel/signerToEcdsaKernelSmartAccount.js +38 -20
  6. package/_cjs/accounts/kernel/signerToEcdsaKernelSmartAccount.js.map +1 -1
  7. package/_cjs/accounts/safe/privateKeyToSafeSmartAccount.js.map +1 -1
  8. package/_cjs/accounts/safe/signerToSafeSmartAccount.js +42 -11
  9. package/_cjs/accounts/safe/signerToSafeSmartAccount.js.map +1 -1
  10. package/_cjs/accounts/simple/privateKeyToSimpleSmartAccount.js.map +1 -1
  11. package/_cjs/accounts/simple/signerToSimpleSmartAccount.js +104 -44
  12. package/_cjs/accounts/simple/signerToSimpleSmartAccount.js.map +1 -1
  13. package/_cjs/accounts/types.js.map +1 -1
  14. package/_cjs/actions/bundler/chainId.js.map +1 -1
  15. package/_cjs/actions/bundler/estimateUserOperationGas.js +20 -3
  16. package/_cjs/actions/bundler/estimateUserOperationGas.js.map +1 -1
  17. package/_cjs/actions/bundler/getUserOperationByHash.js +28 -11
  18. package/_cjs/actions/bundler/getUserOperationByHash.js.map +1 -1
  19. package/_cjs/actions/bundler/getUserOperationReceipt.js.map +1 -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/pimlico/getUserOperationGasPrice.js +7 -7
  23. package/_cjs/actions/pimlico/getUserOperationGasPrice.js.map +1 -1
  24. package/_cjs/actions/pimlico/sponsorUserOperation.js +19 -7
  25. package/_cjs/actions/pimlico/sponsorUserOperation.js.map +1 -1
  26. package/_cjs/actions/pimlico/validateSponsorshipPolicies.js.map +1 -1
  27. package/_cjs/actions/public/getAccountNonce.js.map +1 -1
  28. package/_cjs/actions/public/getSenderAddress.js +5 -2
  29. package/_cjs/actions/public/getSenderAddress.js.map +1 -1
  30. package/_cjs/actions/smartAccount/deployContract.js +3 -4
  31. package/_cjs/actions/smartAccount/deployContract.js.map +1 -1
  32. package/_cjs/actions/smartAccount/prepareUserOperationRequest.js +142 -19
  33. package/_cjs/actions/smartAccount/prepareUserOperationRequest.js.map +1 -1
  34. package/_cjs/actions/smartAccount/sendTransaction.js +3 -4
  35. package/_cjs/actions/smartAccount/sendTransaction.js.map +1 -1
  36. package/_cjs/actions/smartAccount/sendTransactions.js +3 -4
  37. package/_cjs/actions/smartAccount/sendTransactions.js.map +1 -1
  38. package/_cjs/actions/smartAccount/sendUserOperation.js +1 -1
  39. package/_cjs/actions/smartAccount/sendUserOperation.js.map +1 -1
  40. package/_cjs/actions/smartAccount/signMessage.js.map +1 -1
  41. package/_cjs/actions/smartAccount/signTypedData.js.map +1 -1
  42. package/_cjs/actions/smartAccount/writeContract.js.map +1 -1
  43. package/_cjs/actions/stackup/accounts.js +2 -2
  44. package/_cjs/actions/stackup/accounts.js.map +1 -1
  45. package/_cjs/actions/stackup/sponsorUserOperation.js +20 -12
  46. package/_cjs/actions/stackup/sponsorUserOperation.js.map +1 -1
  47. package/_cjs/clients/createBundlerClient.js +1 -1
  48. package/_cjs/clients/createBundlerClient.js.map +1 -1
  49. package/_cjs/clients/createSmartAccountClient.js +3 -3
  50. package/_cjs/clients/createSmartAccountClient.js.map +1 -1
  51. package/_cjs/clients/decorators/bundler.js +6 -3
  52. package/_cjs/clients/decorators/bundler.js.map +1 -1
  53. package/_cjs/clients/decorators/pimlico.js +6 -3
  54. package/_cjs/clients/decorators/pimlico.js.map +1 -1
  55. package/_cjs/clients/decorators/smartAccount.js +7 -7
  56. package/_cjs/clients/decorators/smartAccount.js.map +1 -1
  57. package/_cjs/clients/decorators/stackup.js.map +1 -1
  58. package/_cjs/clients/pimlico.js +4 -2
  59. package/_cjs/clients/pimlico.js.map +1 -1
  60. package/_cjs/clients/stackup.js +3 -1
  61. package/_cjs/clients/stackup.js.map +1 -1
  62. package/_cjs/errors/estimateUserOperationGas.js.map +1 -1
  63. package/_cjs/errors/sendUserOperation.js.map +1 -1
  64. package/_cjs/types/entrypoint.js +3 -0
  65. package/_cjs/types/entrypoint.js.map +1 -0
  66. package/_cjs/utils/errors/getBundlerError.js.map +1 -1
  67. package/_cjs/utils/errors/getEstimateUserOperationGasError.js.map +1 -1
  68. package/_cjs/utils/errors/getSendUserOperationError.js.map +1 -1
  69. package/_cjs/utils/getEntryPointVersion.js +8 -0
  70. package/_cjs/utils/getEntryPointVersion.js.map +1 -0
  71. package/_cjs/utils/getRequiredPrefund.js +19 -6
  72. package/_cjs/utils/getRequiredPrefund.js.map +1 -1
  73. package/_cjs/utils/getUserOperationHash.js +81 -17
  74. package/_cjs/utils/getUserOperationHash.js.map +1 -1
  75. package/_cjs/utils/index.js +5 -1
  76. package/_cjs/utils/index.js.map +1 -1
  77. package/_cjs/utils/providerToSmartAccountSigner.js +1 -1
  78. package/_cjs/utils/providerToSmartAccountSigner.js.map +1 -1
  79. package/_cjs/utils/signUserOperationHashWithECDSA.js +2 -2
  80. package/_cjs/utils/signUserOperationHashWithECDSA.js.map +1 -1
  81. package/_esm/accounts/biconomy/privateKeyToBiconomySmartAccount.js.map +1 -1
  82. package/_esm/accounts/biconomy/signerToBiconomySmartAccount.js +32 -15
  83. package/_esm/accounts/biconomy/signerToBiconomySmartAccount.js.map +1 -1
  84. package/_esm/accounts/kernel/signerToEcdsaKernelSmartAccount.js +38 -21
  85. package/_esm/accounts/kernel/signerToEcdsaKernelSmartAccount.js.map +1 -1
  86. package/_esm/accounts/safe/privateKeyToSafeSmartAccount.js.map +1 -1
  87. package/_esm/accounts/safe/signerToSafeSmartAccount.js +42 -11
  88. package/_esm/accounts/safe/signerToSafeSmartAccount.js.map +1 -1
  89. package/_esm/accounts/simple/privateKeyToSimpleSmartAccount.js.map +1 -1
  90. package/_esm/accounts/simple/signerToSimpleSmartAccount.js +105 -44
  91. package/_esm/accounts/simple/signerToSimpleSmartAccount.js.map +1 -1
  92. package/_esm/accounts/types.js +0 -1
  93. package/_esm/accounts/types.js.map +1 -1
  94. package/_esm/actions/bundler/chainId.js.map +1 -1
  95. package/_esm/actions/bundler/estimateUserOperationGas.js +20 -3
  96. package/_esm/actions/bundler/estimateUserOperationGas.js.map +1 -1
  97. package/_esm/actions/bundler/getUserOperationByHash.js +28 -11
  98. package/_esm/actions/bundler/getUserOperationByHash.js.map +1 -1
  99. package/_esm/actions/bundler/getUserOperationReceipt.js.map +1 -1
  100. package/_esm/actions/bundler/sendUserOperation.js.map +1 -1
  101. package/_esm/actions/bundler/supportedEntryPoints.js.map +1 -1
  102. package/_esm/actions/pimlico/getUserOperationGasPrice.js +7 -7
  103. package/_esm/actions/pimlico/getUserOperationGasPrice.js.map +1 -1
  104. package/_esm/actions/pimlico/sponsorUserOperation.js +19 -7
  105. package/_esm/actions/pimlico/sponsorUserOperation.js.map +1 -1
  106. package/_esm/actions/pimlico/validateSponsorshipPolicies.js.map +1 -1
  107. package/_esm/actions/public/getAccountNonce.js.map +1 -1
  108. package/_esm/actions/public/getSenderAddress.js +6 -3
  109. package/_esm/actions/public/getSenderAddress.js.map +1 -1
  110. package/_esm/actions/smartAccount/deployContract.js +3 -4
  111. package/_esm/actions/smartAccount/deployContract.js.map +1 -1
  112. package/_esm/actions/smartAccount/prepareUserOperationRequest.js +142 -19
  113. package/_esm/actions/smartAccount/prepareUserOperationRequest.js.map +1 -1
  114. package/_esm/actions/smartAccount/sendTransaction.js +3 -4
  115. package/_esm/actions/smartAccount/sendTransaction.js.map +1 -1
  116. package/_esm/actions/smartAccount/sendTransactions.js +3 -4
  117. package/_esm/actions/smartAccount/sendTransactions.js.map +1 -1
  118. package/_esm/actions/smartAccount/sendUserOperation.js +1 -1
  119. package/_esm/actions/smartAccount/sendUserOperation.js.map +1 -1
  120. package/_esm/actions/smartAccount/signMessage.js.map +1 -1
  121. package/_esm/actions/smartAccount/signTypedData.js.map +1 -1
  122. package/_esm/actions/smartAccount/writeContract.js.map +1 -1
  123. package/_esm/actions/stackup/accounts.js +2 -2
  124. package/_esm/actions/stackup/accounts.js.map +1 -1
  125. package/_esm/actions/stackup/sponsorUserOperation.js +20 -12
  126. package/_esm/actions/stackup/sponsorUserOperation.js.map +1 -1
  127. package/_esm/clients/createBundlerClient.js +1 -1
  128. package/_esm/clients/createBundlerClient.js.map +1 -1
  129. package/_esm/clients/createSmartAccountClient.js +22 -3
  130. package/_esm/clients/createSmartAccountClient.js.map +1 -1
  131. package/_esm/clients/decorators/bundler.js +6 -3
  132. package/_esm/clients/decorators/bundler.js.map +1 -1
  133. package/_esm/clients/decorators/pimlico.js +6 -3
  134. package/_esm/clients/decorators/pimlico.js.map +1 -1
  135. package/_esm/clients/decorators/smartAccount.js +7 -7
  136. package/_esm/clients/decorators/smartAccount.js.map +1 -1
  137. package/_esm/clients/decorators/stackup.js.map +1 -1
  138. package/_esm/clients/pimlico.js +4 -2
  139. package/_esm/clients/pimlico.js.map +1 -1
  140. package/_esm/clients/stackup.js +3 -1
  141. package/_esm/clients/stackup.js.map +1 -1
  142. package/_esm/errors/estimateUserOperationGas.js.map +1 -1
  143. package/_esm/errors/sendUserOperation.js.map +1 -1
  144. package/_esm/types/entrypoint.js +2 -0
  145. package/_esm/types/entrypoint.js.map +1 -0
  146. package/_esm/utils/errors/getBundlerError.js.map +1 -1
  147. package/_esm/utils/errors/getEstimateUserOperationGasError.js.map +1 -1
  148. package/_esm/utils/errors/getSendUserOperationError.js.map +1 -1
  149. package/_esm/utils/getEntryPointVersion.js +4 -0
  150. package/_esm/utils/getEntryPointVersion.js.map +1 -0
  151. package/_esm/utils/getRequiredPrefund.js +19 -6
  152. package/_esm/utils/getRequiredPrefund.js.map +1 -1
  153. package/_esm/utils/getUserOperationHash.js +82 -18
  154. package/_esm/utils/getUserOperationHash.js.map +1 -1
  155. package/_esm/utils/index.js +2 -1
  156. package/_esm/utils/index.js.map +1 -1
  157. package/_esm/utils/providerToSmartAccountSigner.js +1 -1
  158. package/_esm/utils/providerToSmartAccountSigner.js.map +1 -1
  159. package/_esm/utils/signUserOperationHashWithECDSA.js +2 -3
  160. package/_esm/utils/signUserOperationHashWithECDSA.js.map +1 -1
  161. package/_types/accounts/biconomy/privateKeyToBiconomySmartAccount.d.ts +4 -4
  162. package/_types/accounts/biconomy/privateKeyToBiconomySmartAccount.d.ts.map +1 -1
  163. package/_types/accounts/biconomy/signerToBiconomySmartAccount.d.ts +5 -4
  164. package/_types/accounts/biconomy/signerToBiconomySmartAccount.d.ts.map +1 -1
  165. package/_types/accounts/kernel/signerToEcdsaKernelSmartAccount.d.ts +5 -4
  166. package/_types/accounts/kernel/signerToEcdsaKernelSmartAccount.d.ts.map +1 -1
  167. package/_types/accounts/safe/privateKeyToSafeSmartAccount.d.ts +4 -4
  168. package/_types/accounts/safe/privateKeyToSafeSmartAccount.d.ts.map +1 -1
  169. package/_types/accounts/safe/signerToSafeSmartAccount.d.ts +6 -5
  170. package/_types/accounts/safe/signerToSafeSmartAccount.d.ts.map +1 -1
  171. package/_types/accounts/simple/privateKeyToSimpleSmartAccount.d.ts +4 -4
  172. package/_types/accounts/simple/privateKeyToSimpleSmartAccount.d.ts.map +1 -1
  173. package/_types/accounts/simple/signerToSimpleSmartAccount.d.ts +5 -4
  174. package/_types/accounts/simple/signerToSimpleSmartAccount.d.ts.map +1 -1
  175. package/_types/accounts/types.d.ts +8 -5
  176. package/_types/accounts/types.d.ts.map +1 -1
  177. package/_types/actions/bundler/chainId.d.ts +2 -1
  178. package/_types/actions/bundler/chainId.d.ts.map +1 -1
  179. package/_types/actions/bundler/estimateUserOperationGas.d.ts +14 -7
  180. package/_types/actions/bundler/estimateUserOperationGas.d.ts.map +1 -1
  181. package/_types/actions/bundler/getUserOperationByHash.d.ts +10 -3
  182. package/_types/actions/bundler/getUserOperationByHash.d.ts.map +1 -1
  183. package/_types/actions/bundler/getUserOperationReceipt.d.ts +2 -1
  184. package/_types/actions/bundler/getUserOperationReceipt.d.ts.map +1 -1
  185. package/_types/actions/bundler/sendUserOperation.d.ts +6 -5
  186. package/_types/actions/bundler/sendUserOperation.d.ts.map +1 -1
  187. package/_types/actions/bundler/supportedEntryPoints.d.ts +3 -2
  188. package/_types/actions/bundler/supportedEntryPoints.d.ts.map +1 -1
  189. package/_types/actions/pimlico/getUserOperationGasPrice.d.ts.map +1 -1
  190. package/_types/actions/pimlico/sponsorUserOperation.d.ts +47 -6
  191. package/_types/actions/pimlico/sponsorUserOperation.d.ts.map +1 -1
  192. package/_types/actions/pimlico/validateSponsorshipPolicies.d.ts +10 -5
  193. package/_types/actions/pimlico/validateSponsorshipPolicies.d.ts.map +1 -1
  194. package/_types/actions/public/getAccountNonce.d.ts +2 -1
  195. package/_types/actions/public/getAccountNonce.d.ts.map +1 -1
  196. package/_types/actions/public/getSenderAddress.d.ts +11 -3
  197. package/_types/actions/public/getSenderAddress.d.ts.map +1 -1
  198. package/_types/actions/smartAccount/deployContract.d.ts +4 -3
  199. package/_types/actions/smartAccount/deployContract.d.ts.map +1 -1
  200. package/_types/actions/smartAccount/prepareUserOperationRequest.d.ts +21 -11
  201. package/_types/actions/smartAccount/prepareUserOperationRequest.d.ts.map +1 -1
  202. package/_types/actions/smartAccount/sendTransaction.d.ts +4 -3
  203. package/_types/actions/smartAccount/sendTransaction.d.ts.map +1 -1
  204. package/_types/actions/smartAccount/sendTransactions.d.ts +5 -4
  205. package/_types/actions/smartAccount/sendTransactions.d.ts.map +1 -1
  206. package/_types/actions/smartAccount/sendUserOperation.d.ts +6 -5
  207. package/_types/actions/smartAccount/sendUserOperation.d.ts.map +1 -1
  208. package/_types/actions/smartAccount/signMessage.d.ts +2 -1
  209. package/_types/actions/smartAccount/signMessage.d.ts.map +1 -1
  210. package/_types/actions/smartAccount/signTypedData.d.ts +3 -2
  211. package/_types/actions/smartAccount/signTypedData.d.ts.map +1 -1
  212. package/_types/actions/smartAccount/writeContract.d.ts +4 -3
  213. package/_types/actions/smartAccount/writeContract.d.ts.map +1 -1
  214. package/_types/actions/smartAccount.d.ts +2 -2
  215. package/_types/actions/smartAccount.d.ts.map +1 -1
  216. package/_types/actions/stackup/accounts.d.ts +4 -3
  217. package/_types/actions/stackup/accounts.d.ts.map +1 -1
  218. package/_types/actions/stackup/sponsorUserOperation.d.ts +6 -6
  219. package/_types/actions/stackup/sponsorUserOperation.d.ts.map +1 -1
  220. package/_types/clients/createBundlerClient.d.ts +6 -3
  221. package/_types/clients/createBundlerClient.d.ts.map +1 -1
  222. package/_types/clients/createSmartAccountClient.d.ts +9 -5
  223. package/_types/clients/createSmartAccountClient.d.ts.map +1 -1
  224. package/_types/clients/decorators/bundler.d.ts +7 -7
  225. package/_types/clients/decorators/bundler.d.ts.map +1 -1
  226. package/_types/clients/decorators/pimlico.d.ts +6 -5
  227. package/_types/clients/decorators/pimlico.d.ts.map +1 -1
  228. package/_types/clients/decorators/smartAccount.d.ts +12 -12
  229. package/_types/clients/decorators/smartAccount.d.ts.map +1 -1
  230. package/_types/clients/decorators/stackup.d.ts +5 -4
  231. package/_types/clients/decorators/stackup.d.ts.map +1 -1
  232. package/_types/clients/pimlico.d.ts +11 -6
  233. package/_types/clients/pimlico.d.ts.map +1 -1
  234. package/_types/clients/stackup.d.ts +6 -3
  235. package/_types/clients/stackup.d.ts.map +1 -1
  236. package/_types/errors/estimateUserOperationGas.d.ts +4 -3
  237. package/_types/errors/estimateUserOperationGas.d.ts.map +1 -1
  238. package/_types/errors/sendUserOperation.d.ts +4 -3
  239. package/_types/errors/sendUserOperation.d.ts.map +1 -1
  240. package/_types/types/bundler.d.ts +16 -21
  241. package/_types/types/bundler.d.ts.map +1 -1
  242. package/_types/types/entrypoint.d.ts +6 -0
  243. package/_types/types/entrypoint.d.ts.map +1 -0
  244. package/_types/types/index.d.ts +6 -4
  245. package/_types/types/index.d.ts.map +1 -1
  246. package/_types/types/pimlico.d.ts +20 -6
  247. package/_types/types/pimlico.d.ts.map +1 -1
  248. package/_types/types/stackup.d.ts +18 -4
  249. package/_types/types/stackup.d.ts.map +1 -1
  250. package/_types/types/userOperation.d.ts +51 -2
  251. package/_types/types/userOperation.d.ts.map +1 -1
  252. package/_types/utils/errors/getBundlerError.d.ts +4 -4
  253. package/_types/utils/errors/getBundlerError.d.ts.map +1 -1
  254. package/_types/utils/errors/getEstimateUserOperationGasError.d.ts +3 -2
  255. package/_types/utils/errors/getEstimateUserOperationGasError.d.ts.map +1 -1
  256. package/_types/utils/errors/getSendUserOperationError.d.ts +2 -1
  257. package/_types/utils/errors/getSendUserOperationError.d.ts.map +1 -1
  258. package/_types/utils/getEntryPointVersion.d.ts +6 -0
  259. package/_types/utils/getEntryPointVersion.d.ts.map +1 -0
  260. package/_types/utils/getRequiredPrefund.d.ts +5 -4
  261. package/_types/utils/getRequiredPrefund.d.ts.map +1 -1
  262. package/_types/utils/getUserOperationHash.d.ts +6 -5
  263. package/_types/utils/getUserOperationHash.d.ts.map +1 -1
  264. package/_types/utils/index.d.ts +2 -1
  265. package/_types/utils/index.d.ts.map +1 -1
  266. package/_types/utils/providerToSmartAccountSigner.d.ts +4 -1
  267. package/_types/utils/providerToSmartAccountSigner.d.ts.map +1 -1
  268. package/_types/utils/signUserOperationHashWithECDSA.d.ts +6 -6
  269. package/_types/utils/signUserOperationHashWithECDSA.d.ts.map +1 -1
  270. package/accounts/biconomy/privateKeyToBiconomySmartAccount.ts +17 -6
  271. package/accounts/biconomy/signerToBiconomySmartAccount.ts +50 -21
  272. package/accounts/kernel/signerToEcdsaKernelSmartAccount.ts +64 -30
  273. package/accounts/safe/privateKeyToSafeSmartAccount.ts +8 -5
  274. package/accounts/safe/signerToSafeSmartAccount.ts +57 -17
  275. package/accounts/simple/privateKeyToSimpleSmartAccount.ts +25 -7
  276. package/accounts/simple/signerToSimpleSmartAccount.ts +127 -56
  277. package/accounts/types.ts +12 -4
  278. package/actions/bundler/chainId.ts +3 -1
  279. package/actions/bundler/estimateUserOperationGas.ts +77 -22
  280. package/actions/bundler/getUserOperationByHash.ts +44 -15
  281. package/actions/bundler/getUserOperationReceipt.ts +3 -1
  282. package/actions/bundler/sendUserOperation.ts +13 -17
  283. package/actions/bundler/supportedEntryPoints.ts +5 -3
  284. package/actions/pimlico/getUserOperationGasPrice.ts +7 -9
  285. package/actions/pimlico/sponsorUserOperation.ts +97 -23
  286. package/actions/pimlico/validateSponsorshipPolicies.ts +18 -7
  287. package/actions/public/getAccountNonce.ts +2 -1
  288. package/actions/public/getSenderAddress.ts +30 -5
  289. package/actions/smartAccount/deployContract.ts +14 -10
  290. package/actions/smartAccount/prepareUserOperationRequest.ts +339 -49
  291. package/actions/smartAccount/sendTransaction.ts +20 -11
  292. package/actions/smartAccount/sendTransactions.ts +17 -11
  293. package/actions/smartAccount/sendUserOperation.ts +56 -23
  294. package/actions/smartAccount/signMessage.ts +3 -1
  295. package/actions/smartAccount/signTypedData.ts +3 -1
  296. package/actions/smartAccount/writeContract.ts +12 -5
  297. package/actions/smartAccount.ts +2 -2
  298. package/actions/stackup/accounts.ts +7 -6
  299. package/actions/stackup/sponsorUserOperation.ts +85 -31
  300. package/clients/createBundlerClient.ts +11 -6
  301. package/clients/createSmartAccountClient.ts +34 -20
  302. package/clients/decorators/bundler.ts +51 -27
  303. package/clients/decorators/pimlico.ts +43 -17
  304. package/clients/decorators/smartAccount.ts +115 -37
  305. package/clients/decorators/stackup.ts +14 -10
  306. package/clients/pimlico.ts +22 -13
  307. package/clients/stackup.ts +13 -7
  308. package/errors/estimateUserOperationGas.ts +7 -4
  309. package/errors/sendUserOperation.ts +9 -5
  310. package/package.json +1 -1
  311. package/types/bundler.ts +40 -28
  312. package/types/entrypoint.ts +13 -0
  313. package/types/index.ts +15 -5
  314. package/types/pimlico.ts +43 -17
  315. package/types/stackup.ts +39 -15
  316. package/types/userOperation.ts +82 -26
  317. package/utils/errors/getBundlerError.ts +10 -6
  318. package/utils/errors/getEstimateUserOperationGasError.ts +13 -10
  319. package/utils/errors/getSendUserOperationError.ts +4 -3
  320. package/utils/getEntryPointVersion.ts +15 -0
  321. package/utils/getRequiredPrefund.ts +35 -11
  322. package/utils/getUserOperationHash.ts +113 -23
  323. package/utils/index.ts +9 -1
  324. package/utils/providerToSmartAccountSigner.ts +6 -3
  325. package/utils/signUserOperationHashWithECDSA.ts +13 -7
@@ -1,15 +1,8 @@
1
- import type {
2
- Account,
3
- Address,
4
- BaseError,
5
- Chain,
6
- Client,
7
- Hash,
8
- Transport
9
- } from "viem"
1
+ import type { Account, BaseError, Chain, Client, Hash, Transport } from "viem"
10
2
  import type { BundlerClient } from "../../clients/createBundlerClient"
11
3
  import type { Prettify } from "../../types/"
12
4
  import type { BundlerRpcSchema } from "../../types/bundler"
5
+ import type { EntryPoint, GetEntryPointVersion } from "../../types/entrypoint"
13
6
  import type {
14
7
  UserOperation,
15
8
  UserOperationWithBigIntAsHex
@@ -17,9 +10,9 @@ import type {
17
10
  import { deepHexlify } from "../../utils/deepHexlify"
18
11
  import { getSendUserOperationError } from "../../utils/errors/getSendUserOperationError"
19
12
 
20
- export type SendUserOperationParameters = {
21
- userOperation: UserOperation
22
- entryPoint: Address
13
+ export type SendUserOperationParameters<entryPoint extends EntryPoint> = {
14
+ userOperation: UserOperation<GetEntryPointVersion<entryPoint>>
15
+ entryPoint: entryPoint
23
16
  }
24
17
 
25
18
  /**
@@ -48,12 +41,13 @@ export type SendUserOperationParameters = {
48
41
  * // Return '0xe9fad2cd67f9ca1d0b7a6513b2a42066784c8df938518da2b51bb8cc9a89ea34'
49
42
  */
50
43
  export const sendUserOperation = async <
44
+ entryPoint extends EntryPoint,
51
45
  TTransport extends Transport = Transport,
52
46
  TChain extends Chain | undefined = Chain | undefined,
53
47
  TAccount extends Account | undefined = Account | undefined
54
48
  >(
55
- client: Client<TTransport, TChain, TAccount, BundlerRpcSchema>,
56
- args: Prettify<SendUserOperationParameters>
49
+ client: Client<TTransport, TChain, TAccount, BundlerRpcSchema<entryPoint>>,
50
+ args: Prettify<SendUserOperationParameters<entryPoint>>
57
51
  ): Promise<Hash> => {
58
52
  const { userOperation, entryPoint } = args
59
53
 
@@ -61,8 +55,10 @@ export const sendUserOperation = async <
61
55
  const userOperationHash = await client.request({
62
56
  method: "eth_sendUserOperation",
63
57
  params: [
64
- deepHexlify(userOperation) as UserOperationWithBigIntAsHex,
65
- entryPoint as Address
58
+ deepHexlify(userOperation) as UserOperationWithBigIntAsHex<
59
+ GetEntryPointVersion<entryPoint>
60
+ >,
61
+ entryPoint
66
62
  ]
67
63
  })
68
64
 
@@ -70,7 +66,7 @@ export const sendUserOperation = async <
70
66
  } catch (err) {
71
67
  throw getSendUserOperationError(
72
68
  err as BaseError,
73
- args as SendUserOperationParameters
69
+ args as SendUserOperationParameters<entryPoint>
74
70
  )
75
71
  }
76
72
  }
@@ -1,6 +1,7 @@
1
- import type { Account, Address, Chain, Client, Transport } from "viem"
1
+ import type { Account, Chain, Client, Transport } from "viem"
2
2
  import type { BundlerClient } from "../../clients/createBundlerClient"
3
3
  import type { BundlerRpcSchema } from "../../types/bundler"
4
+ import type { EntryPoint } from "../../types/entrypoint"
4
5
 
5
6
  /**
6
7
  * Returns the supported entrypoints by the bundler service
@@ -25,12 +26,13 @@ import type { BundlerRpcSchema } from "../../types/bundler"
25
26
  *
26
27
  */
27
28
  export const supportedEntryPoints = async <
29
+ entryPoint extends EntryPoint,
28
30
  TTransport extends Transport = Transport,
29
31
  TChain extends Chain | undefined = Chain | undefined,
30
32
  TAccount extends Account | undefined = Account | undefined
31
33
  >(
32
- client: Client<TTransport, TChain, TAccount, BundlerRpcSchema>
33
- ): Promise<Address[]> => {
34
+ client: Client<TTransport, TChain, TAccount, BundlerRpcSchema<entryPoint>>
35
+ ): Promise<EntryPoint[]> => {
34
36
  return client.request({
35
37
  method: "eth_supportedEntryPoints",
36
38
  params: []
@@ -45,25 +45,23 @@ export const getUserOperationGasPrice = async <
45
45
  >(
46
46
  client: Client<TTransport, TChain, TAccount, PimlicoBundlerRpcSchema>
47
47
  ): Promise<Prettify<GetUserOperationGasPriceReturnType>> => {
48
- const gasPrices = await client.request({
48
+ const gasPrice = await client.request({
49
49
  method: "pimlico_getUserOperationGasPrice",
50
50
  params: []
51
51
  })
52
52
 
53
53
  return {
54
54
  slow: {
55
- maxFeePerGas: BigInt(gasPrices.slow.maxFeePerGas),
56
- maxPriorityFeePerGas: BigInt(gasPrices.slow.maxPriorityFeePerGas)
55
+ maxFeePerGas: BigInt(gasPrice.slow.maxFeePerGas),
56
+ maxPriorityFeePerGas: BigInt(gasPrice.slow.maxPriorityFeePerGas)
57
57
  },
58
58
  standard: {
59
- maxFeePerGas: BigInt(gasPrices.standard.maxFeePerGas),
60
- maxPriorityFeePerGas: BigInt(
61
- gasPrices.standard.maxPriorityFeePerGas
62
- )
59
+ maxFeePerGas: BigInt(gasPrice.standard.maxFeePerGas),
60
+ maxPriorityFeePerGas: BigInt(gasPrice.standard.maxPriorityFeePerGas)
63
61
  },
64
62
  fast: {
65
- maxFeePerGas: BigInt(gasPrices.fast.maxFeePerGas),
66
- maxPriorityFeePerGas: BigInt(gasPrices.fast.maxPriorityFeePerGas)
63
+ maxFeePerGas: BigInt(gasPrice.fast.maxFeePerGas),
64
+ maxPriorityFeePerGas: BigInt(gasPrice.fast.maxPriorityFeePerGas)
67
65
  }
68
66
  }
69
67
  }
@@ -1,26 +1,58 @@
1
- import type { Account, Address, Chain, Client, Transport } from "viem"
1
+ import type { Account, Address, Chain, Client, Hex, Transport } from "viem"
2
2
  import type { PartialBy } from "viem/types/utils"
3
3
  import type { Prettify } from "../../types/"
4
+ import type {
5
+ ENTRYPOINT_ADDRESS_V06_TYPE,
6
+ EntryPoint,
7
+ GetEntryPointVersion
8
+ } from "../../types/entrypoint"
4
9
  import type { PimlicoPaymasterRpcSchema } from "../../types/pimlico"
5
10
  import type {
6
11
  UserOperation,
7
12
  UserOperationWithBigIntAsHex
8
13
  } from "../../types/userOperation"
9
14
  import { deepHexlify } from "../../utils/deepHexlify"
15
+ import { ENTRYPOINT_ADDRESS_V06 } from "../../utils/getEntryPointVersion"
10
16
 
11
- export type PimlicoSponsorUserOperationParameters = {
12
- userOperation: PartialBy<
13
- UserOperation,
14
- | "callGasLimit"
15
- | "preVerificationGas"
16
- | "verificationGasLimit"
17
- | "paymasterAndData"
18
- >
19
- entryPoint: Address
17
+ export type PimlicoSponsorUserOperationParameters<
18
+ entryPoint extends EntryPoint
19
+ > = {
20
+ userOperation: entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE
21
+ ? PartialBy<
22
+ UserOperation<"v0.6">,
23
+ "callGasLimit" | "preVerificationGas" | "verificationGasLimit"
24
+ >
25
+ : PartialBy<
26
+ UserOperation<"v0.7">,
27
+ | "callGasLimit"
28
+ | "preVerificationGas"
29
+ | "verificationGasLimit"
30
+ | "paymasterVerificationGasLimit"
31
+ | "paymasterPostOpGasLimit"
32
+ >
33
+ entryPoint: entryPoint
20
34
  sponsorshipPolicyId?: string
21
35
  }
22
36
 
23
- export type SponsorUserOperationReturnType = UserOperation
37
+ export type SponsorUserOperationReturnType<entryPoint extends EntryPoint> =
38
+ entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE
39
+ ? Pick<
40
+ UserOperation<"v0.6">,
41
+ | "callGasLimit"
42
+ | "verificationGasLimit"
43
+ | "preVerificationGas"
44
+ | "paymasterAndData"
45
+ >
46
+ : Pick<
47
+ UserOperation<"v0.7">,
48
+ | "callGasLimit"
49
+ | "verificationGasLimit"
50
+ | "preVerificationGas"
51
+ | "paymaster"
52
+ | "paymasterVerificationGasLimit"
53
+ | "paymasterPostOpGasLimit"
54
+ | "paymasterData"
55
+ >
24
56
 
25
57
  /**
26
58
  * Returns paymasterAndData & updated gas parameters required to sponsor a userOperation.
@@ -48,20 +80,28 @@ export type SponsorUserOperationReturnType = UserOperation
48
80
  *
49
81
  */
50
82
  export const sponsorUserOperation = async <
83
+ entryPoint extends EntryPoint,
51
84
  TTransport extends Transport = Transport,
52
85
  TChain extends Chain | undefined = Chain | undefined,
53
86
  TAccount extends Account | undefined = Account | undefined
54
87
  >(
55
- client: Client<TTransport, TChain, TAccount, PimlicoPaymasterRpcSchema>,
56
- args: Prettify<PimlicoSponsorUserOperationParameters>
57
- ): Promise<Prettify<SponsorUserOperationReturnType>> => {
88
+ client: Client<
89
+ TTransport,
90
+ TChain,
91
+ TAccount,
92
+ PimlicoPaymasterRpcSchema<entryPoint>
93
+ >,
94
+ args: Prettify<PimlicoSponsorUserOperationParameters<entryPoint>>
95
+ ): Promise<Prettify<SponsorUserOperationReturnType<entryPoint>>> => {
58
96
  const response = await client.request({
59
97
  method: "pm_sponsorUserOperation",
60
98
  params: args.sponsorshipPolicyId
61
99
  ? [
62
100
  deepHexlify(
63
101
  args.userOperation
64
- ) as UserOperationWithBigIntAsHex,
102
+ ) as UserOperationWithBigIntAsHex<
103
+ GetEntryPointVersion<entryPoint>
104
+ >,
65
105
  args.entryPoint,
66
106
  {
67
107
  sponsorshipPolicyId: args.sponsorshipPolicyId
@@ -70,18 +110,52 @@ export const sponsorUserOperation = async <
70
110
  : [
71
111
  deepHexlify(
72
112
  args.userOperation
73
- ) as UserOperationWithBigIntAsHex,
113
+ ) as UserOperationWithBigIntAsHex<
114
+ GetEntryPointVersion<entryPoint>
115
+ >,
74
116
  args.entryPoint
75
117
  ]
76
118
  })
77
119
 
78
- const userOperation: UserOperation = {
79
- ...args.userOperation,
80
- paymasterAndData: response.paymasterAndData,
81
- preVerificationGas: BigInt(response.preVerificationGas),
82
- verificationGasLimit: BigInt(response.verificationGasLimit),
83
- callGasLimit: BigInt(response.callGasLimit)
120
+ if (args.entryPoint === ENTRYPOINT_ADDRESS_V06) {
121
+ const responseV06 = response as {
122
+ paymasterAndData: Hex
123
+ preVerificationGas: Hex
124
+ verificationGasLimit: Hex
125
+ callGasLimit: Hex
126
+ paymaster?: never
127
+ paymasterVerificationGasLimit?: never
128
+ paymasterPostOpGasLimit?: never
129
+ paymasterData?: never
130
+ }
131
+ return {
132
+ paymasterAndData: responseV06.paymasterAndData,
133
+ preVerificationGas: BigInt(responseV06.preVerificationGas),
134
+ verificationGasLimit: BigInt(responseV06.verificationGasLimit),
135
+ callGasLimit: BigInt(responseV06.callGasLimit)
136
+ } as SponsorUserOperationReturnType<entryPoint>
137
+ }
138
+
139
+ const responseV07 = response as {
140
+ preVerificationGas: Hex
141
+ verificationGasLimit: Hex
142
+ callGasLimit: Hex
143
+ paymaster: Address
144
+ paymasterVerificationGasLimit: Hex
145
+ paymasterPostOpGasLimit: Hex
146
+ paymasterData: Hex
147
+ paymasterAndData?: never
84
148
  }
85
149
 
86
- return userOperation
150
+ return {
151
+ callGasLimit: BigInt(responseV07.callGasLimit),
152
+ verificationGasLimit: BigInt(responseV07.verificationGasLimit),
153
+ preVerificationGas: BigInt(responseV07.preVerificationGas),
154
+ paymaster: responseV07.paymaster,
155
+ paymasterVerificationGasLimit: BigInt(
156
+ responseV07.paymasterVerificationGasLimit
157
+ ),
158
+ paymasterPostOpGasLimit: BigInt(responseV07.paymasterPostOpGasLimit),
159
+ paymasterData: responseV07.paymasterData
160
+ } as SponsorUserOperationReturnType<entryPoint>
87
161
  }
@@ -1,5 +1,6 @@
1
- import type { Account, Address, Chain, Client, Transport } from "viem"
1
+ import type { Account, Chain, Client, Transport } from "viem"
2
2
  import type { Prettify } from "../../types/"
3
+ import type { EntryPoint, GetEntryPointVersion } from "../../types/entrypoint"
3
4
  import type { PimlicoPaymasterRpcSchema } from "../../types/pimlico"
4
5
  import type {
5
6
  UserOperation,
@@ -7,9 +8,11 @@ import type {
7
8
  } from "../../types/userOperation"
8
9
  import { deepHexlify } from "../../utils/deepHexlify"
9
10
 
10
- export type ValidateSponsorshipPoliciesParameters = {
11
- userOperation: UserOperation
12
- entryPoint: Address
11
+ export type ValidateSponsorshipPoliciesParameters<
12
+ entryPoint extends EntryPoint
13
+ > = {
14
+ userOperation: UserOperation<GetEntryPointVersion<entryPoint>>
15
+ entryPoint: entryPoint
13
16
  sponsorshipPolicyIds: string[]
14
17
  }
15
18
 
@@ -59,17 +62,25 @@ export type ValidateSponsorshipPolicies = {
59
62
  * ]
60
63
  */
61
64
  export const validateSponsorshipPolicies = async <
65
+ entryPoint extends EntryPoint,
62
66
  TTransport extends Transport = Transport,
63
67
  TChain extends Chain | undefined = Chain | undefined,
64
68
  TAccount extends Account | undefined = Account | undefined
65
69
  >(
66
- client: Client<TTransport, TChain, TAccount, PimlicoPaymasterRpcSchema>,
67
- args: Prettify<ValidateSponsorshipPoliciesParameters>
70
+ client: Client<
71
+ TTransport,
72
+ TChain,
73
+ TAccount,
74
+ PimlicoPaymasterRpcSchema<entryPoint>
75
+ >,
76
+ args: Prettify<ValidateSponsorshipPoliciesParameters<entryPoint>>
68
77
  ): Promise<Prettify<ValidateSponsorshipPolicies>[]> => {
69
78
  return await client.request({
70
79
  method: "pm_validateSponsorshipPolicies",
71
80
  params: [
72
- deepHexlify(args.userOperation) as UserOperationWithBigIntAsHex,
81
+ deepHexlify(args.userOperation) as UserOperationWithBigIntAsHex<
82
+ GetEntryPointVersion<entryPoint>
83
+ >,
73
84
  args.entryPoint,
74
85
  args.sponsorshipPolicyIds
75
86
  ]
@@ -1,11 +1,12 @@
1
1
  import type { Address, Chain, Client, Transport } from "viem"
2
2
  import { readContract } from "viem/actions"
3
3
  import type { Prettify } from "../../types/"
4
+ import type { EntryPoint } from "../../types/entrypoint"
4
5
  import { getAction } from "../../utils/getAction"
5
6
 
6
7
  export type GetAccountNonceParams = {
7
8
  sender: Address
8
- entryPoint: Address
9
+ entryPoint: EntryPoint
9
10
  key?: bigint
10
11
  }
11
12
 
@@ -6,14 +6,32 @@ import {
6
6
  type ContractFunctionExecutionErrorType,
7
7
  type ContractFunctionRevertedErrorType,
8
8
  type Hex,
9
- type Transport
9
+ type Transport,
10
+ concat
10
11
  } from "viem"
11
12
 
12
13
  import { simulateContract } from "viem/actions"
13
14
  import type { Prettify } from "../../types/"
15
+ import type {
16
+ ENTRYPOINT_ADDRESS_V06_TYPE,
17
+ EntryPoint
18
+ } from "../../types/entrypoint"
14
19
  import { getAction } from "../../utils/getAction"
15
20
 
16
- export type GetSenderAddressParams = { initCode: Hex; entryPoint: Address }
21
+ export type GetSenderAddressParams<entryPoint extends EntryPoint> =
22
+ entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE
23
+ ? {
24
+ initCode: Hex
25
+ entryPoint: entryPoint
26
+ factory?: never
27
+ factoryData?: never
28
+ }
29
+ : {
30
+ entryPoint: entryPoint
31
+ factory: Address
32
+ factoryData: Hex
33
+ initCode?: never
34
+ }
17
35
 
18
36
  export class InvalidEntryPointError extends BaseError {
19
37
  override name = "InvalidEntryPointError"
@@ -59,13 +77,20 @@ export class InvalidEntryPointError extends BaseError {
59
77
  * // Return '0x7a88a206ba40b37a8c07a2b5688cf8b287318b63'
60
78
  */
61
79
  export const getSenderAddress = async <
80
+ entryPoint extends EntryPoint,
62
81
  TTransport extends Transport = Transport,
63
82
  TChain extends Chain | undefined = Chain | undefined
64
83
  >(
65
84
  client: Client<TTransport, TChain>,
66
- args: Prettify<GetSenderAddressParams>
85
+ args: Prettify<GetSenderAddressParams<entryPoint>>
67
86
  ): Promise<Address> => {
68
- const { initCode, entryPoint } = args
87
+ const { initCode, entryPoint, factory, factoryData } = args
88
+
89
+ if (!initCode && !factory && !factoryData) {
90
+ throw new Error(
91
+ "Either `initCode` or `factory` and `factoryData` must be provided"
92
+ )
93
+ }
69
94
 
70
95
  try {
71
96
  await getAction(
@@ -100,7 +125,7 @@ export const getSenderAddress = async <
100
125
  }
101
126
  ],
102
127
  functionName: "getSenderAddress",
103
- args: [initCode]
128
+ args: [initCode || concat([factory as Hex, factoryData as Hex])]
104
129
  })
105
130
  } catch (e) {
106
131
  const err = e as ContractFunctionExecutionErrorType
@@ -9,20 +9,24 @@ import type {
9
9
  } from "viem"
10
10
  import type { SmartAccount } from "../../accounts/types"
11
11
  import type { Prettify } from "../../types/"
12
+ import type { EntryPoint } from "../../types/entrypoint"
12
13
  import { parseAccount } from "../../utils/"
13
14
  import { getAction } from "../../utils/getAction"
14
15
  import { AccountOrClientNotFoundError } from "../../utils/signUserOperationHashWithECDSA"
15
16
  import { waitForUserOperationReceipt } from "../bundler/waitForUserOperationReceipt"
16
- import { type SponsorUserOperationMiddleware } from "./prepareUserOperationRequest"
17
+ import { type Middleware } from "./prepareUserOperationRequest"
17
18
  import { sendUserOperation } from "./sendUserOperation"
18
19
 
19
20
  export type DeployContractParametersWithPaymaster<
21
+ entryPoint extends EntryPoint,
20
22
  TAbi extends Abi | readonly unknown[] = Abi | readonly unknown[],
21
23
  TChain extends Chain | undefined = Chain | undefined,
22
- TAccount extends SmartAccount | undefined = SmartAccount | undefined,
24
+ TAccount extends SmartAccount<entryPoint> | undefined =
25
+ | SmartAccount<entryPoint>
26
+ | undefined,
23
27
  TChainOverride extends Chain | undefined = Chain | undefined
24
28
  > = DeployContractParameters<TAbi, TChain, TAccount, TChainOverride> &
25
- SponsorUserOperationMiddleware
29
+ Middleware<entryPoint>
26
30
 
27
31
  /**
28
32
  * Deploys a contract to the network, given bytecode and constructor arguments.
@@ -53,17 +57,18 @@ export type DeployContractParametersWithPaymaster<
53
57
  * })
54
58
  */
55
59
  export async function deployContract<
60
+ entryPoint extends EntryPoint,
56
61
  TChain extends Chain | undefined,
57
- TAccount extends SmartAccount | undefined
62
+ TAccount extends SmartAccount<entryPoint> | undefined
58
63
  >(
59
64
  client: Client<Transport, TChain, TAccount>,
60
- args: Prettify<DeployContractParametersWithPaymaster>
65
+ args: Prettify<DeployContractParametersWithPaymaster<entryPoint>>
61
66
  ): Promise<Hash> {
62
67
  const {
63
68
  abi,
64
69
  args: constructorArgs,
65
70
  bytecode,
66
- sponsorUserOperation,
71
+ middleware,
67
72
  ...request
68
73
  } = args
69
74
 
@@ -75,15 +80,14 @@ export async function deployContract<
75
80
  })
76
81
  }
77
82
 
78
- const account = parseAccount(account_) as SmartAccount
83
+ const account = parseAccount(account_) as SmartAccount<entryPoint>
79
84
 
80
85
  const userOpHash = await getAction(
81
86
  client,
82
- sendUserOperation
87
+ sendUserOperation<entryPoint>
83
88
  )({
84
89
  userOperation: {
85
90
  sender: account.address,
86
- paymasterAndData: "0x",
87
91
  maxFeePerGas: request.maxFeePerGas || 0n,
88
92
  maxPriorityFeePerGas: request.maxPriorityFeePerGas || 0n,
89
93
  callData: await account.encodeDeployCallData({
@@ -93,7 +97,7 @@ export async function deployContract<
93
97
  } as EncodeDeployDataParameters)
94
98
  },
95
99
  account: account,
96
- sponsorUserOperation
100
+ middleware
97
101
  })
98
102
 
99
103
  const userOperationReceipt = await getAction(