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,12 +1,15 @@
1
1
  import { BaseError } from "viem"
2
2
  import type { EstimateUserOperationGasParameters } from "../actions/bundler/estimateUserOperationGas"
3
+ import type { EntryPoint } from "../types/entrypoint"
3
4
  import { prettyPrint } from "./utils"
4
5
 
5
- export type EstimateUserOperationGasErrorType =
6
- EstimateUserOperationGasError & {
6
+ export type EstimateUserOperationGasErrorType<entryPoint extends EntryPoint> =
7
+ EstimateUserOperationGasError<entryPoint> & {
7
8
  name: "EstimateUserOperationGasError"
8
9
  }
9
- export class EstimateUserOperationGasError extends BaseError {
10
+ export class EstimateUserOperationGasError<
11
+ entryPoint extends EntryPoint
12
+ > extends BaseError {
10
13
  override cause: BaseError
11
14
 
12
15
  override name = "EstimateUserOperationGasError"
@@ -17,7 +20,7 @@ export class EstimateUserOperationGasError extends BaseError {
17
20
  userOperation,
18
21
  entryPoint,
19
22
  docsPath
20
- }: EstimateUserOperationGasParameters & {
23
+ }: EstimateUserOperationGasParameters<entryPoint> & {
21
24
  docsPath?: string
22
25
  }
23
26
  ) {
@@ -1,11 +1,15 @@
1
1
  import { BaseError } from "viem"
2
2
  import { type SendUserOperationParameters } from "../actions/bundler/sendUserOperation"
3
+ import type { EntryPoint } from "../types/entrypoint"
3
4
  import { prettyPrint } from "./utils"
4
5
 
5
- export type SendUserOperationErrorType = SendUserOperationError & {
6
- name: "SendUserOperationError"
7
- }
8
- export class SendUserOperationError extends BaseError {
6
+ export type SendUserOperationErrorType<entryPoint extends EntryPoint> =
7
+ SendUserOperationError<entryPoint> & {
8
+ name: "SendUserOperationError"
9
+ }
10
+ export class SendUserOperationError<
11
+ entryPoint extends EntryPoint
12
+ > extends BaseError {
9
13
  override cause: BaseError
10
14
 
11
15
  override name = "SendUserOperationError"
@@ -16,7 +20,7 @@ export class SendUserOperationError extends BaseError {
16
20
  userOperation,
17
21
  entryPoint,
18
22
  docsPath
19
- }: SendUserOperationParameters & {
23
+ }: SendUserOperationParameters<entryPoint> & {
20
24
  docsPath?: string
21
25
  }
22
26
  ) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "permissionless",
3
- "version": "0.0.35",
3
+ "version": "0.1.0",
4
4
  "author": "Pimlico",
5
5
  "homepage": "https://docs.pimlico.io/permissionless",
6
6
  "repository": "github:pimlicolabs/permissionless.js",
package/types/bundler.ts CHANGED
@@ -1,43 +1,53 @@
1
1
  import type { Address, Hash, Hex } from "viem"
2
2
  import type { PartialBy } from "viem/types/utils"
3
+ import type { EntryPoint, GetEntryPointVersion } from "./entrypoint"
3
4
  import type { UserOperationWithBigIntAsHex } from "./userOperation"
4
5
 
5
- export type BundlerRpcSchema = [
6
+ export type BundlerRpcSchema<entryPoint extends EntryPoint> = [
6
7
  {
7
8
  Method: "eth_sendUserOperation"
8
9
  Parameters: [
9
- userOperation: UserOperationWithBigIntAsHex,
10
- entryPoint: Address
10
+ userOperation: UserOperationWithBigIntAsHex<
11
+ GetEntryPointVersion<entryPoint>
12
+ >,
13
+ entryPoint: entryPoint
11
14
  ]
12
15
  ReturnType: Hash
13
16
  },
14
17
  {
15
18
  Method: "eth_estimateUserOperationGas"
16
19
  Parameters: [
17
- userOperation: PartialBy<
18
- UserOperationWithBigIntAsHex,
19
- "callGasLimit" | "preVerificationGas" | "verificationGasLimit"
20
- >,
21
- entryPoint: Address,
22
- stateOverrides?: {
23
- [x: string]: {
24
- balance?: Hex
25
- nonce?: Hex
26
- code?: Hex
27
- state?: {
28
- [x: Hex]: Hex
29
- }
30
- stateDiff?: {
31
- [x: Hex]: Hex
32
- }
33
- }
34
- }
20
+ userOperation: GetEntryPointVersion<entryPoint> extends "v0.6"
21
+ ? PartialBy<
22
+ UserOperationWithBigIntAsHex<"v0.6">,
23
+ | "callGasLimit"
24
+ | "preVerificationGas"
25
+ | "verificationGasLimit"
26
+ >
27
+ : PartialBy<
28
+ UserOperationWithBigIntAsHex<"v0.7">,
29
+ | "callGasLimit"
30
+ | "preVerificationGas"
31
+ | "verificationGasLimit"
32
+ | "paymasterVerificationGasLimit"
33
+ | "paymasterPostOpGasLimit"
34
+ >,
35
+ entryPoint: entryPoint,
36
+ stateOverrides?: StateOverrides
35
37
  ]
36
- ReturnType: {
37
- preVerificationGas: Hex
38
- verificationGasLimit: Hex
39
- callGasLimit: Hex
40
- }
38
+ ReturnType: GetEntryPointVersion<entryPoint> extends "v0.6"
39
+ ? {
40
+ preVerificationGas: Hex
41
+ verificationGasLimit: Hex
42
+ callGasLimit: Hex
43
+ }
44
+ : {
45
+ preVerificationGas: Hex
46
+ verificationGasLimit: Hex
47
+ callGasLimit: Hex | null | undefined
48
+ paymasterVerificationGasLimit: Hex | null | undefined
49
+ paymasterPostOpGasLimit: Hex | null | undefined
50
+ }
41
51
  },
42
52
  {
43
53
  Method: "eth_supportedEntryPoints"
@@ -53,8 +63,10 @@ export type BundlerRpcSchema = [
53
63
  Method: "eth_getUserOperationByHash"
54
64
  Parameters: [hash: Hash]
55
65
  ReturnType: {
56
- userOperation: UserOperationWithBigIntAsHex
57
- entryPoint: Address
66
+ userOperation: UserOperationWithBigIntAsHex<
67
+ GetEntryPointVersion<entryPoint>
68
+ >
69
+ entryPoint: entryPoint
58
70
  transactionHash: Hash
59
71
  blockHash: Hash
60
72
  blockNumber: Hex
@@ -0,0 +1,13 @@
1
+ export type EntryPointVersion = "v0.6" | "v0.7"
2
+
3
+ export type ENTRYPOINT_ADDRESS_V06_TYPE =
4
+ "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
5
+ export type ENTRYPOINT_ADDRESS_V07_TYPE =
6
+ "0x0000000071727De22E5E9d8BAf0edAc6f37da032"
7
+
8
+ export type GetEntryPointVersion<entryPoint extends EntryPoint> =
9
+ entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE ? "v0.6" : "v0.7"
10
+
11
+ export type EntryPoint =
12
+ | ENTRYPOINT_ADDRESS_V06_TYPE
13
+ | ENTRYPOINT_ADDRESS_V07_TYPE
package/types/index.ts CHANGED
@@ -1,9 +1,16 @@
1
1
  import type { Account, Chain, Client, Transport } from "viem"
2
+ import type { IsUndefined } from "viem/types/utils"
2
3
  import type { SmartAccount } from "../accounts/types"
4
+ import type { EntryPoint } from "./entrypoint"
3
5
  import type { UserOperation } from "./userOperation"
4
6
  export type { UserOperation }
5
-
6
- export type IsUndefined<T> = [undefined] extends [T] ? true : false
7
+ export type {
8
+ EntryPointVersion,
9
+ ENTRYPOINT_ADDRESS_V06_TYPE,
10
+ ENTRYPOINT_ADDRESS_V07_TYPE,
11
+ GetEntryPointVersion,
12
+ EntryPoint
13
+ } from "./entrypoint"
7
14
 
8
15
  export type GetAccountParameterWithClient<
9
16
  TTransport extends Transport = Transport,
@@ -14,10 +21,13 @@ export type GetAccountParameterWithClient<
14
21
  : { client: Client<TTransport, TChain, TAccount>; account?: Account }
15
22
 
16
23
  export type GetAccountParameter<
17
- TAccount extends SmartAccount | undefined = SmartAccount | undefined
24
+ entryPoint extends EntryPoint,
25
+ TAccount extends SmartAccount<entryPoint> | undefined =
26
+ | SmartAccount<entryPoint>
27
+ | undefined
18
28
  > = IsUndefined<TAccount> extends true
19
- ? { account: SmartAccount }
20
- : { account?: SmartAccount }
29
+ ? { account: SmartAccount<entryPoint> }
30
+ : { account?: SmartAccount<entryPoint> }
21
31
 
22
32
  export type Prettify<T> = {
23
33
  [K in keyof T]: T[K]
package/types/pimlico.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { Address, Hash, Hex } from "viem"
2
2
  import type { PartialBy } from "viem/types/utils"
3
+ import type { EntryPoint, GetEntryPointVersion } from "./entrypoint"
3
4
  import type { UserOperationWithBigIntAsHex } from "./userOperation"
4
5
 
5
6
  type PimlicoUserOperationGasPriceWithBigIntAsHex = {
@@ -51,34 +52,59 @@ export type PimlicoBundlerRpcSchema = [
51
52
  }
52
53
  ]
53
54
 
54
- export type PimlicoPaymasterRpcSchema = [
55
+ export type PimlicoPaymasterRpcSchema<entryPoint extends EntryPoint> = [
55
56
  {
56
57
  Method: "pm_sponsorUserOperation"
57
58
  Parameters: [
58
- userOperation: PartialBy<
59
- UserOperationWithBigIntAsHex,
60
- | "callGasLimit"
61
- | "preVerificationGas"
62
- | "verificationGasLimit"
63
- | "paymasterAndData"
64
- >,
65
- entryPoint: Address,
59
+ userOperation: GetEntryPointVersion<entryPoint> extends "v0.6"
60
+ ? PartialBy<
61
+ UserOperationWithBigIntAsHex<"v0.6">,
62
+ | "callGasLimit"
63
+ | "preVerificationGas"
64
+ | "verificationGasLimit"
65
+ >
66
+ : PartialBy<
67
+ UserOperationWithBigIntAsHex<"v0.7">,
68
+ | "callGasLimit"
69
+ | "preVerificationGas"
70
+ | "verificationGasLimit"
71
+ | "paymasterVerificationGasLimit"
72
+ | "paymasterPostOpGasLimit"
73
+ >,
74
+ entryPoint: entryPoint,
66
75
  metadata?: {
67
76
  sponsorshipPolicyId?: string
68
77
  }
69
78
  ]
70
- ReturnType: {
71
- paymasterAndData: Hex
72
- preVerificationGas: Hex
73
- verificationGasLimit: Hex
74
- callGasLimit: Hex
75
- }
79
+ ReturnType: GetEntryPointVersion<entryPoint> extends "v0.6"
80
+ ? {
81
+ paymasterAndData: Hex
82
+ preVerificationGas: Hex
83
+ verificationGasLimit: Hex
84
+ callGasLimit: Hex
85
+ paymaster?: never
86
+ paymasterVerificationGasLimit?: never
87
+ paymasterPostOpGasLimit?: never
88
+ paymasterData?: never
89
+ }
90
+ : {
91
+ preVerificationGas: Hex
92
+ verificationGasLimit: Hex
93
+ callGasLimit: Hex
94
+ paymaster: Address
95
+ paymasterVerificationGasLimit: Hex
96
+ paymasterPostOpGasLimit: Hex
97
+ paymasterData: Hex
98
+ paymasterAndData?: never
99
+ }
76
100
  },
77
101
  {
78
102
  Method: "pm_validateSponsorshipPolicies"
79
103
  Parameters: [
80
- userOperation: UserOperationWithBigIntAsHex,
81
- entryPoint: Address,
104
+ userOperation: UserOperationWithBigIntAsHex<
105
+ GetEntryPointVersion<entryPoint>
106
+ >,
107
+ entryPoint: entryPoint,
82
108
  sponsorshipPolicyIds: string[]
83
109
  ]
84
110
  ReturnType: {
package/types/stackup.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { Address, Hex } from "viem"
2
2
  import type { PartialBy } from "viem/types/utils"
3
+ import type { ENTRYPOINT_ADDRESS_V06_TYPE, EntryPoint } from "./entrypoint"
3
4
  import type { UserOperationWithBigIntAsHex } from "./userOperation"
4
5
 
5
6
  interface StackupPaymasterContextType {
@@ -10,26 +11,49 @@ export type StackupPaymasterContext =
10
11
  | (StackupPaymasterContextType & { type: "erc20token"; token: string })
11
12
  | (StackupPaymasterContextType & { type: "payg" })
12
13
 
13
- export type StackupPaymasterRpcSchema = [
14
+ export type StackupPaymasterRpcSchema<entryPoint extends EntryPoint> = [
14
15
  {
15
16
  Method: "pm_sponsorUserOperation"
16
17
  Parameters: [
17
- userOperation: PartialBy<
18
- UserOperationWithBigIntAsHex,
19
- | "callGasLimit"
20
- | "preVerificationGas"
21
- | "verificationGasLimit"
22
- | "paymasterAndData"
23
- >,
24
- entryPoint: Address,
18
+ userOperation: entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE
19
+ ? PartialBy<
20
+ UserOperationWithBigIntAsHex<"v0.6">,
21
+ | "callGasLimit"
22
+ | "preVerificationGas"
23
+ | "verificationGasLimit"
24
+ >
25
+ : PartialBy<
26
+ UserOperationWithBigIntAsHex<"v0.7">,
27
+ | "callGasLimit"
28
+ | "preVerificationGas"
29
+ | "verificationGasLimit"
30
+ | "paymasterVerificationGasLimit"
31
+ | "paymasterPostOpGasLimit"
32
+ >,
33
+ entryPoint: entryPoint,
25
34
  context: StackupPaymasterContext
26
35
  ]
27
- ReturnType: {
28
- paymasterAndData: Hex
29
- preVerificationGas: Hex
30
- verificationGasLimit: Hex
31
- callGasLimit: Hex
32
- }
36
+ ReturnType: entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE
37
+ ? {
38
+ paymasterAndData: Hex
39
+ preVerificationGas: Hex
40
+ verificationGasLimit: Hex
41
+ callGasLimit: Hex
42
+ paymaster?: never
43
+ paymasterVerificationGasLimit?: never
44
+ paymasterPostOpGasLimit?: never
45
+ paymasterData?: never
46
+ }
47
+ : {
48
+ preVerificationGas: Hex
49
+ verificationGasLimit: Hex
50
+ callGasLimit: Hex
51
+ paymaster: Address
52
+ paymasterVerificationGasLimit: Hex
53
+ paymasterPostOpGasLimit: Hex
54
+ paymasterData: Hex
55
+ paymasterAndData?: never
56
+ }
33
57
  },
34
58
  {
35
59
  Method: "pm_accounts"
@@ -1,32 +1,88 @@
1
1
  import type { Address } from "viem"
2
2
  import type { Hex } from "viem"
3
+ import type { EntryPointVersion } from "./entrypoint"
3
4
 
4
5
  export type TStatus = "success" | "reverted"
5
6
 
6
- export type UserOperationWithBigIntAsHex = {
7
- sender: Address
8
- nonce: Hex
9
- initCode: Hex
10
- callData: Hex
11
- callGasLimit: Hex
12
- verificationGasLimit: Hex
13
- preVerificationGas: Hex
14
- maxFeePerGas: Hex
15
- maxPriorityFeePerGas: Hex
16
- paymasterAndData: Hex
17
- signature: Hex
18
- }
7
+ export type UserOperationWithBigIntAsHex<
8
+ entryPointVersion extends EntryPointVersion
9
+ > = entryPointVersion extends "v0.6"
10
+ ? {
11
+ sender: Address
12
+ nonce: Hex
13
+ initCode: Hex
14
+ callData: Hex
15
+ callGasLimit: Hex
16
+ verificationGasLimit: Hex
17
+ preVerificationGas: Hex
18
+ maxFeePerGas: Hex
19
+ maxPriorityFeePerGas: Hex
20
+ paymasterAndData: Hex
21
+ signature: Hex
22
+ factory?: never
23
+ factoryData?: never
24
+ paymaster?: never
25
+ paymasterVerificationGasLimit?: never
26
+ paymasterPostOpGasLimit?: never
27
+ paymasterData?: never
28
+ }
29
+ : {
30
+ sender: Address
31
+ nonce: Hex
32
+ factory: Address
33
+ factoryData: Hex
34
+ callData: Hex
35
+ callGasLimit: Hex
36
+ verificationGasLimit: Hex
37
+ preVerificationGas: Hex
38
+ maxFeePerGas: Hex
39
+ maxPriorityFeePerGas: Hex
40
+ paymaster: Address
41
+ paymasterVerificationGasLimit: Hex
42
+ paymasterPostOpGasLimit: Hex
43
+ paymasterData: Hex
44
+ signature: Hex
45
+ initCode?: never
46
+ paymasterAndData?: never
47
+ }
19
48
 
20
- export type UserOperation = {
21
- sender: Address
22
- nonce: bigint
23
- initCode: Hex
24
- callData: Hex
25
- callGasLimit: bigint
26
- verificationGasLimit: bigint
27
- preVerificationGas: bigint
28
- maxFeePerGas: bigint
29
- maxPriorityFeePerGas: bigint
30
- paymasterAndData: Hex
31
- signature: Hex
32
- }
49
+ export type UserOperation<entryPointVersion extends EntryPointVersion> =
50
+ entryPointVersion extends "v0.6"
51
+ ? {
52
+ sender: Address
53
+ nonce: bigint
54
+ initCode: Hex
55
+ callData: Hex
56
+ callGasLimit: bigint
57
+ verificationGasLimit: bigint
58
+ preVerificationGas: bigint
59
+ maxFeePerGas: bigint
60
+ maxPriorityFeePerGas: bigint
61
+ paymasterAndData: Hex
62
+ signature: Hex
63
+ factory?: never
64
+ factoryData?: never
65
+ paymaster?: never
66
+ paymasterVerificationGasLimit?: never
67
+ paymasterPostOpGasLimit?: never
68
+ paymasterData?: never
69
+ }
70
+ : {
71
+ sender: Address
72
+ nonce: bigint
73
+ factory: Address | undefined
74
+ factoryData: Hex | undefined
75
+ callData: Hex
76
+ callGasLimit: bigint
77
+ verificationGasLimit: bigint
78
+ preVerificationGas: bigint
79
+ maxFeePerGas: bigint
80
+ maxPriorityFeePerGas: bigint
81
+ paymaster: Address | undefined
82
+ paymasterVerificationGasLimit: bigint | undefined
83
+ paymasterPostOpGasLimit: bigint | undefined
84
+ paymasterData: Hex | undefined
85
+ signature: Hex
86
+ initCode?: never
87
+ paymasterAndData?: never
88
+ }
@@ -38,10 +38,14 @@ import {
38
38
  PaymasterValidityPeriodError,
39
39
  type PaymasterValidityPeriodErrorType
40
40
  } from "../../errors/paymaster"
41
- import type { UserOperation } from "../../types"
42
-
43
- export type GetBundlerErrorParameters = {
44
- userOperation: Partial<UserOperation>
41
+ import type {
42
+ EntryPoint,
43
+ GetEntryPointVersion,
44
+ UserOperation
45
+ } from "../../types"
46
+
47
+ export type GetBundlerErrorParameters<entryPoint extends EntryPoint> = {
48
+ userOperation: Partial<UserOperation<GetEntryPointVersion<entryPoint>>>
45
49
  entryPoint: Address
46
50
  }
47
51
 
@@ -63,9 +67,9 @@ export type GetBundlerErrorReturnType =
63
67
  | PaymasterValidationRevertedErrorType
64
68
  | PaymasterDataRejectedErrorType
65
69
 
66
- export function getBundlerError(
70
+ export function getBundlerError<entryPoint extends EntryPoint>(
67
71
  err: BaseError,
68
- args: GetBundlerErrorParameters
72
+ args: GetBundlerErrorParameters<entryPoint>
69
73
  ) {
70
74
  const message = (err.details || "").toLowerCase()
71
75
 
@@ -5,26 +5,29 @@ import {
5
5
  type EstimateUserOperationGasErrorType
6
6
  } from "../../errors/estimateUserOperationGas"
7
7
  import { type ErrorType } from "../../errors/utils"
8
+ import type { EntryPoint } from "../../types/entrypoint"
8
9
  import {
9
10
  type GetBundlerErrorParameters,
10
11
  type GetBundlerErrorReturnType,
11
12
  getBundlerError
12
13
  } from "./getBundlerError"
13
14
 
14
- export type GetEstimateUserOperationGasErrorReturnType<cause = ErrorType> =
15
- Omit<EstimateUserOperationGasErrorType, "cause"> & {
16
- cause: cause | GetBundlerErrorReturnType
17
- }
15
+ export type GetEstimateUserOperationGasErrorReturnType<
16
+ entryPoint extends EntryPoint,
17
+ cause = ErrorType
18
+ > = Omit<EstimateUserOperationGasErrorType<entryPoint>, "cause"> & {
19
+ cause: cause | GetBundlerErrorReturnType
20
+ }
18
21
 
19
- export function getEstimateUserOperationGasError<err extends ErrorType<string>>(
20
- error: err,
21
- args: EstimateUserOperationGasParameters
22
- ) {
22
+ export function getEstimateUserOperationGasError<
23
+ err extends ErrorType<string>,
24
+ entryPoint extends EntryPoint
25
+ >(error: err, args: EstimateUserOperationGasParameters<entryPoint>) {
23
26
  const cause = (() => {
24
27
  const cause = getBundlerError(
25
28
  // biome-ignore lint/complexity/noBannedTypes: <explanation>
26
29
  error as {} as BaseError,
27
- args as GetBundlerErrorParameters
30
+ args as GetBundlerErrorParameters<entryPoint>
28
31
  )
29
32
  // biome-ignore lint/complexity/noBannedTypes: <explanation>
30
33
  if (cause instanceof UnknownNodeError) return error as {} as BaseError
@@ -33,5 +36,5 @@ export function getEstimateUserOperationGasError<err extends ErrorType<string>>(
33
36
 
34
37
  throw new EstimateUserOperationGasError(cause, {
35
38
  ...args
36
- }) as GetEstimateUserOperationGasErrorReturnType<err>
39
+ }) as GetEstimateUserOperationGasErrorReturnType<entryPoint, err>
37
40
  }
@@ -1,19 +1,20 @@
1
1
  import { BaseError, UnknownNodeError } from "viem"
2
2
  import type { SendUserOperationParameters } from "../../actions/bundler/sendUserOperation"
3
3
  import { SendUserOperationError } from "../../errors"
4
+ import type { EntryPoint } from "../../types/entrypoint"
4
5
  import {
5
6
  type GetBundlerErrorParameters,
6
7
  getBundlerError
7
8
  } from "./getBundlerError"
8
9
 
9
- export function getSendUserOperationError(
10
+ export function getSendUserOperationError<entryPoint extends EntryPoint>(
10
11
  err: BaseError,
11
- args: SendUserOperationParameters
12
+ args: SendUserOperationParameters<entryPoint>
12
13
  ) {
13
14
  const cause = (() => {
14
15
  const cause = getBundlerError(
15
16
  err as BaseError,
16
- args as GetBundlerErrorParameters
17
+ args as GetBundlerErrorParameters<entryPoint>
17
18
  )
18
19
  if (cause instanceof UnknownNodeError) return err as BaseError
19
20
  return cause
@@ -0,0 +1,15 @@
1
+ import type {
2
+ ENTRYPOINT_ADDRESS_V06_TYPE,
3
+ ENTRYPOINT_ADDRESS_V07_TYPE
4
+ } from "../types"
5
+ import type { EntryPoint, GetEntryPointVersion } from "../types/entrypoint"
6
+
7
+ export const ENTRYPOINT_ADDRESS_V06: ENTRYPOINT_ADDRESS_V06_TYPE =
8
+ "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
9
+ export const ENTRYPOINT_ADDRESS_V07: ENTRYPOINT_ADDRESS_V07_TYPE =
10
+ "0x0000000071727De22E5E9d8BAf0edAc6f37da032"
11
+
12
+ export const getEntryPointVersion = (
13
+ entryPoint: EntryPoint
14
+ ): GetEntryPointVersion<EntryPoint> =>
15
+ entryPoint === ENTRYPOINT_ADDRESS_V06 ? "v0.6" : "v0.7"
@@ -1,7 +1,9 @@
1
- import type { UserOperation } from "../types"
1
+ import type { EntryPoint, GetEntryPointVersion, UserOperation } from "../types"
2
+ import { ENTRYPOINT_ADDRESS_V06 } from "./getEntryPointVersion"
2
3
 
3
- export type GetRequiredPrefundReturnType = {
4
- userOperation: UserOperation
4
+ export type GetRequiredPrefundReturnType<entryPoint extends EntryPoint> = {
5
+ userOperation: UserOperation<GetEntryPointVersion<entryPoint>>
6
+ entryPoint: entryPoint
5
7
  }
6
8
 
7
9
  /**
@@ -18,14 +20,36 @@ export type GetRequiredPrefundReturnType = {
18
20
  * userOperation
19
21
  * })
20
22
  */
21
- export const getRequiredPrefund = ({
22
- userOperation
23
- }: GetRequiredPrefundReturnType): bigint => {
24
- const multiplier = userOperation.paymasterAndData.length > 2 ? 3n : 1n
23
+ export const getRequiredPrefund = <entryPoint extends EntryPoint>({
24
+ userOperation,
25
+ entryPoint: entryPointAddress
26
+ }: GetRequiredPrefundReturnType<entryPoint>): bigint => {
27
+ if (entryPointAddress === ENTRYPOINT_ADDRESS_V06) {
28
+ const userOperationVersion0_6 = userOperation as UserOperation<"v0.6">
29
+ const multiplier =
30
+ userOperationVersion0_6.paymasterAndData.length > 2 ? 3n : 1n
31
+ const requiredGas =
32
+ userOperationVersion0_6.callGasLimit +
33
+ userOperationVersion0_6.verificationGasLimit * multiplier +
34
+ userOperationVersion0_6.preVerificationGas
35
+
36
+ return (
37
+ BigInt(requiredGas) * BigInt(userOperationVersion0_6.maxFeePerGas)
38
+ )
39
+ }
40
+
41
+ const userOperationV07 = userOperation as UserOperation<"v0.7">
42
+ const multiplier = userOperationV07.paymaster ? 3n : 1n
43
+
44
+ const verificationGasLimit =
45
+ userOperationV07.verificationGasLimit +
46
+ (userOperationV07.paymasterPostOpGasLimit || 0n) +
47
+ (userOperationV07.paymasterVerificationGasLimit || 0n)
48
+
25
49
  const requiredGas =
26
- userOperation.callGasLimit +
27
- userOperation.verificationGasLimit * multiplier +
28
- userOperation.preVerificationGas
50
+ userOperationV07.callGasLimit +
51
+ verificationGasLimit * multiplier +
52
+ userOperationV07.preVerificationGas
29
53
 
30
- return BigInt(requiredGas) * BigInt(userOperation.maxFeePerGas)
54
+ return BigInt(requiredGas) * BigInt(userOperationV07.maxFeePerGas)
31
55
  }