permissionless 0.0.2 → 0.0.4
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 +18 -0
- package/_cjs/actions/bundler.js +6 -5
- package/_cjs/actions/bundler.js.map +1 -1
- package/_cjs/actions/index.js +3 -2
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/pimlico.js +55 -0
- package/_cjs/actions/pimlico.js.map +1 -0
- package/_cjs/actions/utils.js +5 -1
- package/_cjs/actions/utils.js.map +1 -1
- package/_cjs/clients/bundler.js +17 -0
- package/_cjs/clients/bundler.js.map +1 -0
- package/_cjs/clients/index.js +6 -0
- package/_cjs/clients/index.js.map +1 -0
- package/_cjs/clients/pimlico.js +29 -0
- package/_cjs/clients/pimlico.js.map +1 -0
- package/_cjs/index.js +2 -0
- package/_cjs/index.js.map +1 -1
- package/_cjs/types/pimlico.js +3 -0
- package/_cjs/types/pimlico.js.map +1 -0
- package/_cjs/utils/index.js +38 -0
- package/_cjs/utils/index.js.map +1 -0
- package/_esm/actions/bundler.js +14 -147
- package/_esm/actions/bundler.js.map +1 -1
- package/_esm/actions/index.js +2 -2
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/pimlico.js +124 -0
- package/_esm/actions/pimlico.js.map +1 -0
- package/_esm/actions/utils.js +4 -0
- package/_esm/actions/utils.js.map +1 -1
- package/_esm/clients/bundler.js +32 -0
- package/_esm/clients/bundler.js.map +1 -0
- package/_esm/clients/index.js +3 -0
- package/_esm/clients/index.js.map +1 -0
- package/_esm/clients/pimlico.js +62 -0
- package/_esm/clients/pimlico.js.map +1 -0
- package/_esm/index.js +2 -0
- package/_esm/index.js.map +1 -1
- package/_esm/types/pimlico.js +2 -0
- package/_esm/types/pimlico.js.map +1 -0
- package/_esm/utils/index.js +56 -0
- package/_esm/utils/index.js.map +1 -0
- package/_types/actions/bundler.d.ts +116 -27
- package/_types/actions/bundler.d.ts.map +1 -1
- package/_types/actions/index.d.ts +4 -2
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/actions/pimlico.d.ts +178 -0
- package/_types/actions/pimlico.d.ts.map +1 -0
- package/_types/actions/utils.d.ts +4 -0
- package/_types/actions/utils.d.ts.map +1 -1
- package/_types/clients/bundler.d.ts +38 -0
- package/_types/clients/bundler.d.ts.map +1 -0
- package/_types/clients/index.d.ts +3 -0
- package/_types/clients/index.d.ts.map +1 -0
- package/_types/clients/pimlico.d.ts +73 -0
- package/_types/clients/pimlico.d.ts.map +1 -0
- package/_types/index.d.ts +2 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/types/bundler.d.ts +4 -37
- package/_types/types/bundler.d.ts.map +1 -1
- package/_types/types/index.d.ts +1 -2
- package/_types/types/index.d.ts.map +1 -1
- package/_types/types/pimlico.d.ts +50 -0
- package/_types/types/pimlico.d.ts.map +1 -0
- package/_types/types/userOperation.d.ts +1 -0
- package/_types/types/userOperation.d.ts.map +1 -1
- package/_types/utils/index.d.ts +31 -0
- package/_types/utils/index.d.ts.map +1 -0
- package/actions/bundler.ts +87 -35
- package/actions/index.ts +25 -8
- package/actions/pimlico.ts +252 -0
- package/actions/utils.ts +5 -0
- package/clients/bundler.ts +38 -0
- package/clients/index.ts +3 -0
- package/clients/pimlico.ts +91 -0
- package/index.ts +2 -0
- package/package.json +23 -3
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/bundler.ts +4 -39
- package/types/index.ts +1 -2
- package/types/pimlico.ts +55 -0
- package/types/userOperation.ts +2 -0
- package/utils/index.ts +70 -0
package/types/bundler.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Address, Hash, Hex } from "viem"
|
|
2
2
|
import type { PartialBy } from "viem/types/utils"
|
|
3
3
|
import type { UserOperationWithBigIntAsHex } from "./userOperation"
|
|
4
4
|
|
|
5
|
-
export type
|
|
6
|
-
|
|
7
|
-
type BundlerRpcSchema = [
|
|
5
|
+
export type BundlerRpcSchema = [
|
|
8
6
|
{
|
|
9
7
|
Method: "eth_sendUserOperation"
|
|
10
8
|
Parameters: [userOperation: UserOperationWithBigIntAsHex, entryPoint: Address]
|
|
@@ -53,39 +51,6 @@ type BundlerRpcSchema = [
|
|
|
53
51
|
}
|
|
54
52
|
]
|
|
55
53
|
|
|
56
|
-
export type UserOperationReceipt = {
|
|
57
|
-
userOpHash: Hash
|
|
58
|
-
sender: Address
|
|
59
|
-
nonce: bigint
|
|
60
|
-
actualGasUsed: bigint
|
|
61
|
-
actualGasCost: bigint
|
|
62
|
-
success: boolean
|
|
63
|
-
receipt: {
|
|
64
|
-
transactionHash: Hex
|
|
65
|
-
transactionIndex: bigint
|
|
66
|
-
blockHash: Hash
|
|
67
|
-
blockNumber: bigint
|
|
68
|
-
from: Address
|
|
69
|
-
to: Address | null
|
|
70
|
-
cumulativeGasUsed: bigint
|
|
71
|
-
status: bigint | null
|
|
72
|
-
gasUsed: bigint
|
|
73
|
-
contractAddress: Address | null
|
|
74
|
-
logsBloom: string
|
|
75
|
-
effectiveGasPrice: bigint
|
|
76
|
-
}
|
|
77
|
-
logs: {
|
|
78
|
-
data: Hex
|
|
79
|
-
blockNumber: bigint
|
|
80
|
-
blockHash: Hash
|
|
81
|
-
transactionHash: Hash
|
|
82
|
-
logIndex: bigint
|
|
83
|
-
transactionIndex: bigint
|
|
84
|
-
address: Address
|
|
85
|
-
topics: Hex[]
|
|
86
|
-
}[]
|
|
87
|
-
}
|
|
88
|
-
|
|
89
54
|
type UserOperationReceiptWithBigIntAsHex = {
|
|
90
55
|
userOpHash: Hash
|
|
91
56
|
sender: Address
|
|
@@ -101,10 +66,10 @@ type UserOperationReceiptWithBigIntAsHex = {
|
|
|
101
66
|
from: Address
|
|
102
67
|
to: Address | null
|
|
103
68
|
cumulativeGasUsed: Hex
|
|
104
|
-
status:
|
|
69
|
+
status: "0x0" | "0x1"
|
|
105
70
|
gasUsed: Hex
|
|
106
71
|
contractAddress: Address | null
|
|
107
|
-
logsBloom:
|
|
72
|
+
logsBloom: Hex
|
|
108
73
|
effectiveGasPrice: Hex
|
|
109
74
|
}
|
|
110
75
|
logs: {
|
package/types/index.ts
CHANGED
package/types/pimlico.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Address, Hash, Hex } from "viem"
|
|
2
|
+
import type { PartialBy } from "viem/types/utils"
|
|
3
|
+
import type { UserOperationWithBigIntAsHex } from "./userOperation"
|
|
4
|
+
|
|
5
|
+
type PimlicoUserOperationGasPriceWithBigIntAsHex = {
|
|
6
|
+
slow: {
|
|
7
|
+
maxFeePerGas: Hex
|
|
8
|
+
maxPriorityFeePerGas: Hex
|
|
9
|
+
}
|
|
10
|
+
standard: {
|
|
11
|
+
maxFeePerGas: Hex
|
|
12
|
+
maxPriorityFeePerGas: Hex
|
|
13
|
+
}
|
|
14
|
+
fast: {
|
|
15
|
+
maxFeePerGas: Hex
|
|
16
|
+
maxPriorityFeePerGas: Hex
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type PimlicoUserOperationStatus = {
|
|
21
|
+
status: "not_found" | "not_submitted" | "submitted" | "rejected" | "reverted" | "included" | "failed"
|
|
22
|
+
transactionHash: Hash | null
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type PimlicoBundlerRpcSchema = [
|
|
26
|
+
{
|
|
27
|
+
Method: "pimlico_getUserOperationGasPrice"
|
|
28
|
+
Parameters: []
|
|
29
|
+
ReturnType: PimlicoUserOperationGasPriceWithBigIntAsHex
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
Method: "pimlico_getUserOperationStatus"
|
|
33
|
+
Parameters: [hash: Hash]
|
|
34
|
+
ReturnType: PimlicoUserOperationStatus
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
export type PimlicoPaymasterRpcSchema = [
|
|
39
|
+
{
|
|
40
|
+
Method: "pm_sponsorUserOperation"
|
|
41
|
+
Parameters: [
|
|
42
|
+
userOperation: PartialBy<
|
|
43
|
+
UserOperationWithBigIntAsHex,
|
|
44
|
+
"callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "paymasterAndData"
|
|
45
|
+
>,
|
|
46
|
+
entryPoint: Address
|
|
47
|
+
]
|
|
48
|
+
ReturnType: {
|
|
49
|
+
paymasterAndData: Hex
|
|
50
|
+
preVerificationGas: Hex
|
|
51
|
+
verificationGasLimit: Hex
|
|
52
|
+
callGasLimit: Hex
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
]
|
package/types/userOperation.ts
CHANGED
package/utils/index.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Address, Hash, Hex } from "viem"
|
|
2
|
+
import { encodeAbiParameters, keccak256 } from "viem"
|
|
3
|
+
import type { UserOperation } from "../types"
|
|
4
|
+
|
|
5
|
+
function packUserOp({ userOperation }: { userOperation: UserOperation }): Hex {
|
|
6
|
+
const hashedInitCode = keccak256(userOperation.initCode)
|
|
7
|
+
const hashedCallData = keccak256(userOperation.callData)
|
|
8
|
+
const hashedPaymasterAndData = keccak256(userOperation.paymasterAndData)
|
|
9
|
+
|
|
10
|
+
return encodeAbiParameters(
|
|
11
|
+
[
|
|
12
|
+
{ type: "address" },
|
|
13
|
+
{ type: "uint256" },
|
|
14
|
+
{ type: "bytes32" },
|
|
15
|
+
{ type: "bytes32" },
|
|
16
|
+
{ type: "uint256" },
|
|
17
|
+
{ type: "uint256" },
|
|
18
|
+
{ type: "uint256" },
|
|
19
|
+
{ type: "uint256" },
|
|
20
|
+
{ type: "uint256" },
|
|
21
|
+
{ type: "bytes32" }
|
|
22
|
+
],
|
|
23
|
+
[
|
|
24
|
+
userOperation.sender as Address,
|
|
25
|
+
userOperation.nonce,
|
|
26
|
+
hashedInitCode,
|
|
27
|
+
hashedCallData,
|
|
28
|
+
userOperation.callGasLimit,
|
|
29
|
+
userOperation.verificationGasLimit,
|
|
30
|
+
userOperation.preVerificationGas,
|
|
31
|
+
userOperation.maxFeePerGas,
|
|
32
|
+
userOperation.maxPriorityFeePerGas,
|
|
33
|
+
hashedPaymasterAndData
|
|
34
|
+
]
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type GetUserOperationHashParams = { userOperation: UserOperation; entryPoint: Address; chainId: number }
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* Returns user operation hash that is a unique identifier of the user operation.
|
|
43
|
+
*
|
|
44
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/utils/getUserOperationHash
|
|
45
|
+
*
|
|
46
|
+
* @param args: userOperation, entryPoint, chainId as {@link GetUserOperationHashParams}
|
|
47
|
+
* @returns userOperationHash as {@link Hash}
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* import { getUserOperationHash } from "permissionless/utils"
|
|
51
|
+
*
|
|
52
|
+
* const userOperationHash = getUserOperationHash({
|
|
53
|
+
* userOperation,
|
|
54
|
+
* entryPoint,
|
|
55
|
+
* chainId
|
|
56
|
+
* })
|
|
57
|
+
*
|
|
58
|
+
* // Returns "0xe9fad2cd67f9ca1d0b7a6513b2a42066784c8df938518da2b51bb8cc9a89ea34"
|
|
59
|
+
*
|
|
60
|
+
*/
|
|
61
|
+
const getUserOperationHash = ({ userOperation, entryPoint, chainId }: GetUserOperationHashParams): Hash => {
|
|
62
|
+
const encoded = encodeAbiParameters(
|
|
63
|
+
[{ type: "bytes32" }, { type: "address" }, { type: "uint256" }],
|
|
64
|
+
[keccak256(packUserOp({ userOperation })), entryPoint, BigInt(chainId)]
|
|
65
|
+
) as `0x${string}`
|
|
66
|
+
|
|
67
|
+
return keccak256(encoded)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { getUserOperationHash }
|