@zerodev/sdk 5.2.0-alpha-3 → 5.2.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 (203) hide show
  1. package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js +115 -58
  2. package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js.map +1 -1
  3. package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.js +39 -0
  4. package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.js.map +1 -0
  5. package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js +203 -0
  6. package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js.map +1 -0
  7. package/_cjs/accounts/kernel/createKernelAccount.js +43 -22
  8. package/_cjs/accounts/kernel/createKernelAccount.js.map +1 -1
  9. package/_cjs/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.js +22 -0
  10. package/_cjs/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.js.map +1 -0
  11. package/_cjs/accounts/kernel/utils/common/getActionSelector.js +19 -0
  12. package/_cjs/accounts/kernel/utils/common/getActionSelector.js.map +1 -0
  13. package/_cjs/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js +22 -0
  14. package/_cjs/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js.map +1 -0
  15. package/_cjs/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js +39 -0
  16. package/_cjs/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js.map +1 -0
  17. package/_cjs/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.js +21 -0
  18. package/_cjs/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.js.map +1 -0
  19. package/_cjs/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js +41 -0
  20. package/_cjs/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js.map +1 -0
  21. package/_cjs/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.js +20 -0
  22. package/_cjs/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.js.map +1 -0
  23. package/_cjs/accounts/kernel/v1/createKernelV1Account.js +5 -2
  24. package/_cjs/accounts/kernel/v1/createKernelV1Account.js.map +1 -1
  25. package/_cjs/accounts/kernel/v2/createKernelV2Account.js +9 -4
  26. package/_cjs/accounts/kernel/v2/createKernelV2Account.js.map +1 -1
  27. package/_cjs/accounts/utils/getCustomNonceKeyFromString.js +19 -0
  28. package/_cjs/accounts/utils/getCustomNonceKeyFromString.js.map +1 -0
  29. package/_cjs/accounts/utils/index.js +3 -1
  30. package/_cjs/accounts/utils/index.js.map +1 -1
  31. package/_cjs/accounts/utils/toKernelPluginManager.js +120 -184
  32. package/_cjs/accounts/utils/toKernelPluginManager.js.map +1 -1
  33. package/_cjs/actions/account-client/getUserOperationGasPrice.js +15 -0
  34. package/_cjs/actions/account-client/getUserOperationGasPrice.js.map +1 -0
  35. package/_cjs/actions/index.js +3 -1
  36. package/_cjs/actions/index.js.map +1 -1
  37. package/_cjs/actions/paymaster/estimateGasInERC20.js +2 -2
  38. package/_cjs/actions/paymaster/estimateGasInERC20.js.map +1 -1
  39. package/_cjs/actions/paymaster/sponsorUserOperation.js +1 -2
  40. package/_cjs/actions/paymaster/sponsorUserOperation.js.map +1 -1
  41. package/_cjs/clients/decorators/kernel.js +3 -1
  42. package/_cjs/clients/decorators/kernel.js.map +1 -1
  43. package/_cjs/clients/kernelAccountClient.js +29 -3
  44. package/_cjs/clients/kernelAccountClient.js.map +1 -1
  45. package/_cjs/clients/paymasterClient.js +18 -1
  46. package/_cjs/clients/paymasterClient.js.map +1 -1
  47. package/_cjs/clients/utils.js +31 -0
  48. package/_cjs/clients/utils.js.map +1 -0
  49. package/_cjs/constants.js +5 -2
  50. package/_cjs/constants.js.map +1 -1
  51. package/_cjs/index.js +6 -1
  52. package/_cjs/index.js.map +1 -1
  53. package/_cjs/providers/KernelEIP1193Provider.js +37 -0
  54. package/_cjs/providers/KernelEIP1193Provider.js.map +1 -1
  55. package/_cjs/types/index.js.map +1 -1
  56. package/_cjs/types/kernel.js.map +1 -1
  57. package/_cjs/utils.js +1 -2
  58. package/_cjs/utils.js.map +1 -1
  59. package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js +115 -58
  60. package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js.map +1 -1
  61. package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.js +36 -0
  62. package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.js.map +1 -0
  63. package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js +200 -0
  64. package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js.map +1 -0
  65. package/_esm/accounts/kernel/createKernelAccount.js +44 -23
  66. package/_esm/accounts/kernel/createKernelAccount.js.map +1 -1
  67. package/_esm/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.js +18 -0
  68. package/_esm/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.js.map +1 -0
  69. package/_esm/accounts/kernel/utils/common/getActionSelector.js +15 -0
  70. package/_esm/accounts/kernel/utils/common/getActionSelector.js.map +1 -0
  71. package/_esm/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js +18 -0
  72. package/_esm/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js.map +1 -0
  73. package/_esm/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js +35 -0
  74. package/_esm/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js.map +1 -0
  75. package/_esm/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.js +18 -0
  76. package/_esm/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.js.map +1 -0
  77. package/_esm/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js +42 -0
  78. package/_esm/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js.map +1 -0
  79. package/_esm/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.js +16 -0
  80. package/_esm/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.js.map +1 -0
  81. package/_esm/accounts/kernel/v1/createKernelV1Account.js +6 -3
  82. package/_esm/accounts/kernel/v1/createKernelV1Account.js.map +1 -1
  83. package/_esm/accounts/kernel/v2/createKernelV2Account.js +10 -5
  84. package/_esm/accounts/kernel/v2/createKernelV2Account.js.map +1 -1
  85. package/_esm/accounts/utils/getCustomNonceKeyFromString.js +15 -0
  86. package/_esm/accounts/utils/getCustomNonceKeyFromString.js.map +1 -0
  87. package/_esm/accounts/utils/index.js +1 -0
  88. package/_esm/accounts/utils/index.js.map +1 -1
  89. package/_esm/accounts/utils/toKernelPluginManager.js +124 -188
  90. package/_esm/accounts/utils/toKernelPluginManager.js.map +1 -1
  91. package/_esm/actions/account-client/getUserOperationGasPrice.js +11 -0
  92. package/_esm/actions/account-client/getUserOperationGasPrice.js.map +1 -0
  93. package/_esm/actions/index.js +1 -0
  94. package/_esm/actions/index.js.map +1 -1
  95. package/_esm/actions/paymaster/estimateGasInERC20.js +2 -2
  96. package/_esm/actions/paymaster/estimateGasInERC20.js.map +1 -1
  97. package/_esm/actions/paymaster/sponsorUserOperation.js +1 -2
  98. package/_esm/actions/paymaster/sponsorUserOperation.js.map +1 -1
  99. package/_esm/clients/decorators/kernel.js +3 -1
  100. package/_esm/clients/decorators/kernel.js.map +1 -1
  101. package/_esm/clients/kernelAccountClient.js +30 -4
  102. package/_esm/clients/kernelAccountClient.js.map +1 -1
  103. package/_esm/clients/paymasterClient.js +19 -2
  104. package/_esm/clients/paymasterClient.js.map +1 -1
  105. package/_esm/clients/utils.js +26 -0
  106. package/_esm/clients/utils.js.map +1 -0
  107. package/_esm/constants.js +4 -1
  108. package/_esm/constants.js.map +1 -1
  109. package/_esm/index.js +3 -1
  110. package/_esm/index.js.map +1 -1
  111. package/_esm/providers/KernelEIP1193Provider.js +37 -0
  112. package/_esm/providers/KernelEIP1193Provider.js.map +1 -1
  113. package/_esm/types/index.js.map +1 -1
  114. package/_esm/types/kernel.js.map +1 -1
  115. package/_esm/utils.js +2 -3
  116. package/_esm/utils.js.map +1 -1
  117. package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.d.ts +110 -20
  118. package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.d.ts.map +1 -1
  119. package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.d.ts +60 -0
  120. package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.d.ts.map +1 -0
  121. package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.d.ts +215 -0
  122. package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.d.ts.map +1 -0
  123. package/_types/accounts/kernel/createKernelAccount.d.ts +8 -4
  124. package/_types/accounts/kernel/createKernelAccount.d.ts.map +1 -1
  125. package/_types/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.d.ts +3 -0
  126. package/_types/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.d.ts.map +1 -0
  127. package/_types/accounts/kernel/utils/common/getActionSelector.d.ts +4 -0
  128. package/_types/accounts/kernel/utils/common/getActionSelector.d.ts.map +1 -0
  129. package/_types/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.d.ts +9 -0
  130. package/_types/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.d.ts.map +1 -0
  131. package/_types/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.d.ts +13 -0
  132. package/_types/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.d.ts.map +1 -0
  133. package/_types/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.d.ts +9 -0
  134. package/_types/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.d.ts.map +1 -0
  135. package/_types/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.d.ts +10 -0
  136. package/_types/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.d.ts.map +1 -0
  137. package/_types/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.d.ts +3 -0
  138. package/_types/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.d.ts.map +1 -0
  139. package/_types/accounts/kernel/v1/createKernelV1Account.d.ts +1 -1
  140. package/_types/accounts/kernel/v1/createKernelV1Account.d.ts.map +1 -1
  141. package/_types/accounts/kernel/v2/createKernelV2Account.d.ts +3 -1
  142. package/_types/accounts/kernel/v2/createKernelV2Account.d.ts.map +1 -1
  143. package/_types/accounts/utils/getCustomNonceKeyFromString.d.ts +3 -0
  144. package/_types/accounts/utils/getCustomNonceKeyFromString.d.ts.map +1 -0
  145. package/_types/accounts/utils/index.d.ts +1 -0
  146. package/_types/accounts/utils/index.d.ts.map +1 -1
  147. package/_types/accounts/utils/toKernelPluginManager.d.ts +1 -1
  148. package/_types/accounts/utils/toKernelPluginManager.d.ts.map +1 -1
  149. package/_types/actions/account-client/getUserOperationGasPrice.d.ts +9 -0
  150. package/_types/actions/account-client/getUserOperationGasPrice.d.ts.map +1 -0
  151. package/_types/actions/index.d.ts +1 -0
  152. package/_types/actions/index.d.ts.map +1 -1
  153. package/_types/actions/paymaster/estimateGasInERC20.d.ts.map +1 -1
  154. package/_types/actions/paymaster/sponsorUserOperation.d.ts.map +1 -1
  155. package/_types/clients/decorators/kernel.d.ts +8 -1
  156. package/_types/clients/decorators/kernel.d.ts.map +1 -1
  157. package/_types/clients/kernelAccountClient.d.ts +12 -4
  158. package/_types/clients/kernelAccountClient.d.ts.map +1 -1
  159. package/_types/clients/paymasterClient.d.ts.map +1 -1
  160. package/_types/clients/utils.d.ts +3 -0
  161. package/_types/clients/utils.d.ts.map +1 -0
  162. package/_types/constants.d.ts +4 -1
  163. package/_types/constants.d.ts.map +1 -1
  164. package/_types/index.d.ts +3 -1
  165. package/_types/index.d.ts.map +1 -1
  166. package/_types/providers/KernelEIP1193Provider.d.ts +2 -0
  167. package/_types/providers/KernelEIP1193Provider.d.ts.map +1 -1
  168. package/_types/types/index.d.ts +1 -1
  169. package/_types/types/index.d.ts.map +1 -1
  170. package/_types/types/kernel.d.ts +32 -17
  171. package/_types/types/kernel.d.ts.map +1 -1
  172. package/_types/utils.d.ts.map +1 -1
  173. package/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.ts +115 -58
  174. package/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.ts +35 -0
  175. package/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.ts +199 -0
  176. package/accounts/kernel/createKernelAccount.ts +59 -26
  177. package/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.ts +24 -0
  178. package/accounts/kernel/utils/common/getActionSelector.ts +20 -0
  179. package/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.ts +39 -0
  180. package/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.ts +76 -0
  181. package/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.ts +47 -0
  182. package/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.ts +63 -0
  183. package/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.ts +23 -0
  184. package/accounts/kernel/v1/createKernelV1Account.ts +21 -8
  185. package/accounts/kernel/v2/createKernelV2Account.ts +17 -6
  186. package/accounts/utils/getCustomNonceKeyFromString.ts +21 -0
  187. package/accounts/utils/index.ts +2 -0
  188. package/accounts/utils/toKernelPluginManager.ts +155 -224
  189. package/actions/account-client/getUserOperationGasPrice.ts +26 -0
  190. package/actions/index.ts +5 -0
  191. package/actions/paymaster/estimateGasInERC20.ts +2 -3
  192. package/actions/paymaster/sponsorUserOperation.ts +1 -3
  193. package/clients/decorators/kernel.ts +22 -6
  194. package/clients/kernelAccountClient.ts +36 -3
  195. package/clients/paymasterClient.ts +24 -1
  196. package/clients/utils.ts +28 -0
  197. package/constants.ts +6 -2
  198. package/index.ts +6 -1
  199. package/package.json +4 -4
  200. package/providers/KernelEIP1193Provider.ts +51 -0
  201. package/types/index.ts +4 -2
  202. package/types/kernel.ts +52 -38
  203. package/utils.ts +2 -3
