@zerodev/sdk 5.3.26 → 5.4.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (320) hide show
  1. package/_cjs/accounts/index.js.map +1 -1
  2. package/_cjs/accounts/kernel/createKernelAccount.js +171 -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 +81 -94
  29. package/_cjs/accounts/kernel/v1/createKernelAccountV1.js.map +1 -1
  30. package/_cjs/accounts/kernel/v2/createKernelAccountV0_2.js +104 -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 +13 -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 +8 -0
  68. package/_cjs/actions/public/index.js.map +1 -0
  69. package/_cjs/clients/decorators/kernel.js +17 -27
  70. package/_cjs/clients/decorators/kernel.js.map +1 -1
  71. package/_cjs/clients/fallbackKernelAccountClient.js.map +1 -1
  72. package/_cjs/clients/kernelAccountClient.js +27 -45
  73. package/_cjs/clients/kernelAccountClient.js.map +1 -1
  74. package/_cjs/clients/paymasterClient.js +7 -18
  75. package/_cjs/clients/paymasterClient.js.map +1 -1
  76. package/_cjs/errors/index.js +18 -0
  77. package/_cjs/errors/index.js.map +1 -0
  78. package/_cjs/gasTokenAddresses.js +2 -1
  79. package/_cjs/gasTokenAddresses.js.map +1 -1
  80. package/_cjs/index.js.map +1 -1
  81. package/_cjs/providers/KernelEIP1193Provider.js.map +1 -1
  82. package/_cjs/types/kernel.js.map +1 -1
  83. package/_cjs/utils.js +27 -7
  84. package/_cjs/utils.js.map +1 -1
  85. package/_esm/accounts/index.js.map +1 -1
  86. package/_esm/accounts/kernel/createKernelAccount.js +181 -217
  87. package/_esm/accounts/kernel/createKernelAccount.js.map +1 -1
  88. package/_esm/accounts/kernel/utils/account/ep0_6/encodeCallData.js +13 -9
  89. package/_esm/accounts/kernel/utils/account/ep0_6/encodeCallData.js.map +1 -1
  90. package/_esm/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.js.map +1 -1
  91. package/_esm/accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.js +18 -17
  92. package/_esm/accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.js.map +1 -1
  93. package/_esm/accounts/kernel/utils/account/ep0_7/encodeCallData.js +12 -8
  94. package/_esm/accounts/kernel/utils/account/ep0_7/encodeCallData.js.map +1 -1
  95. package/_esm/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.js.map +1 -1
  96. package/_esm/accounts/kernel/utils/common/accountMetadata.js.map +1 -1
  97. package/_esm/accounts/kernel/utils/common/getActionSelector.js +2 -2
  98. package/_esm/accounts/kernel/utils/common/getActionSelector.js.map +1 -1
  99. package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.js +2 -2
  100. package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.js.map +1 -1
  101. package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.js +1 -1
  102. package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.js.map +1 -1
  103. package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.js +1 -1
  104. package/_esm/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.js.map +1 -1
  105. package/_esm/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.js +2 -2
  106. package/_esm/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.js.map +1 -1
  107. package/_esm/accounts/kernel/utils/ep0_7/encodeExecuteCall.js +2 -2
  108. package/_esm/accounts/kernel/utils/ep0_7/encodeExecuteCall.js.map +1 -1
  109. package/_esm/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js.map +1 -1
  110. package/_esm/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js.map +1 -1
  111. package/_esm/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js.map +1 -1
  112. package/_esm/accounts/kernel/v1/createKernelAccountV1.js +91 -98
  113. package/_esm/accounts/kernel/v1/createKernelAccountV1.js.map +1 -1
  114. package/_esm/accounts/kernel/v2/createKernelAccountV0_2.js +105 -118
  115. package/_esm/accounts/kernel/v2/createKernelAccountV0_2.js.map +1 -1
  116. package/_esm/accounts/utils/getCustomNonceKeyFromString.js +2 -4
  117. package/_esm/accounts/utils/getCustomNonceKeyFromString.js.map +1 -1
  118. package/_esm/accounts/utils/index.js +0 -5
  119. package/_esm/accounts/utils/index.js.map +1 -1
  120. package/_esm/accounts/utils/multisend.js.map +1 -1
  121. package/_esm/accounts/utils/toKernelPluginManager.js +14 -16
  122. package/_esm/accounts/utils/toKernelPluginManager.js.map +1 -1
  123. package/_esm/actions/account-client/changeSudoValidator.js +23 -17
  124. package/_esm/actions/account-client/changeSudoValidator.js.map +1 -1
  125. package/_esm/actions/account-client/getKernelV3ModuleCurrentNonce.js +8 -6
  126. package/_esm/actions/account-client/getKernelV3ModuleCurrentNonce.js.map +1 -1
  127. package/_esm/actions/account-client/invalidateNonce.js +20 -15
  128. package/_esm/actions/account-client/invalidateNonce.js.map +1 -1
  129. package/_esm/actions/account-client/sendTransaction.js +85 -0
  130. package/_esm/actions/account-client/sendTransaction.js.map +1 -0
  131. package/_esm/actions/account-client/signMessage.js +58 -0
  132. package/_esm/actions/account-client/signMessage.js.map +1 -0
  133. package/_esm/actions/account-client/signTypedData.js +127 -0
  134. package/_esm/actions/account-client/signTypedData.js.map +1 -0
  135. package/_esm/actions/account-client/signUserOperation.js +7 -5
  136. package/_esm/actions/account-client/signUserOperation.js.map +1 -1
  137. package/_esm/actions/account-client/uninstallPlugin.js +10 -9
  138. package/_esm/actions/account-client/uninstallPlugin.js.map +1 -1
  139. package/_esm/actions/account-client/writeContract.js +18 -0
  140. package/_esm/actions/account-client/writeContract.js.map +1 -0
  141. package/_esm/actions/index.js +6 -1
  142. package/_esm/actions/index.js.map +1 -1
  143. package/_esm/actions/paymaster/estimateGasInERC20.js +3 -3
  144. package/_esm/actions/paymaster/estimateGasInERC20.js.map +1 -1
  145. package/_esm/actions/paymaster/sponsorUserOperation.js +3 -5
  146. package/_esm/actions/paymaster/sponsorUserOperation.js.map +1 -1
  147. package/_esm/actions/public/getAccountNonce.js +61 -0
  148. package/_esm/actions/public/getAccountNonce.js.map +1 -0
  149. package/_esm/actions/public/getSenderAddress.js +191 -0
  150. package/_esm/actions/public/getSenderAddress.js.map +1 -0
  151. package/_esm/actions/public/index.js +3 -0
  152. package/_esm/actions/public/index.js.map +1 -0
  153. package/_esm/clients/decorators/kernel.js +19 -28
  154. package/_esm/clients/decorators/kernel.js.map +1 -1
  155. package/_esm/clients/fallbackKernelAccountClient.js.map +1 -1
  156. package/_esm/clients/kernelAccountClient.js +28 -46
  157. package/_esm/clients/kernelAccountClient.js.map +1 -1
  158. package/_esm/clients/paymasterClient.js +8 -19
  159. package/_esm/clients/paymasterClient.js.map +1 -1
  160. package/_esm/errors/index.js +14 -0
  161. package/_esm/errors/index.js.map +1 -0
  162. package/_esm/gasTokenAddresses.js +2 -1
  163. package/_esm/gasTokenAddresses.js.map +1 -1
  164. package/_esm/index.js.map +1 -1
  165. package/_esm/providers/KernelEIP1193Provider.js.map +1 -1
  166. package/_esm/types/kernel.js.map +1 -1
  167. package/_esm/utils.js +29 -7
  168. package/_esm/utils.js.map +1 -1
  169. package/_types/accounts/index.d.ts +2 -2
  170. package/_types/accounts/index.d.ts.map +1 -1
  171. package/_types/accounts/kernel/createKernelAccount.d.ts +21 -18
  172. package/_types/accounts/kernel/createKernelAccount.d.ts.map +1 -1
  173. package/_types/accounts/kernel/utils/account/ep0_6/encodeCallData.d.ts +8 -3
  174. package/_types/accounts/kernel/utils/account/ep0_6/encodeCallData.d.ts.map +1 -1
  175. package/_types/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.d.ts +3 -2
  176. package/_types/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.d.ts.map +1 -1
  177. package/_types/accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.d.ts +0 -1
  178. package/_types/accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.d.ts.map +1 -1
  179. package/_types/accounts/kernel/utils/account/ep0_7/encodeCallData.d.ts +8 -3
  180. package/_types/accounts/kernel/utils/account/ep0_7/encodeCallData.d.ts.map +1 -1
  181. package/_types/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.d.ts +3 -2
  182. package/_types/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.d.ts.map +1 -1
  183. package/_types/accounts/kernel/utils/common/accountMetadata.d.ts +2 -2
  184. package/_types/accounts/kernel/utils/common/accountMetadata.d.ts.map +1 -1
  185. package/_types/accounts/kernel/utils/common/getActionSelector.d.ts +1 -1
  186. package/_types/accounts/kernel/utils/common/getActionSelector.d.ts.map +1 -1
  187. package/_types/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.d.ts +1 -1
  188. package/_types/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.d.ts.map +1 -1
  189. package/_types/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.d.ts +1 -1
  190. package/_types/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.d.ts.map +1 -1
  191. package/_types/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.d.ts +2 -3
  192. package/_types/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.d.ts.map +1 -1
  193. package/_types/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.d.ts +4 -5
  194. package/_types/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.d.ts.map +1 -1
  195. package/_types/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.d.ts +2 -3
  196. package/_types/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.d.ts.map +1 -1
  197. package/_types/accounts/kernel/utils/types.d.ts +2 -2
  198. package/_types/accounts/kernel/utils/types.d.ts.map +1 -1
  199. package/_types/accounts/kernel/v1/createKernelAccountV1.d.ts +18 -9
  200. package/_types/accounts/kernel/v1/createKernelAccountV1.d.ts.map +1 -1
  201. package/_types/accounts/kernel/v2/createKernelAccountV0_2.d.ts +9 -7
  202. package/_types/accounts/kernel/v2/createKernelAccountV0_2.d.ts.map +1 -1
  203. package/_types/accounts/utils/getCustomNonceKeyFromString.d.ts +2 -2
  204. package/_types/accounts/utils/getCustomNonceKeyFromString.d.ts.map +1 -1
  205. package/_types/accounts/utils/index.d.ts +0 -2
  206. package/_types/accounts/utils/index.d.ts.map +1 -1
  207. package/_types/accounts/utils/multisend.d.ts +2 -2
  208. package/_types/accounts/utils/multisend.d.ts.map +1 -1
  209. package/_types/accounts/utils/toKernelPluginManager.d.ts +4 -4
  210. package/_types/accounts/utils/toKernelPluginManager.d.ts.map +1 -1
  211. package/_types/actions/account-client/changeSudoValidator.d.ts +5 -11
  212. package/_types/actions/account-client/changeSudoValidator.d.ts.map +1 -1
  213. package/_types/actions/account-client/getKernelV3ModuleCurrentNonce.d.ts +2 -5
  214. package/_types/actions/account-client/getKernelV3ModuleCurrentNonce.d.ts.map +1 -1
  215. package/_types/actions/account-client/invalidateNonce.d.ts +4 -6
  216. package/_types/actions/account-client/invalidateNonce.d.ts.map +1 -1
  217. package/_types/actions/account-client/sendTransaction.d.ts +50 -0
  218. package/_types/actions/account-client/sendTransaction.d.ts.map +1 -0
  219. package/_types/actions/account-client/signMessage.d.ts +50 -0
  220. package/_types/actions/account-client/signMessage.d.ts.map +1 -0
  221. package/_types/actions/account-client/signTypedData.d.ts +104 -0
  222. package/_types/actions/account-client/signTypedData.d.ts.map +1 -0
  223. package/_types/actions/account-client/signUserOperation.d.ts +4 -6
  224. package/_types/actions/account-client/signUserOperation.d.ts.map +1 -1
  225. package/_types/actions/account-client/uninstallPlugin.d.ts +5 -7
  226. package/_types/actions/account-client/uninstallPlugin.d.ts.map +1 -1
  227. package/_types/actions/account-client/writeContract.d.ts +4 -0
  228. package/_types/actions/account-client/writeContract.d.ts.map +1 -0
  229. package/_types/actions/index.d.ts +6 -1
  230. package/_types/actions/index.d.ts.map +1 -1
  231. package/_types/actions/paymaster/estimateGasInERC20.d.ts +1305 -4
  232. package/_types/actions/paymaster/estimateGasInERC20.d.ts.map +1 -1
  233. package/_types/actions/paymaster/sponsorUserOperation.d.ts +1314 -10
  234. package/_types/actions/paymaster/sponsorUserOperation.d.ts.map +1 -1
  235. package/_types/actions/public/getAccountNonce.d.ts +34 -0
  236. package/_types/actions/public/getAccountNonce.d.ts.map +1 -0
  237. package/_types/actions/public/getSenderAddress.d.ts +46 -0
  238. package/_types/actions/public/getSenderAddress.d.ts.map +1 -0
  239. package/_types/actions/public/index.d.ts +3 -0
  240. package/_types/actions/public/index.d.ts.map +1 -0
  241. package/_types/clients/decorators/kernel.d.ts +774 -20
  242. package/_types/clients/decorators/kernel.d.ts.map +1 -1
  243. package/_types/clients/fallbackKernelAccountClient.d.ts +255 -4
  244. package/_types/clients/fallbackKernelAccountClient.d.ts.map +1 -1
  245. package/_types/clients/kernelAccountClient.d.ts +34 -36
  246. package/_types/clients/kernelAccountClient.d.ts.map +1 -1
  247. package/_types/clients/paymasterClient.d.ts +10 -24
  248. package/_types/clients/paymasterClient.d.ts.map +1 -1
  249. package/_types/errors/index.d.ts +7 -0
  250. package/_types/errors/index.d.ts.map +1 -0
  251. package/_types/gasTokenAddresses.d.ts +1 -1
  252. package/_types/gasTokenAddresses.d.ts.map +1 -1
  253. package/_types/index.d.ts +1 -1
  254. package/_types/index.d.ts.map +1 -1
  255. package/_types/providers/KernelEIP1193Provider.d.ts +3 -4
  256. package/_types/providers/KernelEIP1193Provider.d.ts.map +1 -1
  257. package/_types/types/index.d.ts +1 -0
  258. package/_types/types/index.d.ts.map +1 -1
  259. package/_types/types/kernel.d.ts +25 -27
  260. package/_types/types/kernel.d.ts.map +1 -1
  261. package/_types/utils.d.ts +1310 -4
  262. package/_types/utils.d.ts.map +1 -1
  263. package/accounts/index.ts +5 -2
  264. package/accounts/kernel/createKernelAccount.ts +312 -357
  265. package/accounts/kernel/utils/account/ep0_6/encodeCallData.ts +22 -12
  266. package/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.ts +6 -3
  267. package/accounts/kernel/utils/account/ep0_6/encodeModuleInstallCallData.ts +22 -19
  268. package/accounts/kernel/utils/account/ep0_7/encodeCallData.ts +21 -11
  269. package/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.ts +6 -3
  270. package/accounts/kernel/utils/common/accountMetadata.ts +2 -7
  271. package/accounts/kernel/utils/common/getActionSelector.ts +3 -3
  272. package/accounts/kernel/utils/ep0_6/encodeExecuteBatchCall.ts +3 -3
  273. package/accounts/kernel/utils/ep0_6/encodeExecuteDelegateCall.ts +1 -1
  274. package/accounts/kernel/utils/ep0_6/encodeExecuteSingleCall.ts +1 -1
  275. package/accounts/kernel/utils/ep0_7/encodeExecuteBatchCall.ts +3 -3
  276. package/accounts/kernel/utils/ep0_7/encodeExecuteCall.ts +2 -2
  277. package/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.ts +2 -8
  278. package/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.ts +4 -10
  279. package/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.ts +2 -8
  280. package/accounts/kernel/utils/types.ts +2 -2
  281. package/accounts/kernel/v1/createKernelAccountV1.ts +147 -174
  282. package/accounts/kernel/v2/createKernelAccountV0_2.ts +135 -179
  283. package/accounts/utils/getCustomNonceKeyFromString.ts +3 -6
  284. package/accounts/utils/index.ts +0 -9
  285. package/accounts/utils/multisend.ts +5 -2
  286. package/accounts/utils/toKernelPluginManager.ts +23 -27
  287. package/actions/account-client/changeSudoValidator.ts +61 -85
  288. package/actions/account-client/getKernelV3ModuleCurrentNonce.ts +12 -51
  289. package/actions/account-client/invalidateNonce.ts +38 -67
  290. package/actions/account-client/sendTransaction.ts +134 -0
  291. package/actions/account-client/signMessage.ts +75 -0
  292. package/actions/account-client/signTypedData.ts +159 -0
  293. package/actions/account-client/signUserOperation.ts +31 -63
  294. package/actions/account-client/uninstallPlugin.ts +35 -56
  295. package/actions/account-client/writeContract.ts +72 -0
  296. package/actions/index.ts +15 -6
  297. package/actions/paymaster/estimateGasInERC20.ts +12 -8
  298. package/actions/paymaster/sponsorUserOperation.ts +52 -50
  299. package/actions/public/getAccountNonce.ts +77 -0
  300. package/actions/public/getSenderAddress.ts +276 -0
  301. package/actions/public/index.ts +9 -0
  302. package/clients/decorators/kernel.ts +363 -159
  303. package/clients/fallbackKernelAccountClient.ts +9 -11
  304. package/clients/kernelAccountClient.ts +142 -104
  305. package/clients/paymasterClient.ts +69 -43
  306. package/errors/index.ts +17 -0
  307. package/gasTokenAddresses.ts +3 -2
  308. package/index.ts +5 -2
  309. package/package.json +11 -34
  310. package/providers/KernelEIP1193Provider.ts +4 -7
  311. package/types/index.ts +2 -0
  312. package/types/kernel.ts +64 -63
  313. package/utils.ts +41 -13
  314. package/_cjs/actions/paymaster/sponsorUserOperationEip7677.js +0 -59
  315. package/_cjs/actions/paymaster/sponsorUserOperationEip7677.js.map +0 -1
  316. package/_esm/actions/paymaster/sponsorUserOperationEip7677.js +0 -58
  317. package/_esm/actions/paymaster/sponsorUserOperationEip7677.js.map +0 -1
  318. package/_types/actions/paymaster/sponsorUserOperationEip7677.d.ts +0 -16
  319. package/_types/actions/paymaster/sponsorUserOperationEip7677.d.ts.map +0 -1
  320. 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,28 @@ 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"
