@zerodev/sdk 5.2.8 → 5.2.10
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/utils/multisend.js.map +1 -1
- package/_cjs/clients/decorators/kernel.js +10 -8
- package/_cjs/clients/decorators/kernel.js.map +1 -1
- package/_cjs/clients/fallbackKernelAccountClient.js +37 -0
- package/_cjs/clients/fallbackKernelAccountClient.js.map +1 -0
- package/_cjs/clients/index.js +3 -1
- package/_cjs/clients/index.js.map +1 -1
- package/_cjs/clients/kernelAccountClient.js.map +1 -1
- package/_cjs/index.js +3 -1
- package/_cjs/index.js.map +1 -1
- package/_esm/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.js +0 -1
- package/_esm/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.js.map +1 -1
- package/_esm/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.js +0 -1
- package/_esm/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.js.map +1 -1
- package/_esm/accounts/kernel/v1/createKernelV1Account.js +0 -2
- package/_esm/accounts/kernel/v1/createKernelV1Account.js.map +1 -1
- package/_esm/accounts/kernel/v2/createKernelV2Account.js +0 -1
- package/_esm/accounts/kernel/v2/createKernelV2Account.js.map +1 -1
- package/_esm/accounts/utils/multisend.js +0 -1
- package/_esm/accounts/utils/multisend.js.map +1 -1
- package/_esm/clients/decorators/kernel.js +10 -10
- package/_esm/clients/decorators/kernel.js.map +1 -1
- package/_esm/clients/fallbackKernelAccountClient.js +38 -0
- package/_esm/clients/fallbackKernelAccountClient.js.map +1 -0
- package/_esm/clients/index.js +1 -0
- package/_esm/clients/index.js.map +1 -1
- package/_esm/clients/kernelAccountClient.js +0 -1
- package/_esm/clients/kernelAccountClient.js.map +1 -1
- package/_esm/constants.js +0 -1
- 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 +0 -2
- package/_esm/providers/KernelEIP1193Provider.js.map +1 -1
- package/_esm/types/kernel.js +0 -2
- package/_esm/types/kernel.js.map +1 -1
- package/_esm/utils.js +1 -1
- package/_esm/utils.js.map +1 -1
- package/_types/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.d.ts +1 -1
- package/_types/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.d.ts +1 -1
- package/_types/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.d.ts.map +1 -1
- 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 +1 -1
- package/_types/accounts/kernel/v2/createKernelV2Account.d.ts.map +1 -1
- package/_types/accounts/utils/multisend.d.ts +1 -1
- package/_types/accounts/utils/multisend.d.ts.map +1 -1
- package/_types/clients/decorators/kernel.d.ts +3 -3
- package/_types/clients/decorators/kernel.d.ts.map +1 -1
- package/_types/clients/fallbackKernelAccountClient.d.ts +6 -0
- package/_types/clients/fallbackKernelAccountClient.d.ts.map +1 -0
- package/_types/clients/index.d.ts +1 -0
- package/_types/clients/index.d.ts.map +1 -1
- package/_types/clients/kernelAccountClient.d.ts +3 -300
- package/_types/clients/kernelAccountClient.d.ts.map +1 -1
- package/_types/constants.d.ts +1 -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 +2 -2
- package/_types/providers/KernelEIP1193Provider.d.ts.map +1 -1
- package/_types/types/kernel.d.ts +2 -2
- package/_types/types/kernel.d.ts.map +1 -1
- package/_types/utils.d.ts +1 -1
- package/_types/utils.d.ts.map +1 -1
- package/accounts/kernel/utils/account/ep0_6/encodeDeployCallData.ts +1 -1
- package/accounts/kernel/utils/account/ep0_7/encodeDeployCallData.ts +1 -1
- package/accounts/kernel/v1/createKernelV1Account.ts +2 -2
- package/accounts/kernel/v2/createKernelV2Account.ts +1 -1
- package/accounts/utils/multisend.ts +1 -4
- package/clients/decorators/kernel.ts +7 -5
- package/clients/fallbackKernelAccountClient.ts +62 -0
- package/clients/index.ts +2 -0
- package/clients/kernelAccountClient.ts +7 -9
- package/constants.ts +1 -1
- package/index.ts +1 -0
- package/package.json +2 -8
- package/providers/KernelEIP1193Provider.ts +6 -6
- package/types/kernel.ts +2 -2
- package/utils.ts +2 -2
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { EntryPoint } from "permissionless/types"
|
|
2
|
+
import type { Chain, Transport } from "viem"
|
|
3
|
+
import type { KernelSmartAccount } from "../accounts/index.js"
|
|
4
|
+
import type { KernelAccountClient } from "./kernelAccountClient.js"
|
|
5
|
+
|
|
6
|
+
export const createFallbackKernelAccountClient = <
|
|
7
|
+
TEntryPoint extends EntryPoint,
|
|
8
|
+
TTransport extends Transport,
|
|
9
|
+
TChain extends Chain | undefined,
|
|
10
|
+
TSmartAccount extends KernelSmartAccount<TEntryPoint> | undefined
|
|
11
|
+
>(
|
|
12
|
+
clients: Array<
|
|
13
|
+
KernelAccountClient<TEntryPoint, TTransport, TChain, TSmartAccount>
|
|
14
|
+
>
|
|
15
|
+
): KernelAccountClient<TEntryPoint, TTransport, TChain, TSmartAccount> => {
|
|
16
|
+
const proxyClient = new Proxy(clients[0], {
|
|
17
|
+
get(_target, prop, receiver) {
|
|
18
|
+
for (const client of clients) {
|
|
19
|
+
const value = Reflect.get(client, prop, receiver)
|
|
20
|
+
if (value !== undefined) {
|
|
21
|
+
// If the property is a function, wrap it to add fallback logic
|
|
22
|
+
if (typeof value === "function") {
|
|
23
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
24
|
+
return async (...args: any[]) => {
|
|
25
|
+
for (let i = 0; i < clients.length; i++) {
|
|
26
|
+
try {
|
|
27
|
+
const method = Reflect.get(
|
|
28
|
+
clients[i],
|
|
29
|
+
prop,
|
|
30
|
+
receiver
|
|
31
|
+
)
|
|
32
|
+
if (typeof method === "function") {
|
|
33
|
+
// Attempt to call the function on the current client
|
|
34
|
+
return await method(...args)
|
|
35
|
+
}
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error(
|
|
38
|
+
`Action ${String(
|
|
39
|
+
prop
|
|
40
|
+
)} failed with client ${
|
|
41
|
+
client.transport.url
|
|
42
|
+
}, trying next if available.`,
|
|
43
|
+
error
|
|
44
|
+
)
|
|
45
|
+
if (i === clients.length - 1) {
|
|
46
|
+
throw error
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// For non-function properties, return the first defined value found
|
|
53
|
+
return value
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// If no clients have a defined value for the property, return undefined
|
|
57
|
+
return undefined
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
return proxyClient
|
|
62
|
+
}
|
package/clients/index.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
type Transport,
|
|
12
12
|
createClient
|
|
13
13
|
} from "viem"
|
|
14
|
-
import {
|
|
14
|
+
import type { KernelSmartAccount } from "../accounts/index.js"
|
|
15
15
|
import { getUserOperationGasPrice } from "../actions/account-client/getUserOperationGasPrice.js"
|
|
16
16
|
import {
|
|
17
17
|
type KernelAccountClientActions,
|
|
@@ -26,14 +26,12 @@ export type KernelAccountClient<
|
|
|
26
26
|
account extends KernelSmartAccount<entryPoint> | undefined =
|
|
27
27
|
| KernelSmartAccount<entryPoint>
|
|
28
28
|
| undefined
|
|
29
|
-
> =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
KernelAccountClientActions<entryPoint, chain, account>
|
|
36
|
-
>
|
|
29
|
+
> = Client<
|
|
30
|
+
transport,
|
|
31
|
+
chain,
|
|
32
|
+
account,
|
|
33
|
+
BundlerRpcSchema<entryPoint>,
|
|
34
|
+
KernelAccountClientActions<entryPoint, chain, account>
|
|
37
35
|
>
|
|
38
36
|
|
|
39
37
|
export type SmartAccountClientConfig<
|
package/constants.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EntryPointVersion } from "permissionless/types/entrypoint"
|
|
2
|
-
import {
|
|
2
|
+
import type { Address, Hex } from "viem"
|
|
3
3
|
|
|
4
4
|
export const DUMMY_ECDSA_SIG =
|
|
5
5
|
"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"
|
package/index.ts
CHANGED
|
@@ -26,6 +26,7 @@ export {
|
|
|
26
26
|
createKernelAccountClient,
|
|
27
27
|
type KernelAccountClient
|
|
28
28
|
} from "./clients/kernelAccountClient.js"
|
|
29
|
+
export { createFallbackKernelAccountClient } from "./clients/fallbackKernelAccountClient.js"
|
|
29
30
|
export {
|
|
30
31
|
type KernelValidator,
|
|
31
32
|
type ZeroDevPaymasterRpcSchema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerodev/sdk",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.10",
|
|
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",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { EventEmitter } from "events"
|
|
2
|
-
import {
|
|
2
|
+
import type { KernelAccountClient } from "@zerodev/sdk"
|
|
3
3
|
import type { EntryPoint } from "permissionless/types"
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import type {
|
|
5
|
+
EIP1193Parameters,
|
|
6
|
+
EIP1193RequestFn,
|
|
7
|
+
Hash,
|
|
8
|
+
SendTransactionParameters
|
|
9
9
|
} from "viem"
|
|
10
10
|
|
|
11
11
|
export class KernelEIP1193Provider<
|
package/types/kernel.ts
CHANGED
|
@@ -7,9 +7,9 @@ import type {
|
|
|
7
7
|
UserOperation,
|
|
8
8
|
UserOperationWithBigIntAsHex
|
|
9
9
|
} from "permissionless/types/userOperation"
|
|
10
|
-
import {
|
|
10
|
+
import type { Address, Hex, LocalAccount } from "viem"
|
|
11
11
|
import type { PartialBy } from "viem/types/utils"
|
|
12
|
-
import { VALIDATOR_TYPE } from "../constants.js"
|
|
12
|
+
import type { VALIDATOR_TYPE } from "../constants.js"
|
|
13
13
|
export type ZeroDevPaymasterRpcSchema<entryPoint extends EntryPoint> = [
|
|
14
14
|
{
|
|
15
15
|
Method: "zd_sponsorUserOperation"
|
package/utils.ts
CHANGED
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
} from "viem"
|
|
16
16
|
import type { ZeroDevPaymasterClient } from "./clients/paymasterClient.js"
|
|
17
17
|
import {
|
|
18
|
-
CALL_TYPE,
|
|
19
|
-
EXEC_TYPE,
|
|
18
|
+
type CALL_TYPE,
|
|
19
|
+
type EXEC_TYPE,
|
|
20
20
|
KernelImplToVersionMap,
|
|
21
21
|
LATEST_KERNEL_VERSION
|
|
22
22
|
} from "./constants.js"
|