@zerodev/sdk 5.3.0-alpha-0 → 5.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/_cjs/accounts/kernel/abi/kernel_v_3_1/KernelAccountAbi.js +796 -0
  2. package/_cjs/accounts/kernel/abi/kernel_v_3_1/KernelAccountAbi.js.map +1 -0
  3. package/_cjs/accounts/kernel/createKernelAccount.js +26 -6
  4. package/_cjs/accounts/kernel/createKernelAccount.js.map +1 -1
  5. package/_cjs/accounts/kernel/utils/common/accountMetadata.js +1 -1
  6. package/_cjs/accounts/kernel/utils/common/accountMetadata.js.map +1 -1
  7. package/_cjs/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js +1 -1
  8. package/_cjs/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js.map +1 -1
  9. package/_cjs/accounts/kernel/v1/createKernelAccountV1.js +1 -1
  10. package/_cjs/accounts/utils/toKernelPluginManager.js +4 -2
  11. package/_cjs/accounts/utils/toKernelPluginManager.js.map +1 -1
  12. package/_cjs/actions/account-client/uninstallPlugin.js +43 -0
  13. package/_cjs/actions/account-client/uninstallPlugin.js.map +1 -0
  14. package/_cjs/actions/index.js +3 -1
  15. package/_cjs/actions/index.js.map +1 -1
  16. package/_cjs/clients/decorators/kernel.js +5 -1
  17. package/_cjs/clients/decorators/kernel.js.map +1 -1
  18. package/_cjs/constants.js +11 -17
  19. package/_cjs/constants.js.map +1 -1
  20. package/_cjs/index.js +3 -1
  21. package/_cjs/index.js.map +1 -1
  22. package/_cjs/utils.js +3 -15
  23. package/_cjs/utils.js.map +1 -1
  24. package/_esm/accounts/kernel/abi/kernel_v_3_1/KernelAccountAbi.js +793 -0
  25. package/_esm/accounts/kernel/abi/kernel_v_3_1/KernelAccountAbi.js.map +1 -0
  26. package/_esm/accounts/kernel/createKernelAccount.js +26 -6
  27. package/_esm/accounts/kernel/createKernelAccount.js.map +1 -1
  28. package/_esm/accounts/kernel/utils/common/accountMetadata.js +1 -1
  29. package/_esm/accounts/kernel/utils/common/accountMetadata.js.map +1 -1
  30. package/_esm/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js +1 -1
  31. package/_esm/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js.map +1 -1
  32. package/_esm/accounts/kernel/v1/createKernelAccountV1.js +1 -1
  33. package/_esm/accounts/utils/toKernelPluginManager.js +4 -2
  34. package/_esm/accounts/utils/toKernelPluginManager.js.map +1 -1
  35. package/_esm/actions/account-client/uninstallPlugin.js +39 -0
  36. package/_esm/actions/account-client/uninstallPlugin.js.map +1 -0
  37. package/_esm/actions/index.js +1 -0
  38. package/_esm/actions/index.js.map +1 -1
  39. package/_esm/clients/decorators/kernel.js +6 -2
  40. package/_esm/clients/decorators/kernel.js.map +1 -1
  41. package/_esm/constants.js +18 -16
  42. package/_esm/constants.js.map +1 -1
  43. package/_esm/index.js +1 -0
  44. package/_esm/index.js.map +1 -1
  45. package/_esm/utils.js +4 -15
  46. package/_esm/utils.js.map +1 -1
  47. package/_types/accounts/kernel/abi/kernel_v_3_1/KernelAccountAbi.d.ts +946 -0
  48. package/_types/accounts/kernel/abi/kernel_v_3_1/KernelAccountAbi.d.ts.map +1 -0
  49. package/_types/accounts/kernel/createKernelAccount.d.ts.map +1 -1
  50. package/_types/accounts/kernel/v1/createKernelAccountV1.d.ts +2 -2
  51. package/_types/accounts/utils/toKernelPluginManager.d.ts.map +1 -1
  52. package/_types/actions/account-client/uninstallPlugin.d.ts +11 -0
  53. package/_types/actions/account-client/uninstallPlugin.d.ts.map +1 -0
  54. package/_types/actions/index.d.ts +1 -0
  55. package/_types/actions/index.d.ts.map +1 -1
  56. package/_types/clients/decorators/kernel.d.ts +11 -2
  57. package/_types/clients/decorators/kernel.d.ts.map +1 -1
  58. package/_types/constants.d.ts +7 -8
  59. package/_types/constants.d.ts.map +1 -1
  60. package/_types/index.d.ts +1 -0
  61. package/_types/index.d.ts.map +1 -1
  62. package/_types/types/kernel.d.ts +1 -1
  63. package/_types/types/kernel.d.ts.map +1 -1
  64. package/_types/utils.d.ts +1 -2
  65. package/_types/utils.d.ts.map +1 -1
  66. package/accounts/kernel/abi/kernel_v_3_1/KernelAccountAbi.ts +792 -0
  67. package/accounts/kernel/createKernelAccount.ts +30 -6
  68. package/accounts/kernel/utils/common/accountMetadata.ts +1 -1
  69. package/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.ts +1 -1
  70. package/accounts/kernel/v1/createKernelAccountV1.ts +2 -2
  71. package/accounts/utils/toKernelPluginManager.ts +4 -2
  72. package/actions/account-client/uninstallPlugin.ts +99 -0
  73. package/actions/index.ts +5 -0
  74. package/clients/decorators/kernel.ts +35 -4
  75. package/constants.ts +22 -17
  76. package/index.ts +1 -0
  77. package/package.json +16 -33
  78. package/types/kernel.ts +1 -1
  79. package/utils.ts +5 -28