@@ -1,8 +1,10 @@
1
+ import { getEntryPointVersion } from "permissionless"
1
2
  import type { SmartAccount } from "permissionless/accounts/types"
2
3
  import type { Middleware } from "permissionless/actions/smartAccount"
3
4
  import type { EntryPoint, Prettify } from "permissionless/types"
4
5
  import type { BundlerRpcSchema } from "permissionless/types/bundler"
5
6
  import {
7
+ http,
6
8
  type Chain,
7
9
  type Client,
8
10
  type ClientConfig,
@@ -10,10 +12,12 @@ import {
10
12
  createClient
11
13
  } from "viem"
12
14
  import { type KernelSmartAccount } from "../accounts/index.js"
15
+ import { getUserOperationGasPrice } from "../actions/account-client/getUserOperationGasPrice.js"
13
16
  import {
14
17
  type KernelAccountClientActions,
15
18
  kernelAccountClientActions
16
19
  } from "./decorators/kernel.js"
20
+ import { hasPimlicoAsProvider, setPimlicoAsProvider } from "./utils.js"
17
21
 
18
22
  export type KernelAccountClient<
19
23
  entryPoint extends EntryPoint,
@@ -69,19 +73,48 @@ export const createKernelAccountClient = <
69
73
  const {
70
74
  key = "Account",
71
75
  name = "Kernel Account Client",
72
- bundlerTransport
76
+ bundlerTransport,
77
+ entryPoint
73
78
  } = parameters
79
+ const entryPointVersion = getEntryPointVersion(entryPoint)
80
+ const shouldIncludePimlicoProvider =
81
+ bundlerTransport({}).config.key === "http" &&
82
+ entryPointVersion === "v0.7"
83
+
74
84
  const client = createClient({
75
85
  ...parameters,
76
86
  key,
77
87
  name,
78
- transport: (opts) => bundlerTransport({ ...opts, retryCount: 0 }),
88
+ transport: (opts) => {
89
+ let _bundlerTransport = bundlerTransport({
90
+ ...opts,
91
+ retryCount: 0
92
+ })
93
+ if (!shouldIncludePimlicoProvider) return _bundlerTransport
94
+ _bundlerTransport = http(
95
+ setPimlicoAsProvider(_bundlerTransport.value?.url)
96
+ )({ ...opts, retryCount: 0 })
97
+ return _bundlerTransport
98
+ },
79
99
  type: "kernelAccountClient"
80
100
  })
81
101
 
102
+ let middleware = parameters.middleware
103
+ if (
104
+ (!middleware ||
105
+ (typeof middleware !== "function" && !middleware.gasPrice)) &&
106
+ client.transport?.url &&
107
+ hasPimlicoAsProvider(client.transport.url)
108
+ ) {
109
+ const gasPrice = () => getUserOperationGasPrice(client)
110
+ middleware = {
111
+ ...middleware,
112
+ gasPrice
113
+ }
114
+ }
82
115
  return client.extend(
83
116
  kernelAccountClientActions({
84
- middleware: parameters.middleware
117
+ middleware
85
118
  })
86
119
  ) as KernelAccountClient<entryPoint, TTransport, TChain, TSmartAccount>
87
120
  }
