@zerodev/sdk 5.3.26 → 5.4.0-beta.1

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 (331) hide show
  1. package/_cjs/accounts/index.js.map +1 -1
  2. package/_cjs/accounts/kernel/createKernelAccount.js +173 -199
  3. package/_cjs/accounts/kernel/createKernelAccount.js.map +1 -1
  4. package/_cjs/accounts/kernel/utils/account/ep0_6/encodeCallData.js +13 -9
  5. package/_cjs/accounts/kernel/utils/account/ep0_6/encodeCallData.js.map +1 -1
  6. package/_cjs/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.js.map +1 -1
  7. package/_cjs/accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.js +18 -17
  8. package/_cjs/accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.js.map +1 -1
  9. package/_cjs/accounts/kernel/utils/account/ep0_7/encodeCallData.js +12 -8
  10. package/_cjs/accounts/kernel/utils/account/ep0_7/encodeCallData.js.map +1 -1
  11. package/_cjs/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.js.map +1 -1
  12. package/_cjs/accounts/kernel/utils/common/accountMetadata.js.map +1 -1
  13. package/_cjs/accounts/kernel/utils/common/getActionSelector.js +2 -2
  14. package/_cjs/accounts/kernel/utils/common/getActionSelector.js.map +1 -1
  15. package/_cjs/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.js +2 -2
  16. package/_cjs/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.js.map +1 -1
  17. package/_cjs/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.js +1 -1
  18. package/_cjs/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.js.map +1 -1
  19. package/_cjs/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.js +1 -1
  20. package/_cjs/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.js.map +1 -1
  21. package/_cjs/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.js +2 -2
  22. package/_cjs/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.js.map +1 -1
  23. package/_cjs/accounts/kernel/utils/ep0_7/encodeExecuteCall.js +2 -2
  24. package/_cjs/accounts/kernel/utils/ep0_7/encodeExecuteCall.js.map +1 -1
  25. package/_cjs/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js.map +1 -1
  26. package/_cjs/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js.map +1 -1
  27. package/_cjs/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js.map +1 -1
  28. package/_cjs/accounts/kernel/v1/createKernelAccountV1.js +83 -94
  29. package/_cjs/accounts/kernel/v1/createKernelAccountV1.js.map +1 -1
  30. package/_cjs/accounts/kernel/v2/createKernelAccountV0_2.js +106 -110
  31. package/_cjs/accounts/kernel/v2/createKernelAccountV0_2.js.map +1 -1
  32. package/_cjs/accounts/utils/getCustomNonceKeyFromString.js +2 -4
  33. package/_cjs/accounts/utils/getCustomNonceKeyFromString.js.map +1 -1
  34. package/_cjs/accounts/utils/index.js +1 -7
  35. package/_cjs/accounts/utils/index.js.map +1 -1
  36. package/_cjs/accounts/utils/multisend.js.map +1 -1
  37. package/_cjs/accounts/utils/toKernelPluginManager.js +14 -16
  38. package/_cjs/accounts/utils/toKernelPluginManager.js.map +1 -1
  39. package/_cjs/actions/account-client/changeSudoValidator.js +27 -21
  40. package/_cjs/actions/account-client/changeSudoValidator.js.map +1 -1
  41. package/_cjs/actions/account-client/getKernelV3ModuleCurrentNonce.js +8 -6
  42. package/_cjs/actions/account-client/getKernelV3ModuleCurrentNonce.js.map +1 -1
  43. package/_cjs/actions/account-client/invalidateNonce.js +20 -15
  44. package/_cjs/actions/account-client/invalidateNonce.js.map +1 -1
  45. package/_cjs/actions/account-client/sendTransaction.js +42 -0
  46. package/_cjs/actions/account-client/sendTransaction.js.map +1 -0
  47. package/_cjs/actions/account-client/signMessage.js +15 -0
  48. package/_cjs/actions/account-client/signMessage.js.map +1 -0
  49. package/_cjs/actions/account-client/signTypedData.js +32 -0
  50. package/_cjs/actions/account-client/signTypedData.js.map +1 -0
  51. package/_cjs/actions/account-client/signUserOperation.js +7 -5
  52. package/_cjs/actions/account-client/signUserOperation.js.map +1 -1
  53. package/_cjs/actions/account-client/uninstallPlugin.js +13 -12
  54. package/_cjs/actions/account-client/uninstallPlugin.js.map +1 -1
  55. package/_cjs/actions/account-client/writeContract.js +21 -0
  56. package/_cjs/actions/account-client/writeContract.js.map +1 -0
  57. package/_cjs/actions/index.js +15 -3
  58. package/_cjs/actions/index.js.map +1 -1
  59. package/_cjs/actions/paymaster/estimateGasInERC20.js +4 -4
  60. package/_cjs/actions/paymaster/estimateGasInERC20.js.map +1 -1
  61. package/_cjs/actions/paymaster/sponsorUserOperation.js +4 -6
  62. package/_cjs/actions/paymaster/sponsorUserOperation.js.map +1 -1
  63. package/_cjs/actions/public/getAccountNonce.js +38 -0
  64. package/_cjs/actions/public/getAccountNonce.js.map +1 -0
  65. package/_cjs/actions/public/getSenderAddress.js +166 -0
  66. package/_cjs/actions/public/getSenderAddress.js.map +1 -0
  67. package/_cjs/actions/public/index.js +10 -0
  68. package/_cjs/actions/public/index.js.map +1 -0
  69. package/_cjs/actions/public/isSmartAccountDeployed.js +14 -0
  70. package/_cjs/actions/public/isSmartAccountDeployed.js.map +1 -0
  71. package/_cjs/clients/decorators/kernel.js +17 -27
  72. package/_cjs/clients/decorators/kernel.js.map +1 -1
  73. package/_cjs/clients/fallbackKernelAccountClient.js.map +1 -1
  74. package/_cjs/clients/kernelAccountClient.js +27 -45
  75. package/_cjs/clients/kernelAccountClient.js.map +1 -1
  76. package/_cjs/clients/paymasterClient.js +7 -18
  77. package/_cjs/clients/paymasterClient.js.map +1 -1
  78. package/_cjs/errors/index.js +26 -0
  79. package/_cjs/errors/index.js.map +1 -0
  80. package/_cjs/gasTokenAddresses.js +2 -1
  81. package/_cjs/gasTokenAddresses.js.map +1 -1
  82. package/_cjs/index.js +1 -0
  83. package/_cjs/index.js.map +1 -1
  84. package/_cjs/providers/KernelEIP1193Provider.js.map +1 -1
  85. package/_cjs/types/index.js.map +1 -1
  86. package/_cjs/types/kernel.js.map +1 -1
  87. package/_cjs/utils.js +27 -7
  88. package/_cjs/utils.js.map +1 -1
  89. package/_esm/accounts/index.js.map +1 -1
  90. package/_esm/accounts/kernel/createKernelAccount.js +183 -217
  91. package/_esm/accounts/kernel/createKernelAccount.js.map +1 -1
  92. package/_esm/accounts/kernel/utils/account/ep0_6/encodeCallData.js +13 -9
  93. package/_esm/accounts/kernel/utils/account/ep0_6/encodeCallData.js.map +1 -1
  94. package/_esm/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.js.map +1 -1
  95. package/_esm/accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.js +18 -17
  96. package/_esm/accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.js.map +1 -1
  97. package/_esm/accounts/kernel/utils/account/ep0_7/encodeCallData.js +12 -8
  98. package/_esm/accounts/kernel/utils/account/ep0_7/encodeCallData.js.map +1 -1
  99. package/_esm/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.js.map +1 -1
  100. package/_esm/accounts/kernel/utils/common/accountMetadata.js.map +1 -1
  101. package/_esm/accounts/kernel/utils/common/getActionSelector.js +2 -2
  102. package/_esm/accounts/kernel/utils/common/getActionSelector.js.map +1 -1
  103. package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.js +2 -2
  104. package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.js.map +1 -1
  105. package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.js +1 -1
  106. package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.js.map +1 -1
  107. package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.js +1 -1
  108. package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.js.map +1 -1
  109. package/_esm/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.js +2 -2
  110. package/_esm/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.js.map +1 -1
  111. package/_esm/accounts/kernel/utils/ep0_7/encodeExecuteCall.js +2 -2
  112. package/_esm/accounts/kernel/utils/ep0_7/encodeExecuteCall.js.map +1 -1
  113. package/_esm/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js.map +1 -1
  114. package/_esm/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js.map +1 -1
  115. package/_esm/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js.map +1 -1
  116. package/_esm/accounts/kernel/v1/createKernelAccountV1.js +93 -98
  117. package/_esm/accounts/kernel/v1/createKernelAccountV1.js.map +1 -1
  118. package/_esm/accounts/kernel/v2/createKernelAccountV0_2.js +107 -118
  119. package/_esm/accounts/kernel/v2/createKernelAccountV0_2.js.map +1 -1
  120. package/_esm/accounts/utils/getCustomNonceKeyFromString.js +2 -4
  121. package/_esm/accounts/utils/getCustomNonceKeyFromString.js.map +1 -1
  122. package/_esm/accounts/utils/index.js +0 -5
  123. package/_esm/accounts/utils/index.js.map +1 -1
  124. package/_esm/accounts/utils/multisend.js.map +1 -1
  125. package/_esm/accounts/utils/toKernelPluginManager.js +14 -16
  126. package/_esm/accounts/utils/toKernelPluginManager.js.map +1 -1
  127. package/_esm/actions/account-client/changeSudoValidator.js +23 -17
  128. package/_esm/actions/account-client/changeSudoValidator.js.map +1 -1
  129. package/_esm/actions/account-client/getKernelV3ModuleCurrentNonce.js +8 -6
  130. package/_esm/actions/account-client/getKernelV3ModuleCurrentNonce.js.map +1 -1
  131. package/_esm/actions/account-client/invalidateNonce.js +20 -15
  132. package/_esm/actions/account-client/invalidateNonce.js.map +1 -1
  133. package/_esm/actions/account-client/sendTransaction.js +85 -0
  134. package/_esm/actions/account-client/sendTransaction.js.map +1 -0
  135. package/_esm/actions/account-client/signMessage.js +58 -0
  136. package/_esm/actions/account-client/signMessage.js.map +1 -0
  137. package/_esm/actions/account-client/signTypedData.js +127 -0
  138. package/_esm/actions/account-client/signTypedData.js.map +1 -0
  139. package/_esm/actions/account-client/signUserOperation.js +7 -5
  140. package/_esm/actions/account-client/signUserOperation.js.map +1 -1
  141. package/_esm/actions/account-client/uninstallPlugin.js +10 -9
  142. package/_esm/actions/account-client/uninstallPlugin.js.map +1 -1
  143. package/_esm/actions/account-client/writeContract.js +18 -0
  144. package/_esm/actions/account-client/writeContract.js.map +1 -0
  145. package/_esm/actions/index.js +7 -1
  146. package/_esm/actions/index.js.map +1 -1
  147. package/_esm/actions/paymaster/estimateGasInERC20.js +3 -3
  148. package/_esm/actions/paymaster/estimateGasInERC20.js.map +1 -1
  149. package/_esm/actions/paymaster/sponsorUserOperation.js +3 -5
  150. package/_esm/actions/paymaster/sponsorUserOperation.js.map +1 -1
  151. package/_esm/actions/public/getAccountNonce.js +61 -0
  152. package/_esm/actions/public/getAccountNonce.js.map +1 -0
  153. package/_esm/actions/public/getSenderAddress.js +191 -0
  154. package/_esm/actions/public/getSenderAddress.js.map +1 -0
  155. package/_esm/actions/public/index.js +4 -0
  156. package/_esm/actions/public/index.js.map +1 -0
  157. package/_esm/actions/public/isSmartAccountDeployed.js +10 -0
  158. package/_esm/actions/public/isSmartAccountDeployed.js.map +1 -0
  159. package/_esm/clients/decorators/kernel.js +19 -28
  160. package/_esm/clients/decorators/kernel.js.map +1 -1
  161. package/_esm/clients/fallbackKernelAccountClient.js.map +1 -1
  162. package/_esm/clients/kernelAccountClient.js +28 -46
  163. package/_esm/clients/kernelAccountClient.js.map +1 -1
  164. package/_esm/clients/paymasterClient.js +8 -19
  165. package/_esm/clients/paymasterClient.js.map +1 -1
  166. package/_esm/errors/index.js +21 -0
  167. package/_esm/errors/index.js.map +1 -0
  168. package/_esm/gasTokenAddresses.js +2 -1
  169. package/_esm/gasTokenAddresses.js.map +1 -1
  170. package/_esm/index.js +1 -0
  171. package/_esm/index.js.map +1 -1
  172. package/_esm/providers/KernelEIP1193Provider.js.map +1 -1
  173. package/_esm/types/index.js.map +1 -1
  174. package/_esm/types/kernel.js.map +1 -1
  175. package/_esm/utils.js +29 -7
  176. package/_esm/utils.js.map +1 -1
  177. package/_types/accounts/index.d.ts +2 -2
  178. package/_types/accounts/index.d.ts.map +1 -1
  179. package/_types/accounts/kernel/createKernelAccount.d.ts +21 -18
  180. package/_types/accounts/kernel/createKernelAccount.d.ts.map +1 -1
  181. package/_types/accounts/kernel/utils/account/ep0_6/encodeCallData.d.ts +8 -3
  182. package/_types/accounts/kernel/utils/account/ep0_6/encodeCallData.d.ts.map +1 -1
  183. package/_types/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.d.ts +3 -2
  184. package/_types/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.d.ts.map +1 -1
  185. package/_types/accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.d.ts +0 -1
  186. package/_types/accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.d.ts.map +1 -1
  187. package/_types/accounts/kernel/utils/account/ep0_7/encodeCallData.d.ts +8 -3
  188. package/_types/accounts/kernel/utils/account/ep0_7/encodeCallData.d.ts.map +1 -1
  189. package/_types/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.d.ts +3 -2
  190. package/_types/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.d.ts.map +1 -1
  191. package/_types/accounts/kernel/utils/common/accountMetadata.d.ts +2 -2
  192. package/_types/accounts/kernel/utils/common/accountMetadata.d.ts.map +1 -1
  193. package/_types/accounts/kernel/utils/common/getActionSelector.d.ts +1 -1
  194. package/_types/accounts/kernel/utils/common/getActionSelector.d.ts.map +1 -1
  195. package/_types/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.d.ts +1 -1
  196. package/_types/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.d.ts.map +1 -1
  197. package/_types/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.d.ts +1 -1
  198. package/_types/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.d.ts.map +1 -1
  199. package/_types/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.d.ts +2 -3
  200. package/_types/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.d.ts.map +1 -1
  201. package/_types/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.d.ts +4 -5
  202. package/_types/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.d.ts.map +1 -1
  203. package/_types/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.d.ts +2 -3
  204. package/_types/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.d.ts.map +1 -1
  205. package/_types/accounts/kernel/utils/types.d.ts +2 -2
  206. package/_types/accounts/kernel/utils/types.d.ts.map +1 -1
  207. package/_types/accounts/kernel/v1/createKernelAccountV1.d.ts +18 -9
  208. package/_types/accounts/kernel/v1/createKernelAccountV1.d.ts.map +1 -1
  209. package/_types/accounts/kernel/v2/createKernelAccountV0_2.d.ts +10 -8
  210. package/_types/accounts/kernel/v2/createKernelAccountV0_2.d.ts.map +1 -1
  211. package/_types/accounts/utils/getCustomNonceKeyFromString.d.ts +2 -2
  212. package/_types/accounts/utils/getCustomNonceKeyFromString.d.ts.map +1 -1
  213. package/_types/accounts/utils/index.d.ts +0 -2
  214. package/_types/accounts/utils/index.d.ts.map +1 -1
  215. package/_types/accounts/utils/multisend.d.ts +2 -2
  216. package/_types/accounts/utils/multisend.d.ts.map +1 -1
  217. package/_types/accounts/utils/toKernelPluginManager.d.ts +4 -4
  218. package/_types/accounts/utils/toKernelPluginManager.d.ts.map +1 -1
  219. package/_types/actions/account-client/changeSudoValidator.d.ts +5 -11
  220. package/_types/actions/account-client/changeSudoValidator.d.ts.map +1 -1
  221. package/_types/actions/account-client/getKernelV3ModuleCurrentNonce.d.ts +2 -5
  222. package/_types/actions/account-client/getKernelV3ModuleCurrentNonce.d.ts.map +1 -1
  223. package/_types/actions/account-client/invalidateNonce.d.ts +4 -6
  224. package/_types/actions/account-client/invalidateNonce.d.ts.map +1 -1
  225. package/_types/actions/account-client/sendTransaction.d.ts +50 -0
  226. package/_types/actions/account-client/sendTransaction.d.ts.map +1 -0
  227. package/_types/actions/account-client/signMessage.d.ts +50 -0
  228. package/_types/actions/account-client/signMessage.d.ts.map +1 -0
  229. package/_types/actions/account-client/signTypedData.d.ts +104 -0
  230. package/_types/actions/account-client/signTypedData.d.ts.map +1 -0
  231. package/_types/actions/account-client/signUserOperation.d.ts +4 -6
  232. package/_types/actions/account-client/signUserOperation.d.ts.map +1 -1
  233. package/_types/actions/account-client/uninstallPlugin.d.ts +5 -7
  234. package/_types/actions/account-client/uninstallPlugin.d.ts.map +1 -1
  235. package/_types/actions/account-client/writeContract.d.ts +4 -0
  236. package/_types/actions/account-client/writeContract.d.ts.map +1 -0
  237. package/_types/actions/index.d.ts +7 -1
  238. package/_types/actions/index.d.ts.map +1 -1
  239. package/_types/actions/paymaster/estimateGasInERC20.d.ts +1305 -4
  240. package/_types/actions/paymaster/estimateGasInERC20.d.ts.map +1 -1
  241. package/_types/actions/paymaster/sponsorUserOperation.d.ts +1314 -10
  242. package/_types/actions/paymaster/sponsorUserOperation.d.ts.map +1 -1
  243. package/_types/actions/public/getAccountNonce.d.ts +34 -0
  244. package/_types/actions/public/getAccountNonce.d.ts.map +1 -0
  245. package/_types/actions/public/getSenderAddress.d.ts +46 -0
  246. package/_types/actions/public/getSenderAddress.d.ts.map +1 -0
  247. package/_types/actions/public/index.d.ts +4 -0
  248. package/_types/actions/public/index.d.ts.map +1 -0
  249. package/_types/actions/public/isSmartAccountDeployed.d.ts +3 -0
  250. package/_types/actions/public/isSmartAccountDeployed.d.ts.map +1 -0
  251. package/_types/clients/decorators/kernel.d.ts +774 -20
  252. package/_types/clients/decorators/kernel.d.ts.map +1 -1
  253. package/_types/clients/fallbackKernelAccountClient.d.ts +255 -4
  254. package/_types/clients/fallbackKernelAccountClient.d.ts.map +1 -1
  255. package/_types/clients/kernelAccountClient.d.ts +34 -36
  256. package/_types/clients/kernelAccountClient.d.ts.map +1 -1
  257. package/_types/clients/paymasterClient.d.ts +10 -24
  258. package/_types/clients/paymasterClient.d.ts.map +1 -1
  259. package/_types/errors/index.d.ts +10 -0
  260. package/_types/errors/index.d.ts.map +1 -0
  261. package/_types/gasTokenAddresses.d.ts +1 -1
  262. package/_types/gasTokenAddresses.d.ts.map +1 -1
  263. package/_types/index.d.ts +2 -1
  264. package/_types/index.d.ts.map +1 -1
  265. package/_types/providers/KernelEIP1193Provider.d.ts +3 -4
  266. package/_types/providers/KernelEIP1193Provider.d.ts.map +1 -1
  267. package/_types/types/index.d.ts +2 -1
  268. package/_types/types/index.d.ts.map +1 -1
  269. package/_types/types/kernel.d.ts +25 -27
  270. package/_types/types/kernel.d.ts.map +1 -1
  271. package/_types/utils.d.ts +1310 -4
  272. package/_types/utils.d.ts.map +1 -1
  273. package/accounts/index.ts +5 -2
  274. package/accounts/kernel/createKernelAccount.ts +315 -359
  275. package/accounts/kernel/utils/account/ep0_6/encodeCallData.ts +22 -12
  276. package/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.ts +6 -3
  277. package/accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.ts +22 -19
  278. package/accounts/kernel/utils/account/ep0_7/encodeCallData.ts +21 -11
  279. package/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.ts +6 -3
  280. package/accounts/kernel/utils/common/accountMetadata.ts +2 -7
  281. package/accounts/kernel/utils/common/getActionSelector.ts +3 -3
  282. package/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.ts +3 -3
  283. package/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.ts +1 -1
  284. package/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.ts +1 -1
  285. package/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.ts +3 -3
  286. package/accounts/kernel/utils/ep0_7/encodeExecuteCall.ts +2 -2
  287. package/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.ts +2 -8
  288. package/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.ts +4 -10
  289. package/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.ts +2 -8
  290. package/accounts/kernel/utils/types.ts +2 -2
  291. package/accounts/kernel/v1/createKernelAccountV1.ts +151 -176
  292. package/accounts/kernel/v2/createKernelAccountV0_2.ts +141 -196
  293. package/accounts/utils/getCustomNonceKeyFromString.ts +3 -6
  294. package/accounts/utils/index.ts +0 -9
  295. package/accounts/utils/multisend.ts +5 -2
  296. package/accounts/utils/toKernelPluginManager.ts +23 -27
  297. package/actions/account-client/changeSudoValidator.ts +61 -85
  298. package/actions/account-client/getKernelV3ModuleCurrentNonce.ts +12 -51
  299. package/actions/account-client/invalidateNonce.ts +38 -67
  300. package/actions/account-client/sendTransaction.ts +134 -0
  301. package/actions/account-client/signMessage.ts +75 -0
  302. package/actions/account-client/signTypedData.ts +159 -0
  303. package/actions/account-client/signUserOperation.ts +31 -63
  304. package/actions/account-client/uninstallPlugin.ts +35 -56
  305. package/actions/account-client/writeContract.ts +72 -0
  306. package/actions/index.ts +16 -5
  307. package/actions/paymaster/estimateGasInERC20.ts +12 -8
  308. package/actions/paymaster/sponsorUserOperation.ts +52 -50
  309. package/actions/public/getAccountNonce.ts +77 -0
  310. package/actions/public/getSenderAddress.ts +276 -0
  311. package/actions/public/index.ts +10 -0
  312. package/actions/public/isSmartAccountDeployed.ts +18 -0
  313. package/clients/decorators/kernel.ts +363 -159
  314. package/clients/fallbackKernelAccountClient.ts +9 -11
  315. package/clients/kernelAccountClient.ts +142 -104
  316. package/clients/paymasterClient.ts +69 -43
  317. package/errors/index.ts +25 -0
  318. package/gasTokenAddresses.ts +3 -2
  319. package/index.ts +6 -2
  320. package/package.json +11 -34
  321. package/providers/KernelEIP1193Provider.ts +4 -7
  322. package/types/index.ts +4 -1
  323. package/types/kernel.ts +64 -63
  324. package/utils.ts +41 -13
  325. package/_cjs/actions/paymaster/sponsorUserOperationEip7677.js +0 -59
  326. package/_cjs/actions/paymaster/sponsorUserOperationEip7677.js.map +0 -1
  327. package/_esm/actions/paymaster/sponsorUserOperationEip7677.js +0 -58
  328. package/_esm/actions/paymaster/sponsorUserOperationEip7677.js.map +0 -1
  329. package/_types/actions/paymaster/sponsorUserOperationEip7677.d.ts +0 -16
  330. package/_types/actions/paymaster/sponsorUserOperationEip7677.d.ts.map +0 -1
  331. package/actions/paymaster/sponsorUserOperationEip7677.ts +0 -152
