@zerodev/sdk 5.1.12 → 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.
- package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js +738 -0
- package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js.map +1 -0
- package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelModuleAbi.js +15 -0
- package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelModuleAbi.js.map +1 -0
- package/_cjs/accounts/kernel/createKernelAccount.js +231 -75
- package/_cjs/accounts/kernel/createKernelAccount.js.map +1 -1
- package/_cjs/accounts/kernel/v1/createKernelV1Account.js +29 -18
- package/_cjs/accounts/kernel/v1/createKernelV1Account.js.map +1 -1
- package/_cjs/accounts/utils/6492.js +19 -3
- package/_cjs/accounts/utils/6492.js.map +1 -1
- package/_cjs/accounts/utils/index.js +4 -3
- package/_cjs/accounts/utils/index.js.map +1 -1
- package/_cjs/accounts/utils/toKernelPluginManager.js +194 -62
- package/_cjs/accounts/utils/toKernelPluginManager.js.map +1 -1
- package/_cjs/actions/account-client/signUserOperation.js +1 -1
- package/_cjs/actions/account-client/signUserOperation.js.map +1 -1
- package/_cjs/actions/paymaster/estimateGasInERC20.js.map +1 -1
- package/_cjs/actions/paymaster/sponsorUserOperation.js +17 -14
- package/_cjs/actions/paymaster/sponsorUserOperation.js.map +1 -1
- package/_cjs/clients/decorators/kernel.js +8 -5
- package/_cjs/clients/decorators/kernel.js.map +1 -1
- package/_cjs/clients/kernelAccountClient.js +3 -3
- package/_cjs/clients/kernelAccountClient.js.map +1 -1
- package/_cjs/clients/paymasterClient.js +1 -1
- package/_cjs/clients/paymasterClient.js.map +1 -1
- package/_cjs/constants.js +28 -3
- package/_cjs/constants.js.map +1 -1
- package/_cjs/index.js +5 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/providers/KernelEIP1193Provider.js.map +1 -1
- package/_cjs/types/kernel.js.map +1 -1
- package/_cjs/utils.js +34 -3
- package/_cjs/utils.js.map +1 -1
- package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js +735 -0
- package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js.map +1 -0
- package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelModuleAbi.js +12 -0
- package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelModuleAbi.js.map +1 -0
- package/_esm/accounts/kernel/createKernelAccount.js +240 -81
- package/_esm/accounts/kernel/createKernelAccount.js.map +1 -1
- package/_esm/accounts/kernel/v1/createKernelV1Account.js +37 -20
- package/_esm/accounts/kernel/v1/createKernelV1Account.js.map +1 -1
- package/_esm/accounts/utils/6492.js +16 -1
- package/_esm/accounts/utils/6492.js.map +1 -1
- package/_esm/accounts/utils/index.js +2 -4
- package/_esm/accounts/utils/index.js.map +1 -1
- package/_esm/accounts/utils/toKernelPluginManager.js +198 -66
- package/_esm/accounts/utils/toKernelPluginManager.js.map +1 -1
- package/_esm/actions/account-client/signUserOperation.js +1 -1
- package/_esm/actions/account-client/signUserOperation.js.map +1 -1
- package/_esm/actions/paymaster/estimateGasInERC20.js.map +1 -1
- package/_esm/actions/paymaster/sponsorUserOperation.js +37 -15
- package/_esm/actions/paymaster/sponsorUserOperation.js.map +1 -1
- package/_esm/clients/decorators/kernel.js +9 -5
- package/_esm/clients/decorators/kernel.js.map +1 -1
- package/_esm/clients/kernelAccountClient.js +3 -3
- package/_esm/clients/kernelAccountClient.js.map +1 -1
- package/_esm/clients/paymasterClient.js +1 -1
- package/_esm/clients/paymasterClient.js.map +1 -1
- package/_esm/constants.js +27 -2
- package/_esm/constants.js.map +1 -1
- package/_esm/index.js +1 -0
- package/_esm/index.js.map +1 -1
- package/_esm/providers/KernelEIP1193Provider.js.map +1 -1
- package/_esm/types/kernel.js +1 -0
- package/_esm/types/kernel.js.map +1 -1
- package/_esm/utils.js +33 -4
- package/_esm/utils.js.map +1 -1
- package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.d.ts +843 -0
- package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.d.ts.map +1 -0
- package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelModuleAbi.d.ts +16 -0
- package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelModuleAbi.d.ts.map +1 -0
- package/_types/accounts/kernel/createKernelAccount.d.ts +14 -11
- package/_types/accounts/kernel/createKernelAccount.d.ts.map +1 -1
- package/_types/accounts/kernel/v1/createKernelV1Account.d.ts +5 -4
- package/_types/accounts/kernel/v1/createKernelV1Account.d.ts.map +1 -1
- package/_types/accounts/utils/6492.d.ts +3 -1
- package/_types/accounts/utils/6492.d.ts.map +1 -1
- package/_types/accounts/utils/index.d.ts +2 -4
- package/_types/accounts/utils/index.d.ts.map +1 -1
- package/_types/accounts/utils/toKernelPluginManager.d.ts +3 -2
- package/_types/accounts/utils/toKernelPluginManager.d.ts.map +1 -1
- package/_types/actions/account-client/signUserOperation.d.ts +7 -7
- package/_types/actions/account-client/signUserOperation.d.ts.map +1 -1
- package/_types/actions/paymaster/estimateGasInERC20.d.ts +3 -2
- package/_types/actions/paymaster/estimateGasInERC20.d.ts.map +1 -1
- package/_types/actions/paymaster/sponsorUserOperation.d.ts +7 -6
- package/_types/actions/paymaster/sponsorUserOperation.d.ts.map +1 -1
- package/_types/clients/decorators/kernel.d.ts +8 -7
- package/_types/clients/decorators/kernel.d.ts.map +1 -1
- package/_types/clients/kernelAccountClient.d.ts +101 -22
- package/_types/clients/kernelAccountClient.d.ts.map +1 -1
- package/_types/clients/paymasterClient.d.ts +6 -3
- package/_types/clients/paymasterClient.d.ts.map +1 -1
- package/_types/constants.d.ts +22 -1
- package/_types/constants.d.ts.map +1 -1
- package/_types/index.d.ts +1 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/providers/KernelEIP1193Provider.d.ts +3 -2
- package/_types/providers/KernelEIP1193Provider.d.ts.map +1 -1
- package/_types/types/kernel.d.ts +44 -12
- package/_types/types/kernel.d.ts.map +1 -1
- package/_types/utils.d.ts +11 -2
- package/_types/utils.d.ts.map +1 -1
- package/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.ts +736 -0
- package/accounts/kernel/abi/kernel_v_3_0_0/KernelModuleAbi.ts +11 -0
- package/accounts/kernel/createKernelAccount.ts +407 -104
- package/accounts/kernel/v1/createKernelV1Account.ts +67 -28
- package/accounts/utils/6492.ts +27 -1
- package/accounts/utils/index.ts +2 -4
- package/accounts/utils/toKernelPluginManager.ts +261 -80
- package/actions/account-client/signUserOperation.ts +25 -13
- package/actions/paymaster/estimateGasInERC20.ts +5 -4
- package/actions/paymaster/sponsorUserOperation.ts +104 -32
- package/clients/decorators/kernel.ts +44 -35
- package/clients/kernelAccountClient.ts +34 -25
- package/clients/paymasterClient.ts +10 -6
- package/constants.ts +25 -2
- package/index.ts +5 -0
- package/package.json +93 -92
- package/providers/KernelEIP1193Provider.ts +6 -3
- package/types/kernel.ts +96 -40
- package/utils.ts +52 -4
package/package.json
CHANGED
|
@@ -1,98 +1,99 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
"exports": {
|
|
46
|
-
".": {
|
|
47
|
-
"types": "./_types/index.d.ts",
|
|
48
|
-
"import": "./_esm/index.js",
|
|
49
|
-
"default": "./_cjs/index.js"
|
|
2
|
+
"name": "@zerodev/sdk",
|
|
3
|
+
"version": "5.2.0-alpha-0",
|
|
4
|
+
"author": "ZeroDev",
|
|
5
|
+
"main": "./_cjs/index.js",
|
|
6
|
+
"module": "./_esm/index.js",
|
|
7
|
+
"types": "./_types/index.d.ts",
|
|
8
|
+
"typings": "./_types/index.d.ts",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"sideEffects": false,
|
|
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
|
+
],
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"files": [
|
|
21
|
+
"_esm",
|
|
22
|
+
"_cjs",
|
|
23
|
+
"_types",
|
|
24
|
+
"./**/*.ts",
|
|
25
|
+
"!_esm/**/*.tsbuildinfo",
|
|
26
|
+
"!_cjs/**/*.tsbuildinfo",
|
|
27
|
+
"!_types/**/*.tsbuildinfo",
|
|
28
|
+
"!.env",
|
|
29
|
+
"!./**/*.test.ts",
|
|
30
|
+
"!.changeset"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "bun run clean && bun run build:cjs && bun run build:esm && bun run build:types",
|
|
34
|
+
"build:cjs": "tsc --project ./tsconfig.build.json --module commonjs --outDir ./_cjs --removeComments --verbatimModuleSyntax false && printf '{\"type\":\"commonjs\"}' > ./_cjs/package.json",
|
|
35
|
+
"build:esm": "tsc --project ./tsconfig.build.json --module es2015 --outDir ./_esm && printf '{\"type\": \"module\",\"sideEffects\":false}' > ./_esm/package.json",
|
|
36
|
+
"build:types": "tsc --project ./tsconfig.build.json --module esnext --declarationDir ./_types --emitDeclarationOnly --declaration --declarationMap",
|
|
37
|
+
"clean": "rimraf _esm _cjs _types",
|
|
38
|
+
"changeset": "changeset",
|
|
39
|
+
"changeset:release": "bun run build && changeset publish",
|
|
40
|
+
"changeset:version": "changeset version && bun install --lockfile-only",
|
|
41
|
+
"format": "biome format . --write",
|
|
42
|
+
"lint": "biome check .",
|
|
43
|
+
"lint:fix": "bun run lint --apply"
|
|
50
44
|
},
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
"exports": {
|
|
46
|
+
".": {
|
|
47
|
+
"types": "./_types/index.d.ts",
|
|
48
|
+
"import": "./_esm/index.js",
|
|
49
|
+
"default": "./_cjs/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./accounts": {
|
|
52
|
+
"types": "./_types/accounts/index.d.ts",
|
|
53
|
+
"import": "./_esm/accounts/index.js",
|
|
54
|
+
"default": "./_cjs/accounts/index.js"
|
|
55
|
+
},
|
|
56
|
+
"./plugins": {
|
|
57
|
+
"types": "./_types/plugins/index.d.ts",
|
|
58
|
+
"import": "./_esm/plugins/index.js",
|
|
59
|
+
"default": "./_cjs/plugins/index.js"
|
|
60
|
+
},
|
|
61
|
+
"./actions": {
|
|
62
|
+
"types": "./_types/actions/index.d.ts",
|
|
63
|
+
"import": "./_esm/actions/index.js",
|
|
64
|
+
"default": "./_cjs/actions/index.js"
|
|
65
|
+
},
|
|
66
|
+
"./types": {
|
|
67
|
+
"types": "./_types/types/index.d.ts",
|
|
68
|
+
"import": "./_esm/types/index.js",
|
|
69
|
+
"default": "./_cjs/types/index.js"
|
|
70
|
+
},
|
|
71
|
+
"./actions/kernel": {
|
|
72
|
+
"types": "./_types/actions/kernel.d.ts",
|
|
73
|
+
"import": "./_esm/actions/kernel.js",
|
|
74
|
+
"default": "./_cjs/actions/kernel.js"
|
|
75
|
+
},
|
|
76
|
+
"./clients": {
|
|
77
|
+
"types": "./_types/clients/index.d.ts",
|
|
78
|
+
"import": "./_esm/clients/index.js",
|
|
79
|
+
"default": "./_cjs/clients/index.js"
|
|
80
|
+
},
|
|
81
|
+
"./clients/kernel": {
|
|
82
|
+
"types": "./_types/clients/kernel.d.ts",
|
|
83
|
+
"import": "./_esm/clients/kernel.js",
|
|
84
|
+
"default": "./_cjs/clients/kernel.js"
|
|
85
|
+
},
|
|
86
|
+
"./providers": {
|
|
87
|
+
"types": "./_types/providers/index.d.ts",
|
|
88
|
+
"import": "./_esm/providers/index.js",
|
|
89
|
+
"default": "./_cjs/providers/index.js"
|
|
90
|
+
}
|
|
55
91
|
},
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
"import": "./_esm/plugins/index.js",
|
|
59
|
-
"default": "./_cjs/plugins/index.js"
|
|
92
|
+
"peerDependencies": {
|
|
93
|
+
"viem": "^2.0.0"
|
|
60
94
|
},
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"default": "./_cjs/actions/index.js"
|
|
65
|
-
},
|
|
66
|
-
"./types": {
|
|
67
|
-
"types": "./_types/types/index.d.ts",
|
|
68
|
-
"import": "./_esm/types/index.js",
|
|
69
|
-
"default": "./_cjs/types/index.js"
|
|
70
|
-
},
|
|
71
|
-
"./actions/kernel": {
|
|
72
|
-
"types": "./_types/actions/kernel.d.ts",
|
|
73
|
-
"import": "./_esm/actions/kernel.js",
|
|
74
|
-
"default": "./_cjs/actions/kernel.js"
|
|
75
|
-
},
|
|
76
|
-
"./clients": {
|
|
77
|
-
"types": "./_types/clients/index.d.ts",
|
|
78
|
-
"import": "./_esm/clients/index.js",
|
|
79
|
-
"default": "./_cjs/clients/index.js"
|
|
80
|
-
},
|
|
81
|
-
"./clients/kernel": {
|
|
82
|
-
"types": "./_types/clients/kernel.d.ts",
|
|
83
|
-
"import": "./_esm/clients/kernel.js",
|
|
84
|
-
"default": "./_cjs/clients/kernel.js"
|
|
85
|
-
},
|
|
86
|
-
"./providers": {
|
|
87
|
-
"types": "./_types/providers/index.d.ts",
|
|
88
|
-
"import": "./_esm/providers/index.js",
|
|
89
|
-
"default": "./_cjs/providers/index.js"
|
|
95
|
+
"dependencies": {
|
|
96
|
+
"semver": "^7.6.0",
|
|
97
|
+
"permissionless": "^0.1.4"
|
|
90
98
|
}
|
|
91
|
-
},
|
|
92
|
-
"peerDependencies": {
|
|
93
|
-
"viem": "^2.0.0"
|
|
94
|
-
},
|
|
95
|
-
"dependencies": {
|
|
96
|
-
"permissionless": "^0.0.34"
|
|
97
|
-
}
|
|
98
99
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from "events"
|
|
2
2
|
import { type KernelAccountClient } from "@zerodev/sdk"
|
|
3
|
+
import type { EntryPoint } from "permissionless/types"
|
|
3
4
|
import {
|
|
4
5
|
type EIP1193Parameters,
|
|
5
6
|
type EIP1193RequestFn,
|
|
@@ -7,10 +8,12 @@ import {
|
|
|
7
8
|
type SendTransactionParameters
|
|
8
9
|
} from "viem"
|
|
9
10
|
|
|
10
|
-
export class KernelEIP1193Provider
|
|
11
|
-
|
|
11
|
+
export class KernelEIP1193Provider<
|
|
12
|
+
entryPoint extends EntryPoint
|
|
13
|
+
> extends EventEmitter {
|
|
14
|
+
private kernelClient: KernelAccountClient<entryPoint>
|
|
12
15
|
|
|
13
|
-
constructor(kernelClient: KernelAccountClient) {
|
|
16
|
+
constructor(kernelClient: KernelAccountClient<entryPoint>) {
|
|
14
17
|
super()
|
|
15
18
|
this.kernelClient = kernelClient
|
|
16
19
|
}
|
package/types/kernel.ts
CHANGED
|
@@ -1,22 +1,33 @@
|
|
|
1
|
+
import type { EntryPoint } from "permissionless/types"
|
|
2
|
+
import type { GetEntryPointVersion } from "permissionless/types/entrypoint"
|
|
1
3
|
import type {
|
|
2
4
|
UserOperation,
|
|
3
5
|
UserOperationWithBigIntAsHex
|
|
4
6
|
} from "permissionless/types/userOperation"
|
|
5
7
|
import { type Address, type Hex, type LocalAccount } from "viem"
|
|
6
8
|
import type { PartialBy } from "viem/types/utils"
|
|
7
|
-
|
|
9
|
+
import { VALIDATOR_TYPE } from "../constants.js"
|
|
10
|
+
export type ZeroDevPaymasterRpcSchema<entryPoint extends EntryPoint> = [
|
|
8
11
|
{
|
|
9
12
|
Method: "zd_sponsorUserOperation"
|
|
10
13
|
Parameters: [
|
|
11
14
|
{
|
|
12
15
|
chainId: number
|
|
13
|
-
userOp:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
userOp: GetEntryPointVersion<entryPoint> extends "v0.6"
|
|
17
|
+
? PartialBy<
|
|
18
|
+
UserOperationWithBigIntAsHex<"v0.6">,
|
|
19
|
+
| "callGasLimit"
|
|
20
|
+
| "preVerificationGas"
|
|
21
|
+
| "verificationGasLimit"
|
|
22
|
+
>
|
|
23
|
+
: PartialBy<
|
|
24
|
+
UserOperationWithBigIntAsHex<"v0.7">,
|
|
25
|
+
| "callGasLimit"
|
|
26
|
+
| "preVerificationGas"
|
|
27
|
+
| "verificationGasLimit"
|
|
28
|
+
| "paymasterVerificationGasLimit"
|
|
29
|
+
| "paymasterPostOpGasLimit"
|
|
30
|
+
>
|
|
20
31
|
entryPointAddress: Address
|
|
21
32
|
gasTokenData?: {
|
|
22
33
|
tokenAddress: Hex
|
|
@@ -26,14 +37,29 @@ export type ZeroDevPaymasterRpcSchema = [
|
|
|
26
37
|
shouldConsume?: boolean
|
|
27
38
|
}
|
|
28
39
|
]
|
|
29
|
-
ReturnType:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
ReturnType: GetEntryPointVersion<entryPoint> extends "v0.6"
|
|
41
|
+
? {
|
|
42
|
+
paymasterAndData: Hex
|
|
43
|
+
preVerificationGas: Hex
|
|
44
|
+
verificationGasLimit: Hex
|
|
45
|
+
callGasLimit: Hex
|
|
46
|
+
maxFeePerGas: Hex
|
|
47
|
+
maxPriorityFeePerGas: Hex
|
|
48
|
+
paymaster?: never
|
|
49
|
+
paymasterVerificationGasLimit?: never
|
|
50
|
+
paymasterPostOpGasLimit?: never
|
|
51
|
+
paymasterData?: never
|
|
52
|
+
}
|
|
53
|
+
: {
|
|
54
|
+
preVerificationGas: Hex
|
|
55
|
+
verificationGasLimit: Hex
|
|
56
|
+
callGasLimit: Hex
|
|
57
|
+
paymaster: Address
|
|
58
|
+
paymasterVerificationGasLimit: Hex
|
|
59
|
+
paymasterPostOpGasLimit: Hex
|
|
60
|
+
paymasterData: Hex
|
|
61
|
+
paymasterAndData?: never
|
|
62
|
+
}
|
|
37
63
|
},
|
|
38
64
|
{
|
|
39
65
|
Method: "zd_pm_accounts"
|
|
@@ -50,7 +76,7 @@ export type ZeroDevPaymasterRpcSchema = [
|
|
|
50
76
|
Parameters: [
|
|
51
77
|
{
|
|
52
78
|
chainId: number
|
|
53
|
-
userOp: UserOperationWithBigIntAsHex
|
|
79
|
+
userOp: UserOperationWithBigIntAsHex<"v0.6">
|
|
54
80
|
entryPointAddress: Address
|
|
55
81
|
tokenAddress: Address
|
|
56
82
|
}
|
|
@@ -62,39 +88,63 @@ export type ZeroDevPaymasterRpcSchema = [
|
|
|
62
88
|
}
|
|
63
89
|
]
|
|
64
90
|
|
|
65
|
-
export type
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
91
|
+
export type ValidatorType = keyof typeof VALIDATOR_TYPE
|
|
92
|
+
|
|
93
|
+
export type KernelValidator<
|
|
94
|
+
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
|
+
}
|
|
79
127
|
|
|
80
128
|
export type ValidatorInitData = {
|
|
81
129
|
validatorAddress: Address
|
|
82
130
|
enableData: Hex
|
|
83
131
|
}
|
|
84
132
|
|
|
85
|
-
export type KernelPluginManager
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
133
|
+
export type KernelPluginManager<entryPoint extends EntryPoint> =
|
|
134
|
+
KernelValidator<entryPoint> & {
|
|
135
|
+
getPluginEnableSignature(accountAddress: Address): Promise<Hex>
|
|
136
|
+
getValidatorInitData(): Promise<ValidatorInitData>
|
|
137
|
+
getExecutorData(): ExecutorData
|
|
138
|
+
getValidityData(): PluginValidityData
|
|
139
|
+
}
|
|
91
140
|
|
|
92
|
-
export type KernelPluginManagerParams = {
|
|
93
|
-
sudo?: KernelValidator
|
|
94
|
-
regular?: KernelValidator
|
|
141
|
+
export type KernelPluginManagerParams<entryPoint extends EntryPoint> = {
|
|
142
|
+
sudo?: KernelValidator<entryPoint>
|
|
143
|
+
regular?: KernelValidator<entryPoint>
|
|
95
144
|
pluginEnableSignature?: Hex
|
|
96
145
|
validatorInitData?: ValidatorInitData
|
|
97
146
|
executorData?: ExecutorData
|
|
147
|
+
entryPoint: entryPoint
|
|
98
148
|
} & Partial<PluginValidityData>
|
|
99
149
|
|
|
100
150
|
export type ExecutorData = {
|
|
@@ -128,3 +178,9 @@ export type KernelEncodeCallDataArgs =
|
|
|
128
178
|
data: Hex
|
|
129
179
|
callType: CallType | undefined
|
|
130
180
|
}[]
|
|
181
|
+
|
|
182
|
+
export type Execution = {
|
|
183
|
+
target: Address
|
|
184
|
+
value: bigint
|
|
185
|
+
callData: Hex
|
|
186
|
+
}
|
package/utils.ts
CHANGED
|
@@ -1,27 +1,65 @@
|
|
|
1
|
+
import { getEntryPointVersion } from "permissionless"
|
|
2
|
+
import type { EntryPoint } from "permissionless/types/entrypoint"
|
|
3
|
+
import { satisfies } from "semver"
|
|
1
4
|
import {
|
|
2
5
|
type Address,
|
|
3
6
|
type Hex,
|
|
7
|
+
concatHex,
|
|
4
8
|
encodeFunctionData,
|
|
5
9
|
erc20Abi,
|
|
6
10
|
hexToSignature,
|
|
7
11
|
isHex,
|
|
12
|
+
pad,
|
|
8
13
|
signatureToHex,
|
|
9
14
|
zeroAddress
|
|
10
15
|
} from "viem"
|
|
11
16
|
import { KERNEL_ADDRESSES } from "./accounts/index.js"
|
|
12
17
|
import type { ZeroDevPaymasterClient } from "./clients/paymasterClient.js"
|
|
13
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
CALL_TYPE,
|
|
20
|
+
EXEC_TYPE,
|
|
21
|
+
KernelImplToVersionMap,
|
|
22
|
+
LATEST_KERNEL_VERSION
|
|
23
|
+
} from "./constants.js"
|
|
14
24
|
|
|
15
|
-
export const getKernelVersion =
|
|
16
|
-
|
|
25
|
+
export const getKernelVersion = <entryPoint extends EntryPoint>(
|
|
26
|
+
entryPointAddress: entryPoint,
|
|
27
|
+
kernelImpl?: Address
|
|
28
|
+
): string => {
|
|
29
|
+
const entryPointVersion = getEntryPointVersion(entryPointAddress)
|
|
30
|
+
if (!kernelImpl || kernelImpl === zeroAddress)
|
|
31
|
+
return LATEST_KERNEL_VERSION[entryPointVersion]
|
|
17
32
|
for (const [addr, ver] of Object.entries(KernelImplToVersionMap)) {
|
|
18
33
|
if (addr.toLowerCase() === kernelImpl.toLowerCase()) return ver
|
|
19
34
|
}
|
|
20
35
|
return "0.2.1"
|
|
21
36
|
}
|
|
22
37
|
|
|
38
|
+
export enum KERNEL_FEATURES {
|
|
39
|
+
ERC1271_SIG_WRAPPER = "ERC1271_SIG_WRAPPER",
|
|
40
|
+
ERC1271_WITH_VALIDATOR = "ERC1271_WITH_VALIDATOR",
|
|
41
|
+
ERC1271_SIG_WRAPPER_WITH_WRAPPED_HASH = "ERC1271_SIG_WRAPPER_WITH_WRAPPED_HASH"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const KERNEL_FEATURES_BY_VERSION: Record<KERNEL_FEATURES, string> = {
|
|
45
|
+
[KERNEL_FEATURES.ERC1271_SIG_WRAPPER]: ">=0.2.3 || >=0.3.0-beta",
|
|
46
|
+
[KERNEL_FEATURES.ERC1271_WITH_VALIDATOR]: ">=0.3.0-beta",
|
|
47
|
+
[KERNEL_FEATURES.ERC1271_SIG_WRAPPER_WITH_WRAPPED_HASH]: ">=0.3.0-beta"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const hasKernelFeature = (
|
|
51
|
+
feature: KERNEL_FEATURES,
|
|
52
|
+
version: string
|
|
53
|
+
): boolean => {
|
|
54
|
+
if (!(feature in KERNEL_FEATURES_BY_VERSION)) {
|
|
55
|
+
return false
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return satisfies(version, KERNEL_FEATURES_BY_VERSION[feature])
|
|
59
|
+
}
|
|
60
|
+
|
|
23
61
|
export const getERC20PaymasterApproveCall = async (
|
|
24
|
-
client: ZeroDevPaymasterClient
|
|
62
|
+
client: ZeroDevPaymasterClient<EntryPoint>,
|
|
25
63
|
{
|
|
26
64
|
gasToken,
|
|
27
65
|
approveAmount
|
|
@@ -64,3 +102,13 @@ export const fixSignedData = (sig: Hex): Hex => {
|
|
|
64
102
|
const joined = signatureToHex({ r, s, v })
|
|
65
103
|
return joined
|
|
66
104
|
}
|
|
105
|
+
|
|
106
|
+
export const getExecMode = (callType: CALL_TYPE, execType: EXEC_TYPE): Hex => {
|
|
107
|
+
return concatHex([
|
|
108
|
+
callType, // 1 byte
|
|
109
|
+
execType, // 1 byte
|
|
110
|
+
"0x00000000", // 4 bytes
|
|
111
|
+
"0x00000000", // 4 bytes
|
|
112
|
+
pad("0x00000000", { size: 22 })
|
|
113
|
+
])
|
|
114
|
+
}
|