@zerodev/sdk 5.4.0-beta.0 → 5.4.0-beta.2
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/createKernelAccount.js +5 -3
- package/_cjs/accounts/kernel/createKernelAccount.js.map +1 -1
- package/_cjs/accounts/kernel/v1/createKernelAccountV1.js +4 -2
- package/_cjs/accounts/kernel/v1/createKernelAccountV1.js.map +1 -1
- package/_cjs/accounts/kernel/v2/createKernelAccountV0_2.js +4 -2
- package/_cjs/accounts/kernel/v2/createKernelAccountV0_2.js.map +1 -1
- package/_cjs/actions/account-client/changeSudoValidator.js.map +1 -1
- package/_cjs/actions/index.js +2 -0
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/paymaster/sponsorUserOperation.js.map +1 -1
- package/_cjs/actions/public/index.js +3 -1
- package/_cjs/actions/public/index.js.map +1 -1
- package/_cjs/actions/public/isSmartAccountDeployed.js +14 -0
- package/_cjs/actions/public/isSmartAccountDeployed.js.map +1 -0
- package/_cjs/clients/decorators/kernel.js.map +1 -1
- package/_cjs/clients/paymasterClient.js.map +1 -1
- package/_cjs/constants.js +14 -1
- package/_cjs/constants.js.map +1 -1
- package/_cjs/errors/index.js +9 -1
- package/_cjs/errors/index.js.map +1 -1
- package/_cjs/index.js +2 -0
- package/_cjs/index.js.map +1 -1
- package/_cjs/types/index.js.map +1 -1
- package/_cjs/types/kernel.js.map +1 -1
- package/_cjs/types/utils.js +3 -0
- package/_cjs/types/utils.js.map +1 -0
- package/_cjs/utils/index.js +5 -0
- package/_cjs/utils/index.js.map +1 -0
- package/_cjs/utils/toSigner.js +58 -0
- package/_cjs/utils/toSigner.js.map +1 -0
- package/_esm/accounts/kernel/createKernelAccount.js +5 -3
- package/_esm/accounts/kernel/createKernelAccount.js.map +1 -1
- package/_esm/accounts/kernel/v1/createKernelAccountV1.js +4 -2
- package/_esm/accounts/kernel/v1/createKernelAccountV1.js.map +1 -1
- package/_esm/accounts/kernel/v2/createKernelAccountV0_2.js +4 -2
- package/_esm/accounts/kernel/v2/createKernelAccountV0_2.js.map +1 -1
- package/_esm/actions/account-client/changeSudoValidator.js.map +1 -1
- package/_esm/actions/index.js +1 -0
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/paymaster/sponsorUserOperation.js.map +1 -1
- package/_esm/actions/public/index.js +1 -0
- package/_esm/actions/public/index.js.map +1 -1
- package/_esm/actions/public/isSmartAccountDeployed.js +10 -0
- package/_esm/actions/public/isSmartAccountDeployed.js.map +1 -0
- package/_esm/clients/decorators/kernel.js.map +1 -1
- package/_esm/clients/paymasterClient.js.map +1 -1
- package/_esm/constants.js +12 -0
- package/_esm/constants.js.map +1 -1
- package/_esm/errors/index.js +7 -0
- package/_esm/errors/index.js.map +1 -1
- package/_esm/index.js +2 -0
- package/_esm/index.js.map +1 -1
- package/_esm/types/index.js.map +1 -1
- package/_esm/types/kernel.js.map +1 -1
- package/_esm/types/utils.js +2 -0
- package/_esm/types/utils.js.map +1 -0
- package/_esm/utils/index.js +2 -0
- package/_esm/utils/index.js.map +1 -0
- package/_esm/utils/toSigner.js +56 -0
- package/_esm/utils/toSigner.js.map +1 -0
- package/_types/accounts/kernel/createKernelAccount.d.ts +3 -6
- package/_types/accounts/kernel/createKernelAccount.d.ts.map +1 -1
- package/_types/accounts/kernel/v1/createKernelAccountV1.d.ts.map +1 -1
- package/_types/accounts/kernel/v2/createKernelAccountV0_2.d.ts +2 -2
- package/_types/accounts/kernel/v2/createKernelAccountV0_2.d.ts.map +1 -1
- package/_types/actions/account-client/changeSudoValidator.d.ts.map +1 -1
- package/_types/actions/index.d.ts +1 -0
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/actions/paymaster/sponsorUserOperation.d.ts +3 -6
- package/_types/actions/paymaster/sponsorUserOperation.d.ts.map +1 -1
- package/_types/actions/public/index.d.ts +1 -0
- package/_types/actions/public/index.d.ts.map +1 -1
- package/_types/actions/public/isSmartAccountDeployed.d.ts +3 -0
- package/_types/actions/public/isSmartAccountDeployed.d.ts.map +1 -0
- package/_types/clients/decorators/kernel.d.ts +5 -19
- package/_types/clients/decorators/kernel.d.ts.map +1 -1
- package/_types/clients/paymasterClient.d.ts +3 -6
- package/_types/clients/paymasterClient.d.ts.map +1 -1
- package/_types/constants.d.ts +3 -1
- package/_types/constants.d.ts.map +1 -1
- package/_types/errors/index.d.ts +3 -0
- package/_types/errors/index.d.ts.map +1 -1
- package/_types/index.d.ts +2 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/types/index.d.ts +2 -1
- package/_types/types/index.d.ts.map +1 -1
- package/_types/types/kernel.d.ts +5 -4
- package/_types/types/kernel.d.ts.map +1 -1
- package/_types/types/utils.d.ts +3 -0
- package/_types/types/utils.d.ts.map +1 -0
- package/_types/utils/index.d.ts +2 -0
- package/_types/utils/index.d.ts.map +1 -0
- package/_types/utils/toSigner.d.ts +7 -0
- package/_types/utils/toSigner.d.ts.map +1 -0
- package/_types/utils.d.ts +2 -5
- package/_types/utils.d.ts.map +1 -1
- package/accounts/kernel/createKernelAccount.ts +10 -11
- package/accounts/kernel/v1/createKernelAccountV1.ts +7 -5
- package/accounts/kernel/v2/createKernelAccountV0_2.ts +9 -20
- package/actions/account-client/changeSudoValidator.ts +1 -1
- package/actions/index.ts +2 -0
- package/actions/paymaster/sponsorUserOperation.ts +2 -5
- package/actions/public/index.ts +1 -0
- package/actions/public/isSmartAccountDeployed.ts +18 -0
- package/clients/decorators/kernel.ts +4 -5
- package/clients/paymasterClient.ts +5 -6
- package/constants.ts +20 -0
- package/errors/index.ts +8 -0
- package/index.ts +2 -0
- package/package.json +1 -1
- package/types/index.ts +5 -1
- package/types/kernel.ts +6 -4
- package/types/utils.ts +15 -0
- package/utils/index.ts +1 -0
- package/utils/toSigner.ts +106 -0
- package/utils.ts +2 -2
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Copied from: https://github.com/pimlicolabs/permissionless.js/blob/main/packages/permissionless/utils/toOwner.ts
|
|
2
|
+
import {
|
|
3
|
+
type Account,
|
|
4
|
+
type Address,
|
|
5
|
+
type Chain,
|
|
6
|
+
type EIP1193Provider,
|
|
7
|
+
type EIP1193RequestFn,
|
|
8
|
+
type EIP1474Methods,
|
|
9
|
+
type LocalAccount,
|
|
10
|
+
type Transport,
|
|
11
|
+
type TypedData,
|
|
12
|
+
type TypedDataDefinition,
|
|
13
|
+
type WalletClient,
|
|
14
|
+
createWalletClient,
|
|
15
|
+
custom
|
|
16
|
+
} from "viem"
|
|
17
|
+
import { toAccount } from "viem/accounts"
|
|
18
|
+
|
|
19
|
+
import { signMessage, signTypedData } from "viem/actions"
|
|
20
|
+
import type { Signer } from "../types"
|
|
21
|
+
|
|
22
|
+
export async function toSigner({
|
|
23
|
+
signer,
|
|
24
|
+
address
|
|
25
|
+
}: {
|
|
26
|
+
signer: Signer
|
|
27
|
+
address?: Address
|
|
28
|
+
}): Promise<LocalAccount> {
|
|
29
|
+
if ("type" in signer && signer.type === "local") {
|
|
30
|
+
return signer as LocalAccount
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let walletClient:
|
|
34
|
+
| WalletClient<Transport, Chain | undefined, Account>
|
|
35
|
+
| undefined = undefined
|
|
36
|
+
|
|
37
|
+
if ("request" in signer) {
|
|
38
|
+
if (!address) {
|
|
39
|
+
try {
|
|
40
|
+
;[address] = await (
|
|
41
|
+
signer.request as EIP1193RequestFn<EIP1474Methods>
|
|
42
|
+
)({
|
|
43
|
+
method: "eth_requestAccounts"
|
|
44
|
+
})
|
|
45
|
+
} catch {
|
|
46
|
+
;[address] = await (
|
|
47
|
+
signer.request as EIP1193RequestFn<EIP1474Methods>
|
|
48
|
+
)({
|
|
49
|
+
method: "eth_accounts"
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (!address) {
|
|
54
|
+
// For TS to be happy
|
|
55
|
+
throw new Error("address is required")
|
|
56
|
+
}
|
|
57
|
+
walletClient = createWalletClient({
|
|
58
|
+
account: address,
|
|
59
|
+
transport: custom(signer as EIP1193Provider)
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!walletClient) {
|
|
64
|
+
walletClient = signer as WalletClient<
|
|
65
|
+
Transport,
|
|
66
|
+
Chain | undefined,
|
|
67
|
+
Account
|
|
68
|
+
>
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return toAccount({
|
|
72
|
+
address: walletClient.account.address,
|
|
73
|
+
async signMessage({ message }) {
|
|
74
|
+
return signMessage(
|
|
75
|
+
walletClient as WalletClient<
|
|
76
|
+
Transport,
|
|
77
|
+
Chain | undefined,
|
|
78
|
+
Account
|
|
79
|
+
>,
|
|
80
|
+
{ message }
|
|
81
|
+
)
|
|
82
|
+
},
|
|
83
|
+
async signTypedData(typedData) {
|
|
84
|
+
const { primaryType, domain, message, types } =
|
|
85
|
+
typedData as TypedDataDefinition<TypedData, string>
|
|
86
|
+
return signTypedData(
|
|
87
|
+
walletClient as WalletClient<
|
|
88
|
+
Transport,
|
|
89
|
+
Chain | undefined,
|
|
90
|
+
Account
|
|
91
|
+
>,
|
|
92
|
+
{
|
|
93
|
+
primaryType,
|
|
94
|
+
domain,
|
|
95
|
+
message,
|
|
96
|
+
types
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
},
|
|
100
|
+
async signTransaction(_) {
|
|
101
|
+
throw new Error(
|
|
102
|
+
"Smart account signer doesn't need to sign transactions"
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
}) as LocalAccount
|
|
106
|
+
}
|
package/utils.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import type { EntryPointVersion } from "viem/account-abstraction"
|
|
15
15
|
import type { ZeroDevPaymasterClient } from "./clients/paymasterClient.js"
|
|
16
16
|
import type { CALL_TYPE, EXEC_TYPE } from "./constants.js"
|
|
17
|
-
import type { GetKernelVersion } from "./types/kernel.js"
|
|
17
|
+
import type { EntryPointType, GetKernelVersion } from "./types/kernel.js"
|
|
18
18
|
|
|
19
19
|
export enum KERNEL_FEATURES {
|
|
20
20
|
ERC1271_SIG_WRAPPER = "ERC1271_SIG_WRAPPER",
|
|
@@ -50,7 +50,7 @@ export const getERC20PaymasterApproveCall = async <
|
|
|
50
50
|
}: {
|
|
51
51
|
gasToken: Address
|
|
52
52
|
approveAmount: bigint
|
|
53
|
-
entryPoint:
|
|
53
|
+
entryPoint: EntryPointType<entryPointVersion>
|
|
54
54
|
}
|
|
55
55
|
): Promise<{ to: Address; value: bigint; data: Hex }> => {
|
|
56
56
|
const response = await client.request({
|