@@ -1,5 +1,7 @@
1
+ import { getEntryPointVersion } from "permissionless"
1
2
  import type { EntryPoint } from "permissionless/types/entrypoint"
2
3
  import {
4
+ http,
3
5
  type Account,
4
6
  type Chain,
5
7
  type Client,
@@ -12,6 +14,7 @@ import {
12
14
  type ZeroDevPaymasterClientActions,
13
15
  zerodevPaymasterActions
14
16
  } from "./decorators/kernel.js"
17
+ import { setPimlicoAsProvider } from "./utils.js"
15
18
 
16
19
  export type ZeroDevPaymasterClient<entryPoint extends EntryPoint> = Client<
17
20
  Transport,
@@ -46,9 +49,29 @@ export const createZeroDevPaymasterClient = <
46
49
  entryPoint: entryPoint
47
50
  }
48
51
  ): ZeroDevPaymasterClient<entryPoint> => {
49
- const { key = "public", name = "ZeroDev Paymaster Client" } = parameters
52
+ const {
53
+ key = "public",
54
+ name = "ZeroDev Paymaster Client",
55
+ entryPoint: entryPointAddress,
56
+ transport
57
+ } = parameters
58
+ const entryPointVersion = getEntryPointVersion(entryPointAddress)
59
+ const shouldIncludePimlicoProvider =
60
+ transport({}).config.key === "http" && entryPointVersion === "v0.7"
50
61
  const client = createClient({
51
62
  ...parameters,
63
+ transport: (opts) => {
64
+ let _transport = transport({
65
+ ...opts,
66
+ retryCount: 0
67
+ })
68
+ if (!shouldIncludePimlicoProvider) return _transport
69
+ _transport = http(setPimlicoAsProvider(_transport.value?.url))({
70
+ ...opts,
71
+ retryCount: 0
72
+ })
73
+ return _transport
74
+ },
52
75
  key,
53
76
  name,
54
77
  type: "zerodevPaymasterClient"
@@ -0,0 +1,28 @@
1
+ export const setPimlicoAsProvider = (urlString: string): string => {
2
+ const url = new URL(urlString)
3
+
4
+ const params = url.searchParams
5
+
6
+ if (params.has("bundlerProvider")) {
7
+ params.set("bundlerProvider", "PIMLICO")
8
+ } else if (params.has("paymasterProvider")) {
9
+ params.set("paymasterProvider", "PIMLICO")
10
+ } else {
11
+ params.set("provider", "PIMLICO")
12
+ }
13
+
14
+ url.search = params.toString()
15
+
16
+ return url.toString()
17
+ }
18
+
19
+ export const hasPimlicoAsProvider = (urlString: string): boolean => {
20
+ const url = new URL(urlString)
21
+ const params = url.searchParams
22
+ const provider =
23
+ params.get("provider") ??
24
+ params.get("bundlerProvider") ??
25
+ params.get("paymasterProvider")
26
+ if (provider === "PIMLICO") return true
27
+ return false
28
+ }
package/constants.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { EntryPointVersion } from "permissionless/types/entrypoint"
2
- import { type Address } from "viem"
2
+ import { type Address, type Hex } from "viem"
3
3
 
4
4
  export const DUMMY_ECDSA_SIG =
5
5
  "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"
@@ -10,7 +10,7 @@ export const KernelImplToVersionMap: { [key: Address]: string } = {
10
10
  "0xD3F582F6B4814E989Ee8E96bc3175320B5A540ab": "0.2.3",
11
11
  "0x5FC0236D6c88a65beD32EECDC5D60a5CAb377717": "0.2.3",
12
12
  "0xd3082872F8B06073A021b4602e022d5A070d7cfC": "0.2.4",
13
- "0x079D5D8A3275A230AF743cB59c341Ff74B82488D": "0.3.0-beta"
13
+ "0x94F097E1ebEB4ecA3AAE54cabb08905B239A7D27": "0.3.0-beta"
14
14
  }
15
15
  export const TOKEN_ACTION = "0x2087C7FfD0d0DAE80a00EE74325aBF3449e0eaf1"
16
16
  export const KERNEL_NAME = "Kernel"
@@ -41,3 +41,7 @@ export enum EXEC_TYPE {
41
41
  // Address was found here: https://github.com/safe-global/safe-deployments/blob/926ec6bbe2ebcac3aa2c2c6c0aff74aa590cbc6a/src/assets/v1.4.1/create_call.json
42
42
  export const safeCreateCallAddress =
43
43
  "0x9b35Af71d77eaf8d7e40252370304687390A1A52"
44
+ export const KernelFactoryToInitCodeHashMap: { [key: Address]: Hex } = {
45
+ "0x5de4839a76cf55d0c90e2061ef4386d962E15ae3":
46
+ "0xee9d8350bd899dd261db689aafd87eb8a30f085adbaff48152399438ff4eed73"
47
+ }
package/index.ts CHANGED
@@ -38,9 +38,14 @@ export {
38
38
  KernelV3ExecuteAbi,
39
39
  KernelV3InitAbi
40
40
  } from "./accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js"
41
+ export { KernelV3FactoryAbi } from "./accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.js"
42
+ export { KernelFactoryStakerAbi } from "./accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js"
41
43
  export { TokenActionsAbi } from "./accounts/kernel/abi/TokenActionsAbi.js"
42
44
  export * as constants from "./constants.js"
43
45
  export * from "./utils.js"
44
46
  export { gasTokenAddresses, type TokenSymbolsMap } from "./gasTokenAddresses.js"
45
- export { verifyEIP6492Signature } from "./accounts/utils/index.js"
47
+ export {
48
+ verifyEIP6492Signature,
49
+ getCustomNonceKeyFromString
50
+ } from "./accounts/utils/index.js"
46
51
  export { KernelEIP1193Provider } from "./providers/index.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerodev/sdk",
3
- "version": "5.2.0-alpha-3",
3
+ "version": "5.2.0",
4
4
  "author": "ZeroDev",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
@@ -90,10 +90,10 @@
90
90
  }
91
91
  },
92
92
  "peerDependencies": {
93
- "viem": "^2.0.0"
93
+ "viem": "^2.0.0",
94
+ "permissionless": "^0.1.16"
94
95
  },
95
96
  "dependencies": {
96
- "semver": "^7.6.0",
97
- "permissionless": "^0.1.4"
97
+ "semver": "^7.6.0"
98
98
  }
99
99
  }
@@ -29,8 +29,13 @@ export class KernelEIP1193Provider<
29
29
  return this.handleEthAccounts()
30
30
  case "eth_sendTransaction":
31
31
  return this.handleEthSendTransaction(params)
32
+ case "eth_sign":
33
+ return this.handleEthSign(params as [string, string])
32
34
  case "personal_sign":
33
35
  return this.handlePersonalSign(params as [string, string])
36
+ case "eth_signTypedData":
37
+ case "eth_signTypedData_v4":
38
+ return this.handleEthSignTypedDataV4(params as [string, string])
34
39
  default:
35
40
  return this.kernelClient.transport.request({ method, params })
36
41
  }
