@zerodev/sdk 5.1.13 → 5.2.0-alpha-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 (123) hide show
  1. package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js +738 -0
  2. package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js.map +1 -0
  3. package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelModuleAbi.js +15 -0
  4. package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelModuleAbi.js.map +1 -0
  5. package/_cjs/accounts/kernel/createKernelAccount.js +231 -75
  6. package/_cjs/accounts/kernel/createKernelAccount.js.map +1 -1
  7. package/_cjs/accounts/kernel/v1/createKernelV1Account.js +29 -18
  8. package/_cjs/accounts/kernel/v1/createKernelV1Account.js.map +1 -1
  9. package/_cjs/accounts/utils/6492.js +19 -3
  10. package/_cjs/accounts/utils/6492.js.map +1 -1
  11. package/_cjs/accounts/utils/index.js +4 -3
  12. package/_cjs/accounts/utils/index.js.map +1 -1
  13. package/_cjs/accounts/utils/toKernelPluginManager.js +194 -62
  14. package/_cjs/accounts/utils/toKernelPluginManager.js.map +1 -1
  15. package/_cjs/actions/account-client/signUserOperation.js +1 -1
  16. package/_cjs/actions/account-client/signUserOperation.js.map +1 -1
  17. package/_cjs/actions/paymaster/estimateGasInERC20.js.map +1 -1
  18. package/_cjs/actions/paymaster/sponsorUserOperation.js +17 -14
  19. package/_cjs/actions/paymaster/sponsorUserOperation.js.map +1 -1
  20. package/_cjs/clients/decorators/kernel.js +8 -5
  21. package/_cjs/clients/decorators/kernel.js.map +1 -1
  22. package/_cjs/clients/kernelAccountClient.js +3 -3
  23. package/_cjs/clients/kernelAccountClient.js.map +1 -1
  24. package/_cjs/clients/paymasterClient.js +1 -1
  25. package/_cjs/clients/paymasterClient.js.map +1 -1
  26. package/_cjs/constants.js +28 -3
  27. package/_cjs/constants.js.map +1 -1
  28. package/_cjs/index.js +5 -1
  29. package/_cjs/index.js.map +1 -1
  30. package/_cjs/providers/KernelEIP1193Provider.js.map +1 -1
  31. package/_cjs/types/kernel.js.map +1 -1
  32. package/_cjs/utils.js +34 -3
  33. package/_cjs/utils.js.map +1 -1
  34. package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js +735 -0
  35. package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js.map +1 -0
  36. package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelModuleAbi.js +12 -0
  37. package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelModuleAbi.js.map +1 -0
  38. package/_esm/accounts/kernel/createKernelAccount.js +240 -81
  39. package/_esm/accounts/kernel/createKernelAccount.js.map +1 -1
  40. package/_esm/accounts/kernel/v1/createKernelV1Account.js +37 -20
  41. package/_esm/accounts/kernel/v1/createKernelV1Account.js.map +1 -1
  42. package/_esm/accounts/utils/6492.js +16 -1
  43. package/_esm/accounts/utils/6492.js.map +1 -1
  44. package/_esm/accounts/utils/index.js +2 -4
  45. package/_esm/accounts/utils/index.js.map +1 -1
  46. package/_esm/accounts/utils/toKernelPluginManager.js +198 -66
  47. package/_esm/accounts/utils/toKernelPluginManager.js.map +1 -1
  48. package/_esm/actions/account-client/signUserOperation.js +1 -1
  49. package/_esm/actions/account-client/signUserOperation.js.map +1 -1
  50. package/_esm/actions/paymaster/estimateGasInERC20.js.map +1 -1
  51. package/_esm/actions/paymaster/sponsorUserOperation.js +37 -15
  52. package/_esm/actions/paymaster/sponsorUserOperation.js.map +1 -1
  53. package/_esm/clients/decorators/kernel.js +9 -5
  54. package/_esm/clients/decorators/kernel.js.map +1 -1
  55. package/_esm/clients/kernelAccountClient.js +3 -3
  56. package/_esm/clients/kernelAccountClient.js.map +1 -1
  57. package/_esm/clients/paymasterClient.js +1 -1
  58. package/_esm/clients/paymasterClient.js.map +1 -1
  59. package/_esm/constants.js +27 -2
  60. package/_esm/constants.js.map +1 -1
  61. package/_esm/index.js +1 -0
  62. package/_esm/index.js.map +1 -1
  63. package/_esm/providers/KernelEIP1193Provider.js.map +1 -1
  64. package/_esm/types/kernel.js +1 -0
  65. package/_esm/types/kernel.js.map +1 -1
  66. package/_esm/utils.js +33 -4
  67. package/_esm/utils.js.map +1 -1
  68. package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.d.ts +843 -0
  69. package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.d.ts.map +1 -0
  70. package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelModuleAbi.d.ts +16 -0
  71. package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelModuleAbi.d.ts.map +1 -0
  72. package/_types/accounts/kernel/createKernelAccount.d.ts +14 -11
  73. package/_types/accounts/kernel/createKernelAccount.d.ts.map +1 -1
  74. package/_types/accounts/kernel/v1/createKernelV1Account.d.ts +5 -4
  75. package/_types/accounts/kernel/v1/createKernelV1Account.d.ts.map +1 -1
  76. package/_types/accounts/utils/6492.d.ts +3 -1
  77. package/_types/accounts/utils/6492.d.ts.map +1 -1
  78. package/_types/accounts/utils/index.d.ts +2 -4
  79. package/_types/accounts/utils/index.d.ts.map +1 -1
  80. package/_types/accounts/utils/toKernelPluginManager.d.ts +3 -2
  81. package/_types/accounts/utils/toKernelPluginManager.d.ts.map +1 -1
  82. package/_types/actions/account-client/signUserOperation.d.ts +7 -7
  83. package/_types/actions/account-client/signUserOperation.d.ts.map +1 -1
  84. package/_types/actions/paymaster/estimateGasInERC20.d.ts +3 -2
  85. package/_types/actions/paymaster/estimateGasInERC20.d.ts.map +1 -1
  86. package/_types/actions/paymaster/sponsorUserOperation.d.ts +7 -6
  87. package/_types/actions/paymaster/sponsorUserOperation.d.ts.map +1 -1
  88. package/_types/clients/decorators/kernel.d.ts +8 -7
  89. package/_types/clients/decorators/kernel.d.ts.map +1 -1
  90. package/_types/clients/kernelAccountClient.d.ts +101 -22
  91. package/_types/clients/kernelAccountClient.d.ts.map +1 -1
  92. package/_types/clients/paymasterClient.d.ts +6 -3
  93. package/_types/clients/paymasterClient.d.ts.map +1 -1
  94. package/_types/constants.d.ts +22 -1
  95. package/_types/constants.d.ts.map +1 -1
  96. package/_types/index.d.ts +1 -0
  97. package/_types/index.d.ts.map +1 -1
  98. package/_types/providers/KernelEIP1193Provider.d.ts +3 -2
  99. package/_types/providers/KernelEIP1193Provider.d.ts.map +1 -1
  100. package/_types/types/kernel.d.ts +44 -12
  101. package/_types/types/kernel.d.ts.map +1 -1
  102. package/_types/utils.d.ts +11 -2
  103. package/_types/utils.d.ts.map +1 -1
  104. package/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.ts +736 -0
  105. package/accounts/kernel/abi/kernel_v_3_0_0/KernelModuleAbi.ts +11 -0
  106. package/accounts/kernel/createKernelAccount.ts +407 -104
  107. package/accounts/kernel/v1/createKernelV1Account.ts +67 -28
  108. package/accounts/utils/6492.ts +27 -1
  109. package/accounts/utils/index.ts +2 -4
  110. package/accounts/utils/toKernelPluginManager.ts +261 -80
  111. package/actions/account-client/signUserOperation.ts +25 -13
  112. package/actions/paymaster/estimateGasInERC20.ts +5 -4
  113. package/actions/paymaster/sponsorUserOperation.ts +104 -32
  114. package/clients/decorators/kernel.ts +44 -35
  115. package/clients/kernelAccountClient.ts +34 -25
  116. package/clients/paymasterClient.ts +10 -6
  117. package/constants.ts +25 -2
  118. package/index.ts +5 -0
  119. package/package.json +93 -92
  120. package/providers/KernelEIP1193Provider.ts +6 -3
  121. package/types/kernel.ts +96 -40
  122. package/utils.ts +52 -4
  123. package/README.md +0 -3
