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
@@ -20,6 +20,8 @@ import { toAccount } from "viem/accounts"
20
20
  import { getChainId, signMessage, signTypedData } from "viem/actions"
21
21
  import { getAccountNonce } from "../../actions/public/getAccountNonce"
22
22
  import type { Prettify } from "../../types"
23
+ import type { ENTRYPOINT_ADDRESS_V06_TYPE } from "../../types/entrypoint"
24
+ import { getEntryPointVersion } from "../../utils"
23
25
  import { getUserOperationHash } from "../../utils/getUserOperationHash"
24
26
  import { isSmartAccountDeployed } from "../../utils/isSmartAccountDeployed"
25
27
  import {
@@ -31,12 +33,12 @@ import {
31
33
  BiconomyExecuteAbi,
32
34
  BiconomyInitAbi
33
35
  } from "./abi/BiconomySmartAccountAbi"
34
- // import Abis
35
36
 
36
37
  export type BiconomySmartAccount<
38
+ entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
37
39
  transport extends Transport = Transport,
38
40
  chain extends Chain | undefined = Chain | undefined
39
- > = SmartAccount<"biconomySmartAccount", transport, chain>
41
+ > = SmartAccount<entryPoint, "biconomySmartAccount", transport, chain>
40
42
 
41
43
  /**
42
44
  * The account creation ABI for Biconomy Smart Account (from the biconomy SmartAccountFactory)
@@ -104,12 +106,10 @@ const BICONOMY_PROXY_CREATION_CODE =
104
106
  const getAccountInitCode = async ({
105
107
  owner,
106
108
  index,
107
- factoryAddress,
108
109
  ecdsaModuleAddress
109
110
  }: {
110
111
  owner: Address
111
112
  index: bigint
112
- factoryAddress: Address
113
113
  ecdsaModuleAddress: Address
114
114
  }): Promise<Hex> => {
115
115
  if (!owner) throw new Error("Owner account not found")
@@ -122,14 +122,11 @@ const getAccountInitCode = async ({
122
122
  })
123
123
 
124
124
  // Build the account init code
125
- return concatHex([
126
- factoryAddress,
127
- encodeFunctionData({
128
- abi: createAccountAbi,
129
- functionName: "deployCounterFactualAccount",
130
- args: [ecdsaModuleAddress, ecdsaOwnershipInitData, index]
131
- }) as Hex
132
- ])
125
+ return encodeFunctionData({
126
+ abi: createAccountAbi,
127
+ functionName: "deployCounterFactualAccount",
128
+ args: [ecdsaModuleAddress, ecdsaOwnershipInitData, index]
129
+ })
133
130
  }
134
131
 
135
132
  const getAccountAddress = async ({
@@ -186,11 +183,12 @@ const getAccountAddress = async ({
186
183
  }
187
184
 
188
185
  export type SignerToBiconomySmartAccountParameters<
186
+ entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
189
187
  TSource extends string = "custom",
190
188
  TAddress extends Address = Address
191
189
  > = Prettify<{
192
190
  signer: SmartAccountSigner<TSource, TAddress>
193
- entryPoint: Address
191
+ entryPoint: entryPoint
194
192
  address?: Address
195
193
  index?: bigint
196
194
  factoryAddress?: Address
@@ -210,6 +208,7 @@ export type SignerToBiconomySmartAccountParameters<
210
208
  * @param ecdsaModuleAddress
211
209
  */
212
210
  export async function signerToBiconomySmartAccount<
211
+ entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
213
212
  TTransport extends Transport = Transport,
214
213
  TChain extends Chain | undefined = Chain | undefined,
215
214
  TSource extends string = "custom",
@@ -219,14 +218,20 @@ export async function signerToBiconomySmartAccount<
219
218
  {
220
219
  signer,
221
220
  address,
222
- entryPoint,
221
+ entryPoint: entryPointAddress,
223
222
  index = 0n,
224
223
  factoryAddress = BICONOMY_ADDRESSES.FACTORY_ADDRESS,
225
224
  accountLogicAddress = BICONOMY_ADDRESSES.ACCOUNT_V2_0_LOGIC,
226
225
  fallbackHandlerAddress = BICONOMY_ADDRESSES.DEFAULT_FALLBACK_HANDLER_ADDRESS,
227
226
  ecdsaModuleAddress = BICONOMY_ADDRESSES.ECDSA_OWNERSHIP_REGISTRY_MODULE
228
- }: SignerToBiconomySmartAccountParameters<TSource, TAddress>
229
- ): Promise<BiconomySmartAccount<TTransport, TChain>> {
227
+ }: SignerToBiconomySmartAccountParameters<entryPoint, TSource, TAddress>
228
+ ): Promise<BiconomySmartAccount<entryPoint, TTransport, TChain>> {
229
+ const entryPointVersion = getEntryPointVersion(entryPointAddress)
230
+
231
+ if (entryPointVersion !== "v0.6") {
232
+ throw new Error("Only EntryPoint 0.6 is supported")
233
+ }
234
+
230
235
  // Get the private key related account
231
236
  const viemSigner: LocalAccount = {
232
237
  ...signer,
@@ -240,7 +245,6 @@ export async function signerToBiconomySmartAccount<
240
245
  getAccountInitCode({
241
246
  owner: viemSigner.address,
242
247
  index,
243
- factoryAddress,
244
248
  ecdsaModuleAddress
245
249
  })
246
250
 
@@ -294,14 +298,14 @@ export async function signerToBiconomySmartAccount<
294
298
  ...account,
295
299
  client: client,
296
300
  publicKey: accountAddress,
297
- entryPoint: entryPoint,
301
+ entryPoint: entryPointAddress,
298
302
  source: "biconomySmartAccount",
299
303
 
300
304
  // Get the nonce of the smart account
301
305
  async getNonce() {
302
306
  return getAccountNonce(client, {
303
307
  sender: accountAddress,
304
- entryPoint: entryPoint
308
+ entryPoint: entryPointAddress
305
309
  })
306
310
  },
307
311
 
@@ -312,7 +316,7 @@ export async function signerToBiconomySmartAccount<
312
316
  ...userOperation,
313
317
  signature: "0x"
314
318
  },
315
- entryPoint: entryPoint,
319
+ entryPoint: entryPointAddress,
316
320
  chainId: chainId
317
321
  })