35
30
  import { KernelVersionToAddressesMap } from "../../constants.js"
36
31
  import type {
32
+ CallType,
33
+ GetEntryPointAbi,
37
34
  GetKernelVersion,
38
- KernelEncodeCallDataArgs,
39
35
  KernelPluginManager,
40
36
  KernelPluginManagerParams
41
37
  } from "../../types/kernel.js"
42
38
  import { KERNEL_FEATURES, hasKernelFeature } from "../../utils.js"
43
39
  import { validateKernelVersionWithEntryPoint } from "../../utils.js"
44
- import { parseFactoryAddressAndCallDataFromAccountInitCode } from "../utils/index.js"
45
40
  import {
46
41
  isKernelPluginManager,
47
42
  toKernelPluginManager
@@ -57,40 +52,62 @@ import { encodeCallData as encodeCallDataEpV07 } from "./utils/account/ep0_7/enc
57
52
  import { encodeDeployCallData as encodeDeployCallDataV07 } from "./utils/account/ep0_7/encodeDeployCallData.js"
58
53
  import { accountMetadata } from "./utils/common/accountMetadata.js"
59
54
  import { eip712WrapHash } from "./utils/common/eip712WrapHash.js"
55
+ import {
56
+ getSenderAddress,
57
+ getAccountNonce
58
+ } from "../../actions/public/index.js"
59
+
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
+ >
60
84
 
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
- }
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
349
  useMetaFactory = true,
