permissionless 0.1.31 → 0.1.32

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 (289) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/_cjs/accounts/biconomy/privateKeyToBiconomySmartAccount.js.map +1 -1
  3. package/_cjs/accounts/biconomy/signerToBiconomySmartAccount.js +4 -3
  4. package/_cjs/accounts/biconomy/signerToBiconomySmartAccount.js.map +1 -1
  5. package/_cjs/accounts/kernel/signerToEcdsaKernelSmartAccount.js +42 -16
  6. package/_cjs/accounts/kernel/signerToEcdsaKernelSmartAccount.js.map +1 -1
  7. package/_cjs/accounts/kernel/utils/encodeCallData.js +2 -1
  8. package/_cjs/accounts/kernel/utils/encodeCallData.js.map +1 -1
  9. package/_cjs/accounts/kernel/utils/getNonceKey.js +2 -1
  10. package/_cjs/accounts/kernel/utils/getNonceKey.js.map +1 -1
  11. package/_cjs/accounts/kernel/utils/isKernelV2.js +9 -0
  12. package/_cjs/accounts/kernel/utils/isKernelV2.js.map +1 -0
  13. package/_cjs/accounts/kernel/utils/signMessage.js +2 -1
  14. package/_cjs/accounts/kernel/utils/signMessage.js.map +1 -1
  15. package/_cjs/accounts/kernel/utils/signTypedData.js +2 -1
  16. package/_cjs/accounts/kernel/utils/signTypedData.js.map +1 -1
  17. package/_cjs/accounts/kernel/utils/wrapMessageHash.js.map +1 -1
  18. package/_cjs/accounts/light/privateKeyToLightSmartAccount.js.map +1 -1
  19. package/_cjs/accounts/light/signerToLightSmartAccount.js +4 -3
  20. package/_cjs/accounts/light/signerToLightSmartAccount.js.map +1 -1
  21. package/_cjs/accounts/safe/privateKeyToSafeSmartAccount.js.map +1 -1
  22. package/_cjs/accounts/safe/signerToSafeSmartAccount.js +591 -174
  23. package/_cjs/accounts/safe/signerToSafeSmartAccount.js.map +1 -1
  24. package/_cjs/accounts/simple/privateKeyToSimpleSmartAccount.js.map +1 -1
  25. package/_cjs/accounts/simple/signerToSimpleSmartAccount.js +4 -3
  26. package/_cjs/accounts/simple/signerToSimpleSmartAccount.js.map +1 -1
  27. package/_cjs/accounts/toSmartAccount.js.map +1 -1
  28. package/_cjs/accounts/trust/privateKeyToTrustSmartAccount.js.map +1 -1
  29. package/_cjs/accounts/trust/signerToTrustSmartAccount.js +4 -3
  30. package/_cjs/accounts/trust/signerToTrustSmartAccount.js.map +1 -1
  31. package/_cjs/accounts/trust/utils/signUserOperation.js +1 -1
  32. package/_cjs/accounts/trust/utils/signUserOperation.js.map +1 -1
  33. package/_cjs/accounts/types.js.map +1 -1
  34. package/_cjs/actions/bundler/waitForUserOperationReceipt.js +1 -1
  35. package/_cjs/actions/bundler/waitForUserOperationReceipt.js.map +1 -1
  36. package/_cjs/actions/erc7579/accountId.js +66 -0
  37. package/_cjs/actions/erc7579/accountId.js.map +1 -0
  38. package/_cjs/actions/erc7579/installModule.js +65 -0
  39. package/_cjs/actions/erc7579/installModule.js.map +1 -0
  40. package/_cjs/actions/erc7579/isModuleInstalled.js +86 -0
  41. package/_cjs/actions/erc7579/isModuleInstalled.js.map +1 -0
  42. package/_cjs/actions/erc7579/supportsExecutionMode.js +95 -0
  43. package/_cjs/actions/erc7579/supportsExecutionMode.js.map +1 -0
  44. package/_cjs/actions/erc7579/supportsModule.js +84 -0
  45. package/_cjs/actions/erc7579/supportsModule.js.map +1 -0
  46. package/_cjs/actions/erc7579/uninstallModule.js +65 -0
  47. package/_cjs/actions/erc7579/uninstallModule.js.map +1 -0
  48. package/_cjs/actions/erc7579.js +27 -0
  49. package/_cjs/actions/erc7579.js.map +1 -0
  50. package/_cjs/actions/smartAccount/deployContract.js.map +1 -1
  51. package/_cjs/actions/smartAccount/prepareUserOperationRequest.js +0 -3
  52. package/_cjs/actions/smartAccount/prepareUserOperationRequest.js.map +1 -1
  53. package/_cjs/errors/estimateUserOperationGas.js +6 -0
  54. package/_cjs/errors/estimateUserOperationGas.js.map +1 -1
  55. package/_cjs/utils/encode7579CallData.js +81 -0
  56. package/_cjs/utils/encode7579CallData.js.map +1 -0
  57. package/_cjs/vitest.config.js +31 -0
  58. package/_cjs/vitest.config.js.map +1 -0
  59. package/_esm/accounts/biconomy/privateKeyToBiconomySmartAccount.js.map +1 -1
  60. package/_esm/accounts/biconomy/signerToBiconomySmartAccount.js +4 -3
  61. package/_esm/accounts/biconomy/signerToBiconomySmartAccount.js.map +1 -1
  62. package/_esm/accounts/kernel/signerToEcdsaKernelSmartAccount.js +46 -20
  63. package/_esm/accounts/kernel/signerToEcdsaKernelSmartAccount.js.map +1 -1
  64. package/_esm/accounts/kernel/utils/encodeCallData.js +2 -1
  65. package/_esm/accounts/kernel/utils/encodeCallData.js.map +1 -1
  66. package/_esm/accounts/kernel/utils/getNonceKey.js +2 -1
  67. package/_esm/accounts/kernel/utils/getNonceKey.js.map +1 -1
  68. package/_esm/accounts/kernel/utils/isKernelV2.js +5 -0
  69. package/_esm/accounts/kernel/utils/isKernelV2.js.map +1 -0
  70. package/_esm/accounts/kernel/utils/signMessage.js +2 -1
  71. package/_esm/accounts/kernel/utils/signMessage.js.map +1 -1
  72. package/_esm/accounts/kernel/utils/signTypedData.js +2 -1
  73. package/_esm/accounts/kernel/utils/signTypedData.js.map +1 -1
  74. package/_esm/accounts/kernel/utils/wrapMessageHash.js.map +1 -1
  75. package/_esm/accounts/light/privateKeyToLightSmartAccount.js.map +1 -1
  76. package/_esm/accounts/light/signerToLightSmartAccount.js +4 -3
  77. package/_esm/accounts/light/signerToLightSmartAccount.js.map +1 -1
  78. package/_esm/accounts/safe/privateKeyToSafeSmartAccount.js.map +1 -1
  79. package/_esm/accounts/safe/signerToSafeSmartAccount.js +593 -175
  80. package/_esm/accounts/safe/signerToSafeSmartAccount.js.map +1 -1
  81. package/_esm/accounts/simple/privateKeyToSimpleSmartAccount.js.map +1 -1
  82. package/_esm/accounts/simple/signerToSimpleSmartAccount.js +4 -3
  83. package/_esm/accounts/simple/signerToSimpleSmartAccount.js.map +1 -1
  84. package/_esm/accounts/toSmartAccount.js.map +1 -1
  85. package/_esm/accounts/trust/privateKeyToTrustSmartAccount.js +0 -1
  86. package/_esm/accounts/trust/privateKeyToTrustSmartAccount.js.map +1 -1
  87. package/_esm/accounts/trust/signerToTrustSmartAccount.js +4 -3
  88. package/_esm/accounts/trust/signerToTrustSmartAccount.js.map +1 -1
  89. package/_esm/accounts/trust/utils/signUserOperation.js +1 -1
  90. package/_esm/accounts/trust/utils/signUserOperation.js.map +1 -1
  91. package/_esm/accounts/types.js.map +1 -1
  92. package/_esm/actions/bundler/waitForUserOperationReceipt.js +1 -1
  93. package/_esm/actions/bundler/waitForUserOperationReceipt.js.map +1 -1
  94. package/_esm/actions/erc7579/accountId.js +62 -0
  95. package/_esm/actions/erc7579/accountId.js.map +1 -0
  96. package/_esm/actions/erc7579/installModule.js +61 -0
  97. package/_esm/actions/erc7579/installModule.js.map +1 -0
  98. package/_esm/actions/erc7579/isModuleInstalled.js +82 -0
  99. package/_esm/actions/erc7579/isModuleInstalled.js.map +1 -0
  100. package/_esm/actions/erc7579/supportsExecutionMode.js +90 -0
  101. package/_esm/actions/erc7579/supportsExecutionMode.js.map +1 -0
  102. package/_esm/actions/erc7579/supportsModule.js +79 -0
  103. package/_esm/actions/erc7579/supportsModule.js.map +1 -0
  104. package/_esm/actions/erc7579/uninstallModule.js +61 -0
  105. package/_esm/actions/erc7579/uninstallModule.js.map +1 -0
  106. package/_esm/actions/erc7579.js +18 -0
  107. package/_esm/actions/erc7579.js.map +1 -0
  108. package/_esm/actions/smartAccount/deployContract.js.map +1 -1
  109. package/_esm/actions/smartAccount/prepareUserOperationRequest.js +0 -3
  110. package/_esm/actions/smartAccount/prepareUserOperationRequest.js.map +1 -1
  111. package/_esm/errors/estimateUserOperationGas.js +6 -0
  112. package/_esm/errors/estimateUserOperationGas.js.map +1 -1
  113. package/_esm/utils/encode7579CallData.js +77 -0
  114. package/_esm/utils/encode7579CallData.js.map +1 -0
  115. package/_esm/vitest.config.js +29 -0
  116. package/_esm/vitest.config.js.map +1 -0
  117. package/_types/accounts/biconomy/privateKeyToBiconomySmartAccount.d.ts +2 -2
  118. package/_types/accounts/biconomy/privateKeyToBiconomySmartAccount.d.ts.map +1 -1
  119. package/_types/accounts/biconomy/signerToBiconomySmartAccount.d.ts +3 -1
  120. package/_types/accounts/biconomy/signerToBiconomySmartAccount.d.ts.map +1 -1
  121. package/_types/accounts/kernel/signerToEcdsaKernelSmartAccount.d.ts +7 -3
  122. package/_types/accounts/kernel/signerToEcdsaKernelSmartAccount.d.ts.map +1 -1
  123. package/_types/accounts/kernel/utils/encodeCallData.d.ts +2 -1
  124. package/_types/accounts/kernel/utils/encodeCallData.d.ts.map +1 -1
  125. package/_types/accounts/kernel/utils/getExecMode.d.ts.map +1 -1
  126. package/_types/accounts/kernel/utils/getNonceKey.d.ts +2 -1
  127. package/_types/accounts/kernel/utils/getNonceKey.d.ts.map +1 -1
  128. package/_types/accounts/kernel/utils/isKernelV2.d.ts +4 -0
  129. package/_types/accounts/kernel/utils/isKernelV2.d.ts.map +1 -0
  130. package/_types/accounts/kernel/utils/signMessage.d.ts.map +1 -1
  131. package/_types/accounts/kernel/utils/signTypedData.d.ts.map +1 -1
  132. package/_types/accounts/kernel/utils/wrapMessageHash.d.ts +3 -1
  133. package/_types/accounts/kernel/utils/wrapMessageHash.d.ts.map +1 -1
  134. package/_types/accounts/light/privateKeyToLightSmartAccount.d.ts +5 -4
  135. package/_types/accounts/light/privateKeyToLightSmartAccount.d.ts.map +1 -1
  136. package/_types/accounts/light/signerToLightSmartAccount.d.ts +3 -2
  137. package/_types/accounts/light/signerToLightSmartAccount.d.ts.map +1 -1
  138. package/_types/accounts/safe/privateKeyToSafeSmartAccount.d.ts +4 -4
  139. package/_types/accounts/safe/privateKeyToSafeSmartAccount.d.ts.map +1 -1
  140. package/_types/accounts/safe/signerToSafeSmartAccount.d.ts +38 -15
  141. package/_types/accounts/safe/signerToSafeSmartAccount.d.ts.map +1 -1
  142. package/_types/accounts/simple/privateKeyToSimpleSmartAccount.d.ts +2 -2
  143. package/_types/accounts/simple/privateKeyToSimpleSmartAccount.d.ts.map +1 -1
  144. package/_types/accounts/simple/signerToSimpleSmartAccount.d.ts +3 -2
  145. package/_types/accounts/simple/signerToSimpleSmartAccount.d.ts.map +1 -1
  146. package/_types/accounts/toSmartAccount.d.ts +3 -3
  147. package/_types/accounts/toSmartAccount.d.ts.map +1 -1
  148. package/_types/accounts/trust/privateKeyToTrustSmartAccount.d.ts +2 -2
  149. package/_types/accounts/trust/privateKeyToTrustSmartAccount.d.ts.map +1 -1
  150. package/_types/accounts/trust/signerToTrustSmartAccount.d.ts +3 -2
  151. package/_types/accounts/trust/signerToTrustSmartAccount.d.ts.map +1 -1
  152. package/_types/accounts/trust/utils/encodeCallData.d.ts.map +1 -1
  153. package/_types/accounts/trust/utils/getAccountAddress.d.ts +1 -1
  154. package/_types/accounts/trust/utils/getAccountAddress.d.ts.map +1 -1
  155. package/_types/accounts/trust/utils/getDummySignature.d.ts.map +1 -1
  156. package/_types/accounts/trust/utils/getFactoryData.d.ts.map +1 -1
  157. package/_types/accounts/trust/utils/signMessage.d.ts.map +1 -1
  158. package/_types/accounts/trust/utils/signTransaction.d.ts +2 -2
  159. package/_types/accounts/trust/utils/signTransaction.d.ts.map +1 -1
  160. package/_types/accounts/trust/utils/signUserOperation.d.ts.map +1 -1
  161. package/_types/accounts/types.d.ts +3 -3
  162. package/_types/accounts/types.d.ts.map +1 -1
  163. package/_types/actions/bundler/chainId.d.ts.map +1 -1
  164. package/_types/actions/bundler/estimateUserOperationGas.d.ts +41 -2
  165. package/_types/actions/bundler/estimateUserOperationGas.d.ts.map +1 -1
  166. package/_types/actions/bundler/getUserOperationByHash.d.ts +1 -7
  167. package/_types/actions/bundler/getUserOperationByHash.d.ts.map +1 -1
  168. package/_types/actions/bundler/getUserOperationReceipt.d.ts.map +1 -1
  169. package/_types/actions/bundler/sendUserOperation.d.ts +4 -1
  170. package/_types/actions/bundler/sendUserOperation.d.ts.map +1 -1
  171. package/_types/actions/bundler/supportedEntryPoints.d.ts.map +1 -1
  172. package/_types/actions/bundler/waitForUserOperationReceipt.d.ts.map +1 -1
  173. package/_types/actions/erc7579/accountId.d.ts +6 -0
  174. package/_types/actions/erc7579/accountId.d.ts.map +1 -0
  175. package/_types/actions/erc7579/installModule.d.ts +16 -0
  176. package/_types/actions/erc7579/installModule.d.ts.map +1 -0
  177. package/_types/actions/erc7579/isModuleInstalled.d.ts +12 -0
  178. package/_types/actions/erc7579/isModuleInstalled.d.ts.map +1 -0
  179. package/_types/actions/erc7579/supportsExecutionMode.d.ts +15 -0
  180. package/_types/actions/erc7579/supportsExecutionMode.d.ts.map +1 -0
  181. package/_types/actions/erc7579/supportsModule.d.ts +11 -0
  182. package/_types/actions/erc7579/supportsModule.d.ts.map +1 -0
  183. package/_types/actions/erc7579/uninstallModule.d.ts +16 -0
  184. package/_types/actions/erc7579/uninstallModule.d.ts.map +1 -0
  185. package/_types/actions/erc7579.d.ts +26 -0
  186. package/_types/actions/erc7579.d.ts.map +1 -0
  187. package/_types/actions/pimlico/getUserOperationGasPrice.d.ts.map +1 -1
  188. package/_types/actions/pimlico/getUserOperationStatus.d.ts.map +1 -1
  189. package/_types/actions/pimlico/sendCompressedUserOperation.d.ts.map +1 -1
  190. package/_types/actions/pimlico/sponsorUserOperation.d.ts +1 -41
  191. package/_types/actions/pimlico/sponsorUserOperation.d.ts.map +1 -1
  192. package/_types/actions/pimlico/validateSponsorshipPolicies.d.ts +1 -5
  193. package/_types/actions/pimlico/validateSponsorshipPolicies.d.ts.map +1 -1
  194. package/_types/actions/public/getAccountNonce.d.ts.map +1 -1
  195. package/_types/actions/public/getSenderAddress.d.ts +1 -1
  196. package/_types/actions/public/getSenderAddress.d.ts.map +1 -1
  197. package/_types/actions/smartAccount/deployContract.d.ts +1 -1
  198. package/_types/actions/smartAccount/deployContract.d.ts.map +1 -1
  199. package/_types/actions/smartAccount/prepareUserOperationRequest.d.ts.map +1 -1
  200. package/_types/actions/stackup/accounts.d.ts.map +1 -1
  201. package/_types/actions/stackup/sponsorUserOperation.d.ts.map +1 -1
  202. package/_types/clients/createBundlerClient.d.ts +2 -18
  203. package/_types/clients/createBundlerClient.d.ts.map +1 -1
  204. package/_types/clients/decorators/bundler.d.ts.map +1 -1
  205. package/_types/clients/decorators/pimlico.d.ts.map +1 -1
  206. package/_types/clients/decorators/smartAccount.d.ts.map +1 -1
  207. package/_types/clients/decorators/stackup.d.ts.map +1 -1
  208. package/_types/clients/pimlico.d.ts +2 -34
  209. package/_types/clients/pimlico.d.ts.map +1 -1
  210. package/_types/clients/stackup.d.ts +1 -17
  211. package/_types/clients/stackup.d.ts.map +1 -1
  212. package/_types/errors/estimateUserOperationGas.d.ts.map +1 -1
  213. package/_types/experimental/eip7677/clients/decorators/paymasterActionsEip7677.d.ts.map +1 -1
  214. package/_types/types/index.d.ts +2 -2
  215. package/_types/types/index.d.ts.map +1 -1
  216. package/_types/utils/encode7579CallData.d.ts +16 -0
  217. package/_types/utils/encode7579CallData.d.ts.map +1 -0
  218. package/_types/utils/getRequiredPrefund.d.ts.map +1 -1
  219. package/_types/utils/getUserOperationHash.d.ts.map +1 -1
  220. package/_types/utils/signUserOperationHashWithECDSA.d.ts.map +1 -1
  221. package/_types/vitest.config.d.ts +3 -0
  222. package/_types/vitest.config.d.ts.map +1 -0
  223. package/accounts/biconomy/privateKeyToBiconomySmartAccount.ts +15 -2
  224. package/accounts/biconomy/signerToBiconomySmartAccount.ts +14 -5
  225. package/accounts/kernel/signerToEcdsaKernelSmartAccount.ts +80 -35
  226. package/accounts/kernel/utils/encodeCallData.ts +4 -2
  227. package/accounts/kernel/utils/getNonceKey.ts +4 -2
  228. package/accounts/kernel/utils/isKernelV2.ts +7 -0
  229. package/accounts/kernel/utils/signMessage.ts +2 -1
  230. package/accounts/kernel/utils/signTypedData.ts +2 -1
  231. package/accounts/kernel/utils/wrapMessageHash.ts +3 -1
  232. package/accounts/light/privateKeyToLightSmartAccount.ts +19 -5
  233. package/accounts/light/signerToLightSmartAccount.ts +15 -4
  234. package/accounts/safe/privateKeyToSafeSmartAccount.ts +18 -5
  235. package/accounts/safe/signerToSafeSmartAccount.ts +775 -199
  236. package/accounts/simple/privateKeyToSimpleSmartAccount.ts +16 -2
  237. package/accounts/simple/signerToSimpleSmartAccount.ts +15 -4
  238. package/accounts/toSmartAccount.ts +5 -3
  239. package/accounts/trust/privateKeyToTrustSmartAccount.ts +15 -2
  240. package/accounts/trust/signerToTrustSmartAccount.ts +15 -4
  241. package/accounts/trust/utils/signUserOperation.ts +1 -1
  242. package/accounts/types.ts +9 -3
  243. package/actions/bundler/chainId.test.ts +25 -0
  244. package/actions/bundler/estimateUserOperationGas.test.ts +205 -0
  245. package/actions/bundler/estimateUserOperationGas.ts +1 -1
  246. package/actions/bundler/getUserOperationByHash.test.ts +139 -0
  247. package/actions/bundler/getUserOperationReceipt.test.ts +127 -0
  248. package/actions/bundler/sendUserOperation.test.ts +126 -0
  249. package/actions/bundler/supportedEntryPoints.test.ts +27 -0
  250. package/actions/bundler/waitForUserOperationReceipt.test.ts +130 -0
  251. package/actions/bundler/waitForUserOperationReceipt.ts +1 -1
  252. package/actions/erc7579/accountId.test.ts +52 -0
  253. package/actions/erc7579/accountId.ts +91 -0
  254. package/actions/erc7579/installModule.test.ts +124 -0
  255. package/actions/erc7579/installModule.ts +109 -0
  256. package/actions/erc7579/isModuleInstalled.test.ts +119 -0
  257. package/actions/erc7579/isModuleInstalled.ts +122 -0
  258. package/actions/erc7579/supportsExecutionMode.test.ts +72 -0
  259. package/actions/erc7579/supportsExecutionMode.ts +154 -0
  260. package/actions/erc7579/supportsModule.test.ts +46 -0
  261. package/actions/erc7579/supportsModule.ts +117 -0
  262. package/actions/erc7579/uninstallModule.test.ts +158 -0
  263. package/actions/erc7579/uninstallModule.ts +113 -0
  264. package/actions/erc7579.ts +114 -0
  265. package/actions/index.test.ts +329 -0
  266. package/actions/pimlico/getUserOperationGasPrice.test.ts +33 -0
  267. package/actions/pimlico/getUserOperationStatus.test.ts +152 -0
  268. package/actions/pimlico/sponsorUserOperation.test.ts +126 -0
  269. package/actions/pimlico/validateSponsorshipPolicies.test.ts +56 -0
  270. package/actions/pimlico.test.ts +222 -0
  271. package/actions/public/getAccountNonce.test.ts +52 -0
  272. package/actions/public/getSenderAddress.test.ts +83 -0
  273. package/actions/smartAccount/deployContract.test.ts +118 -0
  274. package/actions/smartAccount/deployContract.ts +3 -1
  275. package/actions/smartAccount/prepareUserOperationRequest.test.ts +151 -0
  276. package/actions/smartAccount/prepareUserOperationRequest.ts +0 -4
  277. package/actions/smartAccount/sendTransaction.test.ts +108 -0
  278. package/actions/smartAccount/sendTransactions.test.ts +126 -0
  279. package/actions/smartAccount/sendUserOperation.test.ts +133 -0
  280. package/actions/smartAccount/signMessage.test.ts +89 -0
  281. package/actions/smartAccount/signTypedData.test.ts +118 -0
  282. package/actions/smartAccount/writeContract.test.ts +118 -0
  283. package/errors/estimateUserOperationGas.ts +7 -0
  284. package/experimental/eip7677/actions/getPaymasterData.test.ts +137 -0
  285. package/experimental/eip7677/actions/getPaymasterStubData.test.ts +84 -0
  286. package/package.json +7 -2
  287. package/types/index.ts +3 -4
  288. package/utils/encode7579CallData.ts +114 -0
  289. package/vitest.config.ts +29 -0
