@zerodev/sdk 5.2.12-alpha-2 → 5.2.12-alpha-3
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 +0 -7
- package/_cjs/accounts/kernel/createKernelAccount.js.map +1 -1
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.js +1 -2
- package/_cjs/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.js.map +1 -1
- package/_cjs/accounts/utils/toKernelPluginManager.js +2 -4
- package/_cjs/accounts/utils/toKernelPluginManager.js.map +1 -1
- package/_cjs/clients/decorators/kernel.js +1 -5
- package/_cjs/clients/decorators/kernel.js.map +1 -1
- package/_cjs/index.js +5 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/types/kernel.js.map +1 -1
- package/_esm/accounts/kernel/createKernelAccount.js +0 -8
- package/_esm/accounts/kernel/createKernelAccount.js.map +1 -1
- package/_esm/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.js +1 -2
- package/_esm/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.js.map +1 -1
- package/_esm/accounts/utils/toKernelPluginManager.js +2 -4
- package/_esm/accounts/utils/toKernelPluginManager.js.map +1 -1
- package/_esm/clients/decorators/kernel.js +1 -5
- package/_esm/clients/decorators/kernel.js.map +1 -1
- package/_esm/index.js +2 -0
- package/_esm/index.js.map +1 -1
- package/_esm/types/kernel.js.map +1 -1
- package/_types/accounts/kernel/createKernelAccount.d.ts +1 -2
- package/_types/accounts/kernel/createKernelAccount.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.d.ts +6 -6
- package/_types/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.d.ts.map +1 -1
- package/_types/accounts/utils/toKernelPluginManager.d.ts.map +1 -1
- package/_types/clients/decorators/kernel.d.ts +3 -10
- package/_types/clients/decorators/kernel.d.ts.map +1 -1
- package/_types/index.d.ts +2 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/types/kernel.d.ts +0 -2
- package/_types/types/kernel.d.ts.map +1 -1
- package/accounts/kernel/createKernelAccount.ts +1 -22
- package/accounts/kernel/utils/plugins/ep0_7/getEncodedPluginsData.ts +6 -14
- package/accounts/utils/toKernelPluginManager.ts +2 -4
- package/clients/decorators/kernel.ts +4 -50
- package/index.ts +2 -0
- package/package.json +1 -1
- package/types/kernel.ts +0 -5
- package/_cjs/actions/account-client/prepareMultiUserOpRequest.js +0 -110
- package/_cjs/actions/account-client/prepareMultiUserOpRequest.js.map +0 -1
- package/_cjs/actions/account-client/sendSignedUserOperation.js +0 -17
- package/_cjs/actions/account-client/sendSignedUserOperation.js.map +0 -1
- package/_esm/actions/account-client/prepareMultiUserOpRequest.js +0 -108
- package/_esm/actions/account-client/prepareMultiUserOpRequest.js.map +0 -1
- package/_esm/actions/account-client/sendSignedUserOperation.js +0 -14
- package/_esm/actions/account-client/sendSignedUserOperation.js.map +0 -1
- package/_types/actions/account-client/prepareMultiUserOpRequest.d.ts +0 -31
- package/_types/actions/account-client/prepareMultiUserOpRequest.d.ts.map +0 -1
- package/_types/actions/account-client/sendSignedUserOperation.d.ts +0 -7
- package/_types/actions/account-client/sendSignedUserOperation.d.ts.map +0 -1
- package/actions/account-client/prepareMultiUserOpRequest.ts +0 -238
- package/actions/account-client/sendSignedUserOperation.ts +0 -36
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AccountOrClientNotFoundError,
|
|
3
|
-
type UserOperation,
|
|
4
|
-
estimateUserOperationGas,
|
|
5
|
-
parseAccount
|
|
6
|
-
} from "permissionless"
|
|
7
|
-
import type {
|
|
8
|
-
PrepareUserOperationRequestParameters,
|
|
9
|
-
PrepareUserOperationRequestReturnType,
|
|
10
|
-
SponsorUserOperationReturnType
|
|
11
|
-
} from "permissionless/actions/smartAccount"
|
|
12
|
-
import type { StateOverrides } from "permissionless/types/bundler"
|
|
13
|
-
import type {
|
|
14
|
-
ENTRYPOINT_ADDRESS_V07_TYPE,
|
|
15
|
-
EntryPoint,
|
|
16
|
-
GetEntryPointVersion
|
|
17
|
-
} from "permissionless/types/entrypoint"
|
|
18
|
-
import type {
|
|
19
|
-
Abi,
|
|
20
|
-
Address,
|
|
21
|
-
Chain,
|
|
22
|
-
Client,
|
|
23
|
-
Hex,
|
|
24
|
-
LocalAccount,
|
|
25
|
-
Transport
|
|
26
|
-
} from "viem"
|
|
27
|
-
import { estimateFeesPerGas } from "viem/actions"
|
|
28
|
-
import type { Prettify } from "viem/chains"
|
|
29
|
-
import { type EncodeDeployDataParameters, getAction } from "viem/utils"
|
|
30
|
-
import type { KernelSmartAccount } from "../../accounts"
|
|
31
|
-
|
|
32
|
-
export type SmartAccount<
|
|
33
|
-
entryPoint extends EntryPoint,
|
|
34
|
-
TSource extends string = string,
|
|
35
|
-
transport extends Transport = Transport,
|
|
36
|
-
chain extends Chain | undefined = Chain | undefined,
|
|
37
|
-
TAbi extends Abi | readonly unknown[] = Abi
|
|
38
|
-
> = LocalAccount<TSource> & {
|
|
39
|
-
client: Client<transport, chain>
|
|
40
|
-
entryPoint: entryPoint
|
|
41
|
-
getNonce: () => Promise<bigint>
|
|
42
|
-
getInitCode: () => Promise<Hex>
|
|
43
|
-
getFactory: () => Promise<Address | undefined>
|
|
44
|
-
getFactoryData: () => Promise<Hex | undefined>
|
|
45
|
-
encodeCallData: (
|
|
46
|
-
args:
|
|
47
|
-
| {
|
|
48
|
-
to: Address
|
|
49
|
-
value: bigint
|
|
50
|
-
data: Hex
|
|
51
|
-
}
|
|
52
|
-
| {
|
|
53
|
-
to: Address
|
|
54
|
-
value: bigint
|
|
55
|
-
data: Hex
|
|
56
|
-
}[]
|
|
57
|
-
) => Promise<Hex>
|
|
58
|
-
getDummySignature(
|
|
59
|
-
userOperation: UserOperation<GetEntryPointVersion<entryPoint>>
|
|
60
|
-
): Promise<Hex>
|
|
61
|
-
getMultiUserOpDummySignature(
|
|
62
|
-
userOperation: UserOperation<GetEntryPointVersion<entryPoint>>,
|
|
63
|
-
numOfUserOps: number
|
|
64
|
-
): Promise<Hex>
|
|
65
|
-
encodeDeployCallData: ({
|
|
66
|
-
abi,
|
|
67
|
-
args,
|
|
68
|
-
bytecode
|
|
69
|
-
}: EncodeDeployDataParameters<TAbi>) => Promise<Hex>
|
|
70
|
-
signUserOperation: (
|
|
71
|
-
userOperation: UserOperation<GetEntryPointVersion<entryPoint>>
|
|
72
|
-
) => Promise<Hex>
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export async function prepareMultiUserOpRequest<
|
|
76
|
-
entryPoint extends EntryPoint = ENTRYPOINT_ADDRESS_V07_TYPE,
|
|
77
|
-
TTransport extends Transport = Transport,
|
|
78
|
-
TChain extends Chain | undefined = Chain | undefined,
|
|
79
|
-
TSmartAccount extends KernelSmartAccount<entryPoint> | undefined =
|
|
80
|
-
| KernelSmartAccount<entryPoint>
|
|
81
|
-
| undefined
|
|
82
|
-
>(
|
|
83
|
-
client: Client<TTransport, TChain, TSmartAccount>,
|
|
84
|
-
args: Prettify<
|
|
85
|
-
PrepareUserOperationRequestParameters<entryPoint, TSmartAccount>
|
|
86
|
-
>,
|
|
87
|
-
numOfUserOps: number,
|
|
88
|
-
stateOverrides?: StateOverrides
|
|
89
|
-
): Promise<Prettify<PrepareUserOperationRequestReturnType<entryPoint>>> {
|
|
90
|
-
const {
|
|
91
|
-
account: account_ = client.account,
|
|
92
|
-
userOperation: partialUserOperation,
|
|
93
|
-
middleware
|
|
94
|
-
} = args
|
|
95
|
-
|
|
96
|
-
if (!account_) throw new AccountOrClientNotFoundError()
|
|
97
|
-
|
|
98
|
-
const account = parseAccount(
|
|
99
|
-
account_
|
|
100
|
-
) as SmartAccount<ENTRYPOINT_ADDRESS_V07_TYPE>
|
|
101
|
-
|
|
102
|
-
const [sender, nonce, factory, factoryData, callData, gasEstimation] =
|
|
103
|
-
await Promise.all([
|
|
104
|
-
partialUserOperation.sender || account.address,
|
|
105
|
-
partialUserOperation.nonce || account.getNonce(),
|
|
106
|
-
partialUserOperation.factory || account.getFactory(),
|
|
107
|
-
partialUserOperation.factoryData || account.getFactoryData(),
|
|
108
|
-
partialUserOperation.callData,
|
|
109
|
-
!partialUserOperation.maxFeePerGas ||
|
|
110
|
-
!partialUserOperation.maxPriorityFeePerGas
|
|
111
|
-
? estimateFeesPerGas(account.client)
|
|
112
|
-
: undefined
|
|
113
|
-
])
|
|
114
|
-
|
|
115
|
-
const userOperation: UserOperation<"v0.7"> = {
|
|
116
|
-
sender,
|
|
117
|
-
nonce,
|
|
118
|
-
factory: factory,
|
|
119
|
-
factoryData: factoryData,
|
|
120
|
-
callData,
|
|
121
|
-
callGasLimit: partialUserOperation.callGasLimit || BigInt(0),
|
|
122
|
-
verificationGasLimit:
|
|
123
|
-
partialUserOperation.verificationGasLimit || BigInt(0),
|
|
124
|
-
preVerificationGas:
|
|
125
|
-
partialUserOperation.preVerificationGas || BigInt(0),
|
|
126
|
-
maxFeePerGas:
|
|
127
|
-
partialUserOperation.maxFeePerGas ||
|
|
128
|
-
gasEstimation?.maxFeePerGas ||
|
|
129
|
-
BigInt(0),
|
|
130
|
-
maxPriorityFeePerGas:
|
|
131
|
-
partialUserOperation.maxPriorityFeePerGas ||
|
|
132
|
-
gasEstimation?.maxPriorityFeePerGas ||
|
|
133
|
-
BigInt(0),
|
|
134
|
-
signature: partialUserOperation.signature || "0x"
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (typeof middleware === "function") {
|
|
138
|
-
return middleware({
|
|
139
|
-
userOperation,
|
|
140
|
-
entryPoint: account.entryPoint
|
|
141
|
-
} as {
|
|
142
|
-
userOperation: UserOperation<GetEntryPointVersion<entryPoint>>
|
|
143
|
-
entryPoint: entryPoint
|
|
144
|
-
}) as Promise<PrepareUserOperationRequestReturnType<entryPoint>>
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (middleware && typeof middleware !== "function" && middleware.gasPrice) {
|
|
148
|
-
const gasPrice = await middleware.gasPrice()
|
|
149
|
-
userOperation.maxFeePerGas = gasPrice.maxFeePerGas
|
|
150
|
-
userOperation.maxPriorityFeePerGas = gasPrice.maxPriorityFeePerGas
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (!userOperation.maxFeePerGas || !userOperation.maxPriorityFeePerGas) {
|
|
154
|
-
const estimateGas = await estimateFeesPerGas(account.client)
|
|
155
|
-
userOperation.maxFeePerGas =
|
|
156
|
-
userOperation.maxFeePerGas || estimateGas.maxFeePerGas
|
|
157
|
-
userOperation.maxPriorityFeePerGas =
|
|
158
|
-
userOperation.maxPriorityFeePerGas ||
|
|
159
|
-
estimateGas.maxPriorityFeePerGas
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (userOperation.signature === "0x") {
|
|
163
|
-
userOperation.signature = await account.getMultiUserOpDummySignature(
|
|
164
|
-
userOperation,
|
|
165
|
-
numOfUserOps
|
|
166
|
-
)
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (
|
|
170
|
-
middleware &&
|
|
171
|
-
typeof middleware !== "function" &&
|
|
172
|
-
middleware.sponsorUserOperation
|
|
173
|
-
) {
|
|
174
|
-
const sponsorUserOperationData = (await middleware.sponsorUserOperation(
|
|
175
|
-
{
|
|
176
|
-
userOperation,
|
|
177
|
-
entryPoint: account.entryPoint
|
|
178
|
-
} as {
|
|
179
|
-
userOperation: UserOperation<GetEntryPointVersion<entryPoint>>
|
|
180
|
-
entryPoint: entryPoint
|
|
181
|
-
}
|
|
182
|
-
)) as SponsorUserOperationReturnType<ENTRYPOINT_ADDRESS_V07_TYPE>
|
|
183
|
-
|
|
184
|
-
userOperation.callGasLimit = sponsorUserOperationData.callGasLimit
|
|
185
|
-
userOperation.verificationGasLimit =
|
|
186
|
-
sponsorUserOperationData.verificationGasLimit
|
|
187
|
-
userOperation.preVerificationGas =
|
|
188
|
-
sponsorUserOperationData.preVerificationGas
|
|
189
|
-
userOperation.paymaster = sponsorUserOperationData.paymaster
|
|
190
|
-
userOperation.paymasterVerificationGasLimit =
|
|
191
|
-
sponsorUserOperationData.paymasterVerificationGasLimit
|
|
192
|
-
userOperation.paymasterPostOpGasLimit =
|
|
193
|
-
sponsorUserOperationData.paymasterPostOpGasLimit
|
|
194
|
-
userOperation.paymasterData = sponsorUserOperationData.paymasterData
|
|
195
|
-
userOperation.maxFeePerGas =
|
|
196
|
-
sponsorUserOperationData.maxFeePerGas || userOperation.maxFeePerGas
|
|
197
|
-
userOperation.maxPriorityFeePerGas =
|
|
198
|
-
sponsorUserOperationData.maxPriorityFeePerGas ||
|
|
199
|
-
userOperation.maxPriorityFeePerGas
|
|
200
|
-
|
|
201
|
-
return userOperation as PrepareUserOperationRequestReturnType<entryPoint>
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (
|
|
205
|
-
!userOperation.callGasLimit ||
|
|
206
|
-
!userOperation.verificationGasLimit ||
|
|
207
|
-
!userOperation.preVerificationGas
|
|
208
|
-
) {
|
|
209
|
-
const gasParameters = await getAction(
|
|
210
|
-
client,
|
|
211
|
-
estimateUserOperationGas<ENTRYPOINT_ADDRESS_V07_TYPE>,
|
|
212
|
-
"estimateUserOperationGas"
|
|
213
|
-
)(
|
|
214
|
-
{
|
|
215
|
-
userOperation,
|
|
216
|
-
entryPoint: account.entryPoint
|
|
217
|
-
},
|
|
218
|
-
// @ts-ignore getAction takes only two params but when compiled this will work
|
|
219
|
-
stateOverrides
|
|
220
|
-
)
|
|
221
|
-
|
|
222
|
-
userOperation.callGasLimit |= gasParameters.callGasLimit
|
|
223
|
-
userOperation.verificationGasLimit =
|
|
224
|
-
userOperation.verificationGasLimit ||
|
|
225
|
-
gasParameters.verificationGasLimit
|
|
226
|
-
userOperation.preVerificationGas =
|
|
227
|
-
userOperation.preVerificationGas || gasParameters.preVerificationGas
|
|
228
|
-
|
|
229
|
-
userOperation.paymasterPostOpGasLimit =
|
|
230
|
-
userOperation.paymasterPostOpGasLimit ||
|
|
231
|
-
gasParameters.paymasterPostOpGasLimit
|
|
232
|
-
userOperation.paymasterPostOpGasLimit =
|
|
233
|
-
userOperation.paymasterPostOpGasLimit ||
|
|
234
|
-
gasParameters.paymasterPostOpGasLimit
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
return userOperation as PrepareUserOperationRequestReturnType<entryPoint>
|
|
238
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { type SendUserOperationParameters, deepHexlify } from "permissionless"
|
|
2
|
-
import type { SmartAccount } from "permissionless/accounts"
|
|
3
|
-
import type { BundlerRpcSchema } from "permissionless/types/bundler"
|
|
4
|
-
import type {
|
|
5
|
-
EntryPoint,
|
|
6
|
-
GetEntryPointVersion
|
|
7
|
-
} from "permissionless/types/entrypoint"
|
|
8
|
-
import type { UserOperationWithBigIntAsHex } from "permissionless/types/userOperation"
|
|
9
|
-
import type { Chain, Client, Hash, Transport } from "viem"
|
|
10
|
-
|
|
11
|
-
export async function sendSignedUserOperation<
|
|
12
|
-
entryPoint extends EntryPoint,
|
|
13
|
-
TTransport extends Transport = Transport,
|
|
14
|
-
TChain extends Chain | undefined = Chain | undefined,
|
|
15
|
-
TAccount extends SmartAccount<entryPoint> | undefined =
|
|
16
|
-
| SmartAccount<entryPoint>
|
|
17
|
-
| undefined
|
|
18
|
-
>(
|
|
19
|
-
client: Client<TTransport, TChain, TAccount, BundlerRpcSchema<entryPoint>>,
|
|
20
|
-
args: SendUserOperationParameters<entryPoint>
|
|
21
|
-
): Promise<Hash> {
|
|
22
|
-
const { userOperation, entryPoint } = args
|
|
23
|
-
|
|
24
|
-
// send user operation directly without signing
|
|
25
|
-
const userOperationHash = await client.request({
|
|
26
|
-
method: "eth_sendUserOperation",
|
|
27
|
-
params: [
|
|
28
|
-
deepHexlify(userOperation) as UserOperationWithBigIntAsHex<
|
|
29
|
-
GetEntryPointVersion<entryPoint>
|
|
30
|
-
>,
|
|
31
|
-
entryPoint
|
|
32
|
-
]
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
return userOperationHash
|
|
36
|
-
}
|