392
- chainId
393
- }: CreateKernelAccountParameters<entryPoint, KernelVersion>
394
- ): Promise<KernelSmartAccount<entryPoint, TTransport, TChain>> {
395
- const entryPointVersion = getEntryPointVersion(entryPointAddress)
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,40 @@ 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
- }))
411
+ const getFactoryArgs = async () => {
412
+ return {
413
+ factory:
414
+ entryPoint.version === "0.6"
415
+ ? factoryAddress
416
+ : metaFactoryAddress,
417
+ factoryData: await generateInitCode()
418
+ }
419
+ }
452
420
 
453
- if (!accountAddress) throw new Error("Account address not found")
454
421
 
455
- let smartAccountDeployed = await isSmartAccountDeployed(
456
- client,
457
- accountAddress
458
- )
459
-
460
- return {
422
+ // Fetch account address
423
+ let accountAddress =
424
+ address ??
425
+ (await (async () => {
426
+ const { factory, factoryData } = await getFactoryArgs()
427
+
428
+ // Get the sender address based on the init code
429
+ return await getSenderAddress(client, {
430
+ factory,
431
+ factoryData,
432
+ entryPointAddress: entryPoint.address
433
+ })
434
+ })())
435
+
436
+ const _entryPoint = {
437
+ address: entryPoint?.address ?? entryPoint07Address,
438
+ abi: ((entryPoint?.version ?? "0.7") === "0.6"
439
+ ? entryPoint06Abi
440
+ : entryPoint07Abi) as GetEntryPointAbi<entryPointVersion>,
441
+ version: entryPoint?.version ?? "0.7"
442
+ } as const
443
+
444
+ return toSmartAccount<KernelSmartAccountImplementation<entryPointVersion>>({
461
445
  kernelVersion,
462
446
  kernelPluginManager,
463
447
  generateInitCode,
@@ -466,197 +450,168 @@ export async function createKernelAccount<
466
450
  accountAddress
467
451
  )
468
452
  },
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
- },
453
+ nonceKeyManager: createNonceManager({source: {get: () => 0, set: () => {}}}),
454
+ client,
455
+ entryPoint: _entryPoint,
456
+ getFactoryArgs,
457
+ async getAddress() {
458
+ if (accountAddress) return accountAddress
520
459
 
521
- async getFactoryData() {
522
- if (smartAccountDeployed) return undefined
460
+ const { factory, factoryData } = await getFactoryArgs()
523
461
 
524
- smartAccountDeployed = await isSmartAccountDeployed(
525
- client,
526
- accountAddress
527
- )
462
+ // Get the sender address based on the init code
463
+ accountAddress = await getSenderAddress(client, {
464
+ factory,
465
+ factoryData,
466
+ entryPointAddress: entryPoint.address
467
+ })
528
468
 
529
- if (smartAccountDeployed) return undefined
469
+ return accountAddress
470
+ },
471
+ // Encode the deploy call data
472
+ async encodeDeployCallData(_tx) {
473
+ if (entryPoint.version === "0.6") {
474
+ return encodeDeployCallDataV06(_tx)
475
+ }
476
+ return encodeDeployCallDataV07(_tx)
477
+ },
478
+ async encodeCalls(calls, callType) {
479
+ if (
480
+ calls.length === 1 &&
481
+ (!callType || callType === "call") &&
482
+ calls[0].to.toLowerCase() === accountAddress.toLowerCase()
483
+ ) {
484
+ return calls[0].data ?? "0x"
485
+ }
486
+ if (entryPoint.version === "0.6") {
487
+ return encodeCallDataEpV06(calls, callType)
488
+ }
530
489
 
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,
490
+ if (plugins.hook) {
491
+ return encodeCallDataEpV07(calls, callType, true)
492
+ }
493
+ return encodeCallDataEpV07(calls, callType)
494
+ },
495
+ async sign({ hash }) {
496
+ return this.signMessage({ message: hash })
497
+ },
498
+ async signMessage({ message }) {
499
+ const messageHash = hashMessage(message)
500
+ const {
501
+ name,
502
+ chainId: metadataChainId,
503
+ version
504
+ } = await accountMetadata(
505
+ client,
506
+ accountAddress,
507
+ kernelVersion,
508
+ chainId
509
+ )
510
+ const wrappedMessageHash = await eip712WrapHash(messageHash, {
511
+ name,
512
+ chainId: Number(metadataChainId),
513
+ version,
514
+ verifyingContract: accountAddress
515
+ })
516
+ const signature = await kernelPluginManager.signMessage({
517
+ message: { raw: wrappedMessageHash }
518
+ })
519
+
520
+ if (
521
+ !hasKernelFeature(
522
+ KERNEL_FEATURES.ERC1271_WITH_VALIDATOR,
596
523
  version
597
- } = await accountMetadata(
598
- client,
599
- accountAddress,
600
- kernelVersion,
601
- chainId
602
524
  )
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
- },
525
+ ) {
526
+ return signature
527
+ }
647
528
 
648
- // Encode the init code
649
- async getInitCode() {
650
- if (smartAccountDeployed) return "0x"
529
+ return concatHex([kernelPluginManager.getIdentifier(), signature])
530
+ },
531
+ async signTypedData(typedData) {
532
+ const {
533
+ message,
534
+ primaryType,
535
+ types: _types,
536
+ domain
537
+ } = typedData as TypedDataDefinition
538
+ const types = {
539
+ EIP712Domain: getTypesForEIP712Domain({
540
+ domain: domain
541
+ }),
542
+ ..._types
543
+ }
651
544
 
652
- smartAccountDeployed = await isSmartAccountDeployed(
653
- client,
654
- accountAddress
545
+ // Need to do a runtime validation check on addresses, byte ranges, integer ranges, etc
546
+ // as we can't statically check this with TypeScript.
547
+ validateTypedData({
548
+ domain: domain,
549
+ message: message,
550
+ primaryType: primaryType,
551
+ types: types
552
+ })
553
+
554
+ const typedHash = hashTypedData(typedData)
555
+
556
+ const {
557
+ name,
558
+ chainId: metadataChainId,
559
+ version
560
+ } = await accountMetadata(
561
+ client,
562
+ accountAddress,
563
+ kernelVersion,
564
+ chainId
565
+ )
566
+ const wrappedMessageHash = await eip712WrapHash(typedHash, {
567
+ name,
568
+ chainId: Number(metadataChainId),
569
+ version,
570
+ verifyingContract: accountAddress
571
+ })
572
+ const signature = await kernelPluginManager.signMessage({
573
+ message: { raw: wrappedMessageHash }
574
+ })
575
+ if (
576
+ !hasKernelFeature(
577
+ KERNEL_FEATURES.ERC1271_WITH_VALIDATOR,
578
+ version
655
579
  )
656
-
657
- if (smartAccountDeployed) return "0x"
658
- return generateInitCode()
580
+ ) {
581
+ return signature
659
582
  }
660
- })
661
- }
583
+ return concatHex([kernelPluginManager.getIdentifier(), signature])
584
+ },
585
+ // Get the nonce of the smart account
586
+ async getNonce(_args) {
587
+ const key = await kernelPluginManager.getNonceKey(
588
+ accountAddress,
589
+ _args?.key
590
+ )
591
+ return getAccountNonce(client, {
592
+ address: accountAddress,
593
+ entryPointAddress: entryPoint.address,
594
+ key
595
+ })
596
+ },
597
+ async getStubSignature(userOperation) {
598
+ if (!userOperation) {
599
+ throw new Error("No user operation provided")
600
+ }
601
+ return kernelPluginManager.getStubSignature(
602
+ userOperation as UserOperation
603
+ )
604
+ },
605
+
606
+ // Sign a user operation
607
+ async signUserOperation(parameters) {
608
+ const { chainId = await getMemoizedChainId(), ...userOperation } =
609
+ parameters
610
+ return kernelPluginManager.signUserOperation({
611
+ ...userOperation,
612
+ sender: userOperation.sender ?? (await this.getAddress()),
613
+ chainId
614
+ })
615
+ }
616
+ }) as Promise<CreateKernelAccountReturnType<entryPointVersion>>
662
617
  }