@@ -55,6 +60,26 @@ export class KernelEIP1193Provider<
55
60
  return this.kernelClient.sendTransaction(tx)
56
61
  }
57
62
 
63
+ private async handleEthSign(params: [string, string]): Promise<string> {
64
+ if (!this.kernelClient?.account) {
65
+ throw new Error("account not connected!")
66
+ }
67
+ const [address, message] = params
68
+ if (
69
+ address.toLowerCase() !==
70
+ this.kernelClient.account.address.toLowerCase()
71
+ ) {
72
+ throw new Error(
73
+ "cannot sign for address that is not the current account"
74
+ )
75
+ }
76
+
77
+ return this.kernelClient.signMessage({
78
+ message,
79
+ account: this.kernelClient.account
80
+ })
81
+ }
82
+
58
83
  private async handlePersonalSign(
59
84
  params: [string, string]
60
85
  ): Promise<string> {
@@ -76,4 +101,30 @@ export class KernelEIP1193Provider<
76
101
  account: this.kernelClient.account
77
102
  })
78
103
  }
104
+
105
+ private async handleEthSignTypedDataV4(
106
+ params: [string, string]
107
+ ): Promise<string> {
108
+ if (!this.kernelClient?.account) {
109
+ throw new Error("account not connected!")
110
+ }
111
+ const [address, typedDataJSON] = params
112
+ const typedData = JSON.parse(typedDataJSON)
113
+ if (
114
+ address.toLowerCase() !==
115
+ this.kernelClient.account.address.toLowerCase()
116
+ ) {
117
+ throw new Error(
118
+ "cannot sign for address that is not the current account"
119
+ )
120
+ }
121
+
122
+ return this.kernelClient.signTypedData({
123
+ account: this.kernelClient.account,
124
+ domain: typedData.domain,
125
+ types: typedData.types,
126
+ message: typedData.message,
127
+ primaryType: typedData.primaryType
128
+ })
129
+ }
79
130
  }
