@zerodev/sdk 5.2.1-alpha-5 → 5.2.1-alpha-7

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 (59) hide show
  1. package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.js +39 -0
  2. package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.js.map +1 -0
  3. package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js +203 -0
  4. package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js.map +1 -0
  5. package/_cjs/accounts/kernel/createKernelAccount.js +35 -10
  6. package/_cjs/accounts/kernel/createKernelAccount.js.map +1 -1
  7. package/_cjs/accounts/utils/toKernelPluginManager.js +1 -1
  8. package/_cjs/accounts/utils/toKernelPluginManager.js.map +1 -1
  9. package/_cjs/actions/paymaster/estimateGasInERC20.js +2 -2
  10. package/_cjs/actions/paymaster/estimateGasInERC20.js.map +1 -1
  11. package/_cjs/clients/decorators/kernel.js.map +1 -1
  12. package/_cjs/clients/kernelAccountClient.js +3 -4
  13. package/_cjs/clients/kernelAccountClient.js.map +1 -1
  14. package/_cjs/constants.js +1 -1
  15. package/_cjs/index.js +5 -1
  16. package/_cjs/index.js.map +1 -1
  17. package/_cjs/utils.js +1 -2
  18. package/_cjs/utils.js.map +1 -1
  19. package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.js +36 -0
  20. package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.js.map +1 -0
  21. package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js +200 -0
  22. package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js.map +1 -0
  23. package/_esm/accounts/kernel/createKernelAccount.js +36 -11
  24. package/_esm/accounts/kernel/createKernelAccount.js.map +1 -1
  25. package/_esm/accounts/utils/toKernelPluginManager.js +1 -1
  26. package/_esm/accounts/utils/toKernelPluginManager.js.map +1 -1
  27. package/_esm/actions/paymaster/estimateGasInERC20.js +2 -2
  28. package/_esm/actions/paymaster/estimateGasInERC20.js.map +1 -1
  29. package/_esm/clients/decorators/kernel.js.map +1 -1
  30. package/_esm/clients/kernelAccountClient.js +3 -4
  31. package/_esm/clients/kernelAccountClient.js.map +1 -1
  32. package/_esm/constants.js +1 -1
  33. package/_esm/index.js +2 -0
  34. package/_esm/index.js.map +1 -1
  35. package/_esm/utils.js +2 -3
  36. package/_esm/utils.js.map +1 -1
  37. package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.d.ts +60 -0
  38. package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.d.ts.map +1 -0
  39. package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.d.ts +215 -0
  40. package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.d.ts.map +1 -0
  41. package/_types/accounts/kernel/createKernelAccount.d.ts +5 -3
  42. package/_types/accounts/kernel/createKernelAccount.d.ts.map +1 -1
  43. package/_types/actions/paymaster/estimateGasInERC20.d.ts.map +1 -1
  44. package/_types/clients/decorators/kernel.d.ts.map +1 -1
  45. package/_types/clients/kernelAccountClient.d.ts.map +1 -1
  46. package/_types/index.d.ts +2 -0
  47. package/_types/index.d.ts.map +1 -1
  48. package/_types/utils.d.ts.map +1 -1
  49. package/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.ts +35 -0
  50. package/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.ts +199 -0
  51. package/accounts/kernel/createKernelAccount.ts +45 -12
  52. package/accounts/utils/toKernelPluginManager.ts +1 -1
  53. package/actions/paymaster/estimateGasInERC20.ts +2 -3
  54. package/clients/decorators/kernel.ts +7 -4
  55. package/clients/kernelAccountClient.ts +3 -4
  56. package/constants.ts +1 -1
  57. package/index.ts +2 -0
  58. package/package.json +1 -1
  59. package/utils.ts +2 -3
@@ -26,6 +26,7 @@ import {
26
26
  getTypesForEIP712Domain,
27
27
  hashMessage,
28
28
  hashTypedData,
29
+ toHex,
29
30
  validateTypedData,
30
31
  zeroAddress
31
32
  } from "viem"
@@ -42,6 +43,7 @@ import {
42
43
  } from "../utils/toKernelPluginManager.js"
43
44
  import { KernelInitAbi } from "./abi/KernelAccountAbi.js"
44
45
  import { KernelV3InitAbi } from "./abi/kernel_v_3_0_0/KernelAccountAbi.js"
46
+ import { KernelFactoryStakerAbi } from "./abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js"
45
47
  import { encodeCallData as encodeCallDataEpV06 } from "./utils/account/ep0_6/encodeCallData.js"
46
48
  import { encodeDeployCallData as encodeDeployCallDataV06 } from "./utils/account/ep0_6/encodeDeployCallData.js"
47
49
  import { encodeCallData as encodeCallDataEpV07 } from "./utils/account/ep0_7/encodeCallData.js"
@@ -68,6 +70,7 @@ export type CreateKernelAccountParameters<entryPoint extends EntryPoint> = {
68
70
  index?: bigint
69
71
  factoryAddress?: Address
70
72
  accountLogicAddress?: Address
73
+ factoryStakerAddress?: Address
71
74
  deployedAccountAddress?: Address
72
75
  }