@@ -47,6 +47,7 @@ import {
47
47
  import { KernelInitAbi } from "./abi/KernelAccountAbi.js"
48
48
  import { KernelV3InitAbi } from "./abi/kernel_v_3_0_0/KernelAccountAbi.js"
49
49
  import { KernelFactoryStakerAbi } from "./abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js"
50
+ import { KernelV3_1AccountAbi } from "./abi/kernel_v_3_1/KernelAccountAbi.js"
50
51
  import { encodeCallData as encodeCallDataEpV06 } from "./utils/account/ep0_6/encodeCallData.js"
51
52
  import { encodeDeployCallData as encodeDeployCallDataV06 } from "./utils/account/ep0_6/encodeDeployCallData.js"
52
53
  import { encodeCallData as encodeCallDataEpV07 } from "./utils/account/ep0_7/encodeCallData.js"
@@ -137,11 +138,13 @@ export const KERNEL_ADDRESSES: {
137
138
  const getKernelInitData = async <entryPoint extends EntryPoint>({
138
139
  entryPoint: entryPointAddress,
139
140
  kernelPluginManager,
140
- initHook
141
+ initHook,
142
+ kernelVersion
141
143
  }: {
142
144
  entryPoint: entryPoint
143
145
  kernelPluginManager: KernelPluginManager<entryPoint>
144
146
  initHook: boolean
147
+ kernelVersion: GetKernelVersion<entryPoint>
145
148
  }) => {
146
149
  const entryPointVersion = getEntryPointVersion(entryPointAddress)
147
150
  const { enableData, identifier, validatorAddress } =
@@ -155,8 +158,24 @@ const getKernelInitData = async <entryPoint extends EntryPoint>({
155
158
  })
156
159
  }
157
160
 
161
+ if (kernelVersion === "0.3.0") {
162
+ return encodeFunctionData({
163
+ abi: KernelV3InitAbi,
164
+ functionName: "initialize",
165
+ args: [
166
+ identifier,
167
+ initHook && kernelPluginManager.hook
168
+ ? kernelPluginManager.hook?.getIdentifier()
169
+ : zeroAddress,
170
+ enableData,
171
+ initHook && kernelPluginManager.hook
172
+ ? await kernelPluginManager.hook?.getEnableData()
173
+ : "0x"
174
+ ]
175
+ })
176
+ }
158
177
  return encodeFunctionData({
159
- abi: KernelV3InitAbi,
178
+ abi: KernelV3_1AccountAbi,
160
179
  functionName: "initialize",
161
180
  args: [
162
181
  identifier,
@@ -166,7 +185,8 @@ const getKernelInitData = async <entryPoint extends EntryPoint>({
166
185
  enableData,
167
186
  initHook && kernelPluginManager.hook
168
187
  ? await kernelPluginManager.hook?.getEnableData()
169
- : "0x"
188
+ : "0x",
189
+ []
170
190
  ]
171
191
  })
172
192
  }
@@ -185,7 +205,8 @@ const getAccountInitCode = async <entryPoint extends EntryPoint>({
185
205
  metaFactoryAddress,
186
206
  entryPoint: entryPointAddress,
187
207
  kernelPluginManager,
188
- initHook
208
+ initHook,
209
+ kernelVersion
189
210
  }: {
190
211
  index: bigint
191
212
  factoryAddress: Address
@@ -194,12 +215,14 @@ const getAccountInitCode = async <entryPoint extends EntryPoint>({
194
215
  entryPoint: entryPoint
195
216
  kernelPluginManager: KernelPluginManager<entryPoint>
196
217
  initHook: boolean
218
+ kernelVersion: GetKernelVersion<entryPoint>
197
219
  }): Promise<Hex> => {
198
220
  // Build the account initialization data
199
221
  const initialisationData = await getKernelInitData<entryPoint>({
200
222
  entryPoint: entryPointAddress,
201
223
  kernelPluginManager,
202
- initHook
224
+ initHook,
225
+ kernelVersion
203
226
  })
204
227
  const entryPointVersion = getEntryPointVersion(entryPointAddress)
205
228
 
@@ -368,7 +391,8 @@ export async function createKernelAccount<
368
391
  metaFactoryAddress,
369
392
  entryPoint: entryPointAddress,
370
393
  kernelPluginManager,
371
- initHook
394
+ initHook,
395
+ kernelVersion
372
396
  })
373
397
  }
374
398
 
@@ -53,7 +53,7 @@ export const accountMetadata = async <
53
53
  } catch (error) {}
54
54
  return {
55
55
  name: KERNEL_NAME,
56
- version: kernelVersion,
56
+ version: kernelVersion === "0.3.0" ? "0.3.0-beta" : kernelVersion,
57
57
  chainId: client.chain
58
58
  ? BigInt(client.chain.id)
59
59
  : BigInt(await client.extend(publicActions).getChainId())
@@ -37,7 +37,7 @@ export const getPluginsEnableTypedData = async <
37
37
  return {
38
38
  domain: {
39
39
  name: "Kernel",
40
- version: kernelVersion,
40
+ version: kernelVersion === "0.3.0" ? "0.3.0-beta" : kernelVersion,
41
41
  chainId,
42
42
  verifyingContract: accountAddress
43
43
  },
@@ -100,11 +100,11 @@ export async function createKernelAccountV1<
100
100
  client: Client<TTransport, TChain, undefined>,
101
101
  {
102
102
  signer,
103
- entrypoint: entryPointAddress,
103
+ entryPoint: entryPointAddress,
104
104
  index = 0n
105
105
  }: {
106
106
  signer: SmartAccountSigner<TSource, TAddress>
107
- entrypoint: entryPoint
107
+ entryPoint: entryPoint
108
108
  index?: bigint
109
109
  }
110
110
  ): Promise<KernelSmartAccountV1<entryPoint, TTransport, TChain>> {
@@ -84,7 +84,8 @@ export async function toKernelPluginManager<
84
84
  entryPointVersion === "v0.7" &&
85
85
  (action.address.toLowerCase() !== zeroAddress.toLowerCase() ||
86
86
  action.selector.toLowerCase() !==
87
- getActionSelector(entryPointVersion).toLowerCase())
87
+ getActionSelector(entryPointVersion).toLowerCase()) &&
88
+ kernelVersion === "0.3.0"
88
89
  ) {
89
90
  action.hook = {
90
91
  address: action.hook?.address ?? ONLY_ENTRYPOINT_HOOK_ADDRESS
@@ -185,7 +186,7 @@ export async function toKernelPluginManager<
185
186
  const typeData = await getPluginsEnableTypedDataV1({
186
187
  accountAddress,
187
188
  chainId,
188
- kernelVersion: kernelVersion ?? version,
189
+ kernelVersion: version ?? kernelVersion,
189
190
  action,
190
191
  validator: regular,
191
192
  validUntil,
@@ -206,6 +207,7 @@ export async function toKernelPluginManager<
206
207
  validatorNonce
207
208
  })
208
209
  ownerSig = await sudo.signTypedData(typedData)
210
+ pluginEnableSignature = ownerSig
209
211
 
210
212
  return ownerSig
211
213
  }
@@ -0,0 +1,99 @@
1
+ import {
2
+ type SendTransactionWithPaymasterParameters,
3
+ sendTransaction
4
+ } from "permissionless/actions/smartAccount"
5
+ import type { EntryPoint, Prettify } from "permissionless/types"
6
+ import {
7
+ AccountOrClientNotFoundError,
8
+ parseAccount
9
+ } from "permissionless/utils"
10
+ import type { Chain, Client, Hash, Hex, Transport } from "viem"
11
+ import { concatHex, encodeFunctionData, getAction, pad } from "viem/utils"
12
+ import type { KernelSmartAccount } from "../../accounts/index.js"
13
+ import { KernelV3AccountAbi } from "../../accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js"
14
+ import { VALIDATOR_TYPE } from "../../constants.js"
15
+ import type {
16
+ KernelValidator,
17
+ KernelValidatorHook
18
+ } from "../../types/kernel.js"
19
+
20
+ export type UninstallPluginParameters<
21
+ entryPoint extends EntryPoint,
22
+ TChain extends Chain | undefined = Chain | undefined,
23
+ TAccount extends KernelSmartAccount<entryPoint> | undefined =
24
+ | KernelSmartAccount<entryPoint>
25
+ | undefined,
26
+ TChainOverride extends Chain | undefined = Chain | undefined
27
+ > = Prettify<
28
+ SendTransactionWithPaymasterParameters<
29
+ entryPoint,
30
+ TChain,
31
+ TAccount,
32
+ TChainOverride
33
+ > & {
34
+ plugin: KernelValidator<entryPoint, string>
35
+ hook?: KernelValidatorHook
36
+ }
37
+ >
38
+
39
+ export async function uninstallPlugin<
40
+ entryPoint extends EntryPoint,
41
+ TTransport extends Transport = Transport,
42
+ TChain extends Chain | undefined = Chain | undefined,
43
+ TAccount extends KernelSmartAccount<entryPoint> | undefined =
44
+ | KernelSmartAccount<entryPoint>
45
+ | undefined,
46
+ TChainOverride extends Chain | undefined = Chain | undefined
47
+ >(
48
+ client: Client<TTransport, TChain, TAccount>,
49
+ args: Prettify<
50
+ UninstallPluginParameters<entryPoint, TChain, TAccount, TChainOverride>
51
+ >
52
+ ): Promise<Hash> {
53
+ const {
54
+ account: account_ = client.account,
55
+ middleware,
56
+ plugin,
57
+ hook
58
+ } = args
59
+ if (!account_) throw new AccountOrClientNotFoundError()
60
+
61
+ const account = parseAccount(account_) as KernelSmartAccount<entryPoint>
62
+
63
+ let validatorId: Hex
64
+ if (
65
+ [VALIDATOR_TYPE.PERMISSION, VALIDATOR_TYPE.SECONDARY].includes(
66
+ VALIDATOR_TYPE[plugin.validatorType]
67
+ )
68
+ ) {
69
+ validatorId = concatHex([
70
+ VALIDATOR_TYPE[plugin.validatorType],
71
+ pad(plugin.getIdentifier(), {
72
+ size: 20,
73
+ dir: "right"
74
+ })
75
+ ])
76
+ } else {
77
+ throw new Error(`Cannot uninstall ${plugin.validatorType} plugin`)
78
+ }
79
+
80
+ const validatorData = await plugin.getEnableData(account.address)
81
+
82
+ const hookData = (await hook?.getEnableData(account.address)) ?? "0x"
83
+ return await getAction(
84
+ client,
85
+ sendTransaction<TChain, TAccount, entryPoint, TChainOverride>,
86
+ "sendTransaction"
87
+ )({
88
+ ...args,
89
+ to: account.address,
90
+ data: encodeFunctionData({
91
+ abi: KernelV3AccountAbi,
92
+ functionName: "uninstallValidation",
93
+ args: [validatorId, validatorData, hookData]
94
+ }),
95
+ value: 0n,
96
+ account,
97
+ middleware
98
+ })
99
+ }
package/actions/index.ts CHANGED
@@ -15,6 +15,11 @@ export {
15
15
  type GetUserOperationGasPriceReturnType
16
16
  } from "./account-client/getUserOperationGasPrice.js"
17
17
 
18
+ export {
19
+ uninstallPlugin,
20
+ type UninstallPluginParameters
21
+ } from "./account-client/uninstallPlugin.js"
22
+
18
23
  export {
19
24
  estimateGasInERC20,
20
25
  type EstimateGasInERC20Parameters,
@@ -1,7 +1,7 @@
1
1
  import { type SmartAccountActions, smartAccountActions } from "permissionless"
2
2
  import type { Middleware } from "permissionless/actions/smartAccount"
3
3
  import type { EntryPoint, Prettify } from "permissionless/types"
4
- import type { Chain, Client, Transport } from "viem"
4
+ import type { Chain, Client, Hash, Transport } from "viem"
5
5
  import type { KernelSmartAccount } from "../../accounts/index.js"
6
6
  import {
7
7
  type GetUserOperationGasPriceReturnType,
@@ -9,9 +9,10 @@ import {
9
9
  } from "../../actions/account-client/getUserOperationGasPrice.js"
10
10
  import type {
11
11
  SignUserOperationParameters,
12
- SignUserOperationReturnType
12
+ SignUserOperationReturnType,
13
+ UninstallPluginParameters
13
14
  } from "../../actions/index.js"
14
- import { signUserOperation } from "../../actions/index.js"
15
+ import { signUserOperation, uninstallPlugin } from "../../actions/index.js"
15
16
  import {
16
17
  type EstimateGasInERC20Parameters,
17
18
  type EstimateGasInERC20ReturnType,
@@ -87,6 +88,24 @@ export type KernelAccountClientActions<
87
88
  getUserOperationGasPrice: () => Promise<
88
89
  Prettify<GetUserOperationGasPriceReturnType>
89
90
  >
91
+ /**
92
+ * Creates, signs, and sends an uninstall kernel plugin transaction to the network.
93
+ * This function also allows you to sponsor this transaction if sender is a smartAccount
94
+ *
95
+ *
96
+ * @param args - {@link UninstallPermissionParameters}
97
+ * @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash. {@link SendTransactionReturnType}
98
+ */
99
+ uninstallPlugin: <
100
+ TChainOverride extends Chain | undefined = Chain | undefined
101
+ >(
102
+ args: UninstallPluginParameters<
103
+ entryPoint,
104
+ TChain,
105
+ TSmartAccount,
106
+ TChainOverride
107
+ >
108
+ ) => Promise<Hash>
90
109
  }
91
110
 
92
111
  export function kernelAccountClientActions<entryPoint extends EntryPoint>({
@@ -110,6 +129,18 @@ export function kernelAccountClientActions<entryPoint extends EntryPoint>({
110
129
  middleware
111
130
  } as SignUserOperationParameters<entryPoint, TSmartAccount>
112
131
  ),
113
- getUserOperationGasPrice: async () => getUserOperationGasPrice(client)
132
+ getUserOperationGasPrice: async () => getUserOperationGasPrice(client),
133
+ uninstallPlugin: async (args) =>
134
+ uninstallPlugin<entryPoint, TTransport, TChain, TSmartAccount>(
135
+ client,
136
+ {
137
+ ...args,
138
+ middleware
139
+ } as UninstallPluginParameters<
140
+ entryPoint,
141
+ TChain,
142
+ TSmartAccount
143
+ >
144
+ )
114
145
  })
115
146
  }
package/constants.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { EntryPointVersion } from "permissionless/types/entrypoint"
2
1
  import { type Address, type Hex, zeroAddress } from "viem"
3
2
  import type {
3
+ KERNEL_V2_VERSION_TYPE,
4
4
  KERNEL_V3_VERSION_TYPE,
5
5
  KERNEL_VERSION_TYPE
6
6
  } from "./types/kernel.js"
@@ -8,14 +8,14 @@ import type {
8
8
  export const DUMMY_ECDSA_SIG =
9
9
  "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"
10
10
 
11
- export const KernelImplToVersionMap: { [key: Address]: string } = {
12
- "0x8dD4DBB54d8A8Cf0DE6F9CCC4609470A30EfF18C": "0.2.2",
13
- "0x0DA6a956B9488eD4dd761E59f52FDc6c8068E6B5": "0.2.2",
14
- "0xD3F582F6B4814E989Ee8E96bc3175320B5A540ab": "0.2.3",
15
- "0x5FC0236D6c88a65beD32EECDC5D60a5CAb377717": "0.2.3",
16
- "0xd3082872F8B06073A021b4602e022d5A070d7cfC": "0.2.4",
17
- "0x94F097E1ebEB4ecA3AAE54cabb08905B239A7D27": "0.3.0-beta"
18
- }
11
+ // export const KernelImplToVersionMap: { [key: Address]: string } = {
12
+ // "0x8dD4DBB54d8A8Cf0DE6F9CCC4609470A30EfF18C": "0.2.2",
13
+ // "0x0DA6a956B9488eD4dd761E59f52FDc6c8068E6B5": "0.2.2",
14
+ // "0xD3F582F6B4814E989Ee8E96bc3175320B5A540ab": "0.2.3",
15
+ // "0x5FC0236D6c88a65beD32EECDC5D60a5CAb377717": "0.2.3",
16
+ // "0xd3082872F8B06073A021b4602e022d5A070d7cfC": "0.2.4",
17
+ // "0x94F097E1ebEB4ecA3AAE54cabb08905B239A7D27": "0.3.0"
18
+ // }
19
19
 
20
20
  export const FACTORY_ADDRESS_V0_6 = "0x5de4839a76cf55d0c90e2061ef4386d962E15ae3"
21
21
  export const FACTORY_ADDRESS_V0_6_INIT_CODE_HASH =
@@ -53,7 +53,7 @@ export const KernelVersionToAddressesMap: {
53
53
  factoryAddress: FACTORY_ADDRESS_V0_6,
54
54
  initCodeHash: FACTORY_ADDRESS_V0_6_INIT_CODE_HASH
55
55
  },
56
- "0.3.0-beta": {
56
+ "0.3.0": {
57
57
  accountImplementationAddress:
58
58
  "0x94F097E1ebEB4ecA3AAE54cabb08905B239A7D27",
59
59
  factoryAddress: "0x6723b44Abeec4E71eBE3232BD5B455805baDD22f",
@@ -63,21 +63,26 @@ export const KernelVersionToAddressesMap: {
63
63
  },
64
64
  "0.3.1": {
65
65
  accountImplementationAddress:
66
- "0x8549e78dF3C7850A7735f04ADbDC8A2962Db1EB8",
67
- factoryAddress: "0x8ba061431fBAF2A766a773A9C044C92d13A07D7e",
66
+ "0xBAC849bB641841b44E965fB01A4Bf5F074f84b4D",
67
+ factoryAddress: "0xaac5D4240AF87249B3f71BC8E4A2cae074A3E419",
68
68
  metaFactoryAddress: "0xd703aaE79538628d27099B8c4f621bE4CCd142d5",
69
69
  initCodeHash:
70
- "0xc5a51f3c59926dfa1c80e5918d287a4d56df9c48ec0e4c5be1a6ca2f6894a58c"
70
+ "0x85d96aa1c9a65886d094915d76ccae85f14027a02c1647dde659f869460f03e6"
71
71
  }
72
72
  }
73
+
74
+ export const KERNEL_V0_2: KERNEL_V2_VERSION_TYPE = "0.0.2"
75
+ export const KERNEL_V2_2: KERNEL_V2_VERSION_TYPE = "0.2.2"
76
+ export const KERNEL_V2_3: KERNEL_V2_VERSION_TYPE = "0.2.3"
77
+ export const KERNEL_V2_4: KERNEL_V2_VERSION_TYPE = "0.2.4"
78
+ export const KERNEL_V3_0: KERNEL_V3_VERSION_TYPE = "0.3.0"
79
+ export const KERNEL_V3_1: KERNEL_V3_VERSION_TYPE = "0.3.1"
80
+
73
81
  export const TOKEN_ACTION = "0x2087C7FfD0d0DAE80a00EE74325aBF3449e0eaf1"
74
82
  export const ONLY_ENTRYPOINT_HOOK_ADDRESS =
75
83
  "0xb230f0A1C7C95fa11001647383c8C7a8F316b900"
76
84
  export const KERNEL_NAME = "Kernel"
77
- export const LATEST_KERNEL_VERSION: { [key in EntryPointVersion]: string } = {
78
- "v0.6": "0.2.4",
79
- "v0.7": "0.3.0-beta"
80
- }
85
+
81
86
  export const VALIDATOR_TYPE = {
82
87
  SUDO: "0x00",
83
88
  SECONDARY: "0x01",
package/index.ts CHANGED
@@ -43,6 +43,7 @@ export {
43
43
  KernelV3ExecuteAbi,
44
44
  KernelV3InitAbi
45
45
  } from "./accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js"
46
+ export { KernelV3_1AccountAbi } from "./accounts/kernel/abi/kernel_v_3_1/KernelAccountAbi.js"
46
47
  export { KernelV3FactoryAbi } from "./accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.js"
47
48
  export { KernelFactoryStakerAbi } from "./accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js"
48
49
  export { TokenActionsAbi } from "./accounts/kernel/abi/TokenActionsAbi.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerodev/sdk",
3
- "version": "5.3.0-alpha-0",
3
+ "version": "5.3.1",
4
4
  "author": "ZeroDev",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
@@ -9,13 +9,7 @@
9
9
  "type": "module",
10
10
  "sideEffects": false,
11
11
  "description": "A utility library for working with ERC-4337",
12
- "keywords": [
13
- "ethereum",
14
- "erc-4337",
15
- "eip-4337",
16
- "paymaster",
17
- "bundler"
18
- ],
12
+ "keywords": ["ethereum", "erc-4337", "eip-4337", "paymaster", "bundler"],
19
13
  "license": "MIT",
20
14
  "files": [
21
15
  "_esm",
@@ -87,38 +81,27 @@
87
81
  "types": "./_types/providers/index.d.ts",
88
82
  "import": "./_esm/providers/index.js",
89
83
  "default": "./_cjs/providers/index.js"
84
+ },
85
+ "./constants": {
86
+ "types": "./_types/constants.d.ts",
87
+ "import": "./_esm/constants.js",
88
+ "default": "./_cjs/constants.js"
90
89
  }
91
90
  },
92
91
  "typesVersions": {
93
92
  "*": {
94
- "accounts": [
95
- "./_types/accounts/index.d.ts"
96
- ],
97
- "plugins": [
98
- "./_types/plugins/index.d.ts"
99
- ],
100
- "actions": [
101
- "./_types/actions/index.d.ts"
102
- ],
103
- "types": [
104
- "./_types/types/index.d.ts"
105
- ],
106
- "actions/kernel": [
107
- "./_types/actions/kernel/index.d.ts"
108
- ],
109
- "clients": [
110
- "./_types/clients/index.d.ts"
111
- ],
112
- "clients/kernel": [
113
- "./_types/clients/kernel/index.d.ts"
114
- ],
115
- "providers": [
116
- "./_types/providers/index.d.ts"
117
- ]
93
+ "accounts": ["./_types/accounts/index.d.ts"],
94
+ "plugins": ["./_types/plugins/index.d.ts"],
95
+ "actions": ["./_types/actions/index.d.ts"],
96
+ "types": ["./_types/types/index.d.ts"],
97
+ "actions/kernel": ["./_types/actions/kernel/index.d.ts"],
98
+ "clients": ["./_types/clients/index.d.ts"],
99
+ "clients/kernel": ["./_types/clients/kernel/index.d.ts"],
100
+ "providers": ["./_types/providers/index.d.ts"]
118
101
  }
119
102
  },
120
103
  "peerDependencies": {
121
- "viem": "^2.9.17",
104
+ "viem": "^2.15.1",
122
105
  "permissionless": "^0.1.18"
123
106
  },
124
107
  "dependencies": {
package/types/kernel.ts CHANGED
@@ -242,7 +242,7 @@ export type Execution = {
242
242
 
243
243
  export type KERNEL_V2_VERSION_TYPE = "0.0.2" | "0.2.2" | "0.2.3" | "0.2.4"
244
244
 
245
- export type KERNEL_V3_VERSION_TYPE = "0.3.0-beta" | "0.3.1"
245
+ export type KERNEL_V3_VERSION_TYPE = "0.3.0" | "0.3.1"
246
246
 
247
247
  export type KERNEL_VERSION_TYPE =
248
248
  | KERNEL_V2_VERSION_TYPE
package/utils.ts CHANGED
@@ -1,8 +1,4 @@
1
- import {
2
- ENTRYPOINT_ADDRESS_V06,
3
- ENTRYPOINT_ADDRESS_V07,
4
- getEntryPointVersion
5
- } from "permissionless"
1
+ import { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 } from "permissionless"
6
2
  import type { EntryPoint } from "permissionless/types/entrypoint"
7
3
  import { satisfies } from "semver"
8
4
  import {
@@ -14,31 +10,12 @@ import {
14
10
  hexToSignature,
15
11
  isHex,
16
12
  pad,
17
- signatureToHex,
18
- zeroAddress
13
+ signatureToHex
19
14
  } from "viem"
20
15
  import type { ZeroDevPaymasterClient } from "./clients/paymasterClient.js"
21
- import {
22
- type CALL_TYPE,
23
- type EXEC_TYPE,
24
- KernelImplToVersionMap,
25
- LATEST_KERNEL_VERSION
26
- } from "./constants.js"
16
+ import type { CALL_TYPE, EXEC_TYPE } from "./constants.js"
27
17
  import type { GetKernelVersion } from "./types/kernel.js"
28
18
 
29
- export const getKernelVersion = <entryPoint extends EntryPoint>(
30
- entryPointAddress: entryPoint,
31
- kernelImpl?: Address
32
- ): string => {
33
- const entryPointVersion = getEntryPointVersion(entryPointAddress)
34
- if (!kernelImpl || kernelImpl === zeroAddress)
35
- return LATEST_KERNEL_VERSION[entryPointVersion]
36
- for (const [addr, ver] of Object.entries(KernelImplToVersionMap)) {
37
- if (addr.toLowerCase() === kernelImpl.toLowerCase()) return ver
38
- }
39
- return "0.2.1"
40
- }
41
-
42
19
  export enum KERNEL_FEATURES {
43
20
  ERC1271_SIG_WRAPPER = "ERC1271_SIG_WRAPPER",
44
21
  ERC1271_WITH_VALIDATOR = "ERC1271_WITH_VALIDATOR",
@@ -136,10 +113,10 @@ export const validateKernelVersionWithEntryPoint = <
136
113
  (entryPointAddress === ENTRYPOINT_ADDRESS_V06 &&
137
114
  !satisfies(kernelVersion, ">=0.2.2 || <=0.2.4")) ||
138
115
  (entryPointAddress === ENTRYPOINT_ADDRESS_V07 &&
139
- !satisfies(kernelVersion, ">=0.3.0-beta"))
116
+ !satisfies(kernelVersion, ">=0.3.0"))
140
117
  ) {
141
118
  throw new Error(
142
- "KernelVersion should be >= 0.2.2 and <= 0.2.4 for EntryPointV0.6 and >= 0.3.0-beta for EntryPointV0.7"
119
+ "KernelVersion should be >= 0.2.2 and <= 0.2.4 for EntryPointV0.6 and >= 0.3.0 for EntryPointV0.7"
143
120
  )
144
121
  }
145
122
  }