package/types/index.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  export type {
2
2
  KernelValidator,
3
3
  ZeroDevPaymasterRpcSchema,
4
- ExecutorData,
4
+ Action,
5
5
  KernelPluginManager,
6
6
  ValidatorInitData,
7
7
  CallType,
8
8
  KernelEncodeCallDataArgs,
9
- PluginValidityData
9
+ PluginValidityData,
10
+ ZeroDevAccountClientRpcSchema,
11
+ ZeroDevUserOperationGasPriceWithBigIntAsHex
10
12
  } from "./kernel.js"
11
13
 
12
14
  export { ValidatorMode } from "./kernel.js"
package/types/kernel.ts CHANGED
@@ -88,55 +88,69 @@ export type ZeroDevPaymasterRpcSchema<entryPoint extends EntryPoint> = [
88
88
  }
89
89
  ]
90
90
 
91
- export type ValidatorType = keyof typeof VALIDATOR_TYPE
91
+ export type ZeroDevUserOperationGasPriceWithBigIntAsHex = {
92
+ slow: {
93
+ maxFeePerGas: Hex
94
+ maxPriorityFeePerGas: Hex
95
+ }
96
+ standard: {
97
+ maxFeePerGas: Hex
98
+ maxPriorityFeePerGas: Hex
99
+ }
100
+ fast: {
101
+ maxFeePerGas: Hex
102
+ maxPriorityFeePerGas: Hex
103
+ }
104
+ }
105
+
106
+ export type ZeroDevAccountClientRpcSchema = [
107
+ {
108
+ Method: "zd_getUserOperationGasPrice"
109
+ Parameters: []
110
+ ReturnType: ZeroDevUserOperationGasPriceWithBigIntAsHex
111
+ }
112
+ ]
113
+
114
+ export type ValidatorType = Extract<
115
+ keyof typeof VALIDATOR_TYPE,
116
+ "PERMISSION" | "SECONDARY"
117
+ >
92
118
 