73
76
 
@@ -112,13 +115,15 @@ const createAccountAbi = [
112
115
  export const KERNEL_ADDRESSES: {
113
116
  ACCOUNT_LOGIC_V0_6: Address
114
117
  ACCOUNT_LOGIC_V0_7: Address
115
- FACTORY_ADDRESS: Address
116
- ENTRYPOINT_V0_6: Address
118
+ FACTORY_ADDRESS_V0_6: Address
119
+ FACTORY_ADDRESS_V0_7: Address
120
+ FACTORY_STAKER: Address
117
121
  } = {
118
122
  ACCOUNT_LOGIC_V0_6: "0xd3082872F8B06073A021b4602e022d5A070d7cfC",
119
- ACCOUNT_LOGIC_V0_7: "0x541E811D24A54745619a5B9f0c1d4B08D5740144",
120
- FACTORY_ADDRESS: "0x5de4839a76cf55d0c90e2061ef4386d962E15ae3",
121
- ENTRYPOINT_V0_6: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
123
+ ACCOUNT_LOGIC_V0_7: "0xe59cffb45AFFB215e3823F7D1a207a71C1aa09c3",
124
+ FACTORY_ADDRESS_V0_6: "0x5de4839a76cf55d0c90e2061ef4386d962E15ae3",
125
+ FACTORY_ADDRESS_V0_7: "0x17B6697d81844518365484323e810Be08EaA3A6a",
126
+ FACTORY_STAKER: "0xd703aaE79538628d27099B8c4f621bE4CCd142d5"
122
127
  }
123
128
 
124
129
  const getKernelInitData = async <entryPoint extends EntryPoint>({
@@ -158,12 +163,14 @@ const getAccountInitCode = async <entryPoint extends EntryPoint>({
158
163
  index,
159
164
  factoryAddress,
160
165
  accountLogicAddress,
166
+ factoryStakerAddress,
161
167
  entryPoint: entryPointAddress,
162
168
  kernelPluginManager
163
169
  }: {
164
170
  index: bigint
165
171
  factoryAddress: Address
166
172
  accountLogicAddress: Address
173
+ factoryStakerAddress: Address
167
174
  entryPoint: entryPoint
168
175
  kernelPluginManager: KernelPluginManager<entryPoint>
169
176
  }): Promise<Hex> => {
@@ -172,15 +179,31 @@ const getAccountInitCode = async <entryPoint extends EntryPoint>({
172
179
  entryPoint: entryPointAddress,
173
180
  kernelPluginManager
174
181
  })
182
+ const entryPointVersion = getEntryPointVersion(entryPointAddress)
175
183
 
176
184
  // Build the account init code
185
+ if (entryPointVersion === "v0.6") {
186
+ return concatHex([
187
+ factoryAddress,
188
+ encodeFunctionData({
189
+ abi: createAccountAbi,
190
+ functionName: "createAccount",
191
+ args: [accountLogicAddress, initialisationData, index]
192
+ }) as Hex
193
+ ])
194
+ }
195
+
177
196
  return concatHex([
178
- factoryAddress,
197
+ factoryStakerAddress,
179
198
  encodeFunctionData({
180
- abi: createAccountAbi,
181
- functionName: "createAccount",
182
- args: [accountLogicAddress, initialisationData, index]
183
- }) as Hex
199
+ abi: KernelFactoryStakerAbi,
200
+ functionName: "deployWithFactory",
201
+ args: [
202
+ factoryAddress,
203
+ initialisationData,
204
+ toHex(index, { size: 32 })
205
+ ]
206
+ })
184
207
  ])
185
208
  }
186
209
 
@@ -244,8 +267,9 @@ export async function createKernelAccount<
244
267
  plugins,
245
268
  entryPoint: entryPointAddress,
246
269
  index = 0n,
247
- factoryAddress = KERNEL_ADDRESSES.FACTORY_ADDRESS,
270
+ factoryAddress = KERNEL_ADDRESSES.FACTORY_ADDRESS_V0_6,
248
271
  accountLogicAddress = KERNEL_ADDRESSES.ACCOUNT_LOGIC_V0_6,
272
+ factoryStakerAddress = KERNEL_ADDRESSES.FACTORY_STAKER,
249
273
  deployedAccountAddress
250
274
  }: CreateKernelAccountParameters<entryPoint>
251
275
  ): Promise<KernelSmartAccount<entryPoint, TTransport, TChain>> {
@@ -254,6 +278,10 @@ export async function createKernelAccount<
254
278
  entryPointVersion === "v0.6"
255
279
  ? KERNEL_ADDRESSES.ACCOUNT_LOGIC_V0_6
256
280
  : KERNEL_ADDRESSES.ACCOUNT_LOGIC_V0_7
281
+ factoryAddress =
282
+ entryPointVersion === "v0.6"
283
+ ? KERNEL_ADDRESSES.FACTORY_ADDRESS_V0_6
284
+ : KERNEL_ADDRESSES.FACTORY_ADDRESS_V0_7
257
285
 
258
286
  const kernelPluginManager = isKernelPluginManager<entryPoint>(plugins)
259
287
  ? plugins
@@ -270,6 +298,7 @@ export async function createKernelAccount<
270
298
  index,
271
299
  factoryAddress,
272
300
  accountLogicAddress,
301
+ factoryStakerAddress,
273
302
  entryPoint: entryPointAddress,
274
303
  kernelPluginManager
275
304
  })
