permissionless 0.0.6 → 0.0.8
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/bundler/waitForUserOperationReceipt.js +46 -0
- package/_cjs/actions/bundler/waitForUserOperationReceipt.js.map +1 -0
- package/_cjs/actions/index.js +22 -12
- 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} +2 -33
- 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 +21 -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 +28 -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/{actions/utils.js → utils/deepHexlify.js} +1 -1
- package/_cjs/utils/deepHexlify.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/_cjs/utils/observe.js +39 -0
- package/_cjs/utils/observe.js.map +1 -0
- 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/bundler/waitForUserOperationReceipt.js +63 -0
- package/_esm/actions/bundler/waitForUserOperationReceipt.js.map +1 -0
- package/_esm/actions/index.js +11 -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} +1 -57
- 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 +18 -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 +17 -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/{actions/utils.js → utils/deepHexlify.js} +1 -1
- package/_esm/utils/deepHexlify.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/_esm/utils/observe.js +42 -0
- package/_esm/utils/observe.js.map +1 -0
- 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 +62 -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/bundler/waitForUserOperationReceipt.d.ts +43 -0
- package/_types/actions/bundler/waitForUserOperationReceipt.d.ts.map +1 -0
- package/_types/actions/index.d.ts +19 -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} +2 -35
- 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 +3 -3
- package/_types/clients/bundler.d.ts.map +1 -1
- package/_types/clients/decorators/bundler.d.ts +173 -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 +28 -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/{actions/utils.d.ts → utils/deepHexlify.d.ts} +1 -1
- package/_types/utils/deepHexlify.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/_types/utils/observe.d.ts +17 -0
- package/_types/utils/observe.d.ts.map +1 -0
- 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 +112 -0
- package/actions/bundler/sendUserOperation.ts +45 -0
- package/actions/bundler/supportedEntryPoints.ts +31 -0
- package/actions/bundler/waitForUserOperationReceipt.ts +80 -0
- package/actions/index.ts +30 -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} +7 -68
- package/actions/stackup/accounts.ts +40 -0
- package/actions/stackup/sponsorUserOperation.ts +64 -0
- package/actions/stackup.ts +17 -0
- package/clients/bundler.ts +9 -4
- package/clients/decorators/bundler.ts +211 -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 +70 -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/utils/observe.ts +61 -0
- 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/actions/utils.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/actions/utils.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/actions/utils.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
- /package/{actions/utils.ts → utils/deepHexlify.ts} +0 -0
package/actions/pimlico.ts
CHANGED
|
@@ -1,252 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type GetUserOperationStatusParameters = {
|
|
39
|
-
hash: Hash
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type GetUserOperationStatusReturnType = PimlicoUserOperationStatus
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Returns the live gas prices that you can use to send a user operation.
|
|
46
|
-
*
|
|
47
|
-
* - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-bundler-actions/getUserOperationGasPrice
|
|
48
|
-
*
|
|
49
|
-
* @param client {@link PimlicoBundlerClient} that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler.
|
|
50
|
-
* @returns slow, standard & fast values for maxFeePerGas & maxPriorityFeePerGas
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* import { createClient } from "viem"
|
|
55
|
-
* import { getUserOperationGasPrice } from "permissionless/actions"
|
|
56
|
-
*
|
|
57
|
-
* const bundlerClient = createClient({
|
|
58
|
-
* chain: goerli,
|
|
59
|
-
* transport: http("https://api.pimlico.io/v1/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
60
|
-
* })
|
|
61
|
-
*
|
|
62
|
-
* await getUserOperationGasPrice(bundlerClient)
|
|
63
|
-
*
|
|
64
|
-
*/
|
|
65
|
-
export const getUserOperationGasPrice = async (
|
|
66
|
-
client: PimlicoBundlerClient
|
|
67
|
-
): Promise<GetUserOperationGasPriceReturnType> => {
|
|
68
|
-
const gasPrices = await client.request({
|
|
69
|
-
method: "pimlico_getUserOperationGasPrice",
|
|
70
|
-
params: []
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
slow: {
|
|
75
|
-
maxFeePerGas: BigInt(gasPrices.slow.maxFeePerGas),
|
|
76
|
-
maxPriorityFeePerGas: BigInt(gasPrices.slow.maxPriorityFeePerGas)
|
|
77
|
-
},
|
|
78
|
-
standard: {
|
|
79
|
-
maxFeePerGas: BigInt(gasPrices.standard.maxFeePerGas),
|
|
80
|
-
maxPriorityFeePerGas: BigInt(gasPrices.standard.maxPriorityFeePerGas)
|
|
81
|
-
},
|
|
82
|
-
fast: {
|
|
83
|
-
maxFeePerGas: BigInt(gasPrices.fast.maxFeePerGas),
|
|
84
|
-
maxPriorityFeePerGas: BigInt(gasPrices.fast.maxPriorityFeePerGas)
|
|
85
|
-
}
|
|
86
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
type GetUserOperationGasPriceReturnType,
|
|
3
|
+
getUserOperationGasPrice
|
|
4
|
+
} from "./pimlico/getUserOperationGasPrice.js"
|
|
5
|
+
import {
|
|
6
|
+
type GetUserOperationStatusParameters,
|
|
7
|
+
type GetUserOperationStatusReturnType,
|
|
8
|
+
getUserOperationStatus
|
|
9
|
+
} from "./pimlico/getUserOperationStatus.js"
|
|
10
|
+
import {
|
|
11
|
+
type SponsorUserOperationParameters,
|
|
12
|
+
type SponsorUserOperationReturnType,
|
|
13
|
+
sponsorUserOperation
|
|
14
|
+
} from "./pimlico/sponsorUserOperation.js"
|
|
15
|
+
|
|
16
|
+
import type { PimlicoBundlerActions, PimlicoPaymasterClientActions } from "../clients/decorators/pimlico.js"
|
|
17
|
+
import { pimlicoBundlerActions, pimlicoPaymasterActions } from "../clients/decorators/pimlico.js"
|
|
18
|
+
|
|
19
|
+
export type {
|
|
20
|
+
GetUserOperationGasPriceReturnType,
|
|
21
|
+
GetUserOperationStatusParameters,
|
|
22
|
+
GetUserOperationStatusReturnType,
|
|
23
|
+
SponsorUserOperationParameters,
|
|
24
|
+
SponsorUserOperationReturnType,
|
|
25
|
+
PimlicoBundlerActions,
|
|
26
|
+
PimlicoPaymasterClientActions
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
getUserOperationGasPrice,
|
|
31
|
+
getUserOperationStatus,
|
|
32
|
+
sponsorUserOperation,
|
|
33
|
+
pimlicoBundlerActions,
|
|
34
|
+
pimlicoPaymasterActions
|
|
87
35
|
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Returns the status of the userOperation that is pending in the mempool.
|
|
91
|
-
*
|
|
92
|
-
* - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-bundler-actions/getUserOperationStatus
|
|
93
|
-
*
|
|
94
|
-
* @param client {@link PimlicoBundlerClient} that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler.
|
|
95
|
-
* @param hash {@link Hash} UserOpHash that you must have received from sendUserOperation.
|
|
96
|
-
* @returns status & transaction hash if included {@link GetUserOperationStatusReturnType}
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* import { createClient } from "viem"
|
|
101
|
-
* import { getUserOperationStatus } from "permissionless/actions"
|
|
102
|
-
*
|
|
103
|
-
* const bundlerClient = createClient({
|
|
104
|
-
* chain: goerli,
|
|
105
|
-
* transport: http("https://api.pimlico.io/v1/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
106
|
-
* })
|
|
107
|
-
*
|
|
108
|
-
* await getUserOperationStatus(bundlerClient, { hash: userOpHash })
|
|
109
|
-
*
|
|
110
|
-
*/
|
|
111
|
-
export const getUserOperationStatus = async (
|
|
112
|
-
client: PimlicoBundlerClient,
|
|
113
|
-
{ hash }: GetUserOperationStatusParameters
|
|
114
|
-
): Promise<GetUserOperationStatusReturnType> => {
|
|
115
|
-
return client.request({
|
|
116
|
-
method: "pimlico_getUserOperationStatus",
|
|
117
|
-
params: [hash]
|
|
118
|
-
})
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export type PimlicoBundlerActions = {
|
|
122
|
-
/**
|
|
123
|
-
* Returns the live gas prices that you can use to send a user operation.
|
|
124
|
-
*
|
|
125
|
-
* - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-bundler-actions/getUserOperationGasPrice
|
|
126
|
-
*
|
|
127
|
-
* @returns slow, standard & fast values for maxFeePerGas & maxPriorityFeePerGas {@link GetUserOperationGasPriceReturnType}
|
|
128
|
-
*
|
|
129
|
-
* @example
|
|
130
|
-
*
|
|
131
|
-
* import { createClient } from "viem"
|
|
132
|
-
* import { pimlicoBundlerActions } from "permissionless/actions"
|
|
133
|
-
*
|
|
134
|
-
* const bundlerClient = createClient({
|
|
135
|
-
* chain: goerli,
|
|
136
|
-
* transport: http("https://api.pimlico.io/v1/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
137
|
-
* }).extend(pimlicoBundlerActions)
|
|
138
|
-
*
|
|
139
|
-
* await bundlerClient.getUserOperationGasPrice()
|
|
140
|
-
*/
|
|
141
|
-
getUserOperationGasPrice: () => Promise<GetUserOperationGasPriceReturnType>
|
|
142
|
-
/**
|
|
143
|
-
* Returns the status of the userOperation that is pending in the mempool.
|
|
144
|
-
*
|
|
145
|
-
* - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-bundler-actions/getUserOperationStatus
|
|
146
|
-
*
|
|
147
|
-
* @param hash {@link Hash} UserOpHash that you must have received from sendUserOperation.
|
|
148
|
-
* @returns status & transaction hash if included {@link GetUserOperationStatusReturnType}
|
|
149
|
-
*
|
|
150
|
-
* @example
|
|
151
|
-
* import { createClient } from "viem"
|
|
152
|
-
* import { pimlicoBundlerActions } from "permissionless/actions"
|
|
153
|
-
*
|
|
154
|
-
* const bundlerClient = createClient({
|
|
155
|
-
* chain: goerli,
|
|
156
|
-
* transport: http("https://api.pimlico.io/v1/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
157
|
-
* }).extend(pimlicoBundlerActions)
|
|
158
|
-
*
|
|
159
|
-
* await bundlerClient.getUserOperationStatus({ hash: userOpHash })
|
|
160
|
-
*/
|
|
161
|
-
getUserOperationStatus: (args: GetUserOperationStatusParameters) => Promise<GetUserOperationStatusReturnType>
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export const pimlicoBundlerActions = (client: Client): PimlicoBundlerActions => ({
|
|
165
|
-
getUserOperationGasPrice: async () => getUserOperationGasPrice(client as PimlicoBundlerClient),
|
|
166
|
-
getUserOperationStatus: async (args: GetUserOperationStatusParameters) =>
|
|
167
|
-
getUserOperationStatus(client as PimlicoBundlerClient, args)
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Returns paymasterAndData & updated gas parameters required to sponsor a userOperation.
|
|
172
|
-
*
|
|
173
|
-
* - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-paymaster-actions/sponsorUserOperation
|
|
174
|
-
*
|
|
175
|
-
* @param client {@link PimlicoBundlerClient} that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler.
|
|
176
|
-
* @param args {@link sponsorUserOperationParameters} UserOperation you want to sponsor & entryPoint.
|
|
177
|
-
* @returns paymasterAndData & updated gas parameters, see {@link SponsorUserOperationReturnType}
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
* @example
|
|
181
|
-
* import { createClient } from "viem"
|
|
182
|
-
* import { sponsorUserOperation } from "permissionless/actions"
|
|
183
|
-
*
|
|
184
|
-
* const bundlerClient = createClient({
|
|
185
|
-
* chain: goerli,
|
|
186
|
-
* transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
187
|
-
* })
|
|
188
|
-
*
|
|
189
|
-
* await sponsorUserOperation(bundlerClient, {
|
|
190
|
-
* userOperation: userOperationWithDummySignature,
|
|
191
|
-
* entryPoint: entryPoint
|
|
192
|
-
* }})
|
|
193
|
-
*
|
|
194
|
-
*/
|
|
195
|
-
export const sponsorUserOperation = async (
|
|
196
|
-
client: PimlicoPaymasterClient,
|
|
197
|
-
args: SponsorUserOperationParameters
|
|
198
|
-
): Promise<SponsorUserOperationReturnType> => {
|
|
199
|
-
const response = await client.request({
|
|
200
|
-
method: "pm_sponsorUserOperation",
|
|
201
|
-
params: [deepHexlify(args.userOperation) as UserOperationWithBigIntAsHex, args.entryPoint]
|
|
202
|
-
})
|
|
203
|
-
|
|
204
|
-
return {
|
|
205
|
-
paymasterAndData: response.paymasterAndData,
|
|
206
|
-
preVerificationGas: BigInt(response.preVerificationGas),
|
|
207
|
-
verificationGasLimit: BigInt(response.verificationGasLimit),
|
|
208
|
-
callGasLimit: BigInt(response.callGasLimit)
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export type PimlicoPaymasterClientActions = {
|
|
213
|
-
/**
|
|
214
|
-
* Returns paymasterAndData & updated gas parameters required to sponsor a userOperation.
|
|
215
|
-
*
|
|
216
|
-
* https://docs.pimlico.io/permissionless/reference/pimlico-paymaster-actions/sponsorUserOperation
|
|
217
|
-
*
|
|
218
|
-
* @param args {@link SponsorUserOperationParameters} UserOperation you want to sponsor & entryPoint.
|
|
219
|
-
* @returns paymasterAndData & updated gas parameters, see {@link SponsorUserOperationReturnType}
|
|
220
|
-
*
|
|
221
|
-
* @example
|
|
222
|
-
* import { createClient } from "viem"
|
|
223
|
-
* import { sponsorUserOperation } from "permissionless/actions"
|
|
224
|
-
*
|
|
225
|
-
* const bundlerClient = createClient({
|
|
226
|
-
* chain: goerli,
|
|
227
|
-
* transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
228
|
-
* }).extend(pimlicoPaymasterActions)
|
|
229
|
-
*
|
|
230
|
-
* await bundlerClient.sponsorUserOperation(bundlerClient, {
|
|
231
|
-
* userOperation: userOperationWithDummySignature,
|
|
232
|
-
* entryPoint: entryPoint
|
|
233
|
-
* }})
|
|
234
|
-
*
|
|
235
|
-
*/
|
|
236
|
-
sponsorUserOperation: (args: SponsorUserOperationParameters) => Promise<SponsorUserOperationReturnType>
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
export const pimlicoPaymasterActions = (client: Client): PimlicoPaymasterClientActions => ({
|
|
240
|
-
sponsorUserOperation: async (args: SponsorUserOperationParameters) =>
|
|
241
|
-
sponsorUserOperation(client as PimlicoPaymasterClient, args)
|
|
242
|
-
})
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* TODO: Add support for pimlicoActions after we support all the actions of v1 in v2 of the Pimlico API.
|
|
246
|
-
*/
|
|
247
|
-
// export const pimlicoActions = (client: Client) => {
|
|
248
|
-
// return {
|
|
249
|
-
// ...pimlicoBundlerActions(client),
|
|
250
|
-
// ...pimlicoPaymasterActions(client)
|
|
251
|
-
// }
|
|
252
|
-
// }
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Address, PublicClient } from "viem"
|
|
2
|
+
|
|
3
|
+
export type GetAccountNonceParams = { sender: Address; entryPoint: Address; key?: bigint }
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Returns the nonce of the account with the entry point.
|
|
7
|
+
*
|
|
8
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/public-actions/getAccountNonce
|
|
9
|
+
*
|
|
10
|
+
* @param publicClient {@link PublicClient} that you created using viem's createPublicClient.
|
|
11
|
+
* @param args {@link GetAccountNonceParams} address, entryPoint & key
|
|
12
|
+
* @returns bigint nonce
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* import { createPublicClient } from "viem"
|
|
16
|
+
* import { getAccountNonce } from "permissionless/actions"
|
|
17
|
+
*
|
|
18
|
+
* const publicClient = createPublicClient({
|
|
19
|
+
* chain: goerli,
|
|
20
|
+
* transport: http("https://goerli.infura.io/v3/your-infura-key")
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* const nonce = await getAccountNonce(publicClient, {
|
|
24
|
+
* address,
|
|
25
|
+
* entryPoint,
|
|
26
|
+
* key
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* // Return 0n
|
|
30
|
+
*/
|
|
31
|
+
export const getAccountNonce = async (
|
|
32
|
+
publicClient: PublicClient,
|
|
33
|
+
{ sender, entryPoint, key = BigInt(0) }: GetAccountNonceParams
|
|
34
|
+
): Promise<bigint> => {
|
|
35
|
+
return await publicClient.readContract({
|
|
36
|
+
address: entryPoint,
|
|
37
|
+
abi: [
|
|
38
|
+
{
|
|
39
|
+
inputs: [
|
|
40
|
+
{
|
|
41
|
+
name: "sender",
|
|
42
|
+
type: "address"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "key",
|
|
46
|
+
type: "uint192"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
name: "getNonce",
|
|
50
|
+
outputs: [
|
|
51
|
+
{
|
|
52
|
+
name: "nonce",
|
|
53
|
+
type: "uint256"
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
stateMutability: "view",
|
|
57
|
+
type: "function"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
functionName: "getNonce",
|
|
61
|
+
args: [sender, key]
|
|
62
|
+
})
|
|
63
|
+
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
Address,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import {
|
|
2
|
+
type Address,
|
|
3
|
+
BaseError,
|
|
4
|
+
type ContractFunctionExecutionErrorType,
|
|
5
|
+
type ContractFunctionRevertedErrorType,
|
|
6
|
+
type Hex,
|
|
7
|
+
type PublicClient
|
|
7
8
|
} from "viem"
|
|
8
|
-
import { BaseError } from "viem"
|
|
9
9
|
|
|
10
10
|
export type GetSenderAddressParams = { initCode: Hex; entryPoint: Address }
|
|
11
|
-
export type GetAccountNonceParams = { address: Address; entryPoint: Address; key?: bigint }
|
|
12
11
|
|
|
13
12
|
export class InvalidEntryPointError extends BaseError {
|
|
14
13
|
override name = "InvalidEntryPointError"
|
|
@@ -103,63 +102,3 @@ export const getSenderAddress = async (
|
|
|
103
102
|
|
|
104
103
|
throw new InvalidEntryPointError({ entryPoint })
|
|
105
104
|
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Returns the nonce of the account with the entry point.
|
|
109
|
-
*
|
|
110
|
-
* - Docs: https://docs.pimlico.io/permissionless/reference/public-actions/getAccountNonce
|
|
111
|
-
*
|
|
112
|
-
* @param publicClient {@link PublicClient} that you created using viem's createPublicClient.
|
|
113
|
-
* @param args {@link GetAccountNonceParams} address, entryPoint & key
|
|
114
|
-
* @returns bigint nonce
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* import { createPublicClient } from "viem"
|
|
118
|
-
* import { getAccountNonce } from "permissionless/actions"
|
|
119
|
-
*
|
|
120
|
-
* const publicClient = createPublicClient({
|
|
121
|
-
* chain: goerli,
|
|
122
|
-
* transport: http("https://goerli.infura.io/v3/your-infura-key")
|
|
123
|
-
* })
|
|
124
|
-
*
|
|
125
|
-
* const nonce = await getAccountNonce(publicClient, {
|
|
126
|
-
* address,
|
|
127
|
-
* entryPoint,
|
|
128
|
-
* key
|
|
129
|
-
* })
|
|
130
|
-
*
|
|
131
|
-
* // Return 0n
|
|
132
|
-
*/
|
|
133
|
-
export const getAccountNonce = async (
|
|
134
|
-
publicClient: PublicClient,
|
|
135
|
-
{ address, entryPoint, key = 0n }: GetAccountNonceParams
|
|
136
|
-
): Promise<bigint> => {
|
|
137
|
-
return await publicClient.readContract({
|
|
138
|
-
address: entryPoint,
|
|
139
|
-
abi: [
|
|
140
|
-
{
|
|
141
|
-
inputs: [
|
|
142
|
-
{
|
|
143
|
-
name: "sender",
|
|
144
|
-
type: "address"
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
name: "key",
|
|
148
|
-
type: "uint192"
|
|
149
|
-
}
|
|
150
|
-
],
|
|
151
|
-
name: "getNonce",
|
|
152
|
-
outputs: [
|
|
153
|
-
{
|
|
154
|
-
name: "nonce",
|
|
155
|
-
type: "uint256"
|
|
156
|
-
}
|
|
157
|
-
],
|
|
158
|
-
stateMutability: "view",
|
|
159
|
-
type: "function"
|
|
160
|
-
}
|
|
161
|
-
],
|
|
162
|
-
functionName: "getNonce",
|
|
163
|
-
args: [address, key]
|
|
164
|
-
})
|
|
165
|
-
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Address } from "viem"
|
|
2
|
+
import type { StackupPaymasterClient } from "../../clients/stackup.js"
|
|
3
|
+
|
|
4
|
+
export type AccountsParameters = {
|
|
5
|
+
entryPoint: Address
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Returns all the Paymaster addresses associated with an EntryPoint that’s owned by this service.
|
|
10
|
+
*
|
|
11
|
+
* https://docs.stackup.sh/docs/paymaster-api-rpc-methods#pm_accounts
|
|
12
|
+
*
|
|
13
|
+
* @param args {@link AccountsParameters} entryPoint for which you want to get list of supported paymasters.
|
|
14
|
+
* @returns paymaster addresses
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* import { createClient } from "viem"
|
|
18
|
+
* import { accounts } from "permissionless/actions/stackup"
|
|
19
|
+
*
|
|
20
|
+
* const bundlerClient = createClient({
|
|
21
|
+
* chain: goerli,
|
|
22
|
+
* transport: http("https://api.stackup.sh/v1/paymaster/YOUR_API_KEY_HERE")
|
|
23
|
+
* })
|
|
24
|
+
*
|
|
25
|
+
* await accounts(bundlerClient, {
|
|
26
|
+
* entryPoint: entryPoint
|
|
27
|
+
* }})
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
export const accounts = async (
|
|
31
|
+
client: StackupPaymasterClient,
|
|
32
|
+
{ entryPoint }: AccountsParameters
|
|
33
|
+
): Promise<Address[]> => {
|
|
34
|
+
const response = await client.request({
|
|
35
|
+
method: "pm_accounts",
|
|
36
|
+
params: [entryPoint]
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
return response
|
|
40
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem"
|
|
2
|
+
import type { PartialBy } from "viem/types/utils"
|
|
3
|
+
import { type StackupPaymasterClient } from "../../clients/stackup.js"
|
|
4
|
+
import type { StackupPaymasterContext } from "../../types/stackup.js"
|
|
5
|
+
import type { UserOperation, UserOperationWithBigIntAsHex } from "../../types/userOperation.js"
|
|
6
|
+
import { deepHexlify } from "../../utils/deepHexlify.js"
|
|
7
|
+
|
|
8
|
+
export type SponsorUserOperationParameters = {
|
|
9
|
+
userOperation: PartialBy<
|
|
10
|
+
UserOperation,
|
|
11
|
+
"callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "paymasterAndData"
|
|
12
|
+
>
|
|
13
|
+
entryPoint: Address
|
|
14
|
+
context: StackupPaymasterContext
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type SponsorUserOperationReturnType = {
|
|
18
|
+
paymasterAndData: Hex
|
|
19
|
+
preVerificationGas: bigint
|
|
20
|
+
verificationGasLimit: bigint
|
|
21
|
+
callGasLimit: bigint
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Returns paymasterAndData & updated gas parameters required to sponsor a userOperation.
|
|
26
|
+
*
|
|
27
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/stackup-paymaster-actions/sponsorUserOperation
|
|
28
|
+
*
|
|
29
|
+
* @param client {@link PimlicoBundlerClient} that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler.
|
|
30
|
+
* @param args {@link sponsorUserOperationParameters} UserOperation you want to sponsor & entryPoint.
|
|
31
|
+
* @returns paymasterAndData & updated gas parameters, see {@link SponsorUserOperationReturnType}
|
|
32
|
+
*
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* import { createClient } from "viem"
|
|
36
|
+
* import { sponsorUserOperation } from "permissionless/actions/stackup"
|
|
37
|
+
*
|
|
38
|
+
* const bundlerClient = createClient({
|
|
39
|
+
* chain: goerli,
|
|
40
|
+
* transport: http("https://api.stackup.sh/v1/paymaster/YOUR_API_KEY_HERE")
|
|
41
|
+
* })
|
|
42
|
+
*
|
|
43
|
+
* await sponsorUserOperation(bundlerClient, {
|
|
44
|
+
* userOperation: userOperationWithDummySignature,
|
|
45
|
+
* entryPoint: entryPoint
|
|
46
|
+
* }})
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
export const sponsorUserOperation = async (
|
|
50
|
+
client: StackupPaymasterClient,
|
|
51
|
+
args: SponsorUserOperationParameters
|
|
52
|
+
): Promise<SponsorUserOperationReturnType> => {
|
|
53
|
+
const response = await client.request({
|
|
54
|
+
method: "pm_sponsorUserOperation",
|
|
55
|
+
params: [deepHexlify(args.userOperation) as UserOperationWithBigIntAsHex, args.entryPoint, args.context]
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
paymasterAndData: response.paymasterAndData,
|
|
60
|
+
preVerificationGas: BigInt(response.preVerificationGas),
|
|
61
|
+
verificationGasLimit: BigInt(response.verificationGasLimit),
|
|
62
|
+
callGasLimit: BigInt(response.callGasLimit)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { StackupPaymasterClientActions } from "../clients/decorators/stackup.js"
|
|
2
|
+
import { stackupPaymasterActions } from "../clients/decorators/stackup.js"
|
|
3
|
+
import { type AccountsParameters, accounts } from "./stackup/accounts.js"
|
|
4
|
+
import {
|
|
5
|
+
type SponsorUserOperationParameters,
|
|
6
|
+
type SponsorUserOperationReturnType,
|
|
7
|
+
sponsorUserOperation
|
|
8
|
+
} from "./stackup/sponsorUserOperation.js"
|
|
9
|
+
|
|
10
|
+
export type {
|
|
11
|
+
SponsorUserOperationParameters,
|
|
12
|
+
SponsorUserOperationReturnType,
|
|
13
|
+
AccountsParameters,
|
|
14
|
+
StackupPaymasterClientActions
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { sponsorUserOperation, accounts, stackupPaymasterActions }
|
package/clients/bundler.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import type { Account, Chain, Client, PublicClientConfig, Transport } from "viem"
|
|
2
2
|
import { createClient } from "viem"
|
|
3
|
-
import {
|
|
4
|
-
import type
|
|
5
|
-
import type { BundlerRpcSchema } from "../types/bundler"
|
|
3
|
+
import type { BundlerRpcSchema } from "../types/bundler.js"
|
|
4
|
+
import { type BundlerActions, bundlerActions } from "./decorators/bundler.js"
|
|
6
5
|
|
|
7
|
-
export type BundlerClient
|
|
6
|
+
export type BundlerClient<TChain extends Chain | undefined = Chain | undefined> = Client<
|
|
7
|
+
Transport,
|
|
8
|
+
TChain,
|
|
9
|
+
Account | undefined,
|
|
10
|
+
BundlerRpcSchema,
|
|
11
|
+
BundlerActions
|
|
12
|
+
>
|
|
8
13
|
/**
|
|
9
14
|
* Creates a EIP-4337 compliant Bundler Client with a given [Transport](https://viem.sh/docs/clients/intro.html) configured for a [Chain](https://viem.sh/docs/clients/chains.html).
|
|
10
15
|
*
|