93
119
  export type KernelValidator<
94
120
  entryPoint extends EntryPoint,
95
- Name extends string = string,
96
- type extends ValidatorType = "SUDO"
97
- > = type extends "PERMISSION"
98
- ? LocalAccount<Name> & {
99
- getNonceKey: (accountAddress?: Address) => Promise<bigint>
100
- getDummySignature(
101
- userOperation: UserOperation<GetEntryPointVersion<entryPoint>>,
102
- pluginEnableSignature?: Hex
103
- ): Promise<Hex>
104
- signUserOperation: (
105
- userOperation: UserOperation<GetEntryPointVersion<entryPoint>>,
106
- pluginEnableSignature?: Hex
107
- ) => Promise<Hex>
108
- getEnableData(accountAddress?: Address): Promise<Hex>
109
- isEnabled(accountAddress: Address, selector: Hex): Promise<boolean>
110
- isPermissionValidator: boolean
111
- getPermissionId: () => Hex
112
- }
113
- : LocalAccount<Name> & {
114
- getNonceKey: (accountAddress?: Address) => Promise<bigint>
115
- getDummySignature(
116
- userOperation: UserOperation<GetEntryPointVersion<entryPoint>>,
117
- pluginEnableSignature?: Hex
118
- ): Promise<Hex>
119
- signUserOperation: (
120
- userOperation: UserOperation<GetEntryPointVersion<entryPoint>>,
121
- pluginEnableSignature?: Hex
122
- ) => Promise<Hex>
123
- getEnableData(accountAddress?: Address): Promise<Hex>
124
- isEnabled(accountAddress: Address, selector: Hex): Promise<boolean>
125
- isPermissionValidator: boolean
126
- }
121
+ Name extends string = string
122
+ > = LocalAccount<Name> & {
123
+ validatorType: ValidatorType
124
+ getNonceKey: (
125
+ accountAddress?: Address,
126
+ customNonceKey?: bigint
127
+ ) => Promise<bigint>
128
+ getDummySignature(
129
+ userOperation: UserOperation<GetEntryPointVersion<entryPoint>>,
130
+ pluginEnableSignature?: Hex
131
+ ): Promise<Hex>
132
+ signUserOperation: (
133
+ userOperation: UserOperation<GetEntryPointVersion<entryPoint>>,
134
+ pluginEnableSignature?: Hex
135
+ ) => Promise<Hex>
136
+ getEnableData(accountAddress?: Address): Promise<Hex>
137
+ isEnabled(accountAddress: Address, selector: Hex): Promise<boolean>
138
+ getIdentifier: () => Hex
139
+ }
127
140
 
