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,11 +1,86 @@
1
1
  import type { Address, Hash, Hex } from "viem"
2
- import { encodeAbiParameters, keccak256 } from "viem"
2
+ import { concat, encodeAbiParameters, keccak256, pad, toHex } from "viem"
3
+ import type { EntryPoint, GetEntryPointVersion } from "../types"
3
4
  import type { UserOperation } from "../types/userOperation"
5
+ import { getEntryPointVersion } from "./getEntryPointVersion"
4
6
 
5
- function packUserOp({ userOperation }: { userOperation: UserOperation }): Hex {
6
- const hashedInitCode = keccak256(userOperation.initCode)
7
- const hashedCallData = keccak256(userOperation.callData)
8
- const hashedPaymasterAndData = keccak256(userOperation.paymasterAndData)
7
+ function packUserOp<entryPoint extends EntryPoint>({
8
+ userOperation,
9
+ entryPoint: entryPointAddress
10
+ }: {
11
+ userOperation: UserOperation<GetEntryPointVersion<entryPoint>>
12
+ entryPoint: entryPoint
13
+ }): Hex {
14
+ const entryPointVersion = getEntryPointVersion(entryPointAddress)
15
+
16
+ if (entryPointVersion === "v0.6") {
17
+ const userOperationVersion0_6 = userOperation as UserOperation<"v0.6">
18
+ const hashedInitCode = keccak256(userOperationVersion0_6.initCode)
19
+ const hashedCallData = keccak256(userOperationVersion0_6.callData)
20
+ const hashedPaymasterAndData = keccak256(
21
+ userOperationVersion0_6.paymasterAndData
22
+ )
23
+
24
+ return encodeAbiParameters(
25
+ [
26
+ { type: "address" },
27
+ { type: "uint256" },
28
+ { type: "bytes32" },
29
+ { type: "bytes32" },
30
+ { type: "uint256" },
31
+ { type: "uint256" },
32
+ { type: "uint256" },
33
+ { type: "uint256" },
34
+ { type: "uint256" },
35
+ { type: "bytes32" }
36
+ ],
37
+ [
38
+ userOperationVersion0_6.sender as Address,
39
+ userOperationVersion0_6.nonce,
40
+ hashedInitCode,
41
+ hashedCallData,
42
+ userOperationVersion0_6.callGasLimit,
43
+ userOperationVersion0_6.verificationGasLimit,
44
+ userOperationVersion0_6.preVerificationGas,
45
+ userOperationVersion0_6.maxFeePerGas,
46
+ userOperationVersion0_6.maxPriorityFeePerGas,
47
+ hashedPaymasterAndData
48
+ ]
49
+ )
50
+ }
51
+
52
+ const userOperationVersion0_7 = userOperation as UserOperation<"v0.7">
53
+ const hashedInitCode = keccak256(
54
+ userOperationVersion0_7.factory && userOperationVersion0_7.factoryData
55
+ ? concat([
56
+ userOperationVersion0_7.factory,
57
+ userOperationVersion0_7.factoryData
58
+ ])
59
+ : "0x"
60
+ )
61
+ const hashedCallData = keccak256(userOperationVersion0_7.callData)
62
+ const hashedPaymasterAndData = keccak256(
63
+ userOperationVersion0_7.paymaster &&
64
+ userOperationVersion0_7.paymasterVerificationGasLimit &&
65
+ userOperationVersion0_7.paymasterPostOpGasLimit &&
66
+ userOperationVersion0_7.paymasterData
67
+ ? concat([
68
+ userOperationVersion0_7.paymaster,
69
+ pad(
70
+ toHex(
71
+ userOperationVersion0_7.paymasterVerificationGasLimit
72
+ ),
73
+ {
74
+ size: 16
75
+ }
76
+ ),
77
+ pad(toHex(userOperationVersion0_7.paymasterPostOpGasLimit), {
78
+ size: 16
79
+ }),
80
+ userOperationVersion0_7.paymasterData
81
+ ])
82
+ : "0x"
83
+ )
9
84
 
10
85
  return encodeAbiParameters(
11
86
  [
@@ -13,31 +88,37 @@ function packUserOp({ userOperation }: { userOperation: UserOperation }): Hex {
13
88
  { type: "uint256" },
14
89
  { type: "bytes32" },
15
90
  { type: "bytes32" },
91
+ { type: "bytes32" },
16
92
  { type: "uint256" },
17
- { type: "uint256" },
18
- { type: "uint256" },
19
- { type: "uint256" },
20
- { type: "uint256" },
93
+ { type: "bytes32" },
21
94
  { type: "bytes32" }
22
95
  ],
23
96
  [
24
- userOperation.sender as Address,
25
- userOperation.nonce,
97
+ userOperationVersion0_7.sender as Address,
98
+ userOperationVersion0_7.nonce,
26
99
  hashedInitCode,
27
100
  hashedCallData,
28
- userOperation.callGasLimit,
29
- userOperation.verificationGasLimit,
30
- userOperation.preVerificationGas,
31
- userOperation.maxFeePerGas,
32
- userOperation.maxPriorityFeePerGas,
101
+ concat([
102
+ pad(toHex(userOperationVersion0_7.verificationGasLimit), {
103
+ size: 16
104
+ }),
105
+ pad(toHex(userOperationVersion0_7.callGasLimit), { size: 16 })
106
+ ]),
107
+ userOperationVersion0_7.preVerificationGas,
108
+ concat([
109
+ pad(toHex(userOperationVersion0_7.maxPriorityFeePerGas), {
110
+ size: 16
111
+ }),
112
+ pad(toHex(userOperationVersion0_7.maxFeePerGas), { size: 16 })
113
+ ]),
33
114
  hashedPaymasterAndData
34
115
  ]
35
116
  )
36
117
  }
37
118
 
38
- export type GetUserOperationHashParams = {
39
- userOperation: UserOperation
40
- entryPoint: Address
119
+ export type GetUserOperationHashParams<entryPoint extends EntryPoint> = {
120
+ userOperation: UserOperation<GetEntryPointVersion<entryPoint>>
121
+ entryPoint: entryPoint
41
122
  chainId: number
42
123
  }
43
124
 
@@ -62,14 +143,23 @@ export type GetUserOperationHashParams = {
62
143
  * // Returns "0xe9fad2cd67f9ca1d0b7a6513b2a42066784c8df938518da2b51bb8cc9a89ea34"
63
144
  *
64
145
  */
65
- export const getUserOperationHash = ({
146
+ export const getUserOperationHash = <entryPoint extends EntryPoint>({
66
147
  userOperation,
67
- entryPoint,
148
+ entryPoint: entryPointAddress,
68
149
  chainId
69
- }: GetUserOperationHashParams): Hash => {
150
+ }: GetUserOperationHashParams<entryPoint>): Hash => {
70
151
  const encoded = encodeAbiParameters(
71
152
  [{ type: "bytes32" }, { type: "address" }, { type: "uint256" }],
72
- [keccak256(packUserOp({ userOperation })), entryPoint, BigInt(chainId)]
153
+ [
154
+ keccak256(
155
+ packUserOp<entryPoint>({
156
+ userOperation,
157
+ entryPoint: entryPointAddress
158
+ })
159
+ ),
160
+ entryPointAddress,
161
+ BigInt(chainId)
162
+ ]
73
163
  ) as `0x${string}`
74
164
 
75
165
  return keccak256(encoded)
package/utils/index.ts CHANGED
@@ -24,6 +24,11 @@ export function parseAccount(account: Address | Account): Account {
24
24
  return { address: account, type: "json-rpc" }
25
25
  return account
26
26
  }
27
+ import {
28
+ ENTRYPOINT_ADDRESS_V06,
29
+ ENTRYPOINT_ADDRESS_V07,
30
+ getEntryPointVersion
31
+ } from "./getEntryPointVersion"
27
32
 
28
33
  export {
29
34
  transactionReceiptStatus,
@@ -39,5 +44,8 @@ export {
39
44
  AccountOrClientNotFoundError,
40
45
  isSmartAccountDeployed,
41
46
  providerToSmartAccountSigner,
42
- getAddressFromInitCodeOrPaymasterAndData
47
+ getAddressFromInitCodeOrPaymasterAndData,
48
+ getEntryPointVersion,
49
+ ENTRYPOINT_ADDRESS_V06,
50
+ ENTRYPOINT_ADDRESS_V07
43
51
  }
@@ -6,10 +6,13 @@ import {
6
6
  } from "viem"
7
7
  import { walletClientToSmartAccountSigner } from "./walletClientToSmartAccountSigner"
8
8
 
9
- export const providerToSmartAccountSigner = async (
10
- provider: EIP1193Provider,
9
+ export const providerToSmartAccountSigner = async ({
10
+ provider,
11
+ signerAddress
12
+ }: {
13
+ provider: EIP1193Provider
11
14
  signerAddress?: Hex
12
- ) => {
15
+ }) => {
13
16
  let account: Hex
14
17
  if (!signerAddress) {
15
18
  ;[account] = await provider.request({ method: "eth_requestAccounts" })
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  type Account,
3
- type Address,
4
3
  BaseError,
5
4
  type Chain,
6
5
  type Client,
@@ -8,12 +7,17 @@ import {
8
7
  type Hex,
9
8
  type Transport
10
9
  } from "viem"
11
- import { type GetAccountParameterWithClient } from "../types/"
10
+ import type {
11
+ EntryPoint,
12
+ GetAccountParameterWithClient,
13
+ GetEntryPointVersion
14
+ } from "../types/"
12
15
  import type { UserOperation } from "../types/userOperation"
13
16
  import { parseAccount } from "./"
14
17
  import { getUserOperationHash } from "./getUserOperationHash"
15
18
 
16
19
  export type SignUserOperationHashWithECDSAParams<
20
+ entryPoint extends EntryPoint,
17
21
  TTransport extends Transport = Transport,
18
22
  TChain extends Chain | undefined = Chain | undefined,
19
23
  TAccount extends Account | undefined = Account | undefined
@@ -27,8 +31,8 @@ export type SignUserOperationHashWithECDSAParams<
27
31
  }
28
32
  | {
29
33
  hash?: undefined
30
- userOperation: UserOperation
31
- entryPoint: Address
34
+ userOperation: UserOperation<GetEntryPointVersion<entryPoint>>
35
+ entryPoint: entryPoint
32
36
  chainId: number
33
37
  }
34
38
  )
@@ -73,6 +77,7 @@ export class AccountOrClientNotFoundError extends BaseError {
73
77
  *
74
78
  */
75
79
  export const signUserOperationHashWithECDSA = async <
80
+ entryPoint extends EntryPoint,
76
81
  TTransport extends Transport = Transport,
77
82
  TChain extends Chain | undefined = Chain | undefined,
78
83
  TAccount extends Account | undefined = Account | undefined
@@ -82,8 +87,9 @@ export const signUserOperationHashWithECDSA = async <
82
87
  hash,
83
88
  userOperation,
84
89
  chainId,
85
- entryPoint
90
+ entryPoint: entryPointAddress
86
91
  }: SignUserOperationHashWithECDSAParams<
92
+ entryPoint,
87
93
  TTransport,
88
94
  TChain,
89
95
  TAccount
@@ -99,10 +105,10 @@ export const signUserOperationHashWithECDSA = async <
99
105
  if (hash) {
100
106
  userOperationHash = hash
101
107
  } else {
102
- userOperationHash = getUserOperationHash({
108
+ userOperationHash = getUserOperationHash<entryPoint>({
103
109
  userOperation,
104
110
  chainId,
105
- entryPoint
111
+ entryPoint: entryPointAddress
106
112
  })
107
113
  }
108
114