@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.
- package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.js +39 -0
- package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.js.map +1 -0
- package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js +203 -0
- package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js.map +1 -0
- package/_cjs/accounts/kernel/createKernelAccount.js +35 -10
- package/_cjs/accounts/kernel/createKernelAccount.js.map +1 -1
- package/_cjs/accounts/utils/toKernelPluginManager.js +1 -1
- package/_cjs/accounts/utils/toKernelPluginManager.js.map +1 -1
- package/_cjs/actions/paymaster/estimateGasInERC20.js +2 -2
- package/_cjs/actions/paymaster/estimateGasInERC20.js.map +1 -1
- package/_cjs/clients/decorators/kernel.js.map +1 -1
- package/_cjs/clients/kernelAccountClient.js +3 -4
- package/_cjs/clients/kernelAccountClient.js.map +1 -1
- package/_cjs/constants.js +1 -1
- package/_cjs/index.js +5 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/utils.js +1 -2
- package/_cjs/utils.js.map +1 -1
- package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.js +36 -0
- package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.js.map +1 -0
- package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js +200 -0
- package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.js.map +1 -0
- package/_esm/accounts/kernel/createKernelAccount.js +36 -11
- package/_esm/accounts/kernel/createKernelAccount.js.map +1 -1
- package/_esm/accounts/utils/toKernelPluginManager.js +1 -1
- package/_esm/accounts/utils/toKernelPluginManager.js.map +1 -1
- package/_esm/actions/paymaster/estimateGasInERC20.js +2 -2
- package/_esm/actions/paymaster/estimateGasInERC20.js.map +1 -1
- package/_esm/clients/decorators/kernel.js.map +1 -1
- package/_esm/clients/kernelAccountClient.js +3 -4
- package/_esm/clients/kernelAccountClient.js.map +1 -1
- package/_esm/constants.js +1 -1
- package/_esm/index.js +2 -0
- package/_esm/index.js.map +1 -1
- package/_esm/utils.js +2 -3
- package/_esm/utils.js.map +1 -1
- package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.d.ts +60 -0
- package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.d.ts.map +1 -0
- package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.d.ts +215 -0
- package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.d.ts.map +1 -0
- package/_types/accounts/kernel/createKernelAccount.d.ts +5 -3
- package/_types/accounts/kernel/createKernelAccount.d.ts.map +1 -1
- package/_types/actions/paymaster/estimateGasInERC20.d.ts.map +1 -1
- package/_types/clients/decorators/kernel.d.ts.map +1 -1
- package/_types/clients/kernelAccountClient.d.ts.map +1 -1
- package/_types/index.d.ts +2 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/utils.d.ts.map +1 -1
- package/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryAbi.ts +35 -0
- package/accounts/kernel/abi/kernel_v_3_0_0/KernelFactoryStakerAbi.ts +199 -0
- package/accounts/kernel/createKernelAccount.ts +45 -12
- package/accounts/utils/toKernelPluginManager.ts +1 -1
- package/actions/paymaster/estimateGasInERC20.ts +2 -3
- package/clients/decorators/kernel.ts +7 -4
- package/clients/kernelAccountClient.ts +3 -4
- package/constants.ts +1 -1
- package/index.ts +2 -0
- package/package.json +1 -1
- 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
|
-
|
|
116
|
-
|
|
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: "
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
197
|
+
factoryStakerAddress,
|
|
179
198
|
encodeFunctionData({
|
|
180
|
-
abi:
|
|
181
|
-
functionName: "
|
|
182
|
-
args: [
|
|
183
|
-
|
|
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.
|
|
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
|
-
|
|
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:
|
|
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
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
89
|
-
|
|
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
|
-
"
|
|
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
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:
|
|
75
|
+
entryPointAddress: ENTRYPOINT_ADDRESS_V06
|
|
77
76
|
}
|
|
78
77
|
]
|
|
79
78
|
})
|