@@ -1,29 +1,12 @@
1
- import {
2
- getAccountNonce,
3
- getEntryPointVersion,
4
- getSenderAddress,
5
- isSmartAccountDeployed
6
- } from "permissionless"
7
- import {
8
- SignTransactionNotSupportedBySmartAccount,
9
- type SmartAccount,
10
- toSmartAccount
11
- } from "permissionless/accounts"
12
- import type {
13
- ENTRYPOINT_ADDRESS_V06_TYPE,
14
- ENTRYPOINT_ADDRESS_V07_TYPE,
15
- EntryPoint
16
- } from "permissionless/types"
17
1
  import {
18
2
  type Address,
19
- type Chain,
3
+ type Assign,
20
4
  type Client,
5
+ type EncodeDeployDataParameters,
21
6
  type Hex,
22
- type PublicActions,
23
- type PublicRpcSchema,
24
- type Transport,
25
7
  type TypedDataDefinition,
26
8
  concatHex,
9
+ createNonceManager,
27
10
  encodeFunctionData,
28
11
  getTypesForEIP712Domain,
29
12
  hashMessage,
@@ -32,16 +15,32 @@ import {
32
15
  validateTypedData,
33
16
  zeroAddress
34
17
  } from "viem"
18
+ import {
19
+ type EntryPointVersion,
20
+ type SmartAccount,
21
+ type SmartAccountImplementation,
22
+ type UserOperation,
23
+ entryPoint06Abi,
24
+ entryPoint07Abi,
25
+ entryPoint07Address,
26
+ toSmartAccount
27
+ } from "viem/account-abstraction"
28
+ import { getChainId } from "viem/actions"
29
+ import { getAction } from "viem/utils"
30
+ import {
31
+ getAccountNonce,
32
+ getSenderAddress
33
+ } from "../../actions/public/index.js"
35
34
  import { KernelVersionToAddressesMap } from "../../constants.js"
36
35
  import type {
36
+ CallType,
37
+ GetEntryPointAbi,
37
38
  GetKernelVersion,
38
- KernelEncodeCallDataArgs,
39
39
  KernelPluginManager,
40
40
  KernelPluginManagerParams
41
41
  } from "../../types/kernel.js"
42
42
  import { KERNEL_FEATURES, hasKernelFeature } from "../../utils.js"
43
43
  import { validateKernelVersionWithEntryPoint } from "../../utils.js"
44
- import { parseFactoryAddressAndCallDataFromAccountInitCode } from "../utils/index.js"
45
44
  import {
46
45
  isKernelPluginManager,
47
46
  toKernelPluginManager
@@ -58,39 +57,57 @@ import { encodeDeployCallData as encodeDeployCallDataV07 } from "./utils/account
58
57
  import { accountMetadata } from "./utils/common/accountMetadata.js"
59
58
  import { eip712WrapHash } from "./utils/common/eip712WrapHash.js"
60
59
 
61
- export type KernelSmartAccount<
62
- entryPoint extends EntryPoint,
63
- transport extends Transport = Transport,
64
- chain extends Chain | undefined = Chain | undefined
65
- > = SmartAccount<entryPoint, "kernelSmartAccount", transport, chain> & {
66
- kernelVersion: GetKernelVersion<entryPoint>
67
- kernelPluginManager: KernelPluginManager<entryPoint>
68
- getNonce: (customNonceKey?: bigint) => Promise<bigint>
69
- generateInitCode: () => Promise<Hex>
70
- encodeCallData: (args: KernelEncodeCallDataArgs) => Promise<Hex>
71
- encodeModuleInstallCallData: () => Promise<Hex>
72
- }
60
+ export type KernelSmartAccountImplementation<
61
+ entryPointVersion extends EntryPointVersion = "0.7"
62
+ > = Assign<
63
+ SmartAccountImplementation<
64
+ GetEntryPointAbi<entryPointVersion>,
65
+ entryPointVersion
66
+ >,
67
+ {
68
+ sign: NonNullable<SmartAccountImplementation["sign"]>
69
+ encodeCalls: (
70
+ calls: Parameters<SmartAccountImplementation["encodeCalls"]>[0],
71
+ callType?: CallType | undefined
72
+ ) => Promise<Hex>
73
+ kernelVersion: GetKernelVersion<entryPointVersion>
74
+ kernelPluginManager: KernelPluginManager<entryPointVersion>
75
+ generateInitCode: () => Promise<Hex>
76
+ encodeModuleInstallCallData: () => Promise<Hex>
77
+ encodeDeployCallData: ({
78
+ abi,
79
+ args,
80
+ bytecode
81
+ }: EncodeDeployDataParameters) => Promise<Hex>
82
+ }
83
+ >
84
+
85
+ export type CreateKernelAccountReturnType<
86
+ entryPointVersion extends EntryPointVersion = "0.7"
87
+ > = SmartAccount<KernelSmartAccountImplementation<entryPointVersion>>
73
88
 
74
89
  export type CreateKernelAccountParameters<
75
- entryPoint extends EntryPoint,
76
- KernelVerion extends GetKernelVersion<entryPoint>
90
+ entryPointVersion extends EntryPointVersion,
91
+ KernelVerion extends GetKernelVersion<entryPointVersion>
77
92
  > = {
78
93
  plugins:
79
94
  | Omit<
80
- KernelPluginManagerParams<entryPoint>,
95
+ KernelPluginManagerParams<entryPointVersion>,
81
96
  "entryPoint" | "kernelVersion"
82
97
  >
83
- | KernelPluginManager<entryPoint>
84
- entryPoint: entryPoint
98
+ | KernelPluginManager<entryPointVersion>
99
+ entryPoint: {
100
+ address: Address
101
+ version: entryPointVersion
102
+ }
85
103
  index?: bigint
86
104
  factoryAddress?: Address
87
105
  accountImplementationAddress?: Address
88
106
  metaFactoryAddress?: Address
89
- deployedAccountAddress?: Address
90
- kernelVersion: GetKernelVersion<entryPoint>
107
+ address?: Address
108
+ kernelVersion: GetKernelVersion<entryPointVersion>
91
109
  initConfig?: KernelVerion extends "0.3.1" ? Hex[] : never
92
110
  useMetaFactory?: boolean
93
- chainId?: number
94
111
  }
95
112
 
96
113
  /**
@@ -145,20 +162,21 @@ export const KERNEL_ADDRESSES: {
145
162
  FACTORY_STAKER: "0xd703aaE79538628d27099B8c4f621bE4CCd142d5"
146
163
  }
147
164
 
148
- const getKernelInitData = async <entryPoint extends EntryPoint>({
149
- entryPoint: entryPointAddress,
165
+ const getKernelInitData = async <entryPointVersion extends EntryPointVersion>({
166
+ entryPointVersion: _entryPointVersion,
150
167
  kernelPluginManager,
151
168
  initHook,
152
169
  kernelVersion,
153
170
  initConfig
154
171
  }: {
155
- entryPoint: entryPoint
156
- kernelPluginManager: KernelPluginManager<entryPoint>
172
+ entryPointVersion: entryPointVersion
173
+ kernelPluginManager: KernelPluginManager<entryPointVersion>
157
174
  initHook: boolean
158
- kernelVersion: GetKernelVersion<entryPoint>
159
- initConfig?: GetKernelVersion<entryPoint> extends "0.3.1" ? Hex[] : never
175
+ kernelVersion: GetKernelVersion<entryPointVersion>
176
+ initConfig?: GetKernelVersion<entryPointVersion> extends "0.3.1"
177
+ ? Hex[]
178
+ : never
160
179
  }) => {
161
- const entryPointVersion = getEntryPointVersion(entryPointAddress)
162
180
  const {
163
181
  enableData,
164
182
  identifier,
@@ -166,7 +184,7 @@ const getKernelInitData = async <entryPoint extends EntryPoint>({
166
184
  initConfig: initConfig_
167
185
  } = await kernelPluginManager.getValidatorInitData()
168
186
 
169
- if (entryPointVersion === "v0.6") {
187
+ if (_entryPointVersion === "0.6") {
170
188
  return encodeFunctionData({
171
189
  abi: KernelInitAbi,
172
190
  functionName: "initialize",
@@ -214,12 +232,11 @@ const getKernelInitData = async <entryPoint extends EntryPoint>({
214
232
  * @param accountImplementationAddress
215
233
  * @param ecdsaValidatorAddress
216
234
  */
217
- const getAccountInitCode = async <entryPoint extends EntryPoint>({
235
+ const getAccountInitCode = async <entryPointVersion extends EntryPointVersion>({
218
236
  index,
219
237
  factoryAddress,
220
238
  accountImplementationAddress,
221
- metaFactoryAddress,
222
- entryPoint: entryPointAddress,
239
+ entryPointVersion: _entryPointVersion,
223
240
  kernelPluginManager,
224
241
  initHook,
225
242
  kernelVersion,
@@ -229,103 +246,51 @@ const getAccountInitCode = async <entryPoint extends EntryPoint>({
229
246
  index: bigint
230
247
  factoryAddress: Address
231
248
  accountImplementationAddress: Address
232
- metaFactoryAddress?: Address
233
- entryPoint: entryPoint
234
- kernelPluginManager: KernelPluginManager<entryPoint>
249
+ entryPointVersion: entryPointVersion
250
+ kernelPluginManager: KernelPluginManager<entryPointVersion>
235
251
  initHook: boolean
236
- kernelVersion: GetKernelVersion<entryPoint>
237
- initConfig?: GetKernelVersion<entryPoint> extends "0.3.1" ? Hex[] : never
252
+ kernelVersion: GetKernelVersion<entryPointVersion>
253
+ initConfig?: GetKernelVersion<entryPointVersion> extends "0.3.1"
254
+ ? Hex[]
255
+ : never
238
256
  useMetaFactory: boolean
239
257
  }): Promise<Hex> => {
240
258
  // Build the account initialization data
241
- const initialisationData = await getKernelInitData<entryPoint>({
242
- entryPoint: entryPointAddress,
259
+ const initialisationData = await getKernelInitData<entryPointVersion>({
260
+ entryPointVersion: _entryPointVersion,
243
261
  kernelPluginManager,
244
262
  initHook,
245
263
  kernelVersion,
246
264
  initConfig
247
265
  })
248
- const entryPointVersion = getEntryPointVersion(entryPointAddress)
249
266
 
250
267
  // Build the account init code
251
- if (entryPointVersion === "v0.6") {
252
- return concatHex([
253
- factoryAddress,
254
- encodeFunctionData({
255
- abi: createAccountAbi,
256
- functionName: "createAccount",
257
- args: [accountImplementationAddress, initialisationData, index]
258
- }) as Hex
259
- ])
268
+ if (_entryPointVersion === "0.6") {
269
+ return encodeFunctionData({
270
+ abi: createAccountAbi,
271
+ functionName: "createAccount",
272
+ args: [accountImplementationAddress, initialisationData, index]
273
+ })
260
274
  }
261
275
 
262
276
  if (!useMetaFactory) {
263
- return concatHex([
264
- factoryAddress,
265
- encodeFunctionData({
266
- abi: KernelV3FactoryAbi,
267
- functionName: "createAccount",
268
- args: [initialisationData, toHex(index, { size: 32 })]
269
- }) as Hex
270
- ])
271
- }
272
-
273
- return concatHex([
274
- metaFactoryAddress ?? zeroAddress,
275
- encodeFunctionData({
276
- abi: KernelFactoryStakerAbi,
277
- functionName: "deployWithFactory",
278
- args: [
279
- factoryAddress,
280
- initialisationData,
281
- toHex(index, { size: 32 })
282
- ]
283
- })
284
- ])
285
- }
286
-
287
- /**
288
- * Check the validity of an existing account address, or fetch the pre-deterministic account address for a kernel smart wallet
289
- * @param client
290
- * @param entryPoint
291
- * @param initCodeProvider
292
- */
293
- const getAccountAddress = async <
294
- entryPoint extends EntryPoint,
295
- TTransport extends Transport = Transport,
296
- TChain extends Chain | undefined = Chain | undefined
297
- >({
298
- client,
299
- entryPoint: entryPointAddress,
300
- initCodeProvider
301
- }: {
302
- client: Client<TTransport, TChain, undefined>
303
- initCodeProvider: () => Promise<Hex>
304
- entryPoint: entryPoint
305
- }): Promise<Address> => {
306
- const entryPointVersion = getEntryPointVersion(entryPointAddress)
307
-
308
- // Find the init code for this account
309
- const initCode = await initCodeProvider()
310
- if (entryPointVersion === "v0.6") {
311
- return getSenderAddress<ENTRYPOINT_ADDRESS_V06_TYPE>(client, {
312
- initCode,
313
- entryPoint: entryPointAddress as ENTRYPOINT_ADDRESS_V06_TYPE
277
+ return encodeFunctionData({
278
+ abi: KernelV3FactoryAbi,
279
+ functionName: "createAccount",
280
+ args: [initialisationData, toHex(index, { size: 32 })]
314
281
  })
315
282
  }
316
283
 
317
- // Get the sender address based on the init code
318
- return getSenderAddress<ENTRYPOINT_ADDRESS_V07_TYPE>(client, {
319
- factory: parseFactoryAddressAndCallDataFromAccountInitCode(initCode)[0],
320
- factoryData:
321
- parseFactoryAddressAndCallDataFromAccountInitCode(initCode)[1],
322
- entryPoint: entryPointAddress as ENTRYPOINT_ADDRESS_V07_TYPE
284
+ return encodeFunctionData({
285
+ abi: KernelFactoryStakerAbi,
286
+ functionName: "deployWithFactory",
287
+ args: [factoryAddress, initialisationData, toHex(index, { size: 32 })]
323
288
  })
324
289
  }
325
290
 
326
- const getDefaultAddresses = <entryPoint extends EntryPoint>(
327
- entryPointAddress: entryPoint,
328
- kernelVersion: GetKernelVersion<entryPoint>,
291
+ const getDefaultAddresses = <entryPointVersion extends EntryPointVersion>(
292
+ entryPointVersion: entryPointVersion,
293
+ kernelVersion: GetKernelVersion<entryPointVersion>,
329
294
  {
330
295
  accountImplementationAddress,
331
296
  factoryAddress,
@@ -336,7 +301,7 @@ const getDefaultAddresses = <entryPoint extends EntryPoint>(
336
301
  metaFactoryAddress?: Address
337
302
  }
338
303
  ) => {
339
- validateKernelVersionWithEntryPoint(entryPointAddress, kernelVersion)
304
+ validateKernelVersionWithEntryPoint(entryPointVersion, kernelVersion)
340
305
 
341
306
  const addresses = KernelVersionToAddressesMap[kernelVersion]
342
307
  if (!addresses) {
@@ -350,7 +315,8 @@ const getDefaultAddresses = <entryPoint extends EntryPoint>(
350
315
  accountImplementationAddress ??
351
316
  addresses.accountImplementationAddress,
352
317
  factoryAddress: factoryAddress ?? addresses.factoryAddress,
353
- metaFactoryAddress: metaFactoryAddress ?? addresses.metaFactoryAddress
318
+ metaFactoryAddress:
319
+ metaFactoryAddress ?? addresses.metaFactoryAddress ?? zeroAddress
354
320
  }
355
321
  }
356
322
 
@@ -363,60 +329,62 @@ const getDefaultAddresses = <entryPoint extends EntryPoint>(
363
329
  * @param factoryAddress
364
330
  * @param accountImplementationAddress
365
331
  * @param ecdsaValidatorAddress
366
- * @param deployedAccountAddress
332
+ * @param address
367
333
  */
368
334
  export async function createKernelAccount<
369
- entryPoint extends EntryPoint,
370
- KernelVersion extends GetKernelVersion<entryPoint>,
371
- TTransport extends Transport,
372
- TChain extends Chain | undefined
335
+ entryPointVersion extends EntryPointVersion,
336
+ KernelVersion extends GetKernelVersion<entryPointVersion>
373
337
  >(
374
- client: Client<
375
- TTransport,
376
- TChain,
377
- undefined,
378
- PublicRpcSchema,
379
- PublicActions<TTransport, TChain>
380
- >,
338
+ client: Client,
381
339
  {
382
340
  plugins,
383
- entryPoint: entryPointAddress,
341
+ entryPoint,
384
342
  index = 0n,
385
343
  factoryAddress: _factoryAddress,
386
344
  accountImplementationAddress: _accountImplementationAddress,
387
345
  metaFactoryAddress: _metaFactoryAddress,
388
- deployedAccountAddress,
346
+ address,
389
347
  kernelVersion,
390
348
  initConfig,
391
- useMetaFactory = true,
392
- chainId
393
- }: CreateKernelAccountParameters<entryPoint, KernelVersion>
394
- ): Promise<KernelSmartAccount<entryPoint, TTransport, TChain>> {
395
- const entryPointVersion = getEntryPointVersion(entryPointAddress)
349
+ useMetaFactory = true
350
+ }: CreateKernelAccountParameters<entryPointVersion, KernelVersion>
351
+ ): Promise<CreateKernelAccountReturnType<entryPointVersion>> {
396
352
  const { accountImplementationAddress, factoryAddress, metaFactoryAddress } =
397
- getDefaultAddresses(entryPointAddress, kernelVersion, {
353
+ getDefaultAddresses(entryPoint.version, kernelVersion, {
398
354
  accountImplementationAddress: _accountImplementationAddress,
399
355
  factoryAddress: _factoryAddress,
400
356
  metaFactoryAddress: _metaFactoryAddress
401
357
  })
402
358
 
403
- const kernelPluginManager = isKernelPluginManager<entryPoint>(plugins)
359
+ let chainId: number
360
+
361
+ const getMemoizedChainId = async () => {
362
+ if (chainId) return chainId
363
+ chainId = client.chain
364
+ ? client.chain.id
365
+ : await getAction(client, getChainId, "getChainId")({})
366
+ return chainId
367
+ }
368
+
369
+ const kernelPluginManager = isKernelPluginManager<entryPointVersion>(
370
+ plugins
371
+ )
404
372
  ? plugins
405
- : await toKernelPluginManager<entryPoint>(client, {
373
+ : await toKernelPluginManager<entryPointVersion>(client, {
406
374
  sudo: plugins.sudo,
407
375
  regular: plugins.regular,
408
376
  hook: plugins.hook,
409
377
  action: plugins.action,
410
378
  pluginEnableSignature: plugins.pluginEnableSignature,
411
- entryPoint: entryPointAddress,
379
+ entryPoint,
412
380
  kernelVersion,
413
- chainId
381
+ chainId: await getMemoizedChainId()
414
382
  })
415
383
 
416
384
  // initHook flag is activated only if both the hook and sudo validator are given
417
385
  // if the hook is given with regular plugins, then consider it as a hook for regular plugins
418
386
  const initHook = Boolean(
419
- isKernelPluginManager<entryPoint>(plugins)
387
+ isKernelPluginManager<entryPointVersion>(plugins)
420
388
  ? plugins.hook &&
421
389
  plugins.getIdentifier() ===
422
390
  plugins.sudoValidator?.getIdentifier()
@@ -427,12 +395,11 @@ export async function createKernelAccount<
427
395
  const generateInitCode = async () => {
428
396
  if (!accountImplementationAddress || !factoryAddress)
429
397
  throw new Error("Missing account logic address or factory address")
430
- return getAccountInitCode<entryPoint>({
398
+ return getAccountInitCode<entryPointVersion>({
431
399
  index,
432
400
  factoryAddress,
433
401
  accountImplementationAddress,
434
- metaFactoryAddress,
435
- entryPoint: entryPointAddress,
402
+ entryPointVersion: entryPoint.version,
436
403
  kernelPluginManager,
437
404
  initHook,
438
405
  kernelVersion,
@@ -441,23 +408,39 @@ export async function createKernelAccount<
441
408
  })
442
409
  }
443
410
 
444
- // Fetch account address and chain id
445
- const accountAddress =
446
- deployedAccountAddress ??
447
- (await getAccountAddress<entryPoint, TTransport, TChain>({
448
- client,
449
- entryPoint: entryPointAddress,
450
- initCodeProvider: generateInitCode
451
- }))
452
-
453
- if (!accountAddress) throw new Error("Account address not found")
454
-
455
- let smartAccountDeployed = await isSmartAccountDeployed(
456
- client,
457
- accountAddress
458
- )
411
+ const getFactoryArgs = async () => {
412
+ return {
413
+ factory:
414
+ entryPoint.version === "0.6"
415
+ ? factoryAddress
416
+ : metaFactoryAddress,
417
+ factoryData: await generateInitCode()
418
+ }
419
+ }
459
420
 
460
- return {
421
+ // Fetch account address
422
+ let accountAddress =
423
+ address ??
424
+ (await (async () => {
425
+ const { factory, factoryData } = await getFactoryArgs()
426
+
427
+ // Get the sender address based on the init code
428
+ return await getSenderAddress(client, {
429
+ factory,
430
+ factoryData,
431
+ entryPointAddress: entryPoint.address
432
+ })
433
+ })())
434
+
435
+ const _entryPoint = {
436
+ address: entryPoint?.address ?? entryPoint07Address,
437
+ abi: ((entryPoint?.version ?? "0.7") === "0.6"
438
+ ? entryPoint06Abi
439
+ : entryPoint07Abi) as GetEntryPointAbi<entryPointVersion>,
440
+ version: entryPoint?.version ?? "0.7"
441
+ } as const
442
+
443
+ return toSmartAccount<KernelSmartAccountImplementation<entryPointVersion>>({
461
444
  kernelVersion,
462
445
  kernelPluginManager,
463
446
  generateInitCode,
@@ -466,197 +449,170 @@ export async function createKernelAccount<
466
449
  accountAddress
467
450
  )
468
451
  },
469
- ...toSmartAccount({
470
- address: accountAddress,
471
- publicKey: accountAddress,
472
- source: "kernelSmartAccount",
473
- client,
474
- entryPoint: entryPointAddress,
475
- // Encode the deploy call data
476
- async encodeDeployCallData(_tx) {
477
- if (entryPointVersion === "v0.6") {
478
- return encodeDeployCallDataV06(_tx)
479
- }
480
- return encodeDeployCallDataV07(_tx)
481
- },
482
- async encodeCallData(_tx) {
483
- const tx = _tx as KernelEncodeCallDataArgs
484
- if (
485
- !Array.isArray(tx) &&
486
- (!tx.callType || tx.callType === "call") &&
487
- tx.to.toLowerCase() === accountAddress.toLowerCase()
488
- ) {
489
- return tx.data
490
- }
491
- if (entryPointVersion === "v0.6") {
492
- return encodeCallDataEpV06(tx)
493
- }
494
-
495
- if (plugins.hook) {
496
- return encodeCallDataEpV07(tx, true)
497
- }
498
- return encodeCallDataEpV07(tx)
499
- },
500
- async getFactory() {
501
- if (smartAccountDeployed) return undefined
502
-
503
- smartAccountDeployed = await isSmartAccountDeployed(
504
- client,
505
- accountAddress
506
- )
507
-
508
- if (smartAccountDeployed) return undefined
509
-
510
- const entryPointVersion =
511
- getEntryPointVersion(entryPointAddress)
512
- if (entryPointVersion === "v0.6") {
513
- return factoryAddress
514
- }
515
- if (!useMetaFactory) {
516
- return factoryAddress
517
- }
518
- return metaFactoryAddress
519
- },
452
+ nonceKeyManager: createNonceManager({
453
+ source: { get: () => 0, set: () => {} }
454
+ }),
455
+ client,
456
+ entryPoint: _entryPoint,
457
+ getFactoryArgs,
458
+ async getAddress() {
459
+ if (accountAddress) return accountAddress
520
460
 
521
- async getFactoryData() {
522
- if (smartAccountDeployed) return undefined
461
+ const { factory, factoryData } = await getFactoryArgs()
523
462
 
524
- smartAccountDeployed = await isSmartAccountDeployed(
525
- client,
526
- accountAddress
527
- )
463
+ // Get the sender address based on the init code
464
+ accountAddress = await getSenderAddress(client, {
465
+ factory,
466
+ factoryData,
467
+ entryPointAddress: entryPoint.address
468
+ })
528
469
 
529
- if (smartAccountDeployed) return undefined
470
+ return accountAddress
471
+ },
472
+ // Encode the deploy call data
473
+ async encodeDeployCallData(_tx) {
474
+ if (entryPoint.version === "0.6") {
475
+ return encodeDeployCallDataV06(_tx)
476
+ }
477
+ return encodeDeployCallDataV07(_tx)
478
+ },
479
+ async encodeCalls(calls, callType) {
480
+ if (
481
+ calls.length === 1 &&
482
+ (!callType || callType === "call") &&
483
+ calls[0].to.toLowerCase() === accountAddress.toLowerCase()
484
+ ) {
485
+ return calls[0].data ?? "0x"
486
+ }
487
+ if (entryPoint.version === "0.6") {
488
+ return encodeCallDataEpV06(calls, callType)
489
+ }
530
490
 
531
- return parseFactoryAddressAndCallDataFromAccountInitCode(
532
- await generateInitCode()
533
- )[1]
534
- },
535
- async signMessage({ message }) {
536
- const messageHash = hashMessage(message)
537
- const {
538
- name,
539
- chainId: metadataChainId,
540
- version
541
- } = await accountMetadata(
542
- client,
543
- accountAddress,
544
- kernelVersion,
545
- chainId
546
- )
547
- const wrappedMessageHash = await eip712WrapHash(messageHash, {
548
- name,
549
- chainId: Number(metadataChainId),
550
- version,
551
- verifyingContract: accountAddress
552
- })
553
- const signature = await kernelPluginManager.signMessage({
554
- message: { raw: wrappedMessageHash }
555
- })
556
-
557
- if (
558
- !hasKernelFeature(
559
- KERNEL_FEATURES.ERC1271_WITH_VALIDATOR,
560
- version
561
- )
562
- ) {
563
- return signature
564
- }
565
-
566
- return concatHex([
567
- kernelPluginManager.getIdentifier(),
568
- signature
569
- ])
570
- },
571
- async signTransaction(_, __) {
572
- throw new SignTransactionNotSupportedBySmartAccount()
573
- },
574
- async signTypedData(typedData) {
575
- const types = {
576
- EIP712Domain: getTypesForEIP712Domain({
577
- domain: typedData.domain
578
- }),
579
- ...typedData.types
580
- }
581
-
582
- // Need to do a runtime validation check on addresses, byte ranges, integer ranges, etc
583
- // as we can't statically check this with TypeScript.
584
- validateTypedData({
585
- domain: typedData.domain,
586
- message: typedData.message,
587
- primaryType: typedData.primaryType,
588
- types: types
589
- } as TypedDataDefinition)
590
-
591
- const typedHash = hashTypedData(typedData)
592
-
593
- const {
594
- name,
595
- chainId: metadataChainId,
491
+ if (plugins.hook) {
492
+ return encodeCallDataEpV07(calls, callType, true)
493
+ }
494
+ return encodeCallDataEpV07(calls, callType)
495
+ },
496
+ async sign({ hash }) {
497
+ return this.signMessage({ message: hash })
498
+ },
499
+ async signMessage({ message }) {
500
+ const messageHash = hashMessage(message)
501
+ const {
502
+ name,
503
+ chainId: metadataChainId,
504
+ version
505
+ } = await accountMetadata(
506
+ client,
507
+ accountAddress,
508
+ kernelVersion,
509
+ chainId
510
+ )
511
+ const wrappedMessageHash = await eip712WrapHash(messageHash, {
512
+ name,
513
+ chainId: Number(metadataChainId),
514
+ version,
515
+ verifyingContract: accountAddress
516
+ })
517
+ const signature = await kernelPluginManager.signMessage({
518
+ message: { raw: wrappedMessageHash }
519
+ })
520
+
521
+ if (
522
+ !hasKernelFeature(
523
+ KERNEL_FEATURES.ERC1271_WITH_VALIDATOR,
596
524
  version
597
- } = await accountMetadata(
598
- client,
599
- accountAddress,
600
- kernelVersion,
601
- chainId
602
525
  )
603
- const wrappedMessageHash = await eip712WrapHash(typedHash, {
604
- name,
605
- chainId: Number(metadataChainId),
606
- version,
607
- verifyingContract: accountAddress
608
- })
609
- const signature = await kernelPluginManager.signMessage({
610
- message: { raw: wrappedMessageHash }
611
- })
612
- if (
613
- !hasKernelFeature(
614
- KERNEL_FEATURES.ERC1271_WITH_VALIDATOR,
615
- version
616
- )
617
- ) {
618
- return signature
619
- }
620
- return concatHex([
621
- kernelPluginManager.getIdentifier(),
622
- signature
623
- ])
624
- },
625
- // Get the nonce of the smart account
626
- async getNonce(customNonceKey?: bigint) {
627
- const key = await kernelPluginManager.getNonceKey(
628
- accountAddress,
629
- customNonceKey
630
- )
631
- return getAccountNonce(client, {
632
- sender: accountAddress,
633
- entryPoint: entryPointAddress,
634
- key
635
- })
636
- },
637
-
638
- // Sign a user operation
639
- async signUserOperation(userOperation) {
640
- return kernelPluginManager.signUserOperation(userOperation)
641
- },
642
-
643
- // Get simple dummy signature
644
- async getDummySignature(userOperation) {
645
- return kernelPluginManager.getDummySignature(userOperation)
646
- },
526
+ ) {
527
+ return signature
528
+ }
647
529
 
648
- // Encode the init code
649
- async getInitCode() {
650
- if (smartAccountDeployed) return "0x"
530
+ return concatHex([kernelPluginManager.getIdentifier(), signature])
531
+ },
532
+ async signTypedData(typedData) {
533
+ const {
534
+ message,
535
+ primaryType,
536
+ types: _types,
537
+ domain
538
+ } = typedData as TypedDataDefinition
539
+ const types = {
540
+ EIP712Domain: getTypesForEIP712Domain({
541
+ domain: domain
542
+ }),
543
+ ..._types
544
+ }
651
545
 
652
- smartAccountDeployed = await isSmartAccountDeployed(
653
- client,
654
- accountAddress
546
+ // Need to do a runtime validation check on addresses, byte ranges, integer ranges, etc
547
+ // as we can't statically check this with TypeScript.
548
+ validateTypedData({
549
+ domain: domain,
550
+ message: message,
551
+ primaryType: primaryType,
552
+ types: types
553
+ })
554
+
555
+ const typedHash = hashTypedData(typedData)
556
+
557
+ const {
558
+ name,
559
+ chainId: metadataChainId,
560
+ version
561
+ } = await accountMetadata(
562
+ client,
563
+ accountAddress,
564
+ kernelVersion,
565
+ chainId
566
+ )
567
+ const wrappedMessageHash = await eip712WrapHash(typedHash, {
568
+ name,
569
+ chainId: Number(metadataChainId),
570
+ version,
571
+ verifyingContract: accountAddress
572
+ })
573
+ const signature = await kernelPluginManager.signMessage({
574
+ message: { raw: wrappedMessageHash }
575
+ })
576
+ if (
577
+ !hasKernelFeature(
578
+ KERNEL_FEATURES.ERC1271_WITH_VALIDATOR,
579
+ version
655
580
  )
656
-
657
- if (smartAccountDeployed) return "0x"
658
- return generateInitCode()
581
+ ) {
582
+ return signature
659
583
  }
660
- })
661
- }
584
+ return concatHex([kernelPluginManager.getIdentifier(), signature])
585
+ },
586
+ // Get the nonce of the smart account
587
+ async getNonce(_args) {
588
+ const key = await kernelPluginManager.getNonceKey(
589
+ accountAddress,
590
+ _args?.key
591
+ )
592
+ return getAccountNonce(client, {
593
+ address: accountAddress,
594
+ entryPointAddress: entryPoint.address,
595
+ key
596
+ })
597
+ },
598
+ async getStubSignature(userOperation) {
599
+ if (!userOperation) {
600
+ throw new Error("No user operation provided")
601
+ }
602
+ return kernelPluginManager.getStubSignature(
603
+ userOperation as UserOperation
604
+ )
605
+ },
606
+
607
+ // Sign a user operation
608
+ async signUserOperation(parameters) {
609
+ const { chainId = await getMemoizedChainId(), ...userOperation } =
610
+ parameters
611
+ return kernelPluginManager.signUserOperation({
612
+ ...userOperation,
613
+ sender: userOperation.sender ?? (await this.getAddress()),
614
+ chainId
615
+ })
616
+ }
617
+ }) as Promise<CreateKernelAccountReturnType<entryPointVersion>>
662
618
  }