permissionless 0.0.5 → 0.0.7
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 +13 -0
- package/_cjs/actions/bundler/chainId.js +11 -0
- package/_cjs/actions/bundler/chainId.js.map +1 -0
- package/_cjs/actions/bundler/estimateUserOperationGas.js +18 -0
- package/_cjs/actions/bundler/estimateUserOperationGas.js.map +1 -0
- package/_cjs/actions/bundler/getUserOperationByHash.js +30 -0
- package/_cjs/actions/bundler/getUserOperationByHash.js.map +1 -0
- package/_cjs/actions/bundler/getUserOperationReceipt.js +48 -0
- package/_cjs/actions/bundler/getUserOperationReceipt.js.map +1 -0
- package/_cjs/actions/bundler/sendUserOperation.js +13 -0
- package/_cjs/actions/bundler/sendUserOperation.js.map +1 -0
- package/_cjs/actions/bundler/supportedEntryPoints.js +11 -0
- package/_cjs/actions/bundler/supportedEntryPoints.js.map +1 -0
- package/_cjs/actions/index.js +18 -11
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/pimlico/getUserOperationGasPrice.js +25 -0
- package/_cjs/actions/pimlico/getUserOperationGasPrice.js.map +1 -0
- package/_cjs/actions/pimlico/getUserOperationStatus.js +11 -0
- package/_cjs/actions/pimlico/getUserOperationStatus.js.map +1 -0
- package/_cjs/actions/pimlico/sponsorUserOperation.js +18 -0
- package/_cjs/actions/pimlico/sponsorUserOperation.js.map +1 -0
- package/_cjs/actions/pimlico.js +10 -52
- package/_cjs/actions/pimlico.js.map +1 -1
- package/_cjs/actions/public/getAccountNonce.js +35 -0
- package/_cjs/actions/public/getAccountNonce.js.map +1 -0
- package/_cjs/actions/{public.js → public/getSenderAddress.js} +1 -1
- package/_cjs/actions/public/getSenderAddress.js.map +1 -0
- package/_cjs/actions/stackup/accounts.js +12 -0
- package/_cjs/actions/stackup/accounts.js.map +1 -0
- package/_cjs/actions/stackup/sponsorUserOperation.js +18 -0
- package/_cjs/actions/stackup/sponsorUserOperation.js.map +1 -0
- package/_cjs/actions/stackup.js +10 -0
- package/_cjs/actions/stackup.js.map +1 -0
- package/_cjs/clients/bundler.js +2 -2
- package/_cjs/clients/bundler.js.map +1 -1
- package/_cjs/clients/decorators/bundler.js +19 -0
- package/_cjs/clients/decorators/bundler.js.map +1 -0
- package/_cjs/clients/decorators/pimlico.js +16 -0
- package/_cjs/clients/decorators/pimlico.js.map +1 -0
- package/_cjs/clients/decorators/stackup.js +11 -0
- package/_cjs/clients/decorators/stackup.js.map +1 -0
- package/_cjs/clients/pimlico.js +4 -4
- package/_cjs/clients/pimlico.js.map +1 -1
- package/_cjs/clients/stackup.js +18 -0
- package/_cjs/clients/stackup.js.map +1 -0
- package/_cjs/index.js +24 -4
- package/_cjs/index.js.map +1 -1
- package/_cjs/types/stackup.js +3 -0
- package/_cjs/types/stackup.js.map +1 -0
- package/_cjs/utils/getUserOperationHash.js +38 -0
- package/_cjs/utils/getUserOperationHash.js.map +1 -0
- package/_cjs/utils/index.js +2 -34
- package/_cjs/utils/index.js.map +1 -1
- package/_esm/actions/bundler/chainId.js +29 -0
- package/_esm/actions/bundler/chainId.js.map +1 -0
- package/_esm/actions/bundler/estimateUserOperationGas.js +41 -0
- package/_esm/actions/bundler/estimateUserOperationGas.js.map +1 -0
- package/_esm/actions/bundler/getUserOperationByHash.js +48 -0
- package/_esm/actions/bundler/getUserOperationByHash.js.map +1 -0
- package/_esm/actions/bundler/getUserOperationReceipt.js +66 -0
- package/_esm/actions/bundler/getUserOperationReceipt.js.map +1 -0
- package/_esm/actions/bundler/sendUserOperation.js +36 -0
- package/_esm/actions/bundler/sendUserOperation.js.map +1 -0
- package/_esm/actions/bundler/supportedEntryPoints.js +29 -0
- package/_esm/actions/bundler/supportedEntryPoints.js.map +1 -0
- package/_esm/actions/index.js +9 -3
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/pimlico/getUserOperationGasPrice.js +42 -0
- package/_esm/actions/pimlico/getUserOperationGasPrice.js.map +1 -0
- package/_esm/actions/pimlico/getUserOperationStatus.js +29 -0
- package/_esm/actions/pimlico/getUserOperationStatus.js.map +1 -0
- package/_esm/actions/pimlico/sponsorUserOperation.js +39 -0
- package/_esm/actions/pimlico/sponsorUserOperation.js.map +1 -0
- package/_esm/actions/pimlico.js +5 -123
- package/_esm/actions/pimlico.js.map +1 -1
- package/_esm/actions/public/getAccountNonce.js +57 -0
- package/_esm/actions/public/getAccountNonce.js.map +1 -0
- package/_esm/actions/{public.js → public/getSenderAddress.js} +3 -3
- package/_esm/actions/public/getSenderAddress.js.map +1 -0
- package/_esm/actions/stackup/accounts.js +30 -0
- package/_esm/actions/stackup/accounts.js.map +1 -0
- package/_esm/actions/stackup/sponsorUserOperation.js +40 -0
- package/_esm/actions/stackup/sponsorUserOperation.js.map +1 -0
- package/_esm/actions/stackup.js +5 -0
- package/_esm/actions/stackup.js.map +1 -0
- package/_esm/clients/bundler.js +1 -1
- package/_esm/clients/bundler.js.map +1 -1
- package/_esm/clients/decorators/bundler.js +16 -0
- package/_esm/clients/decorators/bundler.js.map +1 -0
- package/_esm/clients/decorators/pimlico.js +20 -0
- package/_esm/clients/decorators/pimlico.js.map +1 -0
- package/_esm/clients/decorators/stackup.js +8 -0
- package/_esm/clients/decorators/stackup.js.map +1 -0
- package/_esm/clients/pimlico.js +2 -2
- package/_esm/clients/pimlico.js.map +1 -1
- package/_esm/clients/stackup.js +33 -0
- package/_esm/clients/stackup.js.map +1 -0
- package/_esm/index.js +15 -4
- package/_esm/index.js.map +1 -1
- package/_esm/types/stackup.js +2 -0
- package/_esm/types/stackup.js.map +1 -0
- package/_esm/utils/getUserOperationHash.js +55 -0
- package/_esm/utils/getUserOperationHash.js.map +1 -0
- package/_esm/utils/index.js +1 -54
- package/_esm/utils/index.js.map +1 -1
- package/_types/actions/bundler/chainId.d.ts +25 -0
- package/_types/actions/bundler/chainId.d.ts.map +1 -0
- package/_types/actions/bundler/estimateUserOperationGas.d.ts +42 -0
- package/_types/actions/bundler/estimateUserOperationGas.d.ts.map +1 -0
- package/_types/actions/bundler/getUserOperationByHash.d.ts +37 -0
- package/_types/actions/bundler/getUserOperationByHash.d.ts.map +1 -0
- package/_types/actions/bundler/getUserOperationReceipt.d.ts +93 -0
- package/_types/actions/bundler/getUserOperationReceipt.d.ts.map +1 -0
- package/_types/actions/bundler/sendUserOperation.d.ts +36 -0
- package/_types/actions/bundler/sendUserOperation.d.ts.map +1 -0
- package/_types/actions/bundler/supportedEntryPoints.d.ts +26 -0
- package/_types/actions/bundler/supportedEntryPoints.d.ts.map +1 -0
- package/_types/actions/index.d.ts +17 -6
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/actions/pimlico/getUserOperationGasPrice.d.ts +38 -0
- package/_types/actions/pimlico/getUserOperationGasPrice.d.ts.map +1 -0
- package/_types/actions/pimlico/getUserOperationStatus.d.ts +31 -0
- package/_types/actions/pimlico/getUserOperationStatus.d.ts.map +1 -0
- package/_types/actions/pimlico/sponsorUserOperation.d.ts +41 -0
- package/_types/actions/pimlico/sponsorUserOperation.d.ts.map +1 -0
- package/_types/actions/pimlico.d.ts +7 -177
- package/_types/actions/pimlico.d.ts.map +1 -1
- package/_types/actions/public/getAccountNonce.d.ts +34 -0
- package/_types/actions/public/getAccountNonce.d.ts.map +1 -0
- package/_types/actions/{public.d.ts → public/getSenderAddress.d.ts} +4 -5
- package/_types/actions/public/getSenderAddress.d.ts.map +1 -0
- package/_types/actions/stackup/accounts.d.ts +29 -0
- package/_types/actions/stackup/accounts.d.ts.map +1 -0
- package/_types/actions/stackup/sponsorUserOperation.d.ts +43 -0
- package/_types/actions/stackup/sponsorUserOperation.d.ts.map +1 -0
- package/_types/actions/stackup.d.ts +7 -0
- package/_types/actions/stackup.d.ts.map +1 -0
- package/_types/clients/bundler.d.ts +2 -2
- package/_types/clients/bundler.d.ts.map +1 -1
- package/_types/clients/decorators/bundler.d.ts +150 -0
- package/_types/clients/decorators/bundler.d.ts.map +1 -0
- package/_types/clients/decorators/pimlico.d.ts +78 -0
- package/_types/clients/decorators/pimlico.d.ts.map +1 -0
- package/_types/clients/decorators/stackup.d.ts +54 -0
- package/_types/clients/decorators/stackup.d.ts.map +1 -0
- package/_types/clients/pimlico.d.ts +3 -3
- package/_types/clients/pimlico.d.ts.map +1 -1
- package/_types/clients/stackup.d.ts +39 -0
- package/_types/clients/stackup.d.ts.map +1 -0
- package/_types/index.d.ts +26 -4
- package/_types/index.d.ts.map +1 -1
- package/_types/types/bundler.d.ts +1 -1
- package/_types/types/bundler.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/pimlico.d.ts +1 -1
- package/_types/types/pimlico.d.ts.map +1 -1
- package/_types/types/stackup.d.ts +35 -0
- package/_types/types/stackup.d.ts.map +1 -0
- package/_types/utils/getUserOperationHash.d.ts +30 -0
- package/_types/utils/getUserOperationHash.d.ts.map +1 -0
- package/_types/utils/index.d.ts +2 -30
- package/_types/utils/index.d.ts.map +1 -1
- package/actions/bundler/chainId.ts +32 -0
- package/actions/bundler/estimateUserOperationGas.ts +62 -0
- package/actions/bundler/getUserOperationByHash.ts +69 -0
- package/actions/bundler/getUserOperationReceipt.ts +109 -0
- package/actions/bundler/sendUserOperation.ts +45 -0
- package/actions/bundler/supportedEntryPoints.ts +31 -0
- package/actions/index.ts +23 -21
- package/actions/pimlico/getUserOperationGasPrice.ts +61 -0
- package/actions/pimlico/getUserOperationStatus.ts +41 -0
- package/actions/pimlico/sponsorUserOperation.ts +62 -0
- package/actions/pimlico.ts +34 -251
- package/actions/public/getAccountNonce.ts +63 -0
- package/actions/{public.ts → public/getSenderAddress.ts} +9 -9
- package/actions/stackup/accounts.ts +40 -0
- package/actions/stackup/sponsorUserOperation.ts +64 -0
- package/actions/stackup.ts +17 -0
- package/clients/bundler.ts +2 -3
- package/clients/decorators/bundler.ts +178 -0
- package/clients/decorators/pimlico.ts +107 -0
- package/clients/decorators/stackup.ts +65 -0
- package/clients/pimlico.ts +3 -4
- package/clients/stackup.ts +44 -0
- package/index.ts +62 -4
- package/package.json +11 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/bundler.ts +1 -1
- package/types/index.ts +1 -1
- package/types/pimlico.ts +1 -1
- package/types/stackup.ts +36 -0
- package/utils/getUserOperationHash.ts +68 -0
- package/utils/index.ts +2 -69
- package/_cjs/actions/bundler.js +0 -118
- package/_cjs/actions/bundler.js.map +0 -1
- package/_cjs/actions/public.js.map +0 -1
- package/_cjs/clients/index.js +0 -6
- package/_cjs/clients/index.js.map +0 -1
- package/_esm/actions/bundler.js +0 -251
- package/_esm/actions/bundler.js.map +0 -1
- package/_esm/actions/public.js.map +0 -1
- package/_esm/clients/index.js +0 -3
- package/_esm/clients/index.js.map +0 -1
- package/_types/actions/bundler.d.ts +0 -393
- package/_types/actions/bundler.d.ts.map +0 -1
- package/_types/actions/public.d.ts.map +0 -1
- package/_types/clients/index.d.ts +0 -3
- package/_types/clients/index.d.ts.map +0 -1
- package/actions/bundler.ts +0 -498
- package/clients/index.ts +0 -3
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { Address } from "abitype"
|
|
2
|
+
import type { Client, Hash } from "viem"
|
|
3
|
+
import { chainId } from "../../actions/bundler/chainId.js"
|
|
4
|
+
import {
|
|
5
|
+
type EstimateUserOperationGasParameters,
|
|
6
|
+
type EstimateUserOperationGasReturnType,
|
|
7
|
+
estimateUserOperationGas
|
|
8
|
+
} from "../../actions/bundler/estimateUserOperationGas.js"
|
|
9
|
+
import {
|
|
10
|
+
type GetUserOperationByHashParameters,
|
|
11
|
+
type GetUserOperationByHashReturnType,
|
|
12
|
+
getUserOperationByHash
|
|
13
|
+
} from "../../actions/bundler/getUserOperationByHash.js"
|
|
14
|
+
import {
|
|
15
|
+
type GetUserOperationReceiptParameters,
|
|
16
|
+
type GetUserOperationReceiptReturnType,
|
|
17
|
+
getUserOperationReceipt
|
|
18
|
+
} from "../../actions/bundler/getUserOperationReceipt.js"
|
|
19
|
+
import { type SendUserOperationParameters, sendUserOperation } from "../../actions/bundler/sendUserOperation.js"
|
|
20
|
+
import { supportedEntryPoints } from "../../actions/bundler/supportedEntryPoints.js"
|
|
21
|
+
import type { BundlerClient } from "../bundler.js"
|
|
22
|
+
|
|
23
|
+
export type BundlerActions = {
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* Sends user operation to the bundler
|
|
27
|
+
*
|
|
28
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/sendUserOperation
|
|
29
|
+
*
|
|
30
|
+
* @param args {@link SendUserOperationParameters}.
|
|
31
|
+
* @returns UserOpHash that you can use to track user operation as {@link Hash}.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* import { createClient } from "viem"
|
|
35
|
+
* import { bundlerActions } from "permissionless"
|
|
36
|
+
*
|
|
37
|
+
* const bundlerClient = createClient({
|
|
38
|
+
* chain: goerli,
|
|
39
|
+
* transport: http("https://api.pimlico.io/v1/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
40
|
+
* }).extend(bundlerActions)
|
|
41
|
+
*
|
|
42
|
+
* const userOpHash = await bundlerClient.sendUserOperation({
|
|
43
|
+
* userOperation: signedUserOperation,
|
|
44
|
+
* entryPoint: entryPoint
|
|
45
|
+
* })
|
|
46
|
+
*
|
|
47
|
+
* // Return '0xe9fad2cd67f9ca1d0b7a6513b2a42066784c8df938518da2b51bb8cc9a89ea34'
|
|
48
|
+
*/
|
|
49
|
+
sendUserOperation: (args: SendUserOperationParameters) => Promise<Hash>
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* Estimates preVerificationGas, verificationGasLimit and callGasLimit for user operation
|
|
53
|
+
*
|
|
54
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/estimateUserOperationGas
|
|
55
|
+
*
|
|
56
|
+
* @param args {@link EstimateUserOperationGasParameters}
|
|
57
|
+
* @returns preVerificationGas, verificationGasLimit and callGasLimit as {@link EstimateUserOperationGasReturnType}
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* import { createClient } from "viem"
|
|
61
|
+
* import { bundlerActions } from "permissionless"
|
|
62
|
+
*
|
|
63
|
+
* const bundlerClient = createClient({
|
|
64
|
+
* chain: goerli,
|
|
65
|
+
* transport: http(BUNDLER_URL)
|
|
66
|
+
* }).extend(bundlerActions)
|
|
67
|
+
*
|
|
68
|
+
* const gasParameters = await bundlerClient.estimateUserOperationGas({
|
|
69
|
+
* userOperation: signedUserOperation,
|
|
70
|
+
* entryPoint: entryPoint
|
|
71
|
+
* })
|
|
72
|
+
*
|
|
73
|
+
* // Return {preVerificationGas: 43492n, verificationGasLimit: 59436n, callGasLimit: 9000n}
|
|
74
|
+
*/
|
|
75
|
+
estimateUserOperationGas: (args: EstimateUserOperationGasParameters) => Promise<EstimateUserOperationGasReturnType>
|
|
76
|
+
/**
|
|
77
|
+
*
|
|
78
|
+
* Returns the supported entrypoints by the bundler service
|
|
79
|
+
*
|
|
80
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/supportedEntryPoints
|
|
81
|
+
*
|
|
82
|
+
* @returns Supported entryPoints
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* import { createClient } from "viem"
|
|
86
|
+
* import { bundlerActions } from "permissionless"
|
|
87
|
+
*
|
|
88
|
+
* const bundlerClient = createClient({
|
|
89
|
+
* chain: goerli,
|
|
90
|
+
* transport: http(BUNDLER_URL)
|
|
91
|
+
* }).extend(bundlerActions)
|
|
92
|
+
*
|
|
93
|
+
* const supportedEntryPoints = await bundlerClient.supportedEntryPoints()
|
|
94
|
+
*
|
|
95
|
+
* // Return ['0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789']
|
|
96
|
+
*/
|
|
97
|
+
supportedEntryPoints: () => Promise<Address[]>
|
|
98
|
+
/**
|
|
99
|
+
*
|
|
100
|
+
* Returns the supported chain id by the bundler service
|
|
101
|
+
*
|
|
102
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/chainId
|
|
103
|
+
*
|
|
104
|
+
* @returns Supported chain id
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* import { createClient } from "viem"
|
|
108
|
+
* import { bundlerActions } from "permissionless"
|
|
109
|
+
*
|
|
110
|
+
* const bundlerClient = createClient({
|
|
111
|
+
* chain: goerli,
|
|
112
|
+
* transport: http(BUNDLER_URL)
|
|
113
|
+
* }).extend(bundlerActions)
|
|
114
|
+
*
|
|
115
|
+
* const chainId = await bundlerClient.chainId()
|
|
116
|
+
* // Return 5n for Goerli
|
|
117
|
+
*/
|
|
118
|
+
chainId: () => Promise<number>
|
|
119
|
+
/**
|
|
120
|
+
*
|
|
121
|
+
* Returns the user operation from userOpHash
|
|
122
|
+
*
|
|
123
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/getUserOperationByHash
|
|
124
|
+
*
|
|
125
|
+
* @param args {@link GetUserOperationByHash} UserOpHash that was returned by {@link sendUserOperation}
|
|
126
|
+
* @returns userOperation along with entryPoint, transactionHash, blockHash, blockNumber if found or null
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* import { createClient } from "viem"
|
|
130
|
+
* import { bundlerActions } from "permissionless"
|
|
131
|
+
*
|
|
132
|
+
* const bundlerClient = createClient({
|
|
133
|
+
* chain: goerli,
|
|
134
|
+
* transport: http(BUNDLER_URL)
|
|
135
|
+
* }).extend(bundlerActions)
|
|
136
|
+
*
|
|
137
|
+
* await bundlerClient.getUserOperationByHash(userOpHash)
|
|
138
|
+
*
|
|
139
|
+
*/
|
|
140
|
+
getUserOperationByHash: (args: GetUserOperationByHashParameters) => Promise<GetUserOperationByHashReturnType>
|
|
141
|
+
/**
|
|
142
|
+
*
|
|
143
|
+
* Returns the user operation receipt from userOpHash
|
|
144
|
+
*
|
|
145
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/getUserOperationReceipt
|
|
146
|
+
*
|
|
147
|
+
* @param args {@link GetUserOperationReceiptParameters} UserOpHash that was returned by {@link sendUserOperation}
|
|
148
|
+
* @returns user operation receipt {@link GetUserOperationReceiptReturnType} if found or null
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* import { createClient } from "viem"
|
|
152
|
+
* import { bundlerActions } from "permissionless"
|
|
153
|
+
*
|
|
154
|
+
* const bundlerClient = createClient({
|
|
155
|
+
* chain: goerli,
|
|
156
|
+
* transport: http(BUNDLER_URL)
|
|
157
|
+
* }).extend(bundlerActions)
|
|
158
|
+
*
|
|
159
|
+
* await bundlerClient.getUserOperationReceipt({hash: userOpHash})
|
|
160
|
+
*
|
|
161
|
+
*/
|
|
162
|
+
getUserOperationReceipt: (args: GetUserOperationReceiptParameters) => Promise<GetUserOperationReceiptReturnType>
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const bundlerActions = (client: Client): BundlerActions => ({
|
|
166
|
+
sendUserOperation: async (args: SendUserOperationParameters): Promise<Hash> =>
|
|
167
|
+
sendUserOperation(client as BundlerClient, args),
|
|
168
|
+
estimateUserOperationGas: (args: EstimateUserOperationGasParameters) =>
|
|
169
|
+
estimateUserOperationGas(client as BundlerClient, args),
|
|
170
|
+
supportedEntryPoints: (): Promise<Address[]> => supportedEntryPoints(client as BundlerClient),
|
|
171
|
+
chainId: () => chainId(client as BundlerClient),
|
|
172
|
+
getUserOperationByHash: (args: GetUserOperationByHashParameters) =>
|
|
173
|
+
getUserOperationByHash(client as BundlerClient, args),
|
|
174
|
+
getUserOperationReceipt: (args: GetUserOperationReceiptParameters) =>
|
|
175
|
+
getUserOperationReceipt(client as BundlerClient, args)
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
export { bundlerActions }
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { Client, Hash } from "viem"
|
|
2
|
+
import {
|
|
3
|
+
type GetUserOperationGasPriceReturnType,
|
|
4
|
+
getUserOperationGasPrice
|
|
5
|
+
} from "../../actions/pimlico/getUserOperationGasPrice.js"
|
|
6
|
+
import {
|
|
7
|
+
type GetUserOperationStatusParameters,
|
|
8
|
+
type GetUserOperationStatusReturnType,
|
|
9
|
+
getUserOperationStatus
|
|
10
|
+
} from "../../actions/pimlico/getUserOperationStatus.js"
|
|
11
|
+
import {
|
|
12
|
+
type SponsorUserOperationParameters,
|
|
13
|
+
type SponsorUserOperationReturnType,
|
|
14
|
+
sponsorUserOperation
|
|
15
|
+
} from "../../actions/pimlico/sponsorUserOperation.js"
|
|
16
|
+
import type { PimlicoBundlerClient, PimlicoPaymasterClient } from "../pimlico.js"
|
|
17
|
+
|
|
18
|
+
export type PimlicoBundlerActions = {
|
|
19
|
+
/**
|
|
20
|
+
* Returns the live gas prices that you can use to send a user operation.
|
|
21
|
+
*
|
|
22
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-bundler-actions/getUserOperationGasPrice
|
|
23
|
+
*
|
|
24
|
+
* @returns slow, standard & fast values for maxFeePerGas & maxPriorityFeePerGas {@link GetUserOperationGasPriceReturnType}
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
*
|
|
28
|
+
* import { createClient } from "viem"
|
|
29
|
+
* import { pimlicoBundlerActions } from "permissionless/actions/pimlico"
|
|
30
|
+
*
|
|
31
|
+
* const bundlerClient = createClient({
|
|
32
|
+
* chain: goerli,
|
|
33
|
+
* transport: http("https://api.pimlico.io/v1/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
34
|
+
* }).extend(pimlicoBundlerActions)
|
|
35
|
+
*
|
|
36
|
+
* await bundlerClient.getUserOperationGasPrice()
|
|
37
|
+
*/
|
|
38
|
+
getUserOperationGasPrice: () => Promise<GetUserOperationGasPriceReturnType>
|
|
39
|
+
/**
|
|
40
|
+
* Returns the status of the userOperation that is pending in the mempool.
|
|
41
|
+
*
|
|
42
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-bundler-actions/getUserOperationStatus
|
|
43
|
+
*
|
|
44
|
+
* @param hash {@link Hash} UserOpHash that you must have received from sendUserOperation.
|
|
45
|
+
* @returns status & transaction hash if included {@link GetUserOperationStatusReturnType}
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* import { createClient } from "viem"
|
|
49
|
+
* import { pimlicoBundlerActions } from "permissionless/actions/pimlico"
|
|
50
|
+
*
|
|
51
|
+
* const bundlerClient = createClient({
|
|
52
|
+
* chain: goerli,
|
|
53
|
+
* transport: http("https://api.pimlico.io/v1/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
54
|
+
* }).extend(pimlicoBundlerActions)
|
|
55
|
+
*
|
|
56
|
+
* await bundlerClient.getUserOperationStatus({ hash: userOpHash })
|
|
57
|
+
*/
|
|
58
|
+
getUserOperationStatus: (args: GetUserOperationStatusParameters) => Promise<GetUserOperationStatusReturnType>
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const pimlicoBundlerActions = (client: Client): PimlicoBundlerActions => ({
|
|
62
|
+
getUserOperationGasPrice: async () => getUserOperationGasPrice(client as PimlicoBundlerClient),
|
|
63
|
+
getUserOperationStatus: async (args: GetUserOperationStatusParameters) =>
|
|
64
|
+
getUserOperationStatus(client as PimlicoBundlerClient, args)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
export type PimlicoPaymasterClientActions = {
|
|
68
|
+
/**
|
|
69
|
+
* Returns paymasterAndData & updated gas parameters required to sponsor a userOperation.
|
|
70
|
+
*
|
|
71
|
+
* https://docs.pimlico.io/permissionless/reference/pimlico-paymaster-actions/sponsorUserOperation
|
|
72
|
+
*
|
|
73
|
+
* @param args {@link SponsorUserOperationParameters} UserOperation you want to sponsor & entryPoint.
|
|
74
|
+
* @returns paymasterAndData & updated gas parameters, see {@link SponsorUserOperationReturnType}
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* import { createClient } from "viem"
|
|
78
|
+
* import { sponsorUserOperation } from "permissionless/actions/pimlico"
|
|
79
|
+
*
|
|
80
|
+
* const bundlerClient = createClient({
|
|
81
|
+
* chain: goerli,
|
|
82
|
+
* transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
83
|
+
* }).extend(pimlicoPaymasterActions)
|
|
84
|
+
*
|
|
85
|
+
* await bundlerClient.sponsorUserOperation(bundlerClient, {
|
|
86
|
+
* userOperation: userOperationWithDummySignature,
|
|
87
|
+
* entryPoint: entryPoint
|
|
88
|
+
* }})
|
|
89
|
+
*
|
|
90
|
+
*/
|
|
91
|
+
sponsorUserOperation: (args: SponsorUserOperationParameters) => Promise<SponsorUserOperationReturnType>
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export const pimlicoPaymasterActions = (client: Client): PimlicoPaymasterClientActions => ({
|
|
95
|
+
sponsorUserOperation: async (args: SponsorUserOperationParameters) =>
|
|
96
|
+
sponsorUserOperation(client as PimlicoPaymasterClient, args)
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* TODO: Add support for pimlicoActions after we support all the actions of v1 in v2 of the Pimlico API.
|
|
101
|
+
*/
|
|
102
|
+
// export const pimlicoActions = (client: Client) => {
|
|
103
|
+
// return {
|
|
104
|
+
// ...pimlicoBundlerActions(client),
|
|
105
|
+
// ...pimlicoPaymasterActions(client)
|
|
106
|
+
// }
|
|
107
|
+
// }
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Address, Client } from "viem"
|
|
2
|
+
import { type AccountsParameters, accounts } from "../../actions/stackup/accounts.js"
|
|
3
|
+
import {
|
|
4
|
+
type SponsorUserOperationParameters,
|
|
5
|
+
type SponsorUserOperationReturnType,
|
|
6
|
+
sponsorUserOperation
|
|
7
|
+
} from "../../actions/stackup/sponsorUserOperation.js"
|
|
8
|
+
import { type StackupPaymasterClient } from "../stackup.js"
|
|
9
|
+
|
|
10
|
+
export type StackupPaymasterClientActions = {
|
|
11
|
+
/**
|
|
12
|
+
* Returns paymasterAndData & updated gas parameters required to sponsor a userOperation.
|
|
13
|
+
*
|
|
14
|
+
* https://docs.stackup.sh/docs/paymaster-api-rpc-methods#pm_sponsoruseroperation
|
|
15
|
+
*
|
|
16
|
+
* @param args {@link SponsorUserOperationParameters} UserOperation you want to sponsor & entryPoint.
|
|
17
|
+
* @returns paymasterAndData & updated gas parameters, see {@link SponsorUserOperationReturnType}
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* import { createClient } from "viem"
|
|
21
|
+
* import { stackupPaymasterActions } from "permissionless/actions/stackup"
|
|
22
|
+
*
|
|
23
|
+
* const bundlerClient = createClient({
|
|
24
|
+
* chain: goerli,
|
|
25
|
+
* transport: http("https://api.stackup.sh/v1/paymaster/YOUR_API_KEY_HERE")
|
|
26
|
+
* }).extend(stackupPaymasterActions)
|
|
27
|
+
*
|
|
28
|
+
* await bundlerClient.sponsorUserOperation(bundlerClient, {
|
|
29
|
+
* userOperation: userOperationWithDummySignature,
|
|
30
|
+
* entryPoint: entryPoint
|
|
31
|
+
* }})
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
sponsorUserOperation: (args: SponsorUserOperationParameters) => Promise<SponsorUserOperationReturnType>
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Returns all the Paymaster addresses associated with an EntryPoint that’s owned by this service.
|
|
38
|
+
*
|
|
39
|
+
* https://docs.stackup.sh/docs/paymaster-api-rpc-methods#pm_accounts
|
|
40
|
+
*
|
|
41
|
+
* @param args {@link AccountsParameters} entryPoint for which you want to get list of supported paymasters.
|
|
42
|
+
* @returns paymaster addresses
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* import { createClient } from "viem"
|
|
46
|
+
* import { stackupPaymasterActions } from "permissionless/actions/stackup"
|
|
47
|
+
*
|
|
48
|
+
* const bundlerClient = createClient({
|
|
49
|
+
* chain: goerli,
|
|
50
|
+
* transport: http("https://api.stackup.sh/v1/paymaster/YOUR_API_KEY_HERE")
|
|
51
|
+
* }).extend(stackupPaymasterActions)
|
|
52
|
+
*
|
|
53
|
+
* await bundlerClient.accounts(bundlerClient, {
|
|
54
|
+
* entryPoint: entryPoint
|
|
55
|
+
* }})
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
accounts: (args: AccountsParameters) => Promise<Address[]>
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const stackupPaymasterActions = (client: Client): StackupPaymasterClientActions => ({
|
|
62
|
+
sponsorUserOperation: async (args: SponsorUserOperationParameters) =>
|
|
63
|
+
sponsorUserOperation(client as StackupPaymasterClient, args),
|
|
64
|
+
accounts: async (args: AccountsParameters) => accounts(client as StackupPaymasterClient, args)
|
|
65
|
+
})
|
package/clients/pimlico.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import type { Account, Chain, Client, PublicClientConfig, Transport } from "viem"
|
|
2
2
|
import { createClient } from "viem"
|
|
3
|
-
import {
|
|
4
|
-
import type
|
|
3
|
+
import type { PimlicoBundlerRpcSchema, PimlicoPaymasterRpcSchema } from "../types/pimlico.js"
|
|
4
|
+
import { type BundlerActions, bundlerActions } from "./decorators/bundler.js"
|
|
5
5
|
import {
|
|
6
6
|
type PimlicoBundlerActions,
|
|
7
7
|
type PimlicoPaymasterClientActions,
|
|
8
8
|
pimlicoBundlerActions,
|
|
9
9
|
pimlicoPaymasterActions
|
|
10
|
-
} from "
|
|
11
|
-
import type { PimlicoBundlerRpcSchema, PimlicoPaymasterRpcSchema } from "../types/pimlico"
|
|
10
|
+
} from "./decorators/pimlico.js"
|
|
12
11
|
|
|
13
12
|
export type PimlicoBundlerClient = Client<
|
|
14
13
|
Transport,
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type Account, type Chain, type Client, type PublicClientConfig, type Transport, createClient } from "viem"
|
|
2
|
+
import type { StackupPaymasterRpcSchema } from "../types/stackup.js"
|
|
3
|
+
import { type BundlerActions, bundlerActions } from "./decorators/bundler.js"
|
|
4
|
+
import { type StackupPaymasterClientActions, stackupPaymasterActions } from "./decorators/stackup.js"
|
|
5
|
+
|
|
6
|
+
export type StackupPaymasterClient = Client<
|
|
7
|
+
Transport,
|
|
8
|
+
Chain | undefined,
|
|
9
|
+
Account | undefined,
|
|
10
|
+
StackupPaymasterRpcSchema,
|
|
11
|
+
StackupPaymasterClientActions & BundlerActions
|
|
12
|
+
>
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Creates a Stackup specific Paymaster Client with a given [Transport](https://viem.sh/docs/clients/intro.html) configured for a [Chain](https://viem.sh/docs/clients/chains.html).
|
|
16
|
+
*
|
|
17
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/clients/stackupPaymasterClient
|
|
18
|
+
*
|
|
19
|
+
* A Stackup Paymaster Client is an interface to "stackup paymaster endpoints" [JSON-RPC API](https://docs.stackup.sh/docs/paymaster-api-rpc-methods) methods such as sponsoring user operation, etc through Stackup Paymaster Actions.
|
|
20
|
+
*
|
|
21
|
+
* @param config - {@link PublicClientConfig}
|
|
22
|
+
* @returns A Stackup Paymaster Client. {@link StackupPaymasterClient}
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* import { createPublicClient, http } from 'viem'
|
|
26
|
+
* import { mainnet } from 'viem/chains'
|
|
27
|
+
*
|
|
28
|
+
* const stackupPaymasterClient = createStackupPaymasterClient({
|
|
29
|
+
* chain: mainnet,
|
|
30
|
+
* transport: http("https://api.stackup.sh/v1/paymaster/YOUR_API_KEY_HERE"),
|
|
31
|
+
* })
|
|
32
|
+
*/
|
|
33
|
+
export const createStackupPaymasterClient = <transport extends Transport, chain extends Chain | undefined = undefined>(
|
|
34
|
+
parameters: PublicClientConfig<transport, chain>
|
|
35
|
+
): StackupPaymasterClient => {
|
|
36
|
+
const { key = "public", name = "Stackup Paymaster Client" } = parameters
|
|
37
|
+
const client = createClient({
|
|
38
|
+
...parameters,
|
|
39
|
+
key,
|
|
40
|
+
name,
|
|
41
|
+
type: "stackupPaymasterClient"
|
|
42
|
+
})
|
|
43
|
+
return client.extend(bundlerActions).extend(stackupPaymasterActions)
|
|
44
|
+
}
|
package/index.ts
CHANGED
|
@@ -1,4 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type {
|
|
2
|
+
EstimateUserOperationGasParameters,
|
|
3
|
+
EstimateUserOperationGasReturnType
|
|
4
|
+
} from "./actions/bundler/estimateUserOperationGas.js"
|
|
5
|
+
import type { GetUserOperationByHashParameters } from "./actions/bundler/getUserOperationByHash.js"
|
|
6
|
+
import type { GetUserOperationByHashReturnType } from "./actions/bundler/getUserOperationByHash.js"
|
|
7
|
+
import type {
|
|
8
|
+
GetUserOperationReceiptParameters,
|
|
9
|
+
GetUserOperationReceiptReturnType
|
|
10
|
+
} from "./actions/bundler/getUserOperationReceipt.js"
|
|
11
|
+
import type { SendUserOperationParameters } from "./actions/bundler/sendUserOperation.js"
|
|
12
|
+
|
|
13
|
+
import type { GetSenderAddressParams } from "./actions/public/getSenderAddress.js"
|
|
14
|
+
import { getSenderAddress } from "./actions/public/getSenderAddress.js"
|
|
15
|
+
|
|
16
|
+
import { chainId } from "./actions/bundler/chainId.js"
|
|
17
|
+
import { estimateUserOperationGas } from "./actions/bundler/estimateUserOperationGas.js"
|
|
18
|
+
import { getUserOperationByHash } from "./actions/bundler/getUserOperationByHash.js"
|
|
19
|
+
import { getUserOperationReceipt } from "./actions/bundler/getUserOperationReceipt.js"
|
|
20
|
+
import { sendUserOperation } from "./actions/bundler/sendUserOperation.js"
|
|
21
|
+
import { supportedEntryPoints } from "./actions/bundler/supportedEntryPoints.js"
|
|
22
|
+
import type { GetAccountNonceParams } from "./actions/public/getAccountNonce.js"
|
|
23
|
+
import { getAccountNonce } from "./actions/public/getAccountNonce.js"
|
|
24
|
+
import { type BundlerClient, createBundlerClient } from "./clients/bundler.js"
|
|
25
|
+
import type { BundlerActions } from "./clients/decorators/bundler.js"
|
|
26
|
+
import { bundlerActions } from "./clients/decorators/bundler.js"
|
|
27
|
+
|
|
28
|
+
export type {
|
|
29
|
+
SendUserOperationParameters,
|
|
30
|
+
EstimateUserOperationGasParameters,
|
|
31
|
+
EstimateUserOperationGasReturnType,
|
|
32
|
+
GetUserOperationByHashParameters,
|
|
33
|
+
GetUserOperationByHashReturnType,
|
|
34
|
+
GetUserOperationReceiptParameters,
|
|
35
|
+
GetUserOperationReceiptReturnType,
|
|
36
|
+
GetSenderAddressParams,
|
|
37
|
+
GetAccountNonceParams,
|
|
38
|
+
BundlerClient,
|
|
39
|
+
BundlerActions
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
sendUserOperation,
|
|
44
|
+
estimateUserOperationGas,
|
|
45
|
+
supportedEntryPoints,
|
|
46
|
+
chainId,
|
|
47
|
+
getUserOperationByHash,
|
|
48
|
+
getUserOperationReceipt,
|
|
49
|
+
getSenderAddress,
|
|
50
|
+
getAccountNonce,
|
|
51
|
+
createBundlerClient,
|
|
52
|
+
bundlerActions
|
|
53
|
+
}
|
|
54
|
+
import type { UserOperation } from "./types/userOperation.js"
|
|
55
|
+
|
|
56
|
+
export { type UserOperation }
|
|
57
|
+
|
|
58
|
+
import type { GetUserOperationHashParams } from "./utils/getUserOperationHash.js"
|
|
59
|
+
import { getUserOperationHash } from "./utils/getUserOperationHash.js"
|
|
60
|
+
|
|
61
|
+
export { getUserOperationHash, type GetUserOperationHashParams }
|
|
62
|
+
export * from "./utils/index.js"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "permissionless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"author": "Pimlico",
|
|
5
5
|
"main": "./_cjs/index.js",
|
|
6
6
|
"module": "./_esm/index.js",
|
|
@@ -33,6 +33,11 @@
|
|
|
33
33
|
"import": "./_esm/actions/pimlico.js",
|
|
34
34
|
"default": "./_cjs/actions/pimlico.js"
|
|
35
35
|
},
|
|
36
|
+
"./actions/stackup": {
|
|
37
|
+
"types": "./_types/actions/stackup.d.ts",
|
|
38
|
+
"import": "./_esm/actions/stackup.js",
|
|
39
|
+
"default": "./_cjs/actions/stackup.js"
|
|
40
|
+
},
|
|
36
41
|
"./clients": {
|
|
37
42
|
"types": "./_types/clients/index.d.ts",
|
|
38
43
|
"import": "./_esm/clients/index.js",
|
|
@@ -43,6 +48,11 @@
|
|
|
43
48
|
"import": "./_esm/clients/pimlico.js",
|
|
44
49
|
"default": "./_cjs/clients/pimlico.js"
|
|
45
50
|
},
|
|
51
|
+
"./clients/stackup": {
|
|
52
|
+
"types": "./_types/clients/stackup.d.ts",
|
|
53
|
+
"import": "./_esm/clients/stackup.js",
|
|
54
|
+
"default": "./_cjs/clients/stackup.js"
|
|
55
|
+
},
|
|
46
56
|
"./utils": {
|
|
47
57
|
"types": "./_types/utils/index.d.ts",
|
|
48
58
|
"import": "./_esm/utils/index.js",
|