@@ -1,36 +1,65 @@
1
+ import type {
2
+ ENTRYPOINT_ADDRESS_V06_TYPE,
3
+ EntryPoint,
4
+ GetEntryPointVersion
5
+ } from "permissionless/types/entrypoint"
1
6
  import type {
2
7
  UserOperation,
3
8
  UserOperationWithBigIntAsHex
4
9
  } from "permissionless/types/userOperation.js"
5
- import { deepHexlify } from "permissionless/utils"
10
+ import { ENTRYPOINT_ADDRESS_V06, deepHexlify } from "permissionless/utils"
6
11
  import type { Address, Hex } from "viem"
7
12
  import type { PartialBy } from "viem/types/utils"
8
13
  import { KERNEL_ADDRESSES } from "../../accounts/index.js"
9
14
  import type { ZeroDevPaymasterClient } from "../../clients/paymasterClient.js"
10
15
 
11
- export type SponsorUserOperationParameters = {
12
- userOperation: PartialBy<
13
- UserOperation,
14
- | "callGasLimit"
15
- | "preVerificationGas"
16
- | "verificationGasLimit"
17
- | "paymasterAndData"
18
- >
19
- entryPoint?: Address
16
+ export type SponsorUserOperationParameters<entryPoint extends EntryPoint> = {
17
+ userOperation: entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE
18
+ ? PartialBy<
19
+ UserOperation<"v0.6">,
20
+ "callGasLimit" | "preVerificationGas" | "verificationGasLimit"
21
+ >
22
+ : PartialBy<
23
+ UserOperation<"v0.7">,
24
+ | "callGasLimit"
25
+ | "preVerificationGas"
26
+ | "verificationGasLimit"
27
+ | "paymasterVerificationGasLimit"
28
+ | "paymasterPostOpGasLimit"
29
+ >
30
+ entryPoint: entryPoint
20
31
  gasToken?: Hex
21
32
  shouldOverrideFee?: boolean
22
33
  shouldConsume?: boolean
23
34
  }
24
35
 
25
- export type SponsorUserOperationReturnType = UserOperation
36
+ export type SponsorUserOperationReturnType<entryPoint extends EntryPoint> =
37
+ entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE
38
+ ? Pick<
39
+ UserOperation<"v0.6">,
40
+ | "callGasLimit"
41
+ | "verificationGasLimit"
42
+ | "preVerificationGas"
43
+ | "paymasterAndData"
44
+ >
45
+ : Pick<
46
+ UserOperation<"v0.7">,
47
+ | "callGasLimit"
48
+ | "verificationGasLimit"
49
+ | "preVerificationGas"
50
+ | "paymaster"
51
+ | "paymasterVerificationGasLimit"
52
+ | "paymasterPostOpGasLimit"
53
+ | "paymasterData"
54
+ >
26
55
 
27
56
  /**
28
57
  * Returns paymasterAndData & updated gas parameters required to sponsor a userOperation.
29
58
  */
30
- export const sponsorUserOperation = async (
31
- client: ZeroDevPaymasterClient,
32
- args: SponsorUserOperationParameters
33
- ): Promise<SponsorUserOperationReturnType> => {
59
+ export const sponsorUserOperation = async <entryPoint extends EntryPoint>(
60
+ client: ZeroDevPaymasterClient<entryPoint>,
61
+ args: SponsorUserOperationParameters<entryPoint>
62
+ ): Promise<SponsorUserOperationReturnType<entryPoint>> => {
34
63
  const response = await client.request({
35
64
  method: "zd_sponsorUserOperation",
36
65
  params: [
@@ -38,7 +67,9 @@ export const sponsorUserOperation = async (
38
67
  chainId: client.chain?.id as number,
39
68
  userOp: deepHexlify(
40
69
  args.userOperation
41
- ) as UserOperationWithBigIntAsHex,
70
+ ) as UserOperationWithBigIntAsHex<
71
+ GetEntryPointVersion<entryPoint>
72
+ >,
42
73
  entryPointAddress:
43
74
  args.entryPoint ?? KERNEL_ADDRESSES.ENTRYPOINT_V0_6,
44
75
  gasTokenData: args.gasToken && {
@@ -49,23 +80,64 @@ export const sponsorUserOperation = async (
49
80
  }
50
81
  ]
51
82
  })
52
- let result: UserOperation = {
53
- ...args.userOperation,
54
- paymasterAndData: response.paymasterAndData,
55
- preVerificationGas: BigInt(response.preVerificationGas),
56
- verificationGasLimit: BigInt(response.verificationGasLimit),
57
- callGasLimit: BigInt(response.callGasLimit)
58
- }
59
- if (
60
- response.maxFeePerGas !== undefined &&
61
- response.maxPriorityFeePerGas !== undefined
62
- ) {
63
- result = {
64
- ...result,
65
- maxFeePerGas: BigInt(response.maxFeePerGas),
66
- maxPriorityFeePerGas: BigInt(response.maxPriorityFeePerGas)
83
+ if (args.entryPoint === ENTRYPOINT_ADDRESS_V06) {
84
+ const responseV06 = response as {
85
+ paymasterAndData: Hex
86
+ preVerificationGas: Hex
87
+ verificationGasLimit: Hex
88
+ callGasLimit: Hex
89
+ paymaster?: never
90
+ paymasterVerificationGasLimit?: never
91
+ paymasterPostOpGasLimit?: never
92
+ paymasterData?: never
67
93
  }
94
+ return {
95
+ paymasterAndData: responseV06.paymasterAndData,
96
+ preVerificationGas: BigInt(responseV06.preVerificationGas),
97
+ verificationGasLimit: BigInt(responseV06.verificationGasLimit),
98
+ callGasLimit: BigInt(responseV06.callGasLimit)
99
+ } as SponsorUserOperationReturnType<entryPoint>
68
100
  }
101
+ const responseV07 = response as {
102
+ preVerificationGas: Hex
103
+ verificationGasLimit: Hex
104
+ callGasLimit: Hex
105
+ paymaster: Address
106
+ paymasterVerificationGasLimit: Hex
107
+ paymasterPostOpGasLimit: Hex
108
+ paymasterData: Hex
109
+ paymasterAndData?: never
110
+ }
111
+
112
+ return {
113
+ callGasLimit: BigInt(responseV07.callGasLimit),
114
+ verificationGasLimit: BigInt(responseV07.verificationGasLimit),
115
+ preVerificationGas: BigInt(responseV07.preVerificationGas),
116
+ paymaster: responseV07.paymaster,
117
+ paymasterVerificationGasLimit: BigInt(
118
+ responseV07.paymasterVerificationGasLimit
119
+ ),
120
+ paymasterPostOpGasLimit: BigInt(responseV07.paymasterPostOpGasLimit),
121
+ paymasterData: responseV07.paymasterData
122
+ } as SponsorUserOperationReturnType<entryPoint>
123
+ // [TODO] Add gas price params in the response in permissionless
124
+ // let result: UserOperation<"v0.6"> = {
125
+ // ...args.userOperation,
126
+ // paymasterAndData: response.paymasterAndData,
127
+ // preVerificationGas: BigInt(response.preVerificationGas),
128
+ // verificationGasLimit: BigInt(response.verificationGasLimit),
129
+ // callGasLimit: BigInt(response.callGasLimit)
130
+ // }
131
+ // if (
132
+ // response.maxFeePerGas !== undefined &&
133
+ // response.maxPriorityFeePerGas !== undefined
134
+ // ) {
135
+ // result = {
136
+ // ...result,
137
+ // maxFeePerGas: BigInt(response.maxFeePerGas),
138
+ // maxPriorityFeePerGas: BigInt(response.maxPriorityFeePerGas)
139
+ // }
140
+ // }
69
141
 
70
- return result
142
+ // return result
71
143
  }
@@ -1,6 +1,7 @@
1
1
  import { type SmartAccountActions, smartAccountActions } from "permissionless"
2
2
  import type { SmartAccount } from "permissionless/accounts/types"
3
- import type { SponsorUserOperationMiddleware } from "permissionless/actions/smartAccount"
3
+ import { type Middleware } from "permissionless/actions/smartAccount"
4
+ import type { EntryPoint } from "permissionless/types"
4
5
  import type { Chain, Client, Transport } from "viem"
5
6
  import type {
6
7
  SignUserOperationParameters,
@@ -19,42 +20,42 @@ import {
19
20
  } from "../../actions/paymaster/sponsorUserOperation.js"
20
21
  import type { ZeroDevPaymasterClient } from "../paymasterClient.js"
21
22
 
22
- export type ZeroDevPaymasterClientActions = {
23
+ export type ZeroDevPaymasterClientActions<entryPoint extends EntryPoint> = {
23
24
  /**
24
25
  * Returns paymasterAndData & updated gas parameters required to sponsor a userOperation.
25
26
  */
26
27
  sponsorUserOperation: (
27
- args: SponsorUserOperationParameters
28
- ) => Promise<SponsorUserOperationReturnType>
28
+ args: SponsorUserOperationParameters<entryPoint>
29
+ ) => Promise<SponsorUserOperationReturnType<entryPoint>>
29
30
  estimateGasInERC20: (
30
31
  args: EstimateGasInERC20Parameters
31
32
  ) => Promise<EstimateGasInERC20ReturnType>
32
33
  }
33
34
 
34
- export const zerodevPaymasterActions = (
35
- client: Client
36
- ): ZeroDevPaymasterClientActions => ({
37
- sponsorUserOperation: async (args: SponsorUserOperationParameters) =>
38
- sponsorUserOperation(client as ZeroDevPaymasterClient, args),
39
- estimateGasInERC20: async (args: EstimateGasInERC20Parameters) =>
40
- estimateGasInERC20(client as ZeroDevPaymasterClient, args)
41
- })
42
-
43
- // export type KernelAccountClientActions<
44
- // TChain extends Chain | undefined = Chain | undefined,
45
- // TSmartAccount extends SmartAccount | undefined = SmartAccount | undefined
46
- // > = {
47
- // signUserOperation: <TTransport extends Transport>(
48
- // args: Parameters<
49
- // typeof signUserOperation<TTransport, TChain, TSmartAccount>
50
- // >[1]
51
- // ) => Promise<SignUserOperationReturnType>
52
- // }
35
+ export const zerodevPaymasterActions =
36
+ <entryPoint extends EntryPoint>(entryPointAddress: entryPoint) =>
37
+ (client: Client): ZeroDevPaymasterClientActions<entryPoint> => ({
38
+ sponsorUserOperation: async (
39
+ args: Omit<SponsorUserOperationParameters<entryPoint>, "entryPoint">
40
+ ) =>
41
+ sponsorUserOperation(client as ZeroDevPaymasterClient<entryPoint>, {
42
+ ...args,
43
+ entryPoint: entryPointAddress
44
+ }),
45
+ estimateGasInERC20: async (args: EstimateGasInERC20Parameters) =>
46
+ estimateGasInERC20(
47
+ client as ZeroDevPaymasterClient<entryPoint>,
48
+ args
49
+ )
50
+ })
53
51
 
54
52
  export type KernelAccountClientActions<
53
+ entryPoint extends EntryPoint,
55
54
  TChain extends Chain | undefined = Chain | undefined,
56
- TSmartAccount extends SmartAccount | undefined = SmartAccount | undefined
57
- > = SmartAccountActions<TChain, TSmartAccount> & {
55
+ TSmartAccount extends SmartAccount<entryPoint> | undefined =
56
+ | SmartAccount<entryPoint>
57
+ | undefined
58
+ > = SmartAccountActions<entryPoint, TChain, TSmartAccount> & {
58
59
  /**
59
60
  * Signs a user operation with the given transport, chain, and smart account.
60
61
  *
@@ -63,26 +64,34 @@ export type KernelAccountClientActions<
63
64
  */
64
65
  signUserOperation: <TTransport extends Transport>(
65
66
  args: Parameters<
66
- typeof signUserOperation<TTransport, TChain, TSmartAccount>
67
+ typeof signUserOperation<
68
+ entryPoint,
69
+ TTransport,
70
+ TChain,
71
+ TSmartAccount
72
+ >
67
73
  >[1]
68
74
  ) => Promise<SignUserOperationReturnType>
69
75
  }
70
76
 
71
77
  export const kernelAccountClientActions =
72
- ({ sponsorUserOperation }: SponsorUserOperationMiddleware) =>
78
+ <entryPoint extends EntryPoint>({ middleware }: Middleware<entryPoint>) =>
73
79
  <
74
80
  TTransport extends Transport,
75
81
  TChain extends Chain | undefined = Chain | undefined,
76
- TSmartAccount extends SmartAccount | undefined =
77
- | SmartAccount
82
+ TSmartAccount extends SmartAccount<entryPoint> | undefined =
83
+ | SmartAccount<entryPoint>
78
84
  | undefined
79
85
  >(
80
86
  client: Client<TTransport, TChain, TSmartAccount>
81
- ): KernelAccountClientActions<TChain, TSmartAccount> => ({
82
- ...smartAccountActions({ sponsorUserOperation })(client),
87
+ ): KernelAccountClientActions<entryPoint, TChain, TSmartAccount> => ({
88
+ ...smartAccountActions({ middleware })(client),
83
89
  signUserOperation: (args) =>
84
- signUserOperation(client, {
85
- ...args,
86
- sponsorUserOperation
87
- } as SignUserOperationParameters<TSmartAccount>)
90
+ signUserOperation<entryPoint, TTransport, TChain, TSmartAccount>(
91
+ client,
92
+ {
93
+ ...args,
94
+ middleware
95
+ } as SignUserOperationParameters<entryPoint, TSmartAccount>
96
+ )
88
97
  })
@@ -1,12 +1,11 @@
1
1
  import type { SmartAccount } from "permissionless/accounts/types"
2
- import type { SponsorUserOperationMiddleware } from "permissionless/actions/smartAccount"
3
- import type { Prettify } from "permissionless/types"
2
+ import type { Middleware } from "permissionless/actions/smartAccount"
3
+ import type { EntryPoint, Prettify } from "permissionless/types"
4
4
  import type { BundlerRpcSchema } from "permissionless/types/bundler"
5
5
  import {
6
6
  type Chain,
7
7
  type Client,
8
8
  type ClientConfig,
9
- type ParseAccount,
10
9
  type Transport,
11
10
  createClient
12
11
  } from "viem"
@@ -17,62 +16,72 @@ import {
17
16
  } from "./decorators/kernel.js"
18
17
 
19
18
  export type KernelAccountClient<
19
+ entryPoint extends EntryPoint,
20
20
  transport extends Transport = Transport,
21
21
  chain extends Chain | undefined = Chain | undefined,
22
- account extends KernelSmartAccount | undefined =
23
- | KernelSmartAccount
22
+ account extends KernelSmartAccount<entryPoint> | undefined =
23
+ | KernelSmartAccount<entryPoint>
24
24
  | undefined
25
25
  > = Prettify<
26
26
  Client<
27
27
  transport,
28
28
  chain,
29
29
  account,
30
- BundlerRpcSchema,
31
- KernelAccountClientActions<chain, account>
30
+ BundlerRpcSchema<entryPoint>,
31
+ KernelAccountClientActions<entryPoint, chain, account>
32
32
  >
33
33
  >
34
34
 
35
35
  export type SmartAccountClientConfig<
36
+ entryPoint extends EntryPoint,
36
37
  transport extends Transport = Transport,
37
38
  chain extends Chain | undefined = Chain | undefined,
38
- TAccount extends SmartAccount | undefined = SmartAccount | undefined
39
+ account extends SmartAccount<entryPoint> | undefined =
40
+ | SmartAccount<entryPoint>
41
+ | undefined
39
42
  > = Prettify<
40
43
  Pick<
41
- ClientConfig<transport, chain, TAccount>,
42
- | "account"
43
- | "cacheTime"
44
- | "chain"
45
- | "key"
46
- | "name"
47
- | "pollingInterval"
48
- | "transport"
49
- >
44
+ ClientConfig<transport, chain, account>,
45
+ "cacheTime" | "chain" | "key" | "name" | "pollingInterval"
46
+ > & {
47
+ account?: account
48
+ bundlerTransport: Transport
49
+ } & Middleware<entryPoint> & {
50
+ entryPoint: entryPoint
51
+ }
50
52
  >
51
53
 
52
54
  export const createKernelAccountClient = <
55
+ entryPoint extends EntryPoint,
53
56
  TTransport extends Transport,
54
57
  TChain extends Chain | undefined = undefined,
55
- TSmartAccount extends KernelSmartAccount | undefined = undefined
58
+ TSmartAccount extends KernelSmartAccount<entryPoint> | undefined =
59
+ | KernelSmartAccount<entryPoint>
60
+ | undefined
56
61
  >(
57
- parameters: SmartAccountClientConfig<TTransport, TChain, TSmartAccount> &
58
- SponsorUserOperationMiddleware
59
- ): KernelAccountClient<TTransport, TChain, ParseAccount<TSmartAccount>> => {
62
+ parameters: SmartAccountClientConfig<
63
+ entryPoint,
64
+ TTransport,
65
+ TChain,
66
+ TSmartAccount
67
+ >
68
+ ): KernelAccountClient<entryPoint, TTransport, TChain, TSmartAccount> => {
60
69
  const {
61
70
  key = "Account",
62
71
  name = "Kernel Account Client",
63
- transport
72
+ bundlerTransport
64
73
  } = parameters
65
74
  const client = createClient({
66
75
  ...parameters,
67
76
  key,
68
77
  name,
69
- transport: (opts) => transport({ ...opts, retryCount: 0 }),
78
+ transport: (opts) => bundlerTransport({ ...opts, retryCount: 0 }),
70
79
  type: "kernelAccountClient"
71
80
  })
72
81
 
73
82
  return client.extend(
74
83
  kernelAccountClientActions({
75
- sponsorUserOperation: parameters.sponsorUserOperation
84
+ middleware: parameters.middleware
76
85
  })
77
- )
86
+ ) as KernelAccountClient<entryPoint, TTransport, TChain, TSmartAccount>
78
87
  }
@@ -1,3 +1,4 @@
1
+ import type { EntryPoint } from "permissionless/types/entrypoint"
1
2
  import {
2
3
  type Account,
3
4
  type Chain,
@@ -12,12 +13,12 @@ import {
12
13
  zerodevPaymasterActions
13
14
  } from "./decorators/kernel.js"
14
15
 
15
- export type ZeroDevPaymasterClient = Client<
16
+ export type ZeroDevPaymasterClient<entryPoint extends EntryPoint> = Client<
16
17
  Transport,
17
18
  Chain | undefined,
18
19
  Account | undefined,
19
- ZeroDevPaymasterRpcSchema,
20
- ZeroDevPaymasterClientActions
20
+ ZeroDevPaymasterRpcSchema<entryPoint>,
21
+ ZeroDevPaymasterClientActions<entryPoint>
21
22
  >
22
23
  /**
23
24
  * Creates a ZeroDev-specific Paymaster Client with a given [Transport](https://viem.sh/docs/clients/intro.html) configured for a [Chain](https://viem.sh/docs/clients/chains.html).
@@ -37,11 +38,14 @@ export type ZeroDevPaymasterClient = Client<
37
38
  * })
38
39
  */
39
40
  export const createZeroDevPaymasterClient = <
41
+ entryPoint extends EntryPoint,
40
42
  transport extends Transport,
41
43
  chain extends Chain | undefined = undefined
42
44
  >(
43
- parameters: PublicClientConfig<transport, chain>
44
- ): ZeroDevPaymasterClient => {
45
+ parameters: PublicClientConfig<transport, chain> & {
46
+ entryPoint: entryPoint
47
+ }
48
+ ): ZeroDevPaymasterClient<entryPoint> => {
45
49
  const { key = "public", name = "ZeroDev Paymaster Client" } = parameters
46
50
  const client = createClient({
47
51
  ...parameters,
@@ -49,5 +53,5 @@ export const createZeroDevPaymasterClient = <
49
53
  name,
50
54
  type: "zerodevPaymasterClient"
51
55
  })
52
- return client.extend(zerodevPaymasterActions)
56
+ return client.extend(zerodevPaymasterActions(parameters.entryPoint))
53
57
  }
package/constants.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { EntryPointVersion } from "permissionless/types/entrypoint"
1
2
  import { type Address } from "viem"
2
3
 
3
4
  export const DUMMY_ECDSA_SIG =
@@ -8,8 +9,30 @@ export const KernelImplToVersionMap: { [key: Address]: string } = {
8
9
  "0x0DA6a956B9488eD4dd761E59f52FDc6c8068E6B5": "0.2.2",
9
10
  "0xD3F582F6B4814E989Ee8E96bc3175320B5A540ab": "0.2.3",
10
11
  "0x5FC0236D6c88a65beD32EECDC5D60a5CAb377717": "0.2.3",
11
- "0xd3082872F8B06073A021b4602e022d5A070d7cfC": "0.2.4"
12
+ "0xd3082872F8B06073A021b4602e022d5A070d7cfC": "0.2.4",
13
+ "0x079D5D8A3275A230AF743cB59c341Ff74B82488D": "0.3.0-beta"
12
14
  }
13
15
  export const TOKEN_ACTION = "0x2087C7FfD0d0DAE80a00EE74325aBF3449e0eaf1"
14
16
  export const KERNEL_NAME = "Kernel"
15
- export const LATEST_KERNEL_VERSION = "0.2.4"
17
+ export const LATEST_KERNEL_VERSION: { [key in EntryPointVersion]: string } = {
18
+ "v0.6": "0.2.4",
19
+ "v0.7": "0.3.0-beta"
20
+ }
21
+ export const VALIDATOR_TYPE = {
22
+ SUDO: "0x00",
23
+ SECONDARY: "0x01",
24
+ PERMISSION: "0x02"
25
+ } as const
26
+ export enum VALIDATOR_MODE {
27
+ DEFAULT = "0x00",
28
+ ENABLE = "0x01"
29
+ }
30
+ export enum CALL_TYPE {
31
+ SINGLE = "0x00",
32
+ BATCH = "0x01",
33
+ DELEGATE_CALL = "0xFF"
34
+ }
35
+ export enum EXEC_TYPE {
36
+ DEFAULT = "0x00",
37
+ TRY_EXEC = "0x01"
38
+ }
package/index.ts CHANGED
@@ -32,6 +32,11 @@ export {
32
32
  } from "./types/kernel.js"
33
33
  export { KernelAccountAbi } from "./accounts/kernel/abi/KernelAccountAbi.js"
34
34
  export { KernelFactoryAbi } from "./accounts/kernel/abi/KernelFactoryAbi.js"
35
+ export {
36
+ KernelV3AccountAbi,
37
+ KernelV3ExecuteAbi,
38
+ KernelV3InitAbi
39
+ } from "./accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js"
35
40
  export { TokenActionsAbi } from "./accounts/kernel/abi/TokenActionsAbi.js"
36
41
  export * as constants from "./constants.js"
37
42
  export * from "./utils.js"