318
322
  const signature = await signMessage(client, {
@@ -327,6 +331,31 @@ export async function signerToBiconomySmartAccount<
327
331
  return signatureWithModuleAddress
328
332
  },
329
333
 
334
+ async getFactory() {
335
+ if (smartAccountDeployed) return undefined
336
+
337
+ smartAccountDeployed = await isSmartAccountDeployed(
338
+ client,
339
+ accountAddress
340
+ )
341
+
342
+ if (smartAccountDeployed) return undefined
343
+
344
+ return factoryAddress
345
+ },
346
+
347
+ async getFactoryData() {
348
+ if (smartAccountDeployed) return undefined
349
+
350
+ smartAccountDeployed = await isSmartAccountDeployed(
351
+ client,
352
+ accountAddress
353
+ )
354
+
355
+ if (smartAccountDeployed) return undefined
356
+ return generateInitCode()
357
+ },
358
+
330
359
  // Encode the init code
331
360
  async getInitCode() {
332
361
  if (smartAccountDeployed) return "0x"
@@ -338,7 +367,7 @@ export async function signerToBiconomySmartAccount<
338
367
 
339
368
  if (smartAccountDeployed) return "0x"
340
369
 
341
- return generateInitCode()
370
+ return concatHex([factoryAddress, await generateInitCode()])
342
371
  },
343
372
 
344
373
  // Encode the deploy call data
@@ -21,6 +21,8 @@ import {
21
21
  import { getAccountNonce } from "../../actions/public/getAccountNonce"
22
22
  import { getSenderAddress } from "../../actions/public/getSenderAddress"
23
23
  import type { Prettify } from "../../types"
24
+ import type { ENTRYPOINT_ADDRESS_V06_TYPE } from "../../types/entrypoint"
25
+ import { getEntryPointVersion } from "../../utils"
24
26
  import { getUserOperationHash } from "../../utils/getUserOperationHash"
25
27
  import { isSmartAccountDeployed } from "../../utils/isSmartAccountDeployed"
26
28
  import type { SmartAccount } from "../types"
@@ -31,9 +33,10 @@ import {
31
33
  import { KernelExecuteAbi, KernelInitAbi } from "./abi/KernelAccountAbi"
32
34
 
33
35
  export type KernelEcdsaSmartAccount<
36
+ entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
34
37
  transport extends Transport = Transport,
35
38
  chain extends Chain | undefined = Chain | undefined
36
- > = SmartAccount<"kernelEcdsaSmartAccount", transport, chain>
39
+ > = SmartAccount<entryPoint, "kernelEcdsaSmartAccount", transport, chain>
37
40
 
38
41
  /**
39
42
  * The account creation ABI for a kernel smart account (from the KernelFactory)
@@ -94,13 +97,11 @@ const KERNEL_ADDRESSES: {
94
97
  const getAccountInitCode = async ({
95
98
  owner,
96
99
  index,
97
- factoryAddress,
98
100
  accountLogicAddress,
99
101
  ecdsaValidatorAddress
100
102
  }: {
101
103
  owner: Address
102
104
  index: bigint
103
- factoryAddress: Address
104
105
  accountLogicAddress: Address
105
106
  ecdsaValidatorAddress: Address
106
107
  }): Promise<Hex> => {
@@ -114,14 +115,11 @@ const getAccountInitCode = async ({
114
115
  })
115
116
 
116
117
  // Build the account init code
117
- return concatHex([
118
- factoryAddress,
119
- encodeFunctionData({
120
- abi: createAccountAbi,
121
- functionName: "createAccount",
122
- args: [accountLogicAddress, initialisationData, index]
123
- }) as Hex
124
- ])
118
+ return encodeFunctionData({
119
+ abi: createAccountAbi,
120
+ functionName: "createAccount",
121
+ args: [accountLogicAddress, initialisationData, index]
122
+ })
125
123
  }
126
124
 
127
125
  /**
@@ -134,20 +132,23 @@ const getAccountInitCode = async ({
134
132
  * @param deployedAccountAddress
135
133
  */
136
134
  const getAccountAddress = async <
135
+ entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
137
136
  TTransport extends Transport = Transport,
138
137
  TChain extends Chain | undefined = Chain | undefined
139
138
  >({
140
139
  client,
141
140
  owner,
142
- entryPoint,
141
+ entryPoint: entryPointAddress,
143
142
  initCodeProvider,
144
143
  ecdsaValidatorAddress,
145
- deployedAccountAddress
144
+ deployedAccountAddress,
145
+ factoryAddress
146
146
  }: {
147
147
  client: Client<TTransport, TChain>
148
148
  owner: Address
149
149
  initCodeProvider: () => Promise<Hex>
150
- entryPoint: Address
150
+ factoryAddress: Address
151
+ entryPoint: entryPoint
151
152
  ecdsaValidatorAddress: Address
152
153
  deployedAccountAddress?: Address
153
154
  }): Promise<Address> => {
@@ -191,21 +192,21 @@ const getAccountAddress = async <
191
192
  }
192
193
 
193
194
  // Find the init code for this account
194
- const initCode = await initCodeProvider()
195
+ const factoryData = await initCodeProvider()
195
196
 
196
- // Get the sender address based on the init code
197
- return getSenderAddress(client, {
198
- initCode,
199
- entryPoint
197
+ return getSenderAddress<ENTRYPOINT_ADDRESS_V06_TYPE>(client, {
198
+ initCode: concatHex([factoryAddress, factoryData]),
199
+ entryPoint: entryPointAddress as ENTRYPOINT_ADDRESS_V06_TYPE
200
200
  })
201
201
  }
202
202
 
203
203
  export type SignerToEcdsaKernelSmartAccountParameters<
204
+ entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
204
205
  TSource extends string = "custom",
205
206
  TAddress extends Address = Address
206
207
  > = Prettify<{
207
208
  signer: SmartAccountSigner<TSource, TAddress>
208
- entryPoint: Address
209
+ entryPoint: entryPoint
209
210
  address?: Address
210
211
  index?: bigint
211
212
  factoryAddress?: Address
@@ -225,6 +226,7 @@ export type SignerToEcdsaKernelSmartAccountParameters<
225
226
  * @param deployedAccountAddress
226
227
  */
227
228
  export async function signerToEcdsaKernelSmartAccount<
229
+ entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
228
230
  TTransport extends Transport = Transport,
229
231
  TChain extends Chain | undefined = Chain | undefined,
230
232
  TSource extends string = "custom",
@@ -234,14 +236,20 @@ export async function signerToEcdsaKernelSmartAccount<
234
236
  {
235
237
  signer,
236
238
  address,
237
- entryPoint,
239
+ entryPoint: entryPointAddress,
238
240
  index = 0n,
239
241
  factoryAddress = KERNEL_ADDRESSES.FACTORY_ADDRESS,
240
242
  accountLogicAddress = KERNEL_ADDRESSES.ACCOUNT_V2_2_LOGIC,
241
243
  ecdsaValidatorAddress = KERNEL_ADDRESSES.ECDSA_VALIDATOR,
242
244
  deployedAccountAddress
243
- }: SignerToEcdsaKernelSmartAccountParameters<TSource, TAddress>
244
- ): Promise<KernelEcdsaSmartAccount<TTransport, TChain>> {
245
+ }: SignerToEcdsaKernelSmartAccountParameters<entryPoint, TSource, TAddress>
246
+ ): Promise<KernelEcdsaSmartAccount<entryPoint, TTransport, TChain>> {
247
+ const entryPointVersion = getEntryPointVersion(entryPointAddress)
248
+
249
+ if (entryPointVersion !== "v0.6") {
250
+ throw new Error("Only EntryPoint 0.6 is supported")
251
+ }
252
+
245
253
  // Get the private key related account
246
254
  const viemSigner: LocalAccount = {
247
255
  ...signer,
@@ -255,7 +263,6 @@ export async function signerToEcdsaKernelSmartAccount<
255
263
  getAccountInitCode({
256
264
  owner: viemSigner.address,
257
265
  index,
258
- factoryAddress,
259
266
  accountLogicAddress,
260
267
  ecdsaValidatorAddress
261
268
  })
@@ -263,13 +270,14 @@ export async function signerToEcdsaKernelSmartAccount<
263
270
  // Fetch account address and chain id
264
271
  const [accountAddress, chainId] = await Promise.all([
265
272
  address ??
266
- getAccountAddress<TTransport, TChain>({
273
+ getAccountAddress<entryPoint, TTransport, TChain>({
267
274
  client,
268
- entryPoint,
275
+ entryPoint: entryPointAddress,
269
276
  owner: viemSigner.address,
270
277
  ecdsaValidatorAddress,
271
278
  initCodeProvider: generateInitCode,
272
- deployedAccountAddress
279
+ deployedAccountAddress,
280
+ factoryAddress
273
281
  }),
274
282
  getChainId(client)
275
283
  ])
@@ -310,14 +318,14 @@ export async function signerToEcdsaKernelSmartAccount<
310
318
  ...account,
311
319
  client: client,
312
320
  publicKey: accountAddress,
313
- entryPoint: entryPoint,
321
+ entryPoint: entryPointAddress,
314
322
  source: "kernelEcdsaSmartAccount",
315
323
 
316
324
  // Get the nonce of the smart account
317
325
  async getNonce() {
318
326
  return getAccountNonce(client, {
319
327
  sender: accountAddress,
320
- entryPoint: entryPoint
328
+ entryPoint: entryPointAddress
321
329
  })
322
330
  },
323
331
 
@@ -328,7 +336,7 @@ export async function signerToEcdsaKernelSmartAccount<
328
336
  ...userOperation,
329
337
  signature: "0x"
330
338
  },
331
- entryPoint: entryPoint,
339
+ entryPoint: entryPointAddress,
332
340
  chainId: chainId
333
341
  })
334
342
  const signature = await signMessage(client, {
@@ -350,6 +358,32 @@ export async function signerToEcdsaKernelSmartAccount<
350
358
 
351
359
  if (smartAccountDeployed) return "0x"
352
360
 
361
+ return concatHex([factoryAddress, await generateInitCode()])
362
+ },
363
+
364
+ async getFactory() {
365
+ if (smartAccountDeployed) return undefined
366
+
367
+ smartAccountDeployed = await isSmartAccountDeployed(
368
+ client,
369
+ accountAddress
370
+ )
371
+
372
+ if (smartAccountDeployed) return undefined
373
+
374
+ return factoryAddress
375
+ },
376
+
377
+ async getFactoryData() {
378
+ if (smartAccountDeployed) return undefined
379
+
380
+ smartAccountDeployed = await isSmartAccountDeployed(
381
+ client,
382
+ accountAddress
383
+ )
384
+
385
+ if (smartAccountDeployed) return undefined
386
+
353
387
  return generateInitCode()
354
388
  },
355
389
 
@@ -1,16 +1,18 @@
1
1
  import { type Chain, type Client, type Hex, type Transport } from "viem"
2
2
  import { privateKeyToAccount } from "viem/accounts"
3
- import type { Prettify } from "../../types"
3
+ import type { ENTRYPOINT_ADDRESS_V06_TYPE, Prettify } from "../../types"
4
4
  import {
5
5
  type SafeSmartAccount,
6
6
  type SignerToSafeSmartAccountParameters,
7
7
  signerToSafeSmartAccount
8
8
  } from "./signerToSafeSmartAccount"
9
9
 
10
- export type PrivateKeyToSafeSmartAccountParameters = Prettify<
10
+ export type PrivateKeyToSafeSmartAccountParameters<
11
+ entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE
12
+ > = Prettify<
11
13
  {
12
14
  privateKey: Hex
13
- } & Omit<SignerToSafeSmartAccountParameters, "signer">
15
+ } & Omit<SignerToSafeSmartAccountParameters<entryPoint>, "signer">
14
16
  >
15
17
 
16
18
  /**
@@ -19,12 +21,13 @@ export type PrivateKeyToSafeSmartAccountParameters = Prettify<
19
21
  * @returns A Private Key Simple Account.
20
22
  */
21
23
  export async function privateKeyToSafeSmartAccount<
24
+ entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
22
25
  TTransport extends Transport = Transport,
23
26
  TChain extends Chain | undefined = Chain | undefined
24
27
  >(
25
28
  client: Client<TTransport, TChain, undefined>,
26
- { privateKey, ...rest }: PrivateKeyToSafeSmartAccountParameters
27
- ): Promise<SafeSmartAccount<TTransport, TChain>> {
29
+ { privateKey, ...rest }: PrivateKeyToSafeSmartAccountParameters<entryPoint>
30
+ ): Promise<SafeSmartAccount<entryPoint, TTransport, TChain>> {
28
31
  const privateKeyAccount = privateKeyToAccount(privateKey)
29
32
 
30
33
  return signerToSafeSmartAccount(client, {
@@ -28,7 +28,9 @@ import {
28
28
  signTypedData
29
29
  } from "viem/actions"
30
30
  import { getAccountNonce } from "../../actions/public/getAccountNonce"
31
- import type { Prettify } from "../../types"
31
+ import type { ENTRYPOINT_ADDRESS_V06_TYPE, Prettify } from "../../types"
32
+ import type { EntryPoint } from "../../types/entrypoint"
33
+ import { getEntryPointVersion } from "../../utils"
32
34
  import { isSmartAccountDeployed } from "../../utils/isSmartAccountDeployed"
33
35
  import {
34
36
  SignTransactionNotSupportedBySmartAccount,
@@ -172,9 +174,11 @@ const encodeMultiSend = (
172
174
  }
173
175
 
174
176
  export type SafeSmartAccount<
177
+ entryPoint extends
178
+ ENTRYPOINT_ADDRESS_V06_TYPE = ENTRYPOINT_ADDRESS_V06_TYPE,
175
179
  transport extends Transport = Transport,
176
180
  chain extends Chain | undefined = Chain | undefined
177
- > = SmartAccount<"SafeSmartAccount", transport, chain>
181
+ > = SmartAccount<entryPoint, "SafeSmartAccount", transport, chain>
178
182
 
179
183
  const getInitializerCode = async ({
180
184
  owner,
@@ -292,7 +296,6 @@ const getAccountInitCode = async ({
292
296
  owner,
293
297
  addModuleLibAddress,
294
298
  safe4337ModuleAddress,
295
- safeProxyFactoryAddress,
296
299
  safeSingletonAddress,
297
300
  multiSendAddress,
298
301
  saltNonce = 0n,
@@ -302,7 +305,6 @@ const getAccountInitCode = async ({
302
305
  owner: Address
303
306
  addModuleLibAddress: Address
304
307
  safe4337ModuleAddress: Address
305
- safeProxyFactoryAddress: Address
306
308
  safeSingletonAddress: Address
307
309
  multiSendAddress: Address
308
310
  saltNonce?: bigint
@@ -359,7 +361,7 @@ const getAccountInitCode = async ({
359
361
  args: [safeSingletonAddress, initializer, saltNonce]
360
362
  })
361
363
 
362
- return concatHex([safeProxyFactoryAddress, initCodeCallData])
364
+ return initCodeCallData
363
365
  }
364
366
 
365
367
  const getAccountAddress = async <
@@ -490,12 +492,13 @@ const getDefaultAddresses = (
490
492
  }
491
493
 
492
494
  export type SignerToSafeSmartAccountParameters<
495
+ entryPoint extends EntryPoint,
493
496
  TSource extends string = "custom",
494
497
  TAddress extends Address = Address
495
498
  > = Prettify<{
496
499
  signer: SmartAccountSigner<TSource, TAddress>
497
500
  safeVersion: SafeVersion
498
- entryPoint: Address
501
+ entryPoint: entryPoint
499
502
  address?: Address
500
503
  addModuleLibAddress?: Address
501
504
  safe4337ModuleAddress?: Address
@@ -520,6 +523,7 @@ export type SignerToSafeSmartAccountParameters<
520
523
  * @returns A Private Key Simple Account.
521
524
  */
522
525
  export async function signerToSafeSmartAccount<
526
+ entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
523
527
  TTransport extends Transport = Transport,
524
528
  TChain extends Chain | undefined = Chain | undefined,
525
529
  TSource extends string = "custom",
@@ -530,7 +534,7 @@ export async function signerToSafeSmartAccount<
530
534
  signer,
531
535
  address,
532
536
  safeVersion,
533
- entryPoint,
537
+ entryPoint: entryPointAddress,
534
538
  addModuleLibAddress: _addModuleLibAddress,
535
539
  safe4337ModuleAddress: _safe4337ModuleAddress,
536
540
  safeProxyFactoryAddress: _safeProxyFactoryAddress,
@@ -542,8 +546,14 @@ export async function signerToSafeSmartAccount<
542
546
  validAfter = 0,
543
547
  safeModules = [],
544
548
  setupTransactions = []
545
- }: SignerToSafeSmartAccountParameters<TSource, TAddress>
546
- ): Promise<SafeSmartAccount<TTransport, TChain>> {
549
+ }: SignerToSafeSmartAccountParameters<entryPoint, TSource, TAddress>
550
+ ): Promise<SafeSmartAccount<entryPoint, TTransport, TChain>> {
551
+ const entryPointVersion = getEntryPointVersion(entryPointAddress)
552
+
553
+ if (entryPointVersion !== "v0.6") {
554
+ throw new Error("Only EntryPoint 0.6 is supported")
555
+ }
556
+
547
557
  const chainId = await getChainId(client)
548
558
 
549
559
  const viemSigner: LocalAccount = {
@@ -647,16 +657,16 @@ export async function signerToSafeSmartAccount<
647
657
  }
648
658
  })
649
659
 
650
- return {
660
+ const safeSmartAccount: SafeSmartAccount<entryPoint, TTransport, TChain> = {
651
661
  ...account,
652
662
  client: client,
653
663
  publicKey: accountAddress,
654
- entryPoint: entryPoint,
664
+ entryPoint: entryPointAddress,
655
665
  source: "SafeSmartAccount",
656
666
  async getNonce() {
657
667
  return getAccountNonce(client, {
658
668
  sender: accountAddress,
659
- entryPoint: entryPoint
669
+ entryPoint: entryPointAddress
660
670
  })
661
671
  },
662
672
  async signUserOperation(userOperation) {
@@ -674,7 +684,7 @@ export async function signerToSafeSmartAccount<
674
684
  message: {
675
685
  safe: accountAddress,
676
686
  callData: userOperation.callData,
677
- entryPoint: entryPoint,
687
+ entryPoint: entryPointAddress,
678
688
  nonce: userOperation.nonce,
679
689
  initCode: userOperation.initCode,
680
690
  maxFeePerGas: userOperation.maxFeePerGas,
@@ -713,11 +723,39 @@ export async function signerToSafeSmartAccount<
713
723
 
714
724
  if (safeDeployed) return "0x"
715
725
 
716
- return getAccountInitCode({
726
+ const initCodeCallData = await getAccountInitCode({
727
+ owner: viemSigner.address,
728
+ addModuleLibAddress,
729
+ safe4337ModuleAddress,
730
+ safeSingletonAddress,
731
+ multiSendAddress,
732
+ saltNonce,
733
+ setupTransactions,
734
+ safeModules
735
+ })
736
+
737
+ return concatHex([safeProxyFactoryAddress, initCodeCallData])
738
+ },
739
+ async getFactory() {
740
+ if (safeDeployed) return undefined
741
+
742
+ safeDeployed = await isSmartAccountDeployed(client, accountAddress)
743
+
744
+ if (safeDeployed) return undefined
745
+
746
+ return safeProxyFactoryAddress
747
+ },
748
+ async getFactoryData() {
749
+ if (safeDeployed) return undefined
750
+
751
+ safeDeployed = await isSmartAccountDeployed(client, accountAddress)
752
+
753
+ if (safeDeployed) return undefined
754
+
755
+ return await getAccountInitCode({
717
756
  owner: viemSigner.address,
718
757
  addModuleLibAddress,
719
758
  safe4337ModuleAddress,
720
- safeProxyFactoryAddress,
721
759
  safeSingletonAddress,
722
760
  multiSendAddress,
723
761
  saltNonce,
@@ -784,13 +822,13 @@ export async function signerToSafeSmartAccount<
784
822
  type: "uint8"
785
823
  }
786
824
  ],
787
- name: "executeUserOp",
825
+ name: "executeUserOpWithErrorString",
788
826
  outputs: [],
789
827
  stateMutability: "nonpayable",
790
828
  type: "function"
791
829
  }
792
830
  ],
793
- functionName: "executeUserOp",
831
+ functionName: "executeUserOpWithErrorString",
794
832
  args: [to, value, data, operationType]
795
833
  })
796
834
  },
@@ -798,4 +836,6 @@ export async function signerToSafeSmartAccount<
798
836
  return "0x000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
799
837
  }
800
838
  }
839
+
840
+ return safeSmartAccount
801
841
  }
@@ -1,16 +1,24 @@
1
- import { type Chain, type Client, type Hex, type Transport } from "viem"
1
+ import {
2
+ type Address,
3
+ type Chain,
4
+ type Client,
5
+ type Hex,
6
+ type Transport
7
+ } from "viem"
2
8
  import { privateKeyToAccount } from "viem/accounts"
3
- import type { Prettify } from "../../types"
9
+ import type { EntryPoint, Prettify } from "../../types"
4
10
  import {
5
11
  type SignerToSimpleSmartAccountParameters,
6
12
  type SimpleSmartAccount,
7
13
  signerToSimpleSmartAccount
8
14
  } from "./signerToSimpleSmartAccount"
9
15
 
10
- export type PrivateKeyToSimpleSmartAccountParameters = Prettify<
16
+ export type PrivateKeyToSimpleSmartAccountParameters<
17
+ entryPoint extends EntryPoint
18
+ > = Prettify<
11
19
  {
12
20
  privateKey: Hex
13
- } & Omit<SignerToSimpleSmartAccountParameters, "signer">
21
+ } & Omit<SignerToSimpleSmartAccountParameters<entryPoint>, "signer">
14
22
  >
15
23
 
16
24
  /**
@@ -19,15 +27,25 @@ export type PrivateKeyToSimpleSmartAccountParameters = Prettify<
19
27
  * @returns A Private Key Simple Account.
20
28
  */
21
29
  export async function privateKeyToSimpleSmartAccount<
30
+ entryPoint extends EntryPoint,
22
31
  TTransport extends Transport = Transport,
23
32
  TChain extends Chain | undefined = Chain | undefined
24
33
  >(
25
34
  client: Client<TTransport, TChain, undefined>,
26
- { privateKey, ...rest }: PrivateKeyToSimpleSmartAccountParameters
27
- ): Promise<SimpleSmartAccount<TTransport, TChain>> {
35
+ {
36
+ privateKey,
37
+ ...rest
38
+ }: PrivateKeyToSimpleSmartAccountParameters<entryPoint>
39
+ ): Promise<SimpleSmartAccount<entryPoint, TTransport, TChain>> {
28
40
  const privateKeyAccount = privateKeyToAccount(privateKey)
29
41
 
30
- return signerToSimpleSmartAccount(client, {
42
+ return signerToSimpleSmartAccount<
43
+ entryPoint,
44
+ TTransport,
45
+ TChain,
46
+ "privateKey",
47
+ Address
48
+ >(client, {
31
49
  signer: privateKeyAccount,
32
50
  ...rest
33
51
  })