permissionless 0.0.6 → 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 +7 -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 -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 +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} +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 +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} +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 +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 +22 -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 +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,45 @@
|
|
|
1
|
+
import type { Address, Hash } from "viem"
|
|
2
|
+
import type { BundlerClient } from "../../clients/bundler.js"
|
|
3
|
+
import type { UserOperation, UserOperationWithBigIntAsHex } from "../../types/userOperation.js"
|
|
4
|
+
import { deepHexlify } from "../utils.js"
|
|
5
|
+
|
|
6
|
+
export type SendUserOperationParameters = {
|
|
7
|
+
userOperation: UserOperation
|
|
8
|
+
entryPoint: Address
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Sends user operation to the bundler
|
|
13
|
+
*
|
|
14
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/sendUserOperation
|
|
15
|
+
*
|
|
16
|
+
* @param client {@link BundlerClient} that you created using viem's createClient and extended it with bundlerActions.
|
|
17
|
+
* @param args {@link SendUserOperationParameters}.
|
|
18
|
+
* @returns UserOpHash that you can use to track user operation as {@link Hash}.
|
|
19
|
+
*
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* import { createClient } from "viem"
|
|
23
|
+
* import { sendUserOperation } from "permissionless/actions"
|
|
24
|
+
*
|
|
25
|
+
* const bundlerClient = createClient({
|
|
26
|
+
* chain: goerli,
|
|
27
|
+
* transport: http(BUNDLER_URL)
|
|
28
|
+
* })
|
|
29
|
+
*
|
|
30
|
+
* const userOpHash = sendUserOperation(bundlerClient, {
|
|
31
|
+
* userOperation: signedUserOperation,
|
|
32
|
+
* entryPoint: entryPoint
|
|
33
|
+
* })
|
|
34
|
+
*
|
|
35
|
+
* // Return '0xe9fad2cd67f9ca1d0b7a6513b2a42066784c8df938518da2b51bb8cc9a89ea34'
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
export const sendUserOperation = async (client: BundlerClient, args: SendUserOperationParameters): Promise<Hash> => {
|
|
39
|
+
const { userOperation, entryPoint } = args
|
|
40
|
+
|
|
41
|
+
return client.request({
|
|
42
|
+
method: "eth_sendUserOperation",
|
|
43
|
+
params: [deepHexlify(userOperation) as UserOperationWithBigIntAsHex, entryPoint as Address]
|
|
44
|
+
})
|
|
45
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Address } from "viem"
|
|
2
|
+
import type { BundlerClient } from "../../clients/bundler.js"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns the supported entrypoints by the bundler service
|
|
6
|
+
*
|
|
7
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/supportedEntryPoints
|
|
8
|
+
*
|
|
9
|
+
* @param client {@link BundlerClient} that you created using viem's createClient and extended it with bundlerActions.
|
|
10
|
+
* @returns Supported entryPoints
|
|
11
|
+
*
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { createClient } from "viem"
|
|
15
|
+
* import { supportedEntryPoints } from "permissionless/actions"
|
|
16
|
+
*
|
|
17
|
+
* const bundlerClient = createClient({
|
|
18
|
+
* chain: goerli,
|
|
19
|
+
* transport: http(BUNDLER_URL)
|
|
20
|
+
* })
|
|
21
|
+
*
|
|
22
|
+
* const entryPointsSupported = supportedEntryPoints(bundlerClient)
|
|
23
|
+
* // Return ['0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789']
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
export const supportedEntryPoints = async (client: BundlerClient): Promise<Address[]> => {
|
|
27
|
+
return client.request({
|
|
28
|
+
method: "eth_supportedEntryPoints",
|
|
29
|
+
params: []
|
|
30
|
+
})
|
|
31
|
+
}
|
package/actions/index.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
EstimateUserOperationGasParameters,
|
|
3
|
-
EstimateUserOperationGasReturnType
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
EstimateUserOperationGasReturnType
|
|
4
|
+
} from "./bundler/estimateUserOperationGas.js"
|
|
5
|
+
import type { GetUserOperationByHashParameters } from "./bundler/getUserOperationByHash.js"
|
|
6
|
+
import type { GetUserOperationByHashReturnType } from "./bundler/getUserOperationByHash.js"
|
|
7
|
+
import type {
|
|
6
8
|
GetUserOperationReceiptParameters,
|
|
7
|
-
GetUserOperationReceiptReturnType
|
|
8
|
-
|
|
9
|
-
} from "./bundler"
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
bundlerActions,
|
|
13
|
-
chainId,
|
|
14
|
-
estimateUserOperationGas,
|
|
15
|
-
getUserOperationByHash,
|
|
16
|
-
getUserOperationReceipt,
|
|
17
|
-
sendUserOperation,
|
|
18
|
-
supportedEntryPoints
|
|
19
|
-
} from "./bundler"
|
|
9
|
+
GetUserOperationReceiptReturnType
|
|
10
|
+
} from "./bundler/getUserOperationReceipt.js"
|
|
11
|
+
import type { SendUserOperationParameters } from "./bundler/sendUserOperation.js"
|
|
20
12
|
|
|
21
|
-
import type { GetSenderAddressParams } from "./public"
|
|
13
|
+
import type { GetSenderAddressParams } from "./public/getSenderAddress.js"
|
|
14
|
+
import { InvalidEntryPointError, getSenderAddress } from "./public/getSenderAddress.js"
|
|
22
15
|
|
|
23
|
-
import {
|
|
16
|
+
import { chainId } from "./bundler/chainId.js"
|
|
17
|
+
import { estimateUserOperationGas } from "./bundler/estimateUserOperationGas.js"
|
|
18
|
+
import { getUserOperationByHash } from "./bundler/getUserOperationByHash.js"
|
|
19
|
+
import { getUserOperationReceipt } from "./bundler/getUserOperationReceipt.js"
|
|
20
|
+
import { sendUserOperation } from "./bundler/sendUserOperation.js"
|
|
21
|
+
import { supportedEntryPoints } from "./bundler/supportedEntryPoints.js"
|
|
22
|
+
import type { GetAccountNonceParams } from "./public/getAccountNonce.js"
|
|
23
|
+
import { getAccountNonce } from "./public/getAccountNonce.js"
|
|
24
24
|
|
|
25
25
|
export type {
|
|
26
26
|
SendUserOperationParameters,
|
|
@@ -30,11 +30,11 @@ export type {
|
|
|
30
30
|
GetUserOperationByHashReturnType,
|
|
31
31
|
GetUserOperationReceiptParameters,
|
|
32
32
|
GetUserOperationReceiptReturnType,
|
|
33
|
-
GetSenderAddressParams
|
|
33
|
+
GetSenderAddressParams,
|
|
34
|
+
GetAccountNonceParams
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
export {
|
|
37
|
-
bundlerActions,
|
|
38
38
|
sendUserOperation,
|
|
39
39
|
estimateUserOperationGas,
|
|
40
40
|
supportedEntryPoints,
|
|
@@ -42,5 +42,6 @@ export {
|
|
|
42
42
|
getUserOperationByHash,
|
|
43
43
|
getUserOperationReceipt,
|
|
44
44
|
getSenderAddress,
|
|
45
|
-
getAccountNonce
|
|
45
|
+
getAccountNonce,
|
|
46
|
+
InvalidEntryPointError
|
|
46
47
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { PimlicoBundlerClient } from "../../clients/pimlico.js"
|
|
2
|
+
|
|
3
|
+
export type GetUserOperationGasPriceReturnType = {
|
|
4
|
+
slow: {
|
|
5
|
+
maxFeePerGas: bigint
|
|
6
|
+
maxPriorityFeePerGas: bigint
|
|
7
|
+
}
|
|
8
|
+
standard: {
|
|
9
|
+
maxFeePerGas: bigint
|
|
10
|
+
maxPriorityFeePerGas: bigint
|
|
11
|
+
}
|
|
12
|
+
fast: {
|
|
13
|
+
maxFeePerGas: bigint
|
|
14
|
+
maxPriorityFeePerGas: bigint
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Returns the live gas prices that you can use to send a user operation.
|
|
20
|
+
*
|
|
21
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-bundler-actions/getUserOperationGasPrice
|
|
22
|
+
*
|
|
23
|
+
* @param client {@link PimlicoBundlerClient} that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler.
|
|
24
|
+
* @returns slow, standard & fast values for maxFeePerGas & maxPriorityFeePerGas
|
|
25
|
+
*
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* import { createClient } from "viem"
|
|
29
|
+
* import { getUserOperationGasPrice } 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
|
+
* })
|
|
35
|
+
*
|
|
36
|
+
* await getUserOperationGasPrice(bundlerClient)
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
39
|
+
export const getUserOperationGasPrice = async (
|
|
40
|
+
client: PimlicoBundlerClient
|
|
41
|
+
): Promise<GetUserOperationGasPriceReturnType> => {
|
|
42
|
+
const gasPrices = await client.request({
|
|
43
|
+
method: "pimlico_getUserOperationGasPrice",
|
|
44
|
+
params: []
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
slow: {
|
|
49
|
+
maxFeePerGas: BigInt(gasPrices.slow.maxFeePerGas),
|
|
50
|
+
maxPriorityFeePerGas: BigInt(gasPrices.slow.maxPriorityFeePerGas)
|
|
51
|
+
},
|
|
52
|
+
standard: {
|
|
53
|
+
maxFeePerGas: BigInt(gasPrices.standard.maxFeePerGas),
|
|
54
|
+
maxPriorityFeePerGas: BigInt(gasPrices.standard.maxPriorityFeePerGas)
|
|
55
|
+
},
|
|
56
|
+
fast: {
|
|
57
|
+
maxFeePerGas: BigInt(gasPrices.fast.maxFeePerGas),
|
|
58
|
+
maxPriorityFeePerGas: BigInt(gasPrices.fast.maxPriorityFeePerGas)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Hash } from "viem"
|
|
2
|
+
import type { PimlicoBundlerClient } from "../../clients/pimlico.js"
|
|
3
|
+
import type { PimlicoUserOperationStatus } from "../../types/pimlico.js"
|
|
4
|
+
|
|
5
|
+
export type GetUserOperationStatusParameters = {
|
|
6
|
+
hash: Hash
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type GetUserOperationStatusReturnType = PimlicoUserOperationStatus
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Returns the status of the userOperation that is pending in the mempool.
|
|
13
|
+
*
|
|
14
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-bundler-actions/getUserOperationStatus
|
|
15
|
+
*
|
|
16
|
+
* @param client {@link PimlicoBundlerClient} that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler.
|
|
17
|
+
* @param hash {@link Hash} UserOpHash that you must have received from sendUserOperation.
|
|
18
|
+
* @returns status & transaction hash if included {@link GetUserOperationStatusReturnType}
|
|
19
|
+
*
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* import { createClient } from "viem"
|
|
23
|
+
* import { getUserOperationStatus } from "permissionless/actions/pimlico"
|
|
24
|
+
*
|
|
25
|
+
* const bundlerClient = createClient({
|
|
26
|
+
* chain: goerli,
|
|
27
|
+
* transport: http("https://api.pimlico.io/v1/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
28
|
+
* })
|
|
29
|
+
*
|
|
30
|
+
* await getUserOperationStatus(bundlerClient, { hash: userOpHash })
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
export const getUserOperationStatus = async (
|
|
34
|
+
client: PimlicoBundlerClient,
|
|
35
|
+
{ hash }: GetUserOperationStatusParameters
|
|
36
|
+
): Promise<GetUserOperationStatusReturnType> => {
|
|
37
|
+
return client.request({
|
|
38
|
+
method: "pimlico_getUserOperationStatus",
|
|
39
|
+
params: [hash]
|
|
40
|
+
})
|
|
41
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem"
|
|
2
|
+
import type { PartialBy } from "viem/types/utils"
|
|
3
|
+
import type { PimlicoPaymasterClient } from "../../clients/pimlico.js"
|
|
4
|
+
import type { UserOperation, UserOperationWithBigIntAsHex } from "../../types/userOperation.js"
|
|
5
|
+
import { deepHexlify } from "../utils.js"
|
|
6
|
+
|
|
7
|
+
export type SponsorUserOperationParameters = {
|
|
8
|
+
userOperation: PartialBy<
|
|
9
|
+
UserOperation,
|
|
10
|
+
"callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "paymasterAndData"
|
|
11
|
+
>
|
|
12
|
+
entryPoint: Address
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type SponsorUserOperationReturnType = {
|
|
16
|
+
paymasterAndData: Hex
|
|
17
|
+
preVerificationGas: bigint
|
|
18
|
+
verificationGasLimit: bigint
|
|
19
|
+
callGasLimit: bigint
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Returns paymasterAndData & updated gas parameters required to sponsor a userOperation.
|
|
24
|
+
*
|
|
25
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-paymaster-actions/sponsorUserOperation
|
|
26
|
+
*
|
|
27
|
+
* @param client {@link PimlicoBundlerClient} that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler.
|
|
28
|
+
* @param args {@link sponsorUserOperationParameters} UserOperation you want to sponsor & entryPoint.
|
|
29
|
+
* @returns paymasterAndData & updated gas parameters, see {@link SponsorUserOperationReturnType}
|
|
30
|
+
*
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* import { createClient } from "viem"
|
|
34
|
+
* import { sponsorUserOperation } from "permissionless/actions/pimlico"
|
|
35
|
+
*
|
|
36
|
+
* const bundlerClient = createClient({
|
|
37
|
+
* chain: goerli,
|
|
38
|
+
* transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
39
|
+
* })
|
|
40
|
+
*
|
|
41
|
+
* await sponsorUserOperation(bundlerClient, {
|
|
42
|
+
* userOperation: userOperationWithDummySignature,
|
|
43
|
+
* entryPoint: entryPoint
|
|
44
|
+
* }})
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
export const sponsorUserOperation = async (
|
|
48
|
+
client: PimlicoPaymasterClient,
|
|
49
|
+
args: SponsorUserOperationParameters
|
|
50
|
+
): Promise<SponsorUserOperationReturnType> => {
|
|
51
|
+
const response = await client.request({
|
|
52
|
+
method: "pm_sponsorUserOperation",
|
|
53
|
+
params: [deepHexlify(args.userOperation) as UserOperationWithBigIntAsHex, args.entryPoint]
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
paymasterAndData: response.paymasterAndData,
|
|
58
|
+
preVerificationGas: BigInt(response.preVerificationGas),
|
|
59
|
+
verificationGasLimit: BigInt(response.verificationGasLimit),
|
|
60
|
+
callGasLimit: BigInt(response.callGasLimit)
|
|
61
|
+
}
|
|
62
|
+
}
|
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
|
+
}
|