@@ -1,10 +1,337 @@
1
- import { concat, concatHex, encodeFunctionData, encodePacked, getContractAddress, hashMessage, hashTypedData, hexToBigInt, keccak256, pad, toBytes, toHex, zeroAddress } from "viem";
1
+ import { concat, concatHex, encodeAbiParameters, encodeFunctionData, encodePacked, getContractAddress, hashMessage, hashTypedData, hexToBigInt, keccak256, pad, toBytes, toHex, zeroAddress } from "viem";
2
2
  import { getChainId, readContract, signMessage, signTypedData } from "viem/actions";
3
3
  import { getAccountNonce } from "../../actions/public/getAccountNonce.js";
4
+ import { encode7579CallData } from "../../utils/encode7579CallData.js";
4
5
  import { getEntryPointVersion, isUserOperationVersion06, isUserOperationVersion07 } from "../../utils/getEntryPointVersion.js";
5
6
  import { isSmartAccountDeployed } from "../../utils/isSmartAccountDeployed.js";
6
7
  import { toSmartAccount } from "../toSmartAccount.js";
7
8
  import { SignTransactionNotSupportedBySmartAccount } from "../types.js";
9
+ const multiSendAbi = [
10
+ {
11
+ inputs: [
12
+ {
13
+ internalType: "bytes",
14
+ name: "transactions",
15
+ type: "bytes"
16
+ }
17
+ ],
18
+ name: "multiSend",
19
+ outputs: [],
20
+ stateMutability: "payable",
21
+ type: "function"
22
+ }
23
+ ];
24
+ const initSafe7579Abi = [
25
+ {
26
+ type: "function",
27
+ name: "initSafe7579",
28
+ inputs: [
29
+ {
30
+ name: "safe7579",
31
+ type: "address",
32
+ internalType: "address"
33
+ },
34
+ {
35
+ name: "executors",
36
+ type: "tuple[]",
37
+ internalType: "struct ModuleInit[]",
38
+ components: [
39
+ {
40
+ name: "module",
41
+ type: "address",
42
+ internalType: "address"
43
+ },
44
+ {
45
+ name: "initData",
46
+ type: "bytes",
47
+ internalType: "bytes"
48
+ }
49
+ ]
50
+ },
51
+ {
52
+ name: "fallbacks",
53
+ type: "tuple[]",
54
+ internalType: "struct ModuleInit[]",
55
+ components: [
56
+ {
57
+ name: "module",
58
+ type: "address",
59
+ internalType: "address"
60
+ },
61
+ {
62
+ name: "initData",
63
+ type: "bytes",
64
+ internalType: "bytes"
65
+ }
66
+ ]
67
+ },
68
+ {
69
+ name: "hooks",
70
+ type: "tuple[]",
71
+ internalType: "struct ModuleInit[]",
72
+ components: [
73
+ {
74
+ name: "module",
75
+ type: "address",
76
+ internalType: "address"
77
+ },
78
+ {
79
+ name: "initData",
80
+ type: "bytes",
81
+ internalType: "bytes"
82
+ }
83
+ ]
84
+ },
85
+ {
86
+ name: "attesters",
87
+ type: "address[]",
88
+ internalType: "address[]"
89
+ },
90
+ {
91
+ name: "threshold",
92
+ type: "uint8",
93
+ internalType: "uint8"
94
+ }
95
+ ],
96
+ outputs: [],
97
+ stateMutability: "nonpayable"
98
+ }
99
+ ];
100
+ const preValidationSetupAbi = [
101
+ {
102
+ type: "function",
103
+ name: "preValidationSetup",
104
+ inputs: [
105
+ {
106
+ name: "initHash",
107
+ type: "bytes32",
108
+ internalType: "bytes32"
109
+ },
110
+ {
111
+ name: "to",
112
+ type: "address",
113
+ internalType: "address"
114
+ },
115
+ {
116
+ name: "preInit",
117
+ type: "bytes",
118
+ internalType: "bytes"
119
+ }
120
+ ],
121
+ outputs: [],
122
+ stateMutability: "nonpayable"
123
+ }
124
+ ];
125
+ const enableModulesAbi = [
126
+ {
127
+ inputs: [
128
+ {
129
+ internalType: "address[]",
130
+ name: "modules",
131
+ type: "address[]"
132
+ }
133
+ ],
134
+ name: "enableModules",
135
+ outputs: [],
136
+ stateMutability: "nonpayable",
137
+ type: "function"
138
+ }
139
+ ];
140
+ const setupAbi = [
141
+ {
142
+ inputs: [
143
+ {
144
+ internalType: "address[]",
145
+ name: "_owners",
146
+ type: "address[]"
147
+ },
148
+ {
149
+ internalType: "uint256",
150
+ name: "_threshold",
151
+ type: "uint256"
152
+ },
153
+ {
154
+ internalType: "address",
155
+ name: "to",
156
+ type: "address"
157
+ },
158
+ {
159
+ internalType: "bytes",
160
+ name: "data",
161
+ type: "bytes"
162
+ },
163
+ {
164
+ internalType: "address",
165
+ name: "fallbackHandler",
166
+ type: "address"
167
+ },
168
+ {
169
+ internalType: "address",
170
+ name: "paymentToken",
171
+ type: "address"
172
+ },
173
+ {
174
+ internalType: "uint256",
175
+ name: "payment",
176
+ type: "uint256"
177
+ },
178
+ {
179
+ internalType: "address payable",
180
+ name: "paymentReceiver",
181
+ type: "address"
182
+ }
183
+ ],
184
+ name: "setup",
185
+ outputs: [],
186
+ stateMutability: "nonpayable",
187
+ type: "function"
188
+ }
189
+ ];
190
+ const createProxyWithNonceAbi = [
191
+ {
192
+ inputs: [
193
+ {
194
+ internalType: "address",
195
+ name: "_singleton",
196
+ type: "address"
197
+ },
198
+ {
199
+ internalType: "bytes",
200
+ name: "initializer",
201
+ type: "bytes"
202
+ },
203
+ {
204
+ internalType: "uint256",
205
+ name: "saltNonce",
206
+ type: "uint256"
207
+ }
208
+ ],
209
+ name: "createProxyWithNonce",
210
+ outputs: [
211
+ {
212
+ internalType: "contract SafeProxy",
213
+ name: "proxy",
214
+ type: "address"
215
+ }
216
+ ],
217
+ stateMutability: "nonpayable",
218
+ type: "function"
219
+ }
220
+ ];
221
+ const proxyCreationCodeAbi = [
222
+ {
223
+ inputs: [],
224
+ name: "proxyCreationCode",
225
+ outputs: [
226
+ {
227
+ internalType: "bytes",
228
+ name: "",
229
+ type: "bytes"
230
+ }
231
+ ],
232
+ stateMutability: "pure",
233
+ type: "function"
234
+ }
235
+ ];
236
+ const setupSafeAbi = [
237
+ {
238
+ type: "function",
239
+ name: "setupSafe",
240
+ inputs: [
241
+ {
242
+ name: "initData",
243
+ type: "tuple",
244
+ internalType: "struct Safe7579Launchpad.InitData",
245
+ components: [
246
+ {
247
+ name: "singleton",
248
+ type: "address",
249
+ internalType: "address"
250
+ },
251
+ {
252
+ name: "owners",
253
+ type: "address[]",
254
+ internalType: "address[]"
255
+ },
256
+ {
257
+ name: "threshold",
258
+ type: "uint256",
259
+ internalType: "uint256"
260
+ },
261
+ {
262
+ name: "setupTo",
263
+ type: "address",
264
+ internalType: "address"
265
+ },
266
+ {
267
+ name: "setupData",
268
+ type: "bytes",
269
+ internalType: "bytes"
270
+ },
271
+ {
272
+ name: "safe7579",
273
+ type: "address",
274
+ internalType: "contract ISafe7579"
275
+ },
276
+ {
277
+ name: "validators",
278
+ type: "tuple[]",
279
+ internalType: "struct ModuleInit[]",
280
+ components: [
281
+ {
282
+ name: "module",
283
+ type: "address",
284
+ internalType: "address"
285
+ },
286
+ {
287
+ name: "initData",
288
+ type: "bytes",
289
+ internalType: "bytes"
290
+ }
291
+ ]
292
+ },
293
+ {
294
+ name: "callData",
295
+ type: "bytes",
296
+ internalType: "bytes"
297
+ }
298
+ ]
299
+ }
300
+ ],
301
+ outputs: [],
302
+ stateMutability: "nonpayable"
303
+ }
304
+ ];
305
+ const executeUserOpWithErrorStringAbi = [
306
+ {
307
+ inputs: [
308
+ {
309
+ internalType: "address",
310
+ name: "to",
311
+ type: "address"
312
+ },
313
+ {
314
+ internalType: "uint256",
315
+ name: "value",
316
+ type: "uint256"
317
+ },
318
+ {
319
+ internalType: "bytes",
320
+ name: "data",
321
+ type: "bytes"
322
+ },
323
+ {
324
+ internalType: "uint8",
325
+ name: "operation",
326
+ type: "uint8"
327
+ }
328
+ ],
329
+ name: "executeUserOpWithErrorString",
330
+ outputs: [],
331
+ stateMutability: "nonpayable",
332
+ type: "function"
333
+ }
334
+ ];
8
335
  const EIP712_SAFE_OPERATION_TYPE_V06 = {
9
336
  SafeOp: [
10
337
  { type: "address", name: "safe" },
@@ -101,45 +428,128 @@ const encodeMultiSend = (txs) => {
101
428
  .map((tx) => encodeInternalTransaction(tx))
102
429
  .join("")}`;
103
430
  return encodeFunctionData({
104
- abi: [
431
+ abi: multiSendAbi,
432
+ functionName: "multiSend",
433
+ args: [data]
434
+ });
435
+ };
436
+ const get7579LaunchPadInitData = ({ safe4337ModuleAddress, safeSingletonAddress, erc7569LaunchpadAddress, owner, validators, executors, fallbacks, hooks, attesters, attestersThreshold }) => {
437
+ const initData = {
438
+ singleton: safeSingletonAddress,
439
+ owners: [owner],
440
+ threshold: BigInt(1),
441
+ setupTo: erc7569LaunchpadAddress,
442
+ setupData: encodeFunctionData({
443
+ abi: initSafe7579Abi,
444
+ functionName: "initSafe7579",
445
+ args: [
446
+ safe4337ModuleAddress, // SAFE_7579_ADDRESS,
447
+ executors.map((executor) => ({
448
+ module: executor.address,
449
+ initData: executor.context
450
+ })),
451
+ fallbacks.map((fallback) => ({
452
+ module: fallback.address,
453
+ initData: fallback.context
454
+ })),
455
+ hooks.map((hook) => ({
456
+ module: hook.address,
457
+ initData: hook.context
458
+ })),
459
+ attesters,
460
+ attestersThreshold
461
+ ]
462
+ }),
463
+ safe7579: safe4337ModuleAddress,
464
+ validators: validators
465
+ };
466
+ return initData;
467
+ };
468
+ const getInitializerCode = async ({ owner, safeModuleSetupAddress, safe4337ModuleAddress, multiSendAddress, safeSingletonAddress, erc7569LaunchpadAddress, setupTransactions = [], safeModules = [], validators = [], executors = [], fallbacks = [], hooks = [], attesters = [], attestersThreshold = 0 }) => {
469
+ if (erc7569LaunchpadAddress) {
470
+ const initData = get7579LaunchPadInitData({
471
+ safe4337ModuleAddress,
472
+ safeSingletonAddress,
473
+ erc7569LaunchpadAddress,
474
+ owner,
475
+ validators,
476
+ executors,
477
+ fallbacks,
478
+ hooks,
479
+ attesters,
480
+ attestersThreshold
481
+ });
482
+ const initHash = keccak256(encodeAbiParameters([
483
+ {
484
+ internalType: "address",
485
+ name: "singleton",
486
+ type: "address"
487
+ },
488
+ {
489
+ internalType: "address[]",
490
+ name: "owners",
491
+ type: "address[]"
492
+ },
493
+ {
494
+ internalType: "uint256",
495
+ name: "threshold",
496
+ type: "uint256"
497
+ },
498
+ {
499
+ internalType: "address",
500
+ name: "setupTo",
501
+ type: "address"
502
+ },
105
503
  {
106
- inputs: [
504
+ internalType: "bytes",
505
+ name: "setupData",
506
+ type: "bytes"
507
+ },
508
+ {
509
+ internalType: "contract ISafe7579",
510
+ name: "safe7579",
511
+ type: "address"
512
+ },
513
+ {
514
+ internalType: "struct ModuleInit[]",
515
+ name: "validators",
516
+ type: "tuple[]",
517
+ components: [
518
+ {
519
+ internalType: "address",
520
+ name: "module",
521
+ type: "address"
522
+ },
107
523
  {
108
524
  internalType: "bytes",
109
- name: "transactions",
525
+ name: "initData",
110
526
  type: "bytes"
111
527
  }
112
- ],
113
- name: "multiSend",
114
- outputs: [],
115
- stateMutability: "payable",
116
- type: "function"
528
+ ]
117
529
  }
118
- ],
119
- functionName: "multiSend",
120
- args: [data]
121
- });
122
- };
123
- const getInitializerCode = async ({ owner, safeModuleSetupAddress, safe4337ModuleAddress, multiSendAddress, setupTransactions = [], safeModules = [] }) => {
530
+ ], [
531
+ initData.singleton,
532
+ initData.owners,
533
+ initData.threshold,
534
+ initData.setupTo,
535
+ initData.setupData,
536
+ initData.safe7579,
537
+ initData.validators.map((validator) => ({
538
+ module: validator.address,
539
+ initData: validator.context
540
+ }))
541
+ ]));
542
+ return encodeFunctionData({
543
+ abi: preValidationSetupAbi,
544
+ functionName: "preValidationSetup",
545
+ args: [initHash, zeroAddress, "0x"]
546
+ });
547
+ }
124
548
  const multiSendCallData = encodeMultiSend([
125
549
  {
126
550
  to: safeModuleSetupAddress,
127
551
  data: encodeFunctionData({
128
- abi: [
129
- {
130
- inputs: [
131
- {
132
- internalType: "address[]",
133
- name: "modules",
134
- type: "address[]"
135
- }
136
- ],
137
- name: "enableModules",
138
- outputs: [],
139
- stateMutability: "nonpayable",
140
- type: "function"
141
- }
142
- ],
552
+ abi: enableModulesAbi,
143
553
  functionName: "enableModules",
144
554
  args: [[safe4337ModuleAddress, ...safeModules]]
145
555
  }),
@@ -149,56 +559,7 @@ const getInitializerCode = async ({ owner, safeModuleSetupAddress, safe4337Modul
149
559
  ...setupTransactions.map((tx) => ({ ...tx, operation: 0 }))
150
560
  ]);
151
561
  return encodeFunctionData({
152
- abi: [
153
- {
154
- inputs: [
155
- {
156
- internalType: "address[]",
157
- name: "_owners",
158
- type: "address[]"
159
- },
160
- {
161
- internalType: "uint256",
162
- name: "_threshold",
163
- type: "uint256"
164
- },
165
- {
166
- internalType: "address",
167
- name: "to",
168
- type: "address"
169
- },
170
- {
171
- internalType: "bytes",
172
- name: "data",
173
- type: "bytes"
174
- },
175
- {
176
- internalType: "address",
177
- name: "fallbackHandler",
178
- type: "address"
179
- },
180
- {
181
- internalType: "address",
182
- name: "paymentToken",
183
- type: "address"
184
- },
185
- {
186
- internalType: "uint256",
187
- name: "payment",
188
- type: "uint256"
189
- },
190
- {
191
- internalType: "address payable",
192
- name: "paymentReceiver",
193
- type: "address"
194
- }
195
- ],
196
- name: "setup",
197
- outputs: [],
198
- stateMutability: "nonpayable",
199
- type: "function"
200
- }
201
- ],
562
+ abi: setupAbi,
202
563
  functionName: "setup",
203
564
  args: [
204
565
  [owner],
@@ -227,83 +588,63 @@ function getPaymasterAndData(unpackedUserOperation) {
227
588
  ])
228
589
  : "0x";
229
590
  }
230
- const getAccountInitCode = async ({ owner, safeModuleSetupAddress, safe4337ModuleAddress, safeSingletonAddress, multiSendAddress, saltNonce = BigInt(0), setupTransactions = [], safeModules = [] }) => {
231
- if (!owner)
591
+ const getAccountInitCode = async ({ owner, safeModuleSetupAddress, safe4337ModuleAddress, safeSingletonAddress, erc7569LaunchpadAddress, multiSendAddress, saltNonce = BigInt(0), setupTransactions = [], safeModules = [], validators = [], executors = [], fallbacks = [], hooks = [], attesters = [], attestersThreshold = 0 }) => {
592
+ if (!owner) {
232
593
  throw new Error("Owner account not found");
594
+ }
233
595
  const initializer = await getInitializerCode({
234
596
  owner,
235
597
  safeModuleSetupAddress,
236
598
  safe4337ModuleAddress,
237
599
  multiSendAddress,
238
600
  setupTransactions,
239
- safeModules
601
+ safeSingletonAddress,
602
+ safeModules,
603
+ erc7569LaunchpadAddress,
604
+ validators,
605
+ executors,
606
+ fallbacks,
607
+ hooks,
608
+ attesters,
609
+ attestersThreshold
240
610
  });
241
611
  const initCodeCallData = encodeFunctionData({
242
- abi: [
243
- {
244
- inputs: [
245
- {
246
- internalType: "address",
247
- name: "_singleton",
248
- type: "address"
249
- },
250
- {
251
- internalType: "bytes",
252
- name: "initializer",
253
- type: "bytes"
254
- },
255
- {
256
- internalType: "uint256",
257
- name: "saltNonce",
258
- type: "uint256"
259
- }
260
- ],
261
- name: "createProxyWithNonce",
262
- outputs: [
263
- {
264
- internalType: "contract SafeProxy",
265
- name: "proxy",
266
- type: "address"
267
- }
268
- ],
269
- stateMutability: "nonpayable",
270
- type: "function"
271
- }
272
- ],
612
+ abi: createProxyWithNonceAbi,
273
613
  functionName: "createProxyWithNonce",
274
- args: [safeSingletonAddress, initializer, saltNonce]
614
+ args: [
615
+ erc7569LaunchpadAddress ?? safeSingletonAddress,
616
+ initializer,
617
+ saltNonce
618
+ ]
275
619
  });
276
620
  return initCodeCallData;
277
621
  };
278
- const getAccountAddress = async ({ client, owner, safeModuleSetupAddress, safe4337ModuleAddress, safeProxyFactoryAddress, safeSingletonAddress, multiSendAddress, setupTransactions = [], safeModules = [], saltNonce = BigInt(0) }) => {
622
+ const getAccountAddress = async ({ client, owner, safeModuleSetupAddress, safe4337ModuleAddress, safeProxyFactoryAddress, safeSingletonAddress, multiSendAddress, erc7569LaunchpadAddress, setupTransactions = [], safeModules = [], saltNonce = BigInt(0), validators = [], executors = [], fallbacks = [], hooks = [], attesters = [], attestersThreshold = 0 }) => {
279
623
  const proxyCreationCode = await readContract(client, {
280
- abi: [
281
- {
282
- inputs: [],
283
- name: "proxyCreationCode",
284
- outputs: [
285
- {
286
- internalType: "bytes",
287
- name: "",
288
- type: "bytes"
289
- }
290
- ],
291
- stateMutability: "pure",
292
- type: "function"
293
- }
294
- ],
624
+ abi: proxyCreationCodeAbi,
295
625
  address: safeProxyFactoryAddress,
296
626
  functionName: "proxyCreationCode"
297
627
  });
298
- const deploymentCode = encodePacked(["bytes", "uint256"], [proxyCreationCode, hexToBigInt(safeSingletonAddress)]);
299
628
  const initializer = await getInitializerCode({
300
629
  owner,
301
630
  safeModuleSetupAddress,
302
631
  safe4337ModuleAddress,
303
632
  multiSendAddress,
304
633
  setupTransactions,
305
- safeModules
634
+ safeSingletonAddress,
635
+ safeModules,
636
+ erc7569LaunchpadAddress,
637
+ validators,
638
+ executors,
639
+ fallbacks,
640
+ hooks,
641
+ attesters,
642
+ attestersThreshold
306
643
  });
644
+ const deploymentCode = encodePacked(["bytes", "uint256"], [
645
+ proxyCreationCode,
646
+ hexToBigInt(erc7569LaunchpadAddress ?? safeSingletonAddress)
647
+ ]);
307
648
  const salt = keccak256(encodePacked(["bytes32", "uint256"], [keccak256(encodePacked(["bytes"], [initializer])), saltNonce]));
308
649
  return getContractAddress({
309
650
  from: safeProxyFactoryAddress,
@@ -341,13 +682,43 @@ const getDefaultAddresses = (safeVersion, entryPointAddress, { addModuleLibAddre
341
682
  multiSendCallOnlyAddress
342
683
  };
343
684
  };
685
+ function isErc7579Args(args) {
686
+ return args.erc7569LaunchpadAddress !== undefined;
687
+ }
344
688
  /**
345
689
  * @description Creates an Simple Account from a private key.
346
690
  *
347
691
  * @returns A Private Key Simple Account.
348
692
  */
349
- export async function signerToSafeSmartAccount(client, { signer, address, safeVersion, entryPoint: entryPointAddress, safeModuleSetupAddress: _safeModuleSetupAddress, safe4337ModuleAddress: _safe4337ModuleAddress, safeProxyFactoryAddress: _safeProxyFactoryAddress, safeSingletonAddress: _safeSingletonAddress, multiSendAddress: _multiSendAddress, multiSendCallOnlyAddress: _multiSendCallOnlyAddress, saltNonce = BigInt(0), validUntil = 0, validAfter = 0, safeModules = [], setupTransactions = [] }) {
693
+ export async function signerToSafeSmartAccount(client, args) {
350
694
  const chainId = client.chain?.id ?? (await getChainId(client));
695
+ const { signer, address, safeVersion, entryPoint: entryPointAddress, safe4337ModuleAddress: _safe4337ModuleAddress, safeProxyFactoryAddress: _safeProxyFactoryAddress, safeSingletonAddress: _safeSingletonAddress, erc7569LaunchpadAddress, saltNonce = BigInt(0), validUntil = 0, validAfter = 0, nonceKey } = args;
696
+ let _safeModuleSetupAddress = undefined;
697
+ let _multiSendAddress = undefined;
698
+ let _multiSendCallOnlyAddress = undefined;
699
+ let safeModules = undefined;
700
+ let setupTransactions = [];
701
+ let validators = [];
702
+ let executors = [];
703
+ let fallbacks = [];
704
+ let hooks = [];
705
+ let attesters = [];
706
+ let attestersThreshold = 0;
707
+ if (!isErc7579Args(args)) {
708
+ _safeModuleSetupAddress = args.safeModuleSetupAddress;
709
+ _multiSendAddress = args.multiSendAddress;
710
+ _multiSendCallOnlyAddress = args.multiSendCallOnlyAddress;
711
+ safeModules = args.safeModules;
712
+ setupTransactions = args.setupTransactions ?? [];
713
+ }
714
+ if (isErc7579Args(args)) {
715
+ validators = args.validators ?? [];
716
+ executors = args.executors ?? [];
717
+ fallbacks = args.fallbacks ?? [];
718
+ hooks = args.hooks ?? [];
719
+ attesters = args.attesters ?? [];
720
+ attestersThreshold = args.attestersThreshold ?? 0;
721
+ }
351
722
  const viemSigner = {
352
723
  ...signer,
353
724
  signTransaction: (_, __) => {
@@ -371,15 +742,26 @@ export async function signerToSafeSmartAccount(client, { signer, address, safeVe
371
742
  safeProxyFactoryAddress,
372
743
  safeSingletonAddress,
373
744
  multiSendAddress,
745
+ erc7569LaunchpadAddress,
374
746
  saltNonce,
375
747
  setupTransactions,
376
- safeModules
748
+ safeModules,
749
+ validators,
750
+ executors,
751
+ fallbacks,
752
+ hooks,
753
+ attesters,
754
+ attestersThreshold
377
755
  }));
378
756
  if (!accountAddress)
379
757
  throw new Error("Account address not found");
380
758
  let safeDeployed = await isSmartAccountDeployed(client, accountAddress);
381
759
  const safeSmartAccount = toSmartAccount({
382
760
  address: accountAddress,
761
+ client: client,
762
+ publicKey: accountAddress,
763
+ entryPoint: entryPointAddress,
764
+ source: "SafeSmartAccount",
383
765
  async signMessage({ message }) {
384
766
  const messageHash = hashTypedData({
385
767
  domain: {
@@ -420,14 +802,11 @@ export async function signerToSafeSmartAccount(client, { signer, address, safeVe
420
802
  }
421
803
  }));
422
804
  },
423
- client: client,
424
- publicKey: accountAddress,
425
- entryPoint: entryPointAddress,
426
- source: "SafeSmartAccount",
427
- async getNonce() {
805
+ async getNonce(key) {
428
806
  return getAccountNonce(client, {
429
807
  sender: accountAddress,
430
- entryPoint: entryPointAddress
808
+ entryPoint: entryPointAddress,
809
+ key: key ?? nonceKey
431
810
  });
432
811
  },
433
812
  async signUserOperation(userOperation) {
@@ -446,8 +825,10 @@ export async function signerToSafeSmartAccount(client, { signer, address, safeVe
446
825
  validUntil: validUntil,
447
826
  entryPoint: entryPointAddress
448
827
  };
828
+ let isDeployed = false;
449
829
  if (isUserOperationVersion06(entryPointAddress, userOperation)) {
450
830
  message.paymasterAndData = userOperation.paymasterAndData;
831
+ isDeployed = userOperation.initCode === "0x";
451
832
  }
452
833
  if (isUserOperationVersion07(entryPointAddress, userOperation)) {
453
834
  if (userOperation.factory && userOperation.factoryData) {
@@ -458,6 +839,11 @@ export async function signerToSafeSmartAccount(client, { signer, address, safeVe
458
839
  }
459
840
  message.paymasterAndData =
460
841
  getPaymasterAndData(userOperation);
842
+ isDeployed = !userOperation.factory;
843
+ }
844
+ let verifyingContract = safe4337ModuleAddress;
845
+ if (erc7569LaunchpadAddress && !isDeployed) {
846
+ verifyingContract = userOperation.sender;
461
847
  }
462
848
  const signatures = [
463
849
  {
@@ -465,8 +851,8 @@ export async function signerToSafeSmartAccount(client, { signer, address, safeVe
465
851
  data: await signTypedData(client, {
466
852
  account: viemSigner,
467
853
  domain: {
468
- chainId: chainId,
469
- verifyingContract: safe4337ModuleAddress
854
+ chainId,
855
+ verifyingContract
470
856
  },
471
857
  types: getEntryPointVersion(entryPointAddress) ===
472
858
  "v0.6"
@@ -514,20 +900,81 @@ export async function signerToSafeSmartAccount(client, { signer, address, safeVe
514
900
  safe4337ModuleAddress,
515
901
  safeSingletonAddress,
516
902
  multiSendAddress,
903
+ erc7569LaunchpadAddress,
517
904
  saltNonce,
518
905
  setupTransactions,
519
- safeModules
906
+ safeModules,
907
+ validators,
908
+ executors,
909
+ fallbacks,
910
+ hooks,
911
+ attesters,
912
+ attestersThreshold
520
913
  });
521
914
  },
522
915
  async encodeDeployCallData(_) {
523
916
  throw new Error("Safe account doesn't support account deployment");
524
917
  },
525
918
  async encodeCallData(args) {
919
+ const isArray = Array.isArray(args);
920
+ if (erc7569LaunchpadAddress) {
921
+ // First transaction will be slower because we need to enable 7579 modules
922
+ safeDeployed =
923
+ safeDeployed ||
924
+ (await isSmartAccountDeployed(client, accountAddress));
925
+ if (!safeDeployed) {
926
+ const initData = get7579LaunchPadInitData({
927
+ safe4337ModuleAddress,
928
+ safeSingletonAddress,
929
+ erc7569LaunchpadAddress,
930
+ owner: viemSigner.address,
931
+ validators,
932
+ executors,
933
+ fallbacks,
934
+ hooks,
935
+ attesters,
936
+ attestersThreshold
937
+ });
938
+ return encodeFunctionData({
939
+ abi: setupSafeAbi,
940
+ functionName: "setupSafe",
941
+ args: [
942
+ {
943
+ ...initData,
944
+ validators: initData.validators.map((validator) => ({
945
+ module: validator.address,
946
+ initData: validator.context
947
+ })),
948
+ callData: encode7579CallData({
949
+ mode: {
950
+ type: isArray
951
+ ? "batchcall"
952
+ : "call",
953
+ revertOnError: false,
954
+ selector: "0x",
955
+ context: "0x"
956
+ },
957
+ callData: args
958
+ })
959
+ }
960
+ ]
961
+ });
962
+ }
963
+ return encode7579CallData({
964
+ mode: {
965
+ type: isArray ? "batchcall" : "call",
966
+ revertOnError: false,
967
+ selector: "0x",
968
+ context: "0x"
969
+ },
970
+ callData: args
971
+ });
972
+ }
526
973
  let to;
527
974
  let value;
528
975
  let data;
529
976
  let operationType = 0;
530
- if (Array.isArray(args)) {
977
+ if (isArray) {
531
978
  const argsArray = args;
532
979
  to = multiSendCallOnlyAddress;
533
980
  value = BigInt(0);
@@ -541,36 +988,7 @@ export async function signerToSafeSmartAccount(client, { signer, address, safeVe
541
988
  value = singleTransaction.value;
542
989
  }
543
990
  return encodeFunctionData({
544
- abi: [
545
- {
546
- inputs: [
547
- {
548
- internalType: "address",
549
- name: "to",
550
- type: "address"
551
- },
552
- {
553
- internalType: "uint256",
554
- name: "value",
555
- type: "uint256"
556
- },
557
- {
558
- internalType: "bytes",
559
- name: "data",
560
- type: "bytes"
561
- },
562
- {
563
- internalType: "uint8",
564
- name: "operation",
565
- type: "uint8"
566
- }
567
- ],
568
- name: "executeUserOpWithErrorString",
569
- outputs: [],
570
- stateMutability: "nonpayable",
571
- type: "function"
572
- }
573
- ],
991
+ abi: executeUserOpWithErrorStringAbi,
574
992
  functionName: "executeUserOpWithErrorString",
575
993
  args: [to, value, data, operationType]
576
994
  });