permissionless 0.0.30 → 0.0.32
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 +12 -0
- package/_cjs/actions/bundler/estimateUserOperationGas.js +21 -15
- package/_cjs/actions/bundler/estimateUserOperationGas.js.map +1 -1
- package/_cjs/actions/bundler/sendUserOperation.js +14 -7
- package/_cjs/actions/bundler/sendUserOperation.js.map +1 -1
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/errors/account.js +311 -0
- package/_cjs/errors/account.js.map +1 -0
- package/_cjs/errors/bundler.js +61 -0
- package/_cjs/errors/bundler.js.map +1 -0
- package/_cjs/errors/estimateUserOperationGas.js +47 -0
- package/_cjs/errors/estimateUserOperationGas.js.map +1 -0
- package/_cjs/errors/gas.js +113 -0
- package/_cjs/errors/gas.js.map +1 -0
- package/_cjs/errors/index.js +35 -0
- package/_cjs/errors/index.js.map +1 -0
- package/_cjs/errors/paymaster.js +228 -0
- package/_cjs/errors/paymaster.js.map +1 -0
- package/_cjs/errors/sendUserOperation.js +47 -0
- package/_cjs/errors/sendUserOperation.js.map +1 -0
- package/_cjs/errors/utils.js +18 -0
- package/_cjs/errors/utils.js.map +1 -0
- package/_cjs/index.js +1 -0
- package/_cjs/index.js.map +1 -1
- package/_cjs/utils/errors/getBundlerError.js +124 -0
- package/_cjs/utils/errors/getBundlerError.js.map +1 -0
- package/_cjs/utils/errors/getEstimateUserOperationGasError.js +19 -0
- package/_cjs/utils/errors/getEstimateUserOperationGasError.js.map +1 -0
- package/_cjs/utils/errors/getSendUserOperationError.js +19 -0
- package/_cjs/utils/errors/getSendUserOperationError.js.map +1 -0
- package/_cjs/utils/getAddressFromInitCodeOrPaymasterAndData.js +15 -0
- package/_cjs/utils/getAddressFromInitCodeOrPaymasterAndData.js.map +1 -0
- package/_cjs/utils/index.js +5 -3
- package/_cjs/utils/index.js.map +1 -1
- package/_esm/actions/bundler/estimateUserOperationGas.js +22 -15
- package/_esm/actions/bundler/estimateUserOperationGas.js.map +1 -1
- package/_esm/actions/bundler/sendUserOperation.js +14 -7
- package/_esm/actions/bundler/sendUserOperation.js.map +1 -1
- package/_esm/actions/index.js.map +1 -1
- package/_esm/errors/account.js +298 -0
- package/_esm/errors/account.js.map +1 -0
- package/_esm/errors/bundler.js +56 -0
- package/_esm/errors/bundler.js.map +1 -0
- package/_esm/errors/estimateUserOperationGas.js +43 -0
- package/_esm/errors/estimateUserOperationGas.js.map +1 -0
- package/_esm/errors/gas.js +106 -0
- package/_esm/errors/gas.js.map +1 -0
- package/_esm/errors/index.js +8 -0
- package/_esm/errors/index.js.map +1 -0
- package/_esm/errors/paymaster.js +218 -0
- package/_esm/errors/paymaster.js.map +1 -0
- package/_esm/errors/sendUserOperation.js +44 -0
- package/_esm/errors/sendUserOperation.js.map +1 -0
- package/_esm/errors/utils.js +14 -0
- package/_esm/errors/utils.js.map +1 -0
- package/_esm/index.js +1 -0
- package/_esm/index.js.map +1 -1
- package/_esm/utils/errors/getBundlerError.js +121 -0
- package/_esm/utils/errors/getBundlerError.js.map +1 -0
- package/_esm/utils/errors/getEstimateUserOperationGasError.js +19 -0
- package/_esm/utils/errors/getEstimateUserOperationGasError.js.map +1 -0
- package/_esm/utils/errors/getSendUserOperationError.js +15 -0
- package/_esm/utils/errors/getSendUserOperationError.js.map +1 -0
- package/_esm/utils/getAddressFromInitCodeOrPaymasterAndData.js +11 -0
- package/_esm/utils/getAddressFromInitCodeOrPaymasterAndData.js.map +1 -0
- package/_esm/utils/index.js +3 -2
- package/_esm/utils/index.js.map +1 -1
- package/_types/actions/bundler/estimateUserOperationGas.d.ts +3 -1
- package/_types/actions/bundler/estimateUserOperationGas.d.ts.map +1 -1
- package/_types/actions/bundler/sendUserOperation.d.ts.map +1 -1
- package/_types/actions/index.d.ts +2 -2
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/errors/account.d.ts +121 -0
- package/_types/errors/account.d.ts.map +1 -0
- package/_types/errors/bundler.d.ts +24 -0
- package/_types/errors/bundler.d.ts.map +1 -0
- package/_types/errors/estimateUserOperationGas.d.ts +13 -0
- package/_types/errors/estimateUserOperationGas.d.ts.map +1 -0
- package/_types/errors/gas.d.ts +47 -0
- package/_types/errors/gas.d.ts.map +1 -0
- package/_types/errors/index.d.ts +8 -0
- package/_types/errors/index.d.ts.map +1 -0
- package/_types/errors/paymaster.d.ts +85 -0
- package/_types/errors/paymaster.d.ts.map +1 -0
- package/_types/errors/sendUserOperation.d.ts +13 -0
- package/_types/errors/sendUserOperation.d.ts.map +1 -0
- package/_types/errors/utils.d.ts +5 -0
- package/_types/errors/utils.d.ts.map +1 -0
- package/_types/index.d.ts +1 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/utils/errors/getBundlerError.d.ts +11 -0
- package/_types/utils/errors/getBundlerError.d.ts.map +1 -0
- package/_types/utils/errors/getEstimateUserOperationGasError.d.ts +9 -0
- package/_types/utils/errors/getEstimateUserOperationGasError.d.ts.map +1 -0
- package/_types/utils/errors/getSendUserOperationError.d.ts +4 -0
- package/_types/utils/errors/getSendUserOperationError.d.ts.map +1 -0
- package/_types/utils/getAddressFromInitCodeOrPaymasterAndData.d.ts +3 -0
- package/_types/utils/getAddressFromInitCodeOrPaymasterAndData.d.ts.map +1 -0
- package/_types/utils/index.d.ts +3 -2
- package/_types/utils/index.d.ts.map +1 -1
- package/actions/bundler/estimateUserOperationGas.ts +33 -15
- package/actions/bundler/sendUserOperation.ts +26 -8
- package/actions/index.ts +3 -1
- package/errors/account.ts +345 -0
- package/errors/bundler.ts +62 -0
- package/errors/estimateUserOperationGas.ts +50 -0
- package/errors/gas.ts +120 -0
- package/errors/index.ts +118 -0
- package/errors/paymaster.ts +257 -0
- package/errors/sendUserOperation.ts +49 -0
- package/errors/utils.ts +19 -0
- package/index.ts +1 -0
- package/package.json +6 -1
- package/utils/errors/getBundlerError.ts +220 -0
- package/utils/errors/getEstimateUserOperationGasError.ts +37 -0
- package/utils/errors/getSendUserOperationError.ts +25 -0
- package/utils/getAddressFromInitCodeOrPaymasterAndData.ts +13 -0
- package/utils/index.ts +4 -2
package/errors/gas.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { BaseError } from "viem"
|
|
2
|
+
|
|
3
|
+
export type VerificationGasLimitTooLowErrorType =
|
|
4
|
+
VerificationGasLimitTooLowError & {
|
|
5
|
+
name: "VerificationGasLimitTooLowError"
|
|
6
|
+
}
|
|
7
|
+
export class VerificationGasLimitTooLowError extends BaseError {
|
|
8
|
+
static message = /aa4[01]/
|
|
9
|
+
override name = "VerificationGasLimitTooLowError"
|
|
10
|
+
constructor({
|
|
11
|
+
cause,
|
|
12
|
+
verificationGasLimit,
|
|
13
|
+
docsPath
|
|
14
|
+
}: {
|
|
15
|
+
cause?: BaseError
|
|
16
|
+
verificationGasLimit?: bigint
|
|
17
|
+
docsPath?: string
|
|
18
|
+
}) {
|
|
19
|
+
super(
|
|
20
|
+
[
|
|
21
|
+
`The smart account and paymaster verification exceeded the verificationGasLimit ${verificationGasLimit} set for the user operation.`,
|
|
22
|
+
"",
|
|
23
|
+
"Possible solutions:",
|
|
24
|
+
"• Verify that the verificationGasLimit set for the user operation is high enough to cover the gas used during smart account and paymaster verification.",
|
|
25
|
+
"• If you are using the eth_estimateUserOperationGas or pm_sponsorUserOperation method from bundler provider to set user operation gas limits and the EntryPoint throws this error during submission, reach out to them.",
|
|
26
|
+
"",
|
|
27
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
28
|
+
].join("\n"),
|
|
29
|
+
{
|
|
30
|
+
cause
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type ActualGasCostTooHighErrorType = ActualGasCostTooHighError & {
|
|
37
|
+
name: "ActualGasCostTooHighError"
|
|
38
|
+
}
|
|
39
|
+
export class ActualGasCostTooHighError extends BaseError {
|
|
40
|
+
static message = /aa51/
|
|
41
|
+
override name = "ActualGasCostTooHighError"
|
|
42
|
+
constructor({
|
|
43
|
+
cause,
|
|
44
|
+
docsPath
|
|
45
|
+
}: {
|
|
46
|
+
cause?: BaseError
|
|
47
|
+
docsPath?: string
|
|
48
|
+
}) {
|
|
49
|
+
super(
|
|
50
|
+
[
|
|
51
|
+
"The actual gas cost of the user operation ended up being higher than the funds paid by the smart account or the paymaster.",
|
|
52
|
+
"",
|
|
53
|
+
"Possible solutions:",
|
|
54
|
+
"• If you encounter this error, try increasing the verificationGasLimit set for the user operation.",
|
|
55
|
+
"• If you are using the eth_estimateUserOperationGas or pm_sponsorUserOperation method from bundler provider to set user operation gas limits and the EntryPoint throws this error during submission, reach out to them.",
|
|
56
|
+
"",
|
|
57
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
58
|
+
].join("\n"),
|
|
59
|
+
{
|
|
60
|
+
cause
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type GasValuesOverflowErrorType = GasValuesOverflowError & {
|
|
67
|
+
name: "GasValuesOverflowError"
|
|
68
|
+
}
|
|
69
|
+
export class GasValuesOverflowError extends BaseError {
|
|
70
|
+
static message = /aa94/
|
|
71
|
+
override name = "GasValuesOverflowError"
|
|
72
|
+
constructor({
|
|
73
|
+
cause,
|
|
74
|
+
docsPath
|
|
75
|
+
}: {
|
|
76
|
+
cause?: BaseError
|
|
77
|
+
docsPath?: string
|
|
78
|
+
}) {
|
|
79
|
+
super(
|
|
80
|
+
[
|
|
81
|
+
"The gas limit values of the user operation overflowed, they must fit in uint160.",
|
|
82
|
+
"",
|
|
83
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
84
|
+
].join("\n"),
|
|
85
|
+
{
|
|
86
|
+
cause
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export type BundlerOutOfGasErrorType = BundlerOutOfGasError & {
|
|
93
|
+
name: "BundlerOutOfGasError"
|
|
94
|
+
}
|
|
95
|
+
export class BundlerOutOfGasError extends BaseError {
|
|
96
|
+
static message = /aa95/
|
|
97
|
+
override name = "BundlerOutOfGasError"
|
|
98
|
+
constructor({
|
|
99
|
+
cause,
|
|
100
|
+
docsPath
|
|
101
|
+
}: {
|
|
102
|
+
cause?: BaseError
|
|
103
|
+
docsPath?: string
|
|
104
|
+
}) {
|
|
105
|
+
super(
|
|
106
|
+
[
|
|
107
|
+
"The bundler tried to bundle the user operation with the gas limit set too low.",
|
|
108
|
+
"",
|
|
109
|
+
"Possible solutions:",
|
|
110
|
+
"• If you are using your own bundler, configure it send gas limits properly.",
|
|
111
|
+
"• If you are using a bundler provider, reach out to them.",
|
|
112
|
+
"",
|
|
113
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
114
|
+
].join("\n"),
|
|
115
|
+
{
|
|
116
|
+
cause
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
}
|
package/errors/index.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InitCodeDidNotDeploySenderError,
|
|
3
|
+
type InitCodeDidNotDeploySenderErrorType,
|
|
4
|
+
InitCodeRevertedError,
|
|
5
|
+
type InitCodeRevertedErrorType,
|
|
6
|
+
InvalidSmartAccountNonceError,
|
|
7
|
+
type InvalidSmartAccountNonceErrorType,
|
|
8
|
+
InvalidSmartAccountSignatureError,
|
|
9
|
+
type InvalidSmartAccountSignatureErrorType,
|
|
10
|
+
SenderAddressMismatchError,
|
|
11
|
+
type SenderAddressMismatchErrorType,
|
|
12
|
+
SenderAlreadyDeployedError,
|
|
13
|
+
type SenderAlreadyDeployedErrorType,
|
|
14
|
+
SenderNotDeployedError,
|
|
15
|
+
type SenderNotDeployedErrorType,
|
|
16
|
+
SmartAccountInsufficientFundsError,
|
|
17
|
+
type SmartAccountInsufficientFundsErrorType,
|
|
18
|
+
SmartAccountSignatureValidityPeriodError,
|
|
19
|
+
type SmartAccountSignatureValidityPeriodErrorType,
|
|
20
|
+
SmartAccountValidationRevertedError,
|
|
21
|
+
type SmartAccountValidationRevertedErrorType
|
|
22
|
+
} from "./account.js"
|
|
23
|
+
import {
|
|
24
|
+
EstimateUserOperationGasError,
|
|
25
|
+
type EstimateUserOperationGasErrorType
|
|
26
|
+
} from "./estimateUserOperationGas.js"
|
|
27
|
+
import {
|
|
28
|
+
SendUserOperationError,
|
|
29
|
+
type SendUserOperationErrorType
|
|
30
|
+
} from "./sendUserOperation.js"
|
|
31
|
+
|
|
32
|
+
import {
|
|
33
|
+
InvalidPaymasterAndDataError,
|
|
34
|
+
type InvalidPaymasterAndDataErrorType,
|
|
35
|
+
PaymasterDataRejectedError,
|
|
36
|
+
type PaymasterDataRejectedErrorType,
|
|
37
|
+
PaymasterDepositTooLowError,
|
|
38
|
+
type PaymasterDepositTooLowErrorType,
|
|
39
|
+
PaymasterNotDeployedError,
|
|
40
|
+
type PaymasterNotDeployedErrorType,
|
|
41
|
+
PaymasterPostOpRevertedError,
|
|
42
|
+
type PaymasterPostOpRevertedErrorType,
|
|
43
|
+
PaymasterValidationRevertedError,
|
|
44
|
+
type PaymasterValidationRevertedErrorType,
|
|
45
|
+
PaymasterValidityPeriodError,
|
|
46
|
+
type PaymasterValidityPeriodErrorType
|
|
47
|
+
} from "./paymaster.js"
|
|
48
|
+
|
|
49
|
+
import {
|
|
50
|
+
InvalidAggregatorError,
|
|
51
|
+
type InvalidAggregatorErrorType,
|
|
52
|
+
InvalidBeneficiaryAddressError,
|
|
53
|
+
type InvalidBeneficiaryAddressErrorType
|
|
54
|
+
} from "./bundler.js"
|
|
55
|
+
|
|
56
|
+
import {
|
|
57
|
+
ActualGasCostTooHighError,
|
|
58
|
+
type ActualGasCostTooHighErrorType,
|
|
59
|
+
BundlerOutOfGasError,
|
|
60
|
+
type BundlerOutOfGasErrorType,
|
|
61
|
+
GasValuesOverflowError,
|
|
62
|
+
type GasValuesOverflowErrorType,
|
|
63
|
+
VerificationGasLimitTooLowError,
|
|
64
|
+
type VerificationGasLimitTooLowErrorType
|
|
65
|
+
} from "./gas.js"
|
|
66
|
+
|
|
67
|
+
export {
|
|
68
|
+
type InitCodeDidNotDeploySenderErrorType,
|
|
69
|
+
type InitCodeRevertedErrorType,
|
|
70
|
+
type InvalidSmartAccountNonceErrorType,
|
|
71
|
+
type InvalidSmartAccountSignatureErrorType,
|
|
72
|
+
type SenderAddressMismatchErrorType,
|
|
73
|
+
type SenderAlreadyDeployedErrorType,
|
|
74
|
+
type SenderNotDeployedErrorType,
|
|
75
|
+
type SmartAccountInsufficientFundsErrorType,
|
|
76
|
+
type SmartAccountSignatureValidityPeriodErrorType,
|
|
77
|
+
type SmartAccountValidationRevertedErrorType,
|
|
78
|
+
type InvalidPaymasterAndDataErrorType,
|
|
79
|
+
type PaymasterDataRejectedErrorType,
|
|
80
|
+
type PaymasterDepositTooLowErrorType,
|
|
81
|
+
type PaymasterNotDeployedErrorType,
|
|
82
|
+
type PaymasterPostOpRevertedErrorType,
|
|
83
|
+
type PaymasterValidationRevertedErrorType,
|
|
84
|
+
type PaymasterValidityPeriodErrorType,
|
|
85
|
+
type InvalidAggregatorErrorType,
|
|
86
|
+
type InvalidBeneficiaryAddressErrorType,
|
|
87
|
+
type ActualGasCostTooHighErrorType,
|
|
88
|
+
type BundlerOutOfGasErrorType,
|
|
89
|
+
type GasValuesOverflowErrorType,
|
|
90
|
+
type VerificationGasLimitTooLowErrorType,
|
|
91
|
+
SenderAlreadyDeployedError,
|
|
92
|
+
EstimateUserOperationGasError,
|
|
93
|
+
InitCodeRevertedError,
|
|
94
|
+
SenderAddressMismatchError,
|
|
95
|
+
InitCodeDidNotDeploySenderError,
|
|
96
|
+
SenderNotDeployedError,
|
|
97
|
+
SmartAccountInsufficientFundsError,
|
|
98
|
+
SmartAccountSignatureValidityPeriodError,
|
|
99
|
+
SmartAccountValidationRevertedError,
|
|
100
|
+
InvalidSmartAccountNonceError,
|
|
101
|
+
PaymasterNotDeployedError,
|
|
102
|
+
PaymasterDepositTooLowError,
|
|
103
|
+
InvalidSmartAccountSignatureError,
|
|
104
|
+
InvalidBeneficiaryAddressError,
|
|
105
|
+
InvalidAggregatorError,
|
|
106
|
+
InvalidPaymasterAndDataError,
|
|
107
|
+
PaymasterDataRejectedError,
|
|
108
|
+
PaymasterValidityPeriodError,
|
|
109
|
+
PaymasterValidationRevertedError,
|
|
110
|
+
VerificationGasLimitTooLowError,
|
|
111
|
+
ActualGasCostTooHighError,
|
|
112
|
+
GasValuesOverflowError,
|
|
113
|
+
BundlerOutOfGasError,
|
|
114
|
+
PaymasterPostOpRevertedError,
|
|
115
|
+
SendUserOperationError,
|
|
116
|
+
type EstimateUserOperationGasErrorType,
|
|
117
|
+
type SendUserOperationErrorType
|
|
118
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { BaseError, type Hex } from "viem"
|
|
2
|
+
import { getAddressFromInitCodeOrPaymasterAndData } from "../utils/index.js"
|
|
3
|
+
|
|
4
|
+
export type PaymasterNotDeployedErrorType = PaymasterNotDeployedError & {
|
|
5
|
+
name: "PaymasterNotDeployedError"
|
|
6
|
+
}
|
|
7
|
+
export class PaymasterNotDeployedError extends BaseError {
|
|
8
|
+
static message = /aa30/
|
|
9
|
+
override name = "PaymasterNotDeployedError"
|
|
10
|
+
constructor({
|
|
11
|
+
cause,
|
|
12
|
+
paymasterAndData,
|
|
13
|
+
docsPath
|
|
14
|
+
}: {
|
|
15
|
+
cause?: BaseError
|
|
16
|
+
paymasterAndData?: Hex
|
|
17
|
+
docsPath?: string
|
|
18
|
+
} = {}) {
|
|
19
|
+
const paymaster = paymasterAndData
|
|
20
|
+
? getAddressFromInitCodeOrPaymasterAndData(paymasterAndData)
|
|
21
|
+
: "0x"
|
|
22
|
+
|
|
23
|
+
super(
|
|
24
|
+
[
|
|
25
|
+
`Paymaster ${paymaster} is not deployed.`,
|
|
26
|
+
"",
|
|
27
|
+
"Possible solutions:",
|
|
28
|
+
"• Verify that the paymasterAndData field is correct, and that the first 20 bytes are the address of the paymaster contract you intend to use.",
|
|
29
|
+
"• Verify that the paymaster contract is deployed on the network you are using.",
|
|
30
|
+
"",
|
|
31
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
32
|
+
].join("\n"),
|
|
33
|
+
{
|
|
34
|
+
cause
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type PaymasterDepositTooLowErrorType = PaymasterDepositTooLowError & {
|
|
41
|
+
name: "PaymasterDepositTooLowError"
|
|
42
|
+
}
|
|
43
|
+
export class PaymasterDepositTooLowError extends BaseError {
|
|
44
|
+
static message = /aa31/
|
|
45
|
+
override name = "PaymasterDepositTooLowError"
|
|
46
|
+
constructor({
|
|
47
|
+
cause,
|
|
48
|
+
paymasterAndData,
|
|
49
|
+
docsPath
|
|
50
|
+
}: {
|
|
51
|
+
cause?: BaseError
|
|
52
|
+
paymasterAndData?: Hex
|
|
53
|
+
docsPath?: string
|
|
54
|
+
} = {}) {
|
|
55
|
+
const paymaster = paymasterAndData
|
|
56
|
+
? getAddressFromInitCodeOrPaymasterAndData(paymasterAndData)
|
|
57
|
+
: "0x"
|
|
58
|
+
|
|
59
|
+
super(
|
|
60
|
+
[
|
|
61
|
+
`Paymaster ${paymaster} contract does not have enough funds deposited into the EntryPoint contract to cover the required funds for the user operation.`,
|
|
62
|
+
"",
|
|
63
|
+
"Possible solutions:",
|
|
64
|
+
"• If you are using your own paymaster contract, deposit more funds into the EntryPoint contract through the deposit() function of the paymaster contract.",
|
|
65
|
+
"• Verify that the paymasterAndData field is correct, and that the first 20 bytes are the address of the paymaster contract you intend to useVerify that the paymasterAndData field is correct, and that the first 20 bytes are the address of the paymaster contract you intend to use.",
|
|
66
|
+
"• If you are using a paymaster service, reach out to them.",
|
|
67
|
+
"",
|
|
68
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
69
|
+
].join("\n"),
|
|
70
|
+
{
|
|
71
|
+
cause
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type PaymasterValidityPeriodErrorType = PaymasterValidityPeriodError & {
|
|
78
|
+
name: "PaymasterValidityPeriodError"
|
|
79
|
+
}
|
|
80
|
+
export class PaymasterValidityPeriodError extends BaseError {
|
|
81
|
+
static message = /aa32/
|
|
82
|
+
override name = "PaymasterValidityPeriodError"
|
|
83
|
+
constructor({
|
|
84
|
+
cause,
|
|
85
|
+
paymasterAndData,
|
|
86
|
+
docsPath
|
|
87
|
+
}: {
|
|
88
|
+
cause?: BaseError
|
|
89
|
+
paymasterAndData?: Hex
|
|
90
|
+
docsPath?: string
|
|
91
|
+
}) {
|
|
92
|
+
const paymaster = paymasterAndData
|
|
93
|
+
? getAddressFromInitCodeOrPaymasterAndData(paymasterAndData)
|
|
94
|
+
: "0x"
|
|
95
|
+
|
|
96
|
+
super(
|
|
97
|
+
[
|
|
98
|
+
`Paymaster ${paymaster}'s data used in the paymasterAndData field of the user operation is not valid, because it is outside of the time range it specified.`,
|
|
99
|
+
"",
|
|
100
|
+
"Possible reasons:",
|
|
101
|
+
"• This error occurs when the block.timestamp falls after the validUntil timestamp, or before the validAfter timestamp.",
|
|
102
|
+
"",
|
|
103
|
+
"Possible solutions:",
|
|
104
|
+
"• If you are using your own paymaster contract and using time-based signatures, verify that the validAfter and validUntil fields are set correctly and that the user operation is sent within the specified range.",
|
|
105
|
+
"• If you are using your own paymaster contract and not looking to use time-based signatures, verify that the validAfter and validUntil fields are set to 0.",
|
|
106
|
+
"• If you are using a service, contact your service provider for their paymaster's validity.",
|
|
107
|
+
"",
|
|
108
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
109
|
+
].join("\n"),
|
|
110
|
+
{
|
|
111
|
+
cause
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export type PaymasterValidationRevertedErrorType =
|
|
118
|
+
PaymasterValidationRevertedError & {
|
|
119
|
+
name: "PaymasterValidationRevertedError"
|
|
120
|
+
}
|
|
121
|
+
export class PaymasterValidationRevertedError extends BaseError {
|
|
122
|
+
static message = /aa33/
|
|
123
|
+
override name = "PaymasterValidationRevertedError"
|
|
124
|
+
constructor({
|
|
125
|
+
cause,
|
|
126
|
+
paymasterAndData,
|
|
127
|
+
docsPath
|
|
128
|
+
}: {
|
|
129
|
+
cause?: BaseError
|
|
130
|
+
paymasterAndData?: Hex
|
|
131
|
+
docsPath?: string
|
|
132
|
+
}) {
|
|
133
|
+
const paymaster = paymasterAndData
|
|
134
|
+
? getAddressFromInitCodeOrPaymasterAndData(paymasterAndData)
|
|
135
|
+
: "0x"
|
|
136
|
+
|
|
137
|
+
super(
|
|
138
|
+
[
|
|
139
|
+
`The validatePaymasterUserOp function of the paymaster ${paymaster} either reverted or ran out of gas.`,
|
|
140
|
+
"",
|
|
141
|
+
"Possible solutions:",
|
|
142
|
+
"• Verify that the verificationGasLimit is high enough to cover the validatePaymasterUserOp function's gas costs.",
|
|
143
|
+
"• If you are using your own paymaster contract, verify that the validatePaymasterUserOp function is implemented with the correct logic, and that the user operation is supposed to be valid.",
|
|
144
|
+
"• If you are using a paymaster service, and the user operation is well formed with a high enough verificationGasLimit, reach out to them.",
|
|
145
|
+
"• If you are not looking to use a paymaster to cover the gas fees, verify that the paymasterAndData field is not set.",
|
|
146
|
+
"",
|
|
147
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
148
|
+
].join("\n"),
|
|
149
|
+
{
|
|
150
|
+
cause
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export type PaymasterDataRejectedErrorType = PaymasterDataRejectedError & {
|
|
157
|
+
name: "PaymasterDataRejectedError"
|
|
158
|
+
}
|
|
159
|
+
export class PaymasterDataRejectedError extends BaseError {
|
|
160
|
+
static message = /aa34/
|
|
161
|
+
override name = "PaymasterDataRejectedError"
|
|
162
|
+
constructor({
|
|
163
|
+
cause,
|
|
164
|
+
paymasterAndData,
|
|
165
|
+
docsPath
|
|
166
|
+
}: {
|
|
167
|
+
cause?: BaseError
|
|
168
|
+
paymasterAndData?: Hex
|
|
169
|
+
docsPath?: string
|
|
170
|
+
}) {
|
|
171
|
+
const paymaster = paymasterAndData
|
|
172
|
+
? getAddressFromInitCodeOrPaymasterAndData(paymasterAndData)
|
|
173
|
+
: "0x"
|
|
174
|
+
|
|
175
|
+
super(
|
|
176
|
+
[
|
|
177
|
+
`The validatePaymasterUserOp function of the paymaster ${paymaster} rejected paymasterAndData.`,
|
|
178
|
+
"",
|
|
179
|
+
"Possible solutions:",
|
|
180
|
+
"• If you are using your own paymaster contract, verify that the user operation was correctly signed according to your implementation, and that the paymaster signature was correctly encoded in the paymasterAndData field of the user operation.",
|
|
181
|
+
"• If you are using a paymaster service, make sure you do not modify any of the fields of the user operation after the paymaster signs over it (except the signature field).",
|
|
182
|
+
"• If you are using a paymaster service and you have not modified any of the fields except the signature but you are still getting this error, reach out to them.",
|
|
183
|
+
"",
|
|
184
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
185
|
+
].join("\n"),
|
|
186
|
+
{
|
|
187
|
+
cause
|
|
188
|
+
}
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export type PaymasterPostOpRevertedErrorType = PaymasterPostOpRevertedError & {
|
|
194
|
+
name: "PaymasterPostOpRevertedError"
|
|
195
|
+
}
|
|
196
|
+
export class PaymasterPostOpRevertedError extends BaseError {
|
|
197
|
+
static message = /aa50/
|
|
198
|
+
override name = "PaymasterPostOpRevertedError"
|
|
199
|
+
constructor({
|
|
200
|
+
cause,
|
|
201
|
+
paymasterAndData,
|
|
202
|
+
docsPath
|
|
203
|
+
}: {
|
|
204
|
+
cause?: BaseError
|
|
205
|
+
paymasterAndData?: Hex
|
|
206
|
+
docsPath?: string
|
|
207
|
+
}) {
|
|
208
|
+
const paymaster = paymasterAndData
|
|
209
|
+
? getAddressFromInitCodeOrPaymasterAndData(paymasterAndData)
|
|
210
|
+
: "0x"
|
|
211
|
+
|
|
212
|
+
super(
|
|
213
|
+
[
|
|
214
|
+
`The postOp function of the paymaster ${paymaster} reverted.`,
|
|
215
|
+
"",
|
|
216
|
+
"Possible solutions:",
|
|
217
|
+
"• If you are using your own paymaster contract, verify that that you have correctly implemented the postOp function (if you are using one). If you do not intent to make use of the postOp function, make sure you do not set the context parameter in the paymaster's validatePaymasterUserOp function.",
|
|
218
|
+
"• If you are using a paymaster service and you see this error, reach out to them.",
|
|
219
|
+
"",
|
|
220
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
221
|
+
].join("\n"),
|
|
222
|
+
{
|
|
223
|
+
cause
|
|
224
|
+
}
|
|
225
|
+
)
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export type InvalidPaymasterAndDataErrorType = InvalidPaymasterAndDataError & {
|
|
230
|
+
name: "InvalidPaymasterAndDataError"
|
|
231
|
+
}
|
|
232
|
+
export class InvalidPaymasterAndDataError extends BaseError {
|
|
233
|
+
static message = /aa93/
|
|
234
|
+
override name = "InvalidPaymasterAndDataError"
|
|
235
|
+
constructor({
|
|
236
|
+
cause,
|
|
237
|
+
docsPath
|
|
238
|
+
}: {
|
|
239
|
+
cause?: BaseError
|
|
240
|
+
docsPath?: string
|
|
241
|
+
}) {
|
|
242
|
+
super(
|
|
243
|
+
[
|
|
244
|
+
"The paymasterAndData field of the user operation is invalid.",
|
|
245
|
+
"",
|
|
246
|
+
"Possible solutions:",
|
|
247
|
+
"• Make sure you have either not set a value for the paymasterAndData, or that it is at least 20 bytes long.",
|
|
248
|
+
"• If you are using a paymaster service, reach out to them.",
|
|
249
|
+
"",
|
|
250
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
251
|
+
].join("\n"),
|
|
252
|
+
{
|
|
253
|
+
cause
|
|
254
|
+
}
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { BaseError } from "viem"
|
|
2
|
+
import { type SendUserOperationParameters } from "../actions/bundler/sendUserOperation.js"
|
|
3
|
+
import { prettyPrint } from "./utils.js"
|
|
4
|
+
|
|
5
|
+
export type SendUserOperationErrorType = SendUserOperationError & {
|
|
6
|
+
name: "SendUserOperationError"
|
|
7
|
+
}
|
|
8
|
+
export class SendUserOperationError extends BaseError {
|
|
9
|
+
override cause: BaseError
|
|
10
|
+
|
|
11
|
+
override name = "SendUserOperationError"
|
|
12
|
+
|
|
13
|
+
constructor(
|
|
14
|
+
cause: BaseError,
|
|
15
|
+
{
|
|
16
|
+
userOperation,
|
|
17
|
+
entryPoint,
|
|
18
|
+
docsPath
|
|
19
|
+
}: SendUserOperationParameters & {
|
|
20
|
+
docsPath?: string
|
|
21
|
+
}
|
|
22
|
+
) {
|
|
23
|
+
const prettyArgs = prettyPrint({
|
|
24
|
+
sender: userOperation.sender,
|
|
25
|
+
nonce: userOperation.nonce,
|
|
26
|
+
initCode: userOperation.initCode,
|
|
27
|
+
callData: userOperation.callData,
|
|
28
|
+
callGasLimit: userOperation.callGasLimit,
|
|
29
|
+
verificationGasLimit: userOperation.verificationGasLimit,
|
|
30
|
+
preVerificationGas: userOperation.preVerificationGas,
|
|
31
|
+
maxFeePerGas: userOperation.maxFeePerGas,
|
|
32
|
+
maxPriorityFeePerGas: userOperation.maxPriorityFeePerGas,
|
|
33
|
+
paymasterAndData: userOperation.paymasterAndData,
|
|
34
|
+
signature: userOperation.signature,
|
|
35
|
+
entryPoint
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
super(cause.shortMessage, {
|
|
39
|
+
cause,
|
|
40
|
+
docsPath,
|
|
41
|
+
metaMessages: [
|
|
42
|
+
...(cause.metaMessages ? [...cause.metaMessages, " "] : []),
|
|
43
|
+
"sendUserOperation Arguments:",
|
|
44
|
+
prettyArgs
|
|
45
|
+
].filter(Boolean) as string[]
|
|
46
|
+
})
|
|
47
|
+
this.cause = cause
|
|
48
|
+
}
|
|
49
|
+
}
|
package/errors/utils.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type ErrorType<name extends string = "Error"> = Error & { name: name }
|
|
2
|
+
|
|
3
|
+
export function prettyPrint(
|
|
4
|
+
args: Record<string, bigint | number | string | undefined | false | unknown>
|
|
5
|
+
) {
|
|
6
|
+
const entries = Object.entries(args)
|
|
7
|
+
.map(([key, value]) => {
|
|
8
|
+
if (value === undefined || value === false) return null
|
|
9
|
+
return [key, value]
|
|
10
|
+
})
|
|
11
|
+
.filter(Boolean) as [string, string][]
|
|
12
|
+
const maxLength = entries.reduce(
|
|
13
|
+
(acc, [key]) => Math.max(acc, key.length),
|
|
14
|
+
0
|
|
15
|
+
)
|
|
16
|
+
return entries
|
|
17
|
+
.map(([key, value]) => ` ${`${key}:`.padEnd(maxLength + 1)} ${value}`)
|
|
18
|
+
.join("\n")
|
|
19
|
+
}
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "permissionless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
4
4
|
"author": "Pimlico",
|
|
5
5
|
"homepage": "https://docs.pimlico.io/permissionless",
|
|
6
6
|
"repository": "github:pimlicolabs/permissionless.js",
|
|
@@ -69,6 +69,11 @@
|
|
|
69
69
|
"types": "./_types/utils/index.d.ts",
|
|
70
70
|
"import": "./_esm/utils/index.js",
|
|
71
71
|
"default": "./_cjs/utils/index.js"
|
|
72
|
+
},
|
|
73
|
+
"./errors": {
|
|
74
|
+
"types": "./_types/errors/index.d.ts",
|
|
75
|
+
"import": "./_esm/errors/index.js",
|
|
76
|
+
"default": "./_cjs/errors/index.js"
|
|
72
77
|
}
|
|
73
78
|
},
|
|
74
79
|
"peerDependencies": {
|