@@ -331,7 +360,11 @@ export async function createKernelAccount<
331
360
 
332
361
  if (smartAccountDeployed) return undefined
333
362
 
334
- return factoryAddress
363
+ const entryPointVersion =
364
+ getEntryPointVersion(entryPointAddress)
365
+ return entryPointVersion === "v0.6"
366
+ ? factoryAddress
367
+ : factoryStakerAddress
335
368
  },
336
369
 
337
370
  async getFactoryData() {
@@ -159,7 +159,7 @@ export async function toKernelPluginManager<
159
159
  const typeData = await getPluginsEnableTypedDataV1({
160
160
  accountAddress,
161
161
  chainId,
162
- kernelVersion: version ?? kernelVersion,
162
+ kernelVersion: kernelVersion ?? version,
163
163
  action,
164
164
  validator: regular,
165
165
  validUntil,
@@ -1,3 +1,4 @@
1
+ import { ENTRYPOINT_ADDRESS_V06 } from "permissionless"
1
2
  import type { EntryPoint } from "permissionless/types"
2
3
  import type {
3
4
  UserOperation,
@@ -5,7 +6,6 @@ import type {
5
6
  } from "permissionless/types/userOperation.js"
6
7
  import { deepHexlify } from "permissionless/utils"
7
8
  import type { Address, Hex } from "viem"
8
- import { KERNEL_ADDRESSES } from "../../accounts/index.js"
9
9
  import type { ZeroDevPaymasterClient } from "../../clients/paymasterClient.js"
10
10
 
11
11
  export type EstimateGasInERC20Parameters = {
@@ -40,8 +40,7 @@ export const estimateGasInERC20 = async <entryPoint extends EntryPoint>(
40
40
  args.userOperation
41
41
  ) as UserOperationWithBigIntAsHex<"v0.6">,
42
42
  tokenAddress: args.gasTokenAddress,
43
- entryPointAddress:
44
- args.entryPoint ?? KERNEL_ADDRESSES.ENTRYPOINT_V0_6
43
+ entryPointAddress: args.entryPoint ?? ENTRYPOINT_ADDRESS_V06
45
44
  }
46
45
  ]
47
46
  })
@@ -42,10 +42,13 @@ export const zerodevPaymasterActions =
42
42
  sponsorUserOperation: async (
43
43
  args: Omit<SponsorUserOperationParameters<entryPoint>, "entryPoint">
44
44
  ) =>
45
- sponsorUserOperation(client as ZeroDevPaymasterClient<entryPoint>, {
46
- ...args,
47
- entryPoint: entryPointAddress
48
- }),
45
+ sponsorUserOperation<entryPoint>(
46
+ client as ZeroDevPaymasterClient<entryPoint>,
47
+ {
48
+ ...args,
49
+ entryPoint: entryPointAddress
50
+ }
51
+ ),
49
52
  estimateGasInERC20: async (args: EstimateGasInERC20Parameters) =>
50
53
  estimateGasInERC20(
51
54
  client as ZeroDevPaymasterClient<entryPoint>,
@@ -84,10 +84,9 @@ export const createKernelAccountClient = <
84
84
  let middleware = parameters.middleware
85
85
 
86
86
  if (
87
- !middleware ||
88
- (typeof middleware !== "function" &&
89
- !middleware.gasPrice &&
90
- parameters.entryPoint === ENTRYPOINT_ADDRESS_V07)
87
+ (!middleware ||
88
+ (typeof middleware !== "function" && !middleware.gasPrice)) &&
89
+ parameters.entryPoint === ENTRYPOINT_ADDRESS_V07
91
90
  ) {
92
91
  const gasPrice = () => getUserOperationGasPrice(client)
93
92
  middleware = {
package/constants.ts CHANGED
@@ -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
- "0x541E811D24A54745619a5B9f0c1d4B08D5740144": "0.3.0-beta"
13
+ "0xe59cffb45AFFB215e3823F7D1a207a71C1aa09c3": "0.3.0-beta"
14
14
  }
15
15
  export const TOKEN_ACTION = "0x2087C7FfD0d0DAE80a00EE74325aBF3449e0eaf1"
16
16
  export const KERNEL_NAME = "Kernel"
package/index.ts CHANGED
@@ -38,6 +38,8 @@ 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"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerodev/sdk",
3
- "version": "5.2.1-alpha-5",
3
+ "version": "5.2.1-alpha-7",
4
4
  "author": "ZeroDev",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
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
  })