@zerodev/sdk 5.2.0-alpha-4 → 5.2.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 +115 -58
- package/_cjs/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.js.map +1 -1
- 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 +42 -22
- package/_cjs/accounts/kernel/createKernelAccount.js.map +1 -1
- package/_cjs/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.js +22 -0
- package/_cjs/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.js.map +1 -0
- package/_cjs/accounts/kernel/utils/common/getActionSelector.js +19 -0
- package/_cjs/accounts/kernel/utils/common/getActionSelector.js.map +1 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js +22 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js.map +1 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js +39 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js.map +1 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.js +21 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.js.map +1 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js +41 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js.map +1 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.js +20 -0
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.js.map +1 -0
- package/_cjs/accounts/kernel/v1/createKernelV1Account.js +4 -2
- package/_cjs/accounts/kernel/v1/createKernelV1Account.js.map +1 -1
- package/_cjs/accounts/kernel/v2/createKernelV2Account.js +9 -4
- package/_cjs/accounts/kernel/v2/createKernelV2Account.js.map +1 -1
- package/_cjs/accounts/utils/getCustomNonceKeyFromString.js +19 -0
- package/_cjs/accounts/utils/getCustomNonceKeyFromString.js.map +1 -0
- package/_cjs/accounts/utils/index.js +3 -1
- package/_cjs/accounts/utils/index.js.map +1 -1
- package/_cjs/accounts/utils/toKernelPluginManager.js +120 -184
- package/_cjs/accounts/utils/toKernelPluginManager.js.map +1 -1
- package/_cjs/actions/account-client/getUserOperationGasPrice.js +15 -0
- package/_cjs/actions/account-client/getUserOperationGasPrice.js.map +1 -0
- package/_cjs/actions/index.js +3 -1
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/paymaster/estimateGasInERC20.js +2 -2
- package/_cjs/actions/paymaster/estimateGasInERC20.js.map +1 -1
- package/_cjs/actions/paymaster/sponsorUserOperation.js +1 -2
- package/_cjs/actions/paymaster/sponsorUserOperation.js.map +1 -1
- package/_cjs/clients/decorators/kernel.js +3 -1
- package/_cjs/clients/decorators/kernel.js.map +1 -1
- package/_cjs/clients/kernelAccountClient.js +29 -3
- package/_cjs/clients/kernelAccountClient.js.map +1 -1
- package/_cjs/clients/paymasterClient.js +18 -1
- package/_cjs/clients/paymasterClient.js.map +1 -1
- package/_cjs/clients/utils.js +31 -0
- package/_cjs/clients/utils.js.map +1 -0
- package/_cjs/constants.js +5 -2
- package/_cjs/constants.js.map +1 -1
- package/_cjs/index.js +6 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/providers/KernelEIP1193Provider.js +37 -0
- package/_cjs/providers/KernelEIP1193Provider.js.map +1 -1
- package/_cjs/types/index.js.map +1 -1
- package/_cjs/types/kernel.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/KernelAccountAbi.js +115 -58
- package/_esm/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.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 +43 -23
- package/_esm/accounts/kernel/createKernelAccount.js.map +1 -1
- package/_esm/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.js +18 -0
- package/_esm/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.js.map +1 -0
- package/_esm/accounts/kernel/utils/common/getActionSelector.js +15 -0
- package/_esm/accounts/kernel/utils/common/getActionSelector.js.map +1 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js +18 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.js.map +1 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js +35 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.js.map +1 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.js +18 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.js.map +1 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js +42 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.js.map +1 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.js +16 -0
- package/_esm/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.js.map +1 -0
- package/_esm/accounts/kernel/v1/createKernelV1Account.js +5 -3
- package/_esm/accounts/kernel/v1/createKernelV1Account.js.map +1 -1
- package/_esm/accounts/kernel/v2/createKernelV2Account.js +10 -5
- package/_esm/accounts/kernel/v2/createKernelV2Account.js.map +1 -1
- package/_esm/accounts/utils/getCustomNonceKeyFromString.js +15 -0
- package/_esm/accounts/utils/getCustomNonceKeyFromString.js.map +1 -0
- package/_esm/accounts/utils/index.js +1 -0
- package/_esm/accounts/utils/index.js.map +1 -1
- package/_esm/accounts/utils/toKernelPluginManager.js +124 -188
- package/_esm/accounts/utils/toKernelPluginManager.js.map +1 -1
- package/_esm/actions/account-client/getUserOperationGasPrice.js +11 -0
- package/_esm/actions/account-client/getUserOperationGasPrice.js.map +1 -0
- package/_esm/actions/index.js +1 -0
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/paymaster/estimateGasInERC20.js +2 -2
- package/_esm/actions/paymaster/estimateGasInERC20.js.map +1 -1
- package/_esm/actions/paymaster/sponsorUserOperation.js +1 -2
- package/_esm/actions/paymaster/sponsorUserOperation.js.map +1 -1
- package/_esm/clients/decorators/kernel.js +3 -1
- package/_esm/clients/decorators/kernel.js.map +1 -1
- package/_esm/clients/kernelAccountClient.js +30 -4
- package/_esm/clients/kernelAccountClient.js.map +1 -1
- package/_esm/clients/paymasterClient.js +19 -2
- package/_esm/clients/paymasterClient.js.map +1 -1
- package/_esm/clients/utils.js +26 -0
- package/_esm/clients/utils.js.map +1 -0
- package/_esm/constants.js +4 -1
- package/_esm/constants.js.map +1 -1
- package/_esm/index.js +3 -1
- package/_esm/index.js.map +1 -1
- package/_esm/providers/KernelEIP1193Provider.js +37 -0
- package/_esm/providers/KernelEIP1193Provider.js.map +1 -1
- package/_esm/types/index.js.map +1 -1
- package/_esm/types/kernel.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/KernelAccountAbi.d.ts +110 -20
- package/_types/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.d.ts.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 +7 -4
- package/_types/accounts/kernel/createKernelAccount.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.d.ts +3 -0
- package/_types/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/common/getActionSelector.d.ts +4 -0
- package/_types/accounts/kernel/utils/common/getActionSelector.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.d.ts +9 -0
- package/_types/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.d.ts +13 -0
- package/_types/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.d.ts +9 -0
- package/_types/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.d.ts +10 -0
- package/_types/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.d.ts +3 -0
- package/_types/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.d.ts.map +1 -0
- package/_types/accounts/kernel/v1/createKernelV1Account.d.ts +1 -1
- package/_types/accounts/kernel/v1/createKernelV1Account.d.ts.map +1 -1
- package/_types/accounts/kernel/v2/createKernelV2Account.d.ts +3 -1
- package/_types/accounts/kernel/v2/createKernelV2Account.d.ts.map +1 -1
- package/_types/accounts/utils/getCustomNonceKeyFromString.d.ts +3 -0
- package/_types/accounts/utils/getCustomNonceKeyFromString.d.ts.map +1 -0
- package/_types/accounts/utils/index.d.ts +1 -0
- package/_types/accounts/utils/index.d.ts.map +1 -1
- package/_types/accounts/utils/toKernelPluginManager.d.ts +1 -1
- package/_types/accounts/utils/toKernelPluginManager.d.ts.map +1 -1
- package/_types/actions/account-client/getUserOperationGasPrice.d.ts +9 -0
- package/_types/actions/account-client/getUserOperationGasPrice.d.ts.map +1 -0
- package/_types/actions/index.d.ts +1 -0
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/actions/paymaster/estimateGasInERC20.d.ts.map +1 -1
- package/_types/actions/paymaster/sponsorUserOperation.d.ts.map +1 -1
- package/_types/clients/decorators/kernel.d.ts +8 -1
- package/_types/clients/decorators/kernel.d.ts.map +1 -1
- package/_types/clients/kernelAccountClient.d.ts +12 -4
- package/_types/clients/kernelAccountClient.d.ts.map +1 -1
- package/_types/clients/paymasterClient.d.ts.map +1 -1
- package/_types/clients/utils.d.ts +3 -0
- package/_types/clients/utils.d.ts.map +1 -0
- package/_types/constants.d.ts +4 -1
- package/_types/constants.d.ts.map +1 -1
- package/_types/index.d.ts +3 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/providers/KernelEIP1193Provider.d.ts +2 -0
- package/_types/providers/KernelEIP1193Provider.d.ts.map +1 -1
- package/_types/types/index.d.ts +1 -1
- package/_types/types/index.d.ts.map +1 -1
- package/_types/types/kernel.d.ts +32 -17
- package/_types/types/kernel.d.ts.map +1 -1
- package/_types/utils.d.ts.map +1 -1
- package/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.ts +115 -58
- 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 +57 -26
- package/accounts/kernel/utils/account/ep0_7/getKernelV3Nonce.ts +24 -0
- package/accounts/kernel/utils/common/getActionSelector.ts +20 -0
- package/accounts/kernel/utils/plugins/ep0_6/getEncodedPluginsData.ts +39 -0
- package/accounts/kernel/utils/plugins/ep0_6/getPluginsEnableTypedData.ts +76 -0
- package/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.ts +47 -0
- package/accounts/kernel/utils/plugins/ep0_7/getPluginsEnableTypedData.ts +63 -0
- package/accounts/kernel/utils/plugins/ep0_7/isPluginInitialized.ts +23 -0
- package/accounts/kernel/v1/createKernelV1Account.ts +20 -8
- package/accounts/kernel/v2/createKernelV2Account.ts +17 -6
- package/accounts/utils/getCustomNonceKeyFromString.ts +21 -0
- package/accounts/utils/index.ts +2 -0
- package/accounts/utils/toKernelPluginManager.ts +155 -224
- package/actions/account-client/getUserOperationGasPrice.ts +26 -0
- package/actions/index.ts +5 -0
- package/actions/paymaster/estimateGasInERC20.ts +2 -3
- package/actions/paymaster/sponsorUserOperation.ts +1 -3
- package/clients/decorators/kernel.ts +22 -6
- package/clients/kernelAccountClient.ts +36 -3
- package/clients/paymasterClient.ts +24 -1
- package/clients/utils.ts +28 -0
- package/constants.ts +6 -2
- package/index.ts +6 -1
- package/package.json +4 -4
- package/providers/KernelEIP1193Provider.ts +51 -0
- package/types/index.ts +4 -2
- package/types/kernel.ts +52 -38
- package/utils.ts +2 -3
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { getEntryPointVersion } from "permissionless"
|
|
1
2
|
import type { SmartAccount } from "permissionless/accounts/types"
|
|
2
3
|
import type { Middleware } from "permissionless/actions/smartAccount"
|
|
3
4
|
import type { EntryPoint, Prettify } from "permissionless/types"
|
|
4
5
|
import type { BundlerRpcSchema } from "permissionless/types/bundler"
|
|
5
6
|
import {
|
|
7
|
+
http,
|
|
6
8
|
type Chain,
|
|
7
9
|
type Client,
|
|
8
10
|
type ClientConfig,
|
|
@@ -10,10 +12,12 @@ import {
|
|
|
10
12
|
createClient
|
|
11
13
|
} from "viem"
|
|
12
14
|
import { type KernelSmartAccount } from "../accounts/index.js"
|
|
15
|
+
import { getUserOperationGasPrice } from "../actions/account-client/getUserOperationGasPrice.js"
|
|
13
16
|
import {
|
|
14
17
|
type KernelAccountClientActions,
|
|
15
18
|
kernelAccountClientActions
|
|
16
19
|
} from "./decorators/kernel.js"
|
|
20
|
+
import { hasPimlicoAsProvider, setPimlicoAsProvider } from "./utils.js"
|
|
17
21
|
|
|
18
22
|
export type KernelAccountClient<
|
|
19
23
|
entryPoint extends EntryPoint,
|
|
@@ -69,19 +73,48 @@ export const createKernelAccountClient = <
|
|
|
69
73
|
const {
|
|
70
74
|
key = "Account",
|
|
71
75
|
name = "Kernel Account Client",
|
|
72
|
-
bundlerTransport
|
|
76
|
+
bundlerTransport,
|
|
77
|
+
entryPoint
|
|
73
78
|
} = parameters
|
|
79
|
+
const entryPointVersion = getEntryPointVersion(entryPoint)
|
|
80
|
+
const shouldIncludePimlicoProvider =
|
|
81
|
+
bundlerTransport({}).config.key === "http" &&
|
|
82
|
+
entryPointVersion === "v0.7"
|
|
83
|
+
|
|
74
84
|
const client = createClient({
|
|
75
85
|
...parameters,
|
|
76
86
|
key,
|
|
77
87
|
name,
|
|
78
|
-
transport: (opts) =>
|
|
88
|
+
transport: (opts) => {
|
|
89
|
+
let _bundlerTransport = bundlerTransport({
|
|
90
|
+
...opts,
|
|
91
|
+
retryCount: 0
|
|
92
|
+
})
|
|
93
|
+
if (!shouldIncludePimlicoProvider) return _bundlerTransport
|
|
94
|
+
_bundlerTransport = http(
|
|
95
|
+
setPimlicoAsProvider(_bundlerTransport.value?.url)
|
|
96
|
+
)({ ...opts, retryCount: 0 })
|
|
97
|
+
return _bundlerTransport
|
|
98
|
+
},
|
|
79
99
|
type: "kernelAccountClient"
|
|
80
100
|
})
|
|
81
101
|
|
|
102
|
+
let middleware = parameters.middleware
|
|
103
|
+
if (
|
|
104
|
+
(!middleware ||
|
|
105
|
+
(typeof middleware !== "function" && !middleware.gasPrice)) &&
|
|
106
|
+
client.transport?.url &&
|
|
107
|
+
hasPimlicoAsProvider(client.transport.url)
|
|
108
|
+
) {
|
|
109
|
+
const gasPrice = () => getUserOperationGasPrice(client)
|
|
110
|
+
middleware = {
|
|
111
|
+
...middleware,
|
|
112
|
+
gasPrice
|
|
113
|
+
}
|
|
114
|
+
}
|
|
82
115
|
return client.extend(
|
|
83
116
|
kernelAccountClientActions({
|
|
84
|
-
middleware
|
|
117
|
+
middleware
|
|
85
118
|
})
|
|
86
119
|
) as KernelAccountClient<entryPoint, TTransport, TChain, TSmartAccount>
|
|
87
120
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { getEntryPointVersion } from "permissionless"
|
|
1
2
|
import type { EntryPoint } from "permissionless/types/entrypoint"
|
|
2
3
|
import {
|
|
4
|
+
http,
|
|
3
5
|
type Account,
|
|
4
6
|
type Chain,
|
|
5
7
|
type Client,
|
|
@@ -12,6 +14,7 @@ import {
|
|
|
12
14
|
type ZeroDevPaymasterClientActions,
|
|
13
15
|
zerodevPaymasterActions
|
|
14
16
|
} from "./decorators/kernel.js"
|
|
17
|
+
import { setPimlicoAsProvider } from "./utils.js"
|
|
15
18
|
|
|
16
19
|
export type ZeroDevPaymasterClient<entryPoint extends EntryPoint> = Client<
|
|
17
20
|
Transport,
|
|
@@ -46,9 +49,29 @@ export const createZeroDevPaymasterClient = <
|
|
|
46
49
|
entryPoint: entryPoint
|
|
47
50
|
}
|
|
48
51
|
): ZeroDevPaymasterClient<entryPoint> => {
|
|
49
|
-
const {
|
|
52
|
+
const {
|
|
53
|
+
key = "public",
|
|
54
|
+
name = "ZeroDev Paymaster Client",
|
|
55
|
+
entryPoint: entryPointAddress,
|
|
56
|
+
transport
|
|
57
|
+
} = parameters
|
|
58
|
+
const entryPointVersion = getEntryPointVersion(entryPointAddress)
|
|
59
|
+
const shouldIncludePimlicoProvider =
|
|
60
|
+
transport({}).config.key === "http" && entryPointVersion === "v0.7"
|
|
50
61
|
const client = createClient({
|
|
51
62
|
...parameters,
|
|
63
|
+
transport: (opts) => {
|
|
64
|
+
let _transport = transport({
|
|
65
|
+
...opts,
|
|
66
|
+
retryCount: 0
|
|
67
|
+
})
|
|
68
|
+
if (!shouldIncludePimlicoProvider) return _transport
|
|
69
|
+
_transport = http(setPimlicoAsProvider(_transport.value?.url))({
|
|
70
|
+
...opts,
|
|
71
|
+
retryCount: 0
|
|
72
|
+
})
|
|
73
|
+
return _transport
|
|
74
|
+
},
|
|
52
75
|
key,
|
|
53
76
|
name,
|
|
54
77
|
type: "zerodevPaymasterClient"
|
package/clients/utils.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const setPimlicoAsProvider = (urlString: string): string => {
|
|
2
|
+
const url = new URL(urlString)
|
|
3
|
+
|
|
4
|
+
const params = url.searchParams
|
|
5
|
+
|
|
6
|
+
if (params.has("bundlerProvider")) {
|
|
7
|
+
params.set("bundlerProvider", "PIMLICO")
|
|
8
|
+
} else if (params.has("paymasterProvider")) {
|
|
9
|
+
params.set("paymasterProvider", "PIMLICO")
|
|
10
|
+
} else {
|
|
11
|
+
params.set("provider", "PIMLICO")
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
url.search = params.toString()
|
|
15
|
+
|
|
16
|
+
return url.toString()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const hasPimlicoAsProvider = (urlString: string): boolean => {
|
|
20
|
+
const url = new URL(urlString)
|
|
21
|
+
const params = url.searchParams
|
|
22
|
+
const provider =
|
|
23
|
+
params.get("provider") ??
|
|
24
|
+
params.get("bundlerProvider") ??
|
|
25
|
+
params.get("paymasterProvider")
|
|
26
|
+
if (provider === "PIMLICO") return true
|
|
27
|
+
return false
|
|
28
|
+
}
|
package/constants.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EntryPointVersion } from "permissionless/types/entrypoint"
|
|
2
|
-
import { type Address } from "viem"
|
|
2
|
+
import { type Address, type Hex } from "viem"
|
|
3
3
|
|
|
4
4
|
export const DUMMY_ECDSA_SIG =
|
|
5
5
|
"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"
|
|
@@ -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
|
+
"0x94F097E1ebEB4ecA3AAE54cabb08905B239A7D27": "0.3.0-beta"
|
|
14
14
|
}
|
|
15
15
|
export const TOKEN_ACTION = "0x2087C7FfD0d0DAE80a00EE74325aBF3449e0eaf1"
|
|
16
16
|
export const KERNEL_NAME = "Kernel"
|
|
@@ -41,3 +41,7 @@ export enum EXEC_TYPE {
|
|
|
41
41
|
// Address was found here: https://github.com/safe-global/safe-deployments/blob/926ec6bbe2ebcac3aa2c2c6c0aff74aa590cbc6a/src/assets/v1.4.1/create_call.json
|
|
42
42
|
export const safeCreateCallAddress =
|
|
43
43
|
"0x9b35Af71d77eaf8d7e40252370304687390A1A52"
|
|
44
|
+
export const KernelFactoryToInitCodeHashMap: { [key: Address]: Hex } = {
|
|
45
|
+
"0x5de4839a76cf55d0c90e2061ef4386d962E15ae3":
|
|
46
|
+
"0xee9d8350bd899dd261db689aafd87eb8a30f085adbaff48152399438ff4eed73"
|
|
47
|
+
}
|
package/index.ts
CHANGED
|
@@ -38,9 +38,14 @@ 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"
|
|
44
46
|
export { gasTokenAddresses, type TokenSymbolsMap } from "./gasTokenAddresses.js"
|
|
45
|
-
export {
|
|
47
|
+
export {
|
|
48
|
+
verifyEIP6492Signature,
|
|
49
|
+
getCustomNonceKeyFromString
|
|
50
|
+
} from "./accounts/utils/index.js"
|
|
46
51
|
export { KernelEIP1193Provider } from "./providers/index.js"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerodev/sdk",
|
|
3
|
-
"version": "5.2.0
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"author": "ZeroDev",
|
|
5
5
|
"main": "./_cjs/index.js",
|
|
6
6
|
"module": "./_esm/index.js",
|
|
@@ -90,10 +90,10 @@
|
|
|
90
90
|
}
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
|
-
"viem": "^2.0.0"
|
|
93
|
+
"viem": "^2.0.0",
|
|
94
|
+
"permissionless": "^0.1.16"
|
|
94
95
|
},
|
|
95
96
|
"dependencies": {
|
|
96
|
-
"semver": "^7.6.0"
|
|
97
|
-
"permissionless": "^0.1.4"
|
|
97
|
+
"semver": "^7.6.0"
|
|
98
98
|
}
|
|
99
99
|
}
|
|
@@ -29,8 +29,13 @@ export class KernelEIP1193Provider<
|
|
|
29
29
|
return this.handleEthAccounts()
|
|
30
30
|
case "eth_sendTransaction":
|
|
31
31
|
return this.handleEthSendTransaction(params)
|
|
32
|
+
case "eth_sign":
|
|
33
|
+
return this.handleEthSign(params as [string, string])
|
|
32
34
|
case "personal_sign":
|
|
33
35
|
return this.handlePersonalSign(params as [string, string])
|
|
36
|
+
case "eth_signTypedData":
|
|
37
|
+
case "eth_signTypedData_v4":
|
|
38
|
+
return this.handleEthSignTypedDataV4(params as [string, string])
|
|
34
39
|
default:
|
|
35
40
|
return this.kernelClient.transport.request({ method, params })
|
|
36
41
|
}
|
|
@@ -55,6 +60,26 @@ export class KernelEIP1193Provider<
|
|
|
55
60
|
return this.kernelClient.sendTransaction(tx)
|
|
56
61
|
}
|
|
57
62
|
|
|
63
|
+
private async handleEthSign(params: [string, string]): Promise<string> {
|
|
64
|
+
if (!this.kernelClient?.account) {
|
|
65
|
+
throw new Error("account not connected!")
|
|
66
|
+
}
|
|
67
|
+
const [address, message] = params
|
|
68
|
+
if (
|
|
69
|
+
address.toLowerCase() !==
|
|
70
|
+
this.kernelClient.account.address.toLowerCase()
|
|
71
|
+
) {
|
|
72
|
+
throw new Error(
|
|
73
|
+
"cannot sign for address that is not the current account"
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return this.kernelClient.signMessage({
|
|
78
|
+
message,
|
|
79
|
+
account: this.kernelClient.account
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
|
|
58
83
|
private async handlePersonalSign(
|
|
59
84
|
params: [string, string]
|
|
60
85
|
): Promise<string> {
|
|
@@ -76,4 +101,30 @@ export class KernelEIP1193Provider<
|
|
|
76
101
|
account: this.kernelClient.account
|
|
77
102
|
})
|
|
78
103
|
}
|
|
104
|
+
|
|
105
|
+
private async handleEthSignTypedDataV4(
|
|
106
|
+
params: [string, string]
|
|
107
|
+
): Promise<string> {
|
|
108
|
+
if (!this.kernelClient?.account) {
|
|
109
|
+
throw new Error("account not connected!")
|
|
110
|
+
}
|
|
111
|
+
const [address, typedDataJSON] = params
|
|
112
|
+
const typedData = JSON.parse(typedDataJSON)
|
|
113
|
+
if (
|
|
114
|
+
address.toLowerCase() !==
|
|
115
|
+
this.kernelClient.account.address.toLowerCase()
|
|
116
|
+
) {
|
|
117
|
+
throw new Error(
|
|
118
|
+
"cannot sign for address that is not the current account"
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return this.kernelClient.signTypedData({
|
|
123
|
+
account: this.kernelClient.account,
|
|
124
|
+
domain: typedData.domain,
|
|
125
|
+
types: typedData.types,
|
|
126
|
+
message: typedData.message,
|
|
127
|
+
primaryType: typedData.primaryType
|
|
128
|
+
})
|
|
129
|
+
}
|
|
79
130
|
}
|
package/types/index.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export type {
|
|
2
2
|
KernelValidator,
|
|
3
3
|
ZeroDevPaymasterRpcSchema,
|
|
4
|
-
|
|
4
|
+
Action,
|
|
5
5
|
KernelPluginManager,
|
|
6
6
|
ValidatorInitData,
|
|
7
7
|
CallType,
|
|
8
8
|
KernelEncodeCallDataArgs,
|
|
9
|
-
PluginValidityData
|
|
9
|
+
PluginValidityData,
|
|
10
|
+
ZeroDevAccountClientRpcSchema,
|
|
11
|
+
ZeroDevUserOperationGasPriceWithBigIntAsHex
|
|
10
12
|
} from "./kernel.js"
|
|
11
13
|
|
|
12
14
|
export { ValidatorMode } from "./kernel.js"
|
package/types/kernel.ts
CHANGED
|
@@ -88,55 +88,69 @@ export type ZeroDevPaymasterRpcSchema<entryPoint extends EntryPoint> = [
|
|
|
88
88
|
}
|
|
89
89
|
]
|
|
90
90
|
|
|
91
|
-
export type
|
|
91
|
+
export type ZeroDevUserOperationGasPriceWithBigIntAsHex = {
|
|
92
|
+
slow: {
|
|
93
|
+
maxFeePerGas: Hex
|
|
94
|
+
maxPriorityFeePerGas: Hex
|
|
95
|
+
}
|
|
96
|
+
standard: {
|
|
97
|
+
maxFeePerGas: Hex
|
|
98
|
+
maxPriorityFeePerGas: Hex
|
|
99
|
+
}
|
|
100
|
+
fast: {
|
|
101
|
+
maxFeePerGas: Hex
|
|
102
|
+
maxPriorityFeePerGas: Hex
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type ZeroDevAccountClientRpcSchema = [
|
|
107
|
+
{
|
|
108
|
+
Method: "zd_getUserOperationGasPrice"
|
|
109
|
+
Parameters: []
|
|
110
|
+
ReturnType: ZeroDevUserOperationGasPriceWithBigIntAsHex
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
|
|
114
|
+
export type ValidatorType = Extract<
|
|
115
|
+
keyof typeof VALIDATOR_TYPE,
|
|
116
|
+
"PERMISSION" | "SECONDARY"
|
|
117
|
+
>
|
|
92
118
|
|
|
93
119
|
export type KernelValidator<
|
|
94
120
|
entryPoint extends EntryPoint,
|
|
95
|
-
Name extends string = string
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
}
|
|
121
|
+
Name extends string = string
|
|
122
|
+
> = LocalAccount<Name> & {
|
|
123
|
+
validatorType: ValidatorType
|
|
124
|
+
getNonceKey: (
|
|
125
|
+
accountAddress?: Address,
|
|
126
|
+
customNonceKey?: bigint
|
|
127
|
+
) => Promise<bigint>
|
|
128
|
+
getDummySignature(
|
|
129
|
+
userOperation: UserOperation<GetEntryPointVersion<entryPoint>>,
|
|
130
|
+
pluginEnableSignature?: Hex
|
|
131
|
+
): Promise<Hex>
|
|
132
|
+
signUserOperation: (
|
|
133
|
+
userOperation: UserOperation<GetEntryPointVersion<entryPoint>>,
|
|
134
|
+
pluginEnableSignature?: Hex
|
|
135
|
+
) => Promise<Hex>
|
|
136
|
+
getEnableData(accountAddress?: Address): Promise<Hex>
|
|
137
|
+
isEnabled(accountAddress: Address, selector: Hex): Promise<boolean>
|
|
138
|
+
getIdentifier: () => Hex
|
|
139
|
+
}
|
|
127
140
|
|
|
128
141
|
export type ValidatorInitData = {
|
|
129
142
|
validatorAddress: Address
|
|
130
143
|
enableData: Hex
|
|
144
|
+
identifier: Hex
|
|
131
145
|
}
|
|
132
146
|
|
|
133
147
|
export type KernelPluginManager<entryPoint extends EntryPoint> =
|
|
134
148
|
KernelValidator<entryPoint> & {
|
|
135
149
|
getPluginEnableSignature(accountAddress: Address): Promise<Hex>
|
|
136
150
|
getValidatorInitData(): Promise<ValidatorInitData>
|
|
137
|
-
|
|
151
|
+
getAction(): Action
|
|
138
152
|
getValidityData(): PluginValidityData
|
|
139
|
-
|
|
153
|
+
getIdentifier(isSudo?: boolean): Hex
|
|
140
154
|
}
|
|
141
155
|
|
|
142
156
|
export type KernelPluginManagerParams<entryPoint extends EntryPoint> = {
|
|
@@ -144,13 +158,13 @@ export type KernelPluginManagerParams<entryPoint extends EntryPoint> = {
|
|
|
144
158
|
regular?: KernelValidator<entryPoint>
|
|
145
159
|
pluginEnableSignature?: Hex
|
|
146
160
|
validatorInitData?: ValidatorInitData
|
|
147
|
-
|
|
161
|
+
action?: Action
|
|
148
162
|
entryPoint: entryPoint
|
|
149
163
|
kernelVersion?: string
|
|
150
164
|
} & Partial<PluginValidityData>
|
|
151
165
|
|
|
152
|
-
export type
|
|
153
|
-
|
|
166
|
+
export type Action = {
|
|
167
|
+
address: Address
|
|
154
168
|
selector: Hex
|
|
155
169
|
}
|
|
156
170
|
|
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
|
})
|