permissionless 0.0.1 → 0.0.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/CHANGELOG.md +17 -0
- package/_cjs/actions/bundler.js +118 -0
- package/_cjs/actions/bundler.js.map +1 -0
- package/_cjs/actions/index.js +12 -0
- package/_cjs/actions/index.js.map +1 -0
- package/_cjs/actions/pimlico.js +55 -0
- package/_cjs/actions/pimlico.js.map +1 -0
- package/_cjs/actions/utils.js +31 -0
- package/_cjs/actions/utils.js.map +1 -0
- package/_cjs/clients/bundler.js +17 -0
- package/_cjs/clients/bundler.js.map +1 -0
- package/_cjs/clients/index.js +6 -0
- package/_cjs/clients/index.js.map +1 -0
- package/_cjs/clients/pimlico.js +29 -0
- package/_cjs/clients/pimlico.js.map +1 -0
- package/_cjs/index.js +7 -0
- package/_cjs/index.js.map +1 -0
- package/_cjs/package.json +1 -0
- package/_cjs/types/bundler.js +3 -0
- package/_cjs/types/bundler.js.map +1 -0
- package/_cjs/types/index.js +3 -0
- package/_cjs/types/index.js.map +1 -0
- package/_cjs/types/pimlico.js +3 -0
- package/_cjs/types/pimlico.js.map +1 -0
- package/_cjs/types/userOperation.js +3 -0
- package/_cjs/types/userOperation.js.map +1 -0
- package/_esm/actions/bundler.js +251 -0
- package/_esm/actions/bundler.js.map +1 -0
- package/_esm/actions/index.js +3 -0
- package/_esm/actions/index.js.map +1 -0
- package/_esm/actions/pimlico.js +127 -0
- package/_esm/actions/pimlico.js.map +1 -0
- package/_esm/actions/utils.js +28 -0
- package/_esm/actions/utils.js.map +1 -0
- package/_esm/clients/bundler.js +33 -0
- package/_esm/clients/bundler.js.map +1 -0
- package/_esm/clients/index.js +3 -0
- package/_esm/clients/index.js.map +1 -0
- package/_esm/clients/pimlico.js +64 -0
- package/_esm/clients/pimlico.js.map +1 -0
- package/_esm/index.js +4 -0
- package/_esm/index.js.map +1 -0
- package/_esm/package.json +1 -0
- package/_esm/types/bundler.js +2 -0
- package/_esm/types/bundler.js.map +1 -0
- package/_esm/types/index.js +2 -0
- package/_esm/types/index.js.map +1 -0
- package/_esm/types/pimlico.js +2 -0
- package/_esm/types/pimlico.js.map +1 -0
- package/_esm/types/userOperation.js +2 -0
- package/_esm/types/userOperation.js.map +1 -0
- package/_types/actions/bundler.d.ts +393 -0
- package/_types/actions/bundler.d.ts.map +1 -0
- package/_types/actions/index.d.ts +5 -0
- package/_types/actions/index.d.ts.map +1 -0
- package/_types/actions/pimlico.d.ts +184 -0
- package/_types/actions/pimlico.d.ts.map +1 -0
- package/_types/actions/utils.d.ts +6 -0
- package/_types/actions/utils.d.ts.map +1 -0
- package/_types/clients/bundler.d.ts +39 -0
- package/_types/clients/bundler.d.ts.map +1 -0
- package/_types/clients/index.d.ts +3 -0
- package/_types/clients/index.d.ts.map +1 -0
- package/_types/clients/pimlico.d.ts +75 -0
- package/_types/clients/pimlico.d.ts.map +1 -0
- package/_types/index.d.ts +4 -0
- package/_types/index.d.ts.map +1 -0
- package/_types/types/bundler.d.ts +82 -0
- package/_types/types/bundler.d.ts.map +1 -0
- package/_types/types/index.d.ts +3 -0
- package/_types/types/index.d.ts.map +1 -0
- package/_types/types/pimlico.d.ts +50 -0
- package/_types/types/pimlico.d.ts.map +1 -0
- package/_types/types/userOperation.d.ts +30 -0
- package/_types/types/userOperation.d.ts.map +1 -0
- package/actions/bundler.ts +498 -0
- package/actions/index.ts +38 -0
- package/actions/package.json +6 -0
- package/actions/pimlico.ts +258 -0
- package/actions/utils.ts +30 -0
- package/clients/bundler.ts +39 -0
- package/clients/index.ts +3 -0
- package/clients/pimlico.ts +93 -0
- package/index.ts +3 -0
- package/package.json +49 -11
- package/tsconfig.build.tsbuildinfo +1 -0
- package/types/bundler.ts +85 -0
- package/types/index.ts +3 -0
- package/types/package.json +6 -0
- package/types/pimlico.ts +55 -0
- package/types/userOperation.ts +32 -0
- package/LICENSE +0 -21
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
import type { Address } from "abitype"
|
|
2
|
+
import type { Client, Hash, Hex } from "viem"
|
|
3
|
+
import type { PartialBy } from "viem/types/utils"
|
|
4
|
+
import type { BundlerClient } from "../clients/bundler"
|
|
5
|
+
import type { UserOperation } from "../types"
|
|
6
|
+
import type { TStatus, UserOperationWithBigIntAsHex } from "../types/userOperation"
|
|
7
|
+
import { deepHexlify, transactionReceiptStatus } from "./utils"
|
|
8
|
+
|
|
9
|
+
export type SendUserOperationParameters = {
|
|
10
|
+
userOperation: UserOperation
|
|
11
|
+
entryPoint: Address
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type EstimateUserOperationGasParameters = {
|
|
15
|
+
userOperation: PartialBy<UserOperation, "callGasLimit" | "preVerificationGas" | "verificationGasLimit">
|
|
16
|
+
entryPoint: Address
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type EstimateUserOperationGasReturnType = {
|
|
20
|
+
preVerificationGas: bigint
|
|
21
|
+
verificationGasLimit: bigint
|
|
22
|
+
callGasLimit: bigint
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type GetUserOperationByHashParameters = {
|
|
26
|
+
hash: Hash
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type GetUserOperationByHashReturnType = {
|
|
30
|
+
userOperation: UserOperation
|
|
31
|
+
entryPoint: Address
|
|
32
|
+
transactionHash: Hash
|
|
33
|
+
blockHash: Hash
|
|
34
|
+
blockNumber: bigint
|
|
35
|
+
} | null
|
|
36
|
+
|
|
37
|
+
export type GetUserOperationReceiptParameters = {
|
|
38
|
+
hash: Hash
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type GetUserOperationReceiptReturnType = {
|
|
42
|
+
userOpHash: Hash
|
|
43
|
+
sender: Address
|
|
44
|
+
nonce: bigint
|
|
45
|
+
actualGasUsed: bigint
|
|
46
|
+
actualGasCost: bigint
|
|
47
|
+
success: boolean
|
|
48
|
+
receipt: {
|
|
49
|
+
transactionHash: Hex
|
|
50
|
+
transactionIndex: bigint
|
|
51
|
+
blockHash: Hash
|
|
52
|
+
blockNumber: bigint
|
|
53
|
+
from: Address
|
|
54
|
+
to: Address | null
|
|
55
|
+
cumulativeGasUsed: bigint
|
|
56
|
+
status: TStatus
|
|
57
|
+
gasUsed: bigint
|
|
58
|
+
contractAddress: Address | null
|
|
59
|
+
logsBloom: Hex
|
|
60
|
+
effectiveGasPrice: bigint
|
|
61
|
+
}
|
|
62
|
+
logs: {
|
|
63
|
+
data: Hex
|
|
64
|
+
blockNumber: bigint
|
|
65
|
+
blockHash: Hash
|
|
66
|
+
transactionHash: Hash
|
|
67
|
+
logIndex: bigint
|
|
68
|
+
transactionIndex: bigint
|
|
69
|
+
address: Address
|
|
70
|
+
topics: Hex[]
|
|
71
|
+
}[]
|
|
72
|
+
} | null
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Sends user operation to the bundler
|
|
76
|
+
*
|
|
77
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/sendUserOperation
|
|
78
|
+
*
|
|
79
|
+
* @param client {@link BundlerClient} that you created using viem's createClient and extended it with bundlerActions.
|
|
80
|
+
* @param args {@link SendUserOperationParameters}.
|
|
81
|
+
* @returns UserOpHash that you can use to track user operation as {@link Hash}.
|
|
82
|
+
*
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* import { createClient } from "viem"
|
|
86
|
+
* import { sendUserOperation } from "permissionless/actions"
|
|
87
|
+
*
|
|
88
|
+
* const bundlerClient = createClient({
|
|
89
|
+
* chain: goerli,
|
|
90
|
+
* transport: http(BUNDLER_URL)
|
|
91
|
+
* })
|
|
92
|
+
*
|
|
93
|
+
* const userOpHash = sendUserOperation(bundlerClient, {
|
|
94
|
+
* userOperation: signedUserOperation,
|
|
95
|
+
* entryPoint: entryPoint
|
|
96
|
+
* })
|
|
97
|
+
*
|
|
98
|
+
* // Return '0xe9fad2cd67f9ca1d0b7a6513b2a42066784c8df938518da2b51bb8cc9a89ea34'
|
|
99
|
+
*
|
|
100
|
+
*/
|
|
101
|
+
export const sendUserOperation = async (client: BundlerClient, args: SendUserOperationParameters): Promise<Hash> => {
|
|
102
|
+
const { userOperation, entryPoint } = args
|
|
103
|
+
|
|
104
|
+
return client.request({
|
|
105
|
+
method: "eth_sendUserOperation",
|
|
106
|
+
params: [deepHexlify(userOperation) as UserOperationWithBigIntAsHex, entryPoint as Address]
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Estimates preVerificationGas, verificationGasLimit and callGasLimit for user operation
|
|
112
|
+
*
|
|
113
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/estimateUserOperationGas
|
|
114
|
+
*
|
|
115
|
+
* @param client {@link BundlerClient} that you created using viem's createClient and extended it with bundlerActions.
|
|
116
|
+
* @param args {@link EstimateUserOperationGasParameters}
|
|
117
|
+
* @returns preVerificationGas, verificationGasLimit and callGasLimit as {@link EstimateUserOperationGasReturnType}
|
|
118
|
+
*
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* import { createClient } from "viem"
|
|
122
|
+
* import { estimateUserOperationGas } from "permissionless/actions"
|
|
123
|
+
*
|
|
124
|
+
* const bundlerClient = createClient({
|
|
125
|
+
* chain: goerli,
|
|
126
|
+
* transport: http(BUNDLER_URL)
|
|
127
|
+
* })
|
|
128
|
+
*
|
|
129
|
+
* const gasParameters = estimateUserOperationGas(bundlerClient, {
|
|
130
|
+
* serOperation: signedUserOperation,
|
|
131
|
+
* entryPoint: entryPoint
|
|
132
|
+
* })
|
|
133
|
+
*
|
|
134
|
+
* // Return {preVerificationGas: 43492n, verificationGasLimit: 59436n, callGasLimit: 9000n}
|
|
135
|
+
*
|
|
136
|
+
*/
|
|
137
|
+
export const estimateUserOperationGas = async (
|
|
138
|
+
client: BundlerClient,
|
|
139
|
+
args: EstimateUserOperationGasParameters
|
|
140
|
+
): Promise<EstimateUserOperationGasReturnType> => {
|
|
141
|
+
const { userOperation, entryPoint } = args
|
|
142
|
+
|
|
143
|
+
const response = await client.request({
|
|
144
|
+
method: "eth_estimateUserOperationGas",
|
|
145
|
+
params: [deepHexlify(userOperation) as UserOperationWithBigIntAsHex, entryPoint as Address]
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
preVerificationGas: BigInt(response.preVerificationGas || 0n),
|
|
150
|
+
verificationGasLimit: BigInt(response.verificationGasLimit || 0n),
|
|
151
|
+
callGasLimit: BigInt(response.callGasLimit || 0n)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Returns the supported entrypoints by the bundler service
|
|
157
|
+
*
|
|
158
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/supportedEntryPoints
|
|
159
|
+
*
|
|
160
|
+
* @param client {@link BundlerClient} that you created using viem's createClient and extended it with bundlerActions.
|
|
161
|
+
* @returns Supported entryPoints
|
|
162
|
+
*
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* import { createClient } from "viem"
|
|
166
|
+
* import { supportedEntryPoints } from "permissionless/actions"
|
|
167
|
+
*
|
|
168
|
+
* const bundlerClient = createClient({
|
|
169
|
+
* chain: goerli,
|
|
170
|
+
* transport: http(BUNDLER_URL)
|
|
171
|
+
* })
|
|
172
|
+
*
|
|
173
|
+
* const entryPointsSupported = supportedEntryPoints(bundlerClient)
|
|
174
|
+
* // Return ['0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789']
|
|
175
|
+
*
|
|
176
|
+
*/
|
|
177
|
+
export const supportedEntryPoints = async (client: BundlerClient): Promise<Address[]> => {
|
|
178
|
+
return client.request({
|
|
179
|
+
method: "eth_supportedEntryPoints",
|
|
180
|
+
params: []
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Returns the supported chain id by the bundler service
|
|
186
|
+
*
|
|
187
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/chainId
|
|
188
|
+
*
|
|
189
|
+
* @param client {@link BundlerClient} that you created using viem's createClient and extended it with bundlerActions.
|
|
190
|
+
* @returns Supported chain id
|
|
191
|
+
*
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* import { createClient } from "viem"
|
|
195
|
+
* import { chainId } from "permissionless/actions"
|
|
196
|
+
*
|
|
197
|
+
* const bundlerClient = createClient({
|
|
198
|
+
* chain: goerli,
|
|
199
|
+
* transport: http(BUNDLER_URL)
|
|
200
|
+
* })
|
|
201
|
+
*
|
|
202
|
+
* const bundlerChainId = chainId(bundlerClient)
|
|
203
|
+
* // Return 5n for Goerli
|
|
204
|
+
*
|
|
205
|
+
*/
|
|
206
|
+
export const chainId = async (client: BundlerClient) => {
|
|
207
|
+
return BigInt(
|
|
208
|
+
await client.request({
|
|
209
|
+
method: "eth_chainId",
|
|
210
|
+
params: []
|
|
211
|
+
})
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Returns the user operation from userOpHash
|
|
217
|
+
*
|
|
218
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/getUserOperationByHash
|
|
219
|
+
*
|
|
220
|
+
* @param client {@link BundlerClient} that you created using viem's createClient and extended it with bundlerActions.
|
|
221
|
+
* @param args {@link GetUserOperationByHashParameters} UserOpHash that was returned by {@link sendUserOperation}
|
|
222
|
+
* @returns userOperation along with entryPoint, transactionHash, blockHash, blockNumber if found or null
|
|
223
|
+
*
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* import { createClient } from "viem"
|
|
227
|
+
* import { getUserOperationByHash } from "permissionless/actions"
|
|
228
|
+
*
|
|
229
|
+
* const bundlerClient = createClient({
|
|
230
|
+
* chain: goerli,
|
|
231
|
+
* transport: http(BUNDLER_URL)
|
|
232
|
+
* })
|
|
233
|
+
*
|
|
234
|
+
* getUserOperationByHash(bundlerClient, {hash: userOpHash})
|
|
235
|
+
*
|
|
236
|
+
*/
|
|
237
|
+
export const getUserOperationByHash = async (
|
|
238
|
+
client: BundlerClient,
|
|
239
|
+
{ hash }: GetUserOperationByHashParameters
|
|
240
|
+
): Promise<{
|
|
241
|
+
userOperation: UserOperation
|
|
242
|
+
entryPoint: Address
|
|
243
|
+
transactionHash: Hash
|
|
244
|
+
blockHash: Hash
|
|
245
|
+
blockNumber: bigint
|
|
246
|
+
} | null> => {
|
|
247
|
+
const params: [Hash] = [hash]
|
|
248
|
+
|
|
249
|
+
const response = await client.request({
|
|
250
|
+
method: "eth_getUserOperationByHash",
|
|
251
|
+
params
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
if (!response) return null
|
|
255
|
+
|
|
256
|
+
const { userOperation, entryPoint, transactionHash, blockHash, blockNumber } = response
|
|
257
|
+
|
|
258
|
+
return {
|
|
259
|
+
userOperation: {
|
|
260
|
+
...userOperation,
|
|
261
|
+
nonce: BigInt(userOperation.nonce),
|
|
262
|
+
callGasLimit: BigInt(userOperation.callGasLimit),
|
|
263
|
+
verificationGasLimit: BigInt(userOperation.verificationGasLimit),
|
|
264
|
+
preVerificationGas: BigInt(userOperation.preVerificationGas),
|
|
265
|
+
maxFeePerGas: BigInt(userOperation.maxFeePerGas),
|
|
266
|
+
maxPriorityFeePerGas: BigInt(userOperation.maxPriorityFeePerGas)
|
|
267
|
+
} as UserOperation,
|
|
268
|
+
entryPoint: entryPoint,
|
|
269
|
+
transactionHash: transactionHash,
|
|
270
|
+
blockHash: blockHash,
|
|
271
|
+
blockNumber: BigInt(blockNumber)
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Returns the user operation receipt from userOpHash
|
|
277
|
+
*
|
|
278
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/getUserOperationReceipt
|
|
279
|
+
*
|
|
280
|
+
* @param client {@link BundlerClient} that you created using viem's createClient and extended it with bundlerActions.
|
|
281
|
+
* @param args {@link GetUserOperationReceiptParameters} UserOpHash that was returned by {@link sendUserOperation}
|
|
282
|
+
* @returns user operation receipt {@link GetUserOperationReceiptReturnType} if found or null
|
|
283
|
+
*
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* import { createClient } from "viem"
|
|
287
|
+
* import { getUserOperationReceipt } from "permissionless/actions"
|
|
288
|
+
*
|
|
289
|
+
* const bundlerClient = createClient({
|
|
290
|
+
* chain: goerli,
|
|
291
|
+
* transport: http(BUNDLER_URL)
|
|
292
|
+
* })
|
|
293
|
+
*
|
|
294
|
+
* getUserOperationReceipt(bundlerClient, {hash: userOpHash})
|
|
295
|
+
*
|
|
296
|
+
*/
|
|
297
|
+
export const getUserOperationReceipt = async (client: BundlerClient, { hash }: GetUserOperationReceiptParameters) => {
|
|
298
|
+
const params: [Hash] = [hash]
|
|
299
|
+
|
|
300
|
+
const response = await client.request({
|
|
301
|
+
method: "eth_getUserOperationReceipt",
|
|
302
|
+
params
|
|
303
|
+
})
|
|
304
|
+
|
|
305
|
+
if (!response) return null
|
|
306
|
+
|
|
307
|
+
const userOperationReceipt: GetUserOperationReceiptReturnType = {
|
|
308
|
+
userOpHash: response.userOpHash,
|
|
309
|
+
sender: response.sender,
|
|
310
|
+
nonce: BigInt(response.nonce),
|
|
311
|
+
actualGasUsed: BigInt(response.actualGasUsed),
|
|
312
|
+
actualGasCost: BigInt(response.actualGasCost),
|
|
313
|
+
success: response.success,
|
|
314
|
+
receipt: {
|
|
315
|
+
transactionHash: response.receipt.transactionHash,
|
|
316
|
+
transactionIndex: BigInt(response.receipt.transactionIndex),
|
|
317
|
+
blockHash: response.receipt.blockHash,
|
|
318
|
+
blockNumber: BigInt(response.receipt.blockNumber),
|
|
319
|
+
from: response.receipt.from,
|
|
320
|
+
to: response.receipt.to,
|
|
321
|
+
cumulativeGasUsed: BigInt(response.receipt.cumulativeGasUsed),
|
|
322
|
+
status: transactionReceiptStatus[response.receipt.status],
|
|
323
|
+
gasUsed: BigInt(response.receipt.gasUsed),
|
|
324
|
+
contractAddress: response.receipt.contractAddress,
|
|
325
|
+
logsBloom: response.receipt.logsBloom,
|
|
326
|
+
effectiveGasPrice: BigInt(response.receipt.effectiveGasPrice)
|
|
327
|
+
},
|
|
328
|
+
logs: response.logs.map((log) => ({
|
|
329
|
+
data: log.data,
|
|
330
|
+
blockNumber: BigInt(log.blockNumber),
|
|
331
|
+
blockHash: log.blockHash,
|
|
332
|
+
transactionHash: log.transactionHash,
|
|
333
|
+
logIndex: BigInt(log.logIndex),
|
|
334
|
+
transactionIndex: BigInt(log.transactionIndex),
|
|
335
|
+
address: log.address,
|
|
336
|
+
topics: log.topics
|
|
337
|
+
}))
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
return userOperationReceipt
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export type BundlerActions = {
|
|
344
|
+
/**
|
|
345
|
+
*
|
|
346
|
+
* Sends user operation to the bundler
|
|
347
|
+
*
|
|
348
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/sendUserOperation
|
|
349
|
+
*
|
|
350
|
+
* @param args {@link SendUserOperationParameters}.
|
|
351
|
+
* @returns UserOpHash that you can use to track user operation as {@link Hash}.
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* import { createClient } from "viem"
|
|
355
|
+
* import { bundlerActions } from "permissionless"
|
|
356
|
+
*
|
|
357
|
+
* const bundlerClient = createClient({
|
|
358
|
+
* chain: goerli,
|
|
359
|
+
* transport: http("https://api.pimlico.io/v1/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
360
|
+
* }).extend(bundlerActions)
|
|
361
|
+
*
|
|
362
|
+
* const userOpHash = await bundlerClient.sendUserOperation({
|
|
363
|
+
* userOperation: signedUserOperation,
|
|
364
|
+
* entryPoint: entryPoint
|
|
365
|
+
* })
|
|
366
|
+
*
|
|
367
|
+
* // Return '0xe9fad2cd67f9ca1d0b7a6513b2a42066784c8df938518da2b51bb8cc9a89ea34'
|
|
368
|
+
*/
|
|
369
|
+
sendUserOperation: (args: SendUserOperationParameters) => Promise<Hash>
|
|
370
|
+
/**
|
|
371
|
+
*
|
|
372
|
+
* Estimates preVerificationGas, verificationGasLimit and callGasLimit for user operation
|
|
373
|
+
*
|
|
374
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/estimateUserOperationGas
|
|
375
|
+
*
|
|
376
|
+
* @param args {@link EstimateUserOperationGasParameters}
|
|
377
|
+
* @returns preVerificationGas, verificationGasLimit and callGasLimit as {@link EstimateUserOperationGasReturnType}
|
|
378
|
+
*
|
|
379
|
+
* @example
|
|
380
|
+
* import { createClient } from "viem"
|
|
381
|
+
* import { bundlerActions } from "permissionless"
|
|
382
|
+
*
|
|
383
|
+
* const bundlerClient = createClient({
|
|
384
|
+
* chain: goerli,
|
|
385
|
+
* transport: http(BUNDLER_URL)
|
|
386
|
+
* }).extend(bundlerActions)
|
|
387
|
+
*
|
|
388
|
+
* const gasParameters = await bundlerClient.estimateUserOperationGas({
|
|
389
|
+
* userOperation: signedUserOperation,
|
|
390
|
+
* entryPoint: entryPoint
|
|
391
|
+
* })
|
|
392
|
+
*
|
|
393
|
+
* // Return {preVerificationGas: 43492n, verificationGasLimit: 59436n, callGasLimit: 9000n}
|
|
394
|
+
*/
|
|
395
|
+
estimateUserOperationGas: (args: EstimateUserOperationGasParameters) => Promise<EstimateUserOperationGasReturnType>
|
|
396
|
+
/**
|
|
397
|
+
*
|
|
398
|
+
* Returns the supported entrypoints by the bundler service
|
|
399
|
+
*
|
|
400
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/supportedEntryPoints
|
|
401
|
+
*
|
|
402
|
+
* @returns Supported entryPoints
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* import { createClient } from "viem"
|
|
406
|
+
* import { bundlerActions } from "permissionless"
|
|
407
|
+
*
|
|
408
|
+
* const bundlerClient = createClient({
|
|
409
|
+
* chain: goerli,
|
|
410
|
+
* transport: http(BUNDLER_URL)
|
|
411
|
+
* }).extend(bundlerActions)
|
|
412
|
+
*
|
|
413
|
+
* const supportedEntryPoints = await bundlerClient.supportedEntryPoints()
|
|
414
|
+
*
|
|
415
|
+
* // Return ['0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789']
|
|
416
|
+
*/
|
|
417
|
+
supportedEntryPoints: () => Promise<Address[]>
|
|
418
|
+
/**
|
|
419
|
+
*
|
|
420
|
+
* Returns the supported chain id by the bundler service
|
|
421
|
+
*
|
|
422
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/chainId
|
|
423
|
+
*
|
|
424
|
+
* @returns Supported chain id
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* import { createClient } from "viem"
|
|
428
|
+
* import { bundlerActions } from "permissionless"
|
|
429
|
+
*
|
|
430
|
+
* const bundlerClient = createClient({
|
|
431
|
+
* chain: goerli,
|
|
432
|
+
* transport: http(BUNDLER_URL)
|
|
433
|
+
* }).extend(bundlerActions)
|
|
434
|
+
*
|
|
435
|
+
* const chainId = await bundlerClient.chainId()
|
|
436
|
+
* // Return 5n for Goerli
|
|
437
|
+
*/
|
|
438
|
+
chainId: () => Promise<bigint>
|
|
439
|
+
/**
|
|
440
|
+
*
|
|
441
|
+
* Returns the user operation from userOpHash
|
|
442
|
+
*
|
|
443
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/getUserOperationByHash
|
|
444
|
+
*
|
|
445
|
+
* @param args {@link GetUserOperationByHash} UserOpHash that was returned by {@link sendUserOperation}
|
|
446
|
+
* @returns userOperation along with entryPoint, transactionHash, blockHash, blockNumber if found or null
|
|
447
|
+
*
|
|
448
|
+
* @example
|
|
449
|
+
* import { createClient } from "viem"
|
|
450
|
+
* import { bundlerActions } from "permissionless"
|
|
451
|
+
*
|
|
452
|
+
* const bundlerClient = createClient({
|
|
453
|
+
* chain: goerli,
|
|
454
|
+
* transport: http(BUNDLER_URL)
|
|
455
|
+
* }).extend(bundlerActions)
|
|
456
|
+
*
|
|
457
|
+
* await bundlerClient.getUserOperationByHash(userOpHash)
|
|
458
|
+
*
|
|
459
|
+
*/
|
|
460
|
+
getUserOperationByHash: (args: GetUserOperationByHashParameters) => Promise<GetUserOperationByHashReturnType>
|
|
461
|
+
/**
|
|
462
|
+
*
|
|
463
|
+
* Returns the user operation receipt from userOpHash
|
|
464
|
+
*
|
|
465
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/getUserOperationReceipt
|
|
466
|
+
*
|
|
467
|
+
* @param args {@link GetUserOperationReceiptParameters} UserOpHash that was returned by {@link sendUserOperation}
|
|
468
|
+
* @returns user operation receipt {@link GetUserOperationReceiptReturnType} if found or null
|
|
469
|
+
*
|
|
470
|
+
* @example
|
|
471
|
+
* import { createClient } from "viem"
|
|
472
|
+
* import { bundlerActions } from "permissionless"
|
|
473
|
+
*
|
|
474
|
+
* const bundlerClient = createClient({
|
|
475
|
+
* chain: goerli,
|
|
476
|
+
* transport: http(BUNDLER_URL)
|
|
477
|
+
* }).extend(bundlerActions)
|
|
478
|
+
*
|
|
479
|
+
* await bundlerClient.getUserOperationReceipt({hash: userOpHash})
|
|
480
|
+
*
|
|
481
|
+
*/
|
|
482
|
+
getUserOperationReceipt: (args: GetUserOperationReceiptParameters) => Promise<GetUserOperationReceiptReturnType>
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
const bundlerActions = (client: Client): BundlerActions => ({
|
|
486
|
+
sendUserOperation: async (args: SendUserOperationParameters): Promise<Hash> =>
|
|
487
|
+
sendUserOperation(client as BundlerClient, args),
|
|
488
|
+
estimateUserOperationGas: (args: EstimateUserOperationGasParameters) =>
|
|
489
|
+
estimateUserOperationGas(client as BundlerClient, args),
|
|
490
|
+
supportedEntryPoints: (): Promise<Address[]> => supportedEntryPoints(client as BundlerClient),
|
|
491
|
+
chainId: () => chainId(client as BundlerClient),
|
|
492
|
+
getUserOperationByHash: (args: GetUserOperationByHashParameters) =>
|
|
493
|
+
getUserOperationByHash(client as BundlerClient, args),
|
|
494
|
+
getUserOperationReceipt: (args: GetUserOperationReceiptParameters) =>
|
|
495
|
+
getUserOperationReceipt(client as BundlerClient, args)
|
|
496
|
+
})
|
|
497
|
+
|
|
498
|
+
export default bundlerActions
|
package/actions/index.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
EstimateUserOperationGasParameters,
|
|
3
|
+
EstimateUserOperationGasReturnType,
|
|
4
|
+
GetUserOperationByHashParameters,
|
|
5
|
+
GetUserOperationByHashReturnType,
|
|
6
|
+
GetUserOperationReceiptParameters,
|
|
7
|
+
GetUserOperationReceiptReturnType,
|
|
8
|
+
SendUserOperationParameters
|
|
9
|
+
} from "./bundler"
|
|
10
|
+
|
|
11
|
+
import bundlerActions, {
|
|
12
|
+
chainId,
|
|
13
|
+
estimateUserOperationGas,
|
|
14
|
+
getUserOperationByHash,
|
|
15
|
+
getUserOperationReceipt,
|
|
16
|
+
sendUserOperation,
|
|
17
|
+
supportedEntryPoints
|
|
18
|
+
} from "./bundler"
|
|
19
|
+
|
|
20
|
+
export type {
|
|
21
|
+
SendUserOperationParameters,
|
|
22
|
+
EstimateUserOperationGasParameters,
|
|
23
|
+
EstimateUserOperationGasReturnType,
|
|
24
|
+
GetUserOperationByHashParameters,
|
|
25
|
+
GetUserOperationByHashReturnType,
|
|
26
|
+
GetUserOperationReceiptParameters,
|
|
27
|
+
GetUserOperationReceiptReturnType
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
bundlerActions,
|
|
32
|
+
sendUserOperation,
|
|
33
|
+
estimateUserOperationGas,
|
|
34
|
+
supportedEntryPoints,
|
|
35
|
+
chainId,
|
|
36
|
+
getUserOperationByHash,
|
|
37
|
+
getUserOperationReceipt
|
|
38
|
+
}
|