128
141
  export type ValidatorInitData = {
129
142
  validatorAddress: Address
130
143
  enableData: Hex
144
+ identifier: Hex
131
145
  }
132
146
 
133
147
  export type KernelPluginManager<entryPoint extends EntryPoint> =
134
148
  KernelValidator<entryPoint> & {
135
149
  getPluginEnableSignature(accountAddress: Address): Promise<Hex>
136
150
  getValidatorInitData(): Promise<ValidatorInitData>
137
- getExecutorData(): ExecutorData
151
+ getAction(): Action
138
152
  getValidityData(): PluginValidityData
139
- getValidationId(isSudo?: boolean): Hex
153
+ getIdentifier(isSudo?: boolean): Hex
140
154
  }
141
155
 
142
156
  export type KernelPluginManagerParams<entryPoint extends EntryPoint> = {
@@ -144,13 +158,13 @@ export type KernelPluginManagerParams<entryPoint extends EntryPoint> = {
144
158
  regular?: KernelValidator<entryPoint>
145
159
  pluginEnableSignature?: Hex
146
160
  validatorInitData?: ValidatorInitData
147
- executorData?: ExecutorData
161
+ action?: Action
148
162
  entryPoint: entryPoint
149
163
  kernelVersion?: string
150
164
  } & Partial<PluginValidityData>
151
165
 
152
- export type ExecutorData = {
153
- executor: Address
166
+ export type Action = {
167
+ address: Address
154
168
  selector: Hex
155
169
  }
156
170
 
package/utils.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { getEntryPointVersion } from "permissionless"
1
+ import { ENTRYPOINT_ADDRESS_V06, getEntryPointVersion } from "permissionless"
2
2
  import type { EntryPoint } from "permissionless/types/entrypoint"
3
3
  import { satisfies } from "semver"
4
4
  import {
@@ -13,7 +13,6 @@ import {
13
13
  signatureToHex,
14
14
  zeroAddress
15
15
  } from "viem"
16
- import { KERNEL_ADDRESSES } from "./accounts/index.js"
17
16
  import type { ZeroDevPaymasterClient } from "./clients/paymasterClient.js"
18
17
  import {
19
18
  CALL_TYPE,
@@ -73,7 +72,7 @@ export const getERC20PaymasterApproveCall = async (
73
72
  params: [
74
73
  {
75
74
  chainId: client.chain?.id as number,
76
- entryPointAddress: KERNEL_ADDRESSES.ENTRYPOINT_V0_6
75
+ entryPointAddress: ENTRYPOINT_ADDRESS_V06
77
76
  }
78
77
  ]
79
78
  })