permissionless 0.0.31 → 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 +6 -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 +3 -1
- 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 +2 -1
- 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 +2 -1
- 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 +3 -1
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
Account,
|
|
3
|
+
Address,
|
|
4
|
+
BaseError,
|
|
5
|
+
Chain,
|
|
6
|
+
Client,
|
|
7
|
+
Hash,
|
|
8
|
+
Transport
|
|
9
|
+
} from "viem"
|
|
2
10
|
import type { BundlerClient } from "../../clients/createBundlerClient.js"
|
|
3
11
|
import type { BundlerRpcSchema } from "../../types/bundler.js"
|
|
4
12
|
import type { Prettify } from "../../types/index.js"
|
|
@@ -7,6 +15,7 @@ import type {
|
|
|
7
15
|
UserOperationWithBigIntAsHex
|
|
8
16
|
} from "../../types/userOperation.js"
|
|
9
17
|
import { deepHexlify } from "../../utils/deepHexlify.js"
|
|
18
|
+
import { getSendUserOperationError } from "../../utils/errors/getSendUserOperationError.js"
|
|
10
19
|
|
|
11
20
|
export type SendUserOperationParameters = {
|
|
12
21
|
userOperation: UserOperation
|
|
@@ -48,11 +57,20 @@ export const sendUserOperation = async <
|
|
|
48
57
|
): Promise<Hash> => {
|
|
49
58
|
const { userOperation, entryPoint } = args
|
|
50
59
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
try {
|
|
61
|
+
const userOperationHash = await client.request({
|
|
62
|
+
method: "eth_sendUserOperation",
|
|
63
|
+
params: [
|
|
64
|
+
deepHexlify(userOperation) as UserOperationWithBigIntAsHex,
|
|
65
|
+
entryPoint as Address
|
|
66
|
+
]
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
return userOperationHash
|
|
70
|
+
} catch (err) {
|
|
71
|
+
throw getSendUserOperationError(
|
|
72
|
+
err as BaseError,
|
|
73
|
+
args as SendUserOperationParameters
|
|
74
|
+
)
|
|
75
|
+
}
|
|
58
76
|
}
|
package/actions/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
EstimateUserOperationErrorType,
|
|
2
3
|
EstimateUserOperationGasParameters,
|
|
3
4
|
EstimateUserOperationGasReturnType
|
|
4
5
|
} from "./bundler/estimateUserOperationGas.js"
|
|
@@ -40,7 +41,8 @@ export type {
|
|
|
40
41
|
GetUserOperationReceiptReturnType,
|
|
41
42
|
GetSenderAddressParams,
|
|
42
43
|
GetAccountNonceParams,
|
|
43
|
-
WaitForUserOperationReceiptParameters
|
|
44
|
+
WaitForUserOperationReceiptParameters,
|
|
45
|
+
EstimateUserOperationErrorType
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
export {
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { type Address, BaseError } from "viem"
|
|
2
|
+
|
|
3
|
+
export type SenderAlreadyDeployedErrorType = SenderAlreadyDeployedError & {
|
|
4
|
+
name: "SenderAlreadyDeployedError"
|
|
5
|
+
}
|
|
6
|
+
export class SenderAlreadyDeployedError extends BaseError {
|
|
7
|
+
static message = /aa10/
|
|
8
|
+
override name = "SenderAlreadyDeployedError" as const
|
|
9
|
+
constructor({
|
|
10
|
+
cause,
|
|
11
|
+
sender,
|
|
12
|
+
docsPath
|
|
13
|
+
}: { cause?: BaseError; sender?: Address; docsPath?: string } = {}) {
|
|
14
|
+
super(
|
|
15
|
+
[
|
|
16
|
+
`Smart account ${sender} is already deployed.`,
|
|
17
|
+
"",
|
|
18
|
+
"Possible solutions:",
|
|
19
|
+
`• Remove the initCode from the user operation and set it to "0x"`,
|
|
20
|
+
"",
|
|
21
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
22
|
+
].join("\n"),
|
|
23
|
+
{
|
|
24
|
+
cause
|
|
25
|
+
}
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type InitCodeRevertedErrorType = InitCodeRevertedError & {
|
|
31
|
+
name: "InitCodeRevertedError"
|
|
32
|
+
}
|
|
33
|
+
export class InitCodeRevertedError extends BaseError {
|
|
34
|
+
static message = /aa13/
|
|
35
|
+
override name = "InitCodeRevertedError" as const
|
|
36
|
+
constructor({
|
|
37
|
+
cause,
|
|
38
|
+
docsPath
|
|
39
|
+
}: { cause?: BaseError; docsPath?: string } = {}) {
|
|
40
|
+
super(
|
|
41
|
+
[
|
|
42
|
+
"EntryPoint failed to create the smart account with the initCode provided.",
|
|
43
|
+
"",
|
|
44
|
+
"Possible reasons:",
|
|
45
|
+
"• The initCode ran out of gas",
|
|
46
|
+
"• The initCode reverted during the account deployment process",
|
|
47
|
+
"",
|
|
48
|
+
"Possible solutions:",
|
|
49
|
+
"• Verify that the factory address in the initCode is correct (the factory address is the first 20 bytes of the initCode).",
|
|
50
|
+
"• Verify that the initCode is correct.",
|
|
51
|
+
"• Check whether the verificationGasLimit is sufficient for the initCode to complete without running out of gas.",
|
|
52
|
+
"",
|
|
53
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
54
|
+
].join("\n"),
|
|
55
|
+
{
|
|
56
|
+
cause
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type SenderAddressMismatchErrorType = SenderAddressMismatchError & {
|
|
63
|
+
name: "SenderAddressMismatchError"
|
|
64
|
+
}
|
|
65
|
+
export class SenderAddressMismatchError extends BaseError {
|
|
66
|
+
static message = /aa14/
|
|
67
|
+
override name = "SenderAddressMismatchError" as const
|
|
68
|
+
constructor({
|
|
69
|
+
cause,
|
|
70
|
+
sender,
|
|
71
|
+
docsPath
|
|
72
|
+
}: {
|
|
73
|
+
cause?: BaseError
|
|
74
|
+
sender: Address
|
|
75
|
+
docsPath?: string
|
|
76
|
+
}) {
|
|
77
|
+
super(
|
|
78
|
+
[
|
|
79
|
+
"The initCode returned a different smart account address than expected.",
|
|
80
|
+
`Expected: ${sender}`,
|
|
81
|
+
"",
|
|
82
|
+
"Possible reasons:",
|
|
83
|
+
"• Account deployed with the initCode provided does not match match the sender address provided",
|
|
84
|
+
"",
|
|
85
|
+
"Possible solutions:",
|
|
86
|
+
"• Verify that the sender address was generated deterministically from the initCode. (consider leveraging functions like getSenderAddress)",
|
|
87
|
+
"• Verify that the factory address in the initCode is correct (the factory address is the first 20 bytes of the initCode)",
|
|
88
|
+
"• Verify that the initCode is correct.",
|
|
89
|
+
"",
|
|
90
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
91
|
+
].join("\n"),
|
|
92
|
+
{
|
|
93
|
+
cause
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export type InitCodeDidNotDeploySenderErrorType =
|
|
100
|
+
InitCodeDidNotDeploySenderError & {
|
|
101
|
+
name: "InitCodeDidNotDeploySenderError"
|
|
102
|
+
}
|
|
103
|
+
export class InitCodeDidNotDeploySenderError extends BaseError {
|
|
104
|
+
static message = /aa15/
|
|
105
|
+
override name = "InitCodeDidNotDeploySenderError" as const
|
|
106
|
+
constructor({
|
|
107
|
+
cause,
|
|
108
|
+
sender,
|
|
109
|
+
docsPath
|
|
110
|
+
}: {
|
|
111
|
+
cause?: BaseError
|
|
112
|
+
sender: Address
|
|
113
|
+
docsPath?: string
|
|
114
|
+
}) {
|
|
115
|
+
super(
|
|
116
|
+
[
|
|
117
|
+
`The initCode did not deploy the sender at the address ${sender}.`,
|
|
118
|
+
"",
|
|
119
|
+
"Possible reasons:",
|
|
120
|
+
"• The initCode factory is not creating an account.",
|
|
121
|
+
"• The initCode factory is creating an account, but is not implemented correctly as it is not deploying at the sender address",
|
|
122
|
+
"",
|
|
123
|
+
"Possible solutions:",
|
|
124
|
+
"• Verify that the factory address in the initCode is correct (the factory address is the first 20 bytes of the initCode).",
|
|
125
|
+
"• Verify that the initCode factory is implemented correctly. The factory must deploy the smart account at the sender address.",
|
|
126
|
+
"",
|
|
127
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
128
|
+
].join("\n"),
|
|
129
|
+
{
|
|
130
|
+
cause
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export type SenderNotDeployedErrorType = SenderNotDeployedError & {
|
|
137
|
+
name: "SenderNotDeployedError"
|
|
138
|
+
}
|
|
139
|
+
export class SenderNotDeployedError extends BaseError {
|
|
140
|
+
static message = /aa20/
|
|
141
|
+
override name = "SenderNotDeployedError" as const
|
|
142
|
+
constructor({
|
|
143
|
+
cause,
|
|
144
|
+
sender,
|
|
145
|
+
docsPath
|
|
146
|
+
}: {
|
|
147
|
+
cause?: BaseError
|
|
148
|
+
sender: Address
|
|
149
|
+
docsPath?: string
|
|
150
|
+
}) {
|
|
151
|
+
super(
|
|
152
|
+
[
|
|
153
|
+
`Smart account ${sender} is not deployed.`,
|
|
154
|
+
"",
|
|
155
|
+
"Possible reasons:",
|
|
156
|
+
"• An initCode was not specified, but the sender address (i.e. the smart account) is not deployed.",
|
|
157
|
+
"",
|
|
158
|
+
"Possible solutions:",
|
|
159
|
+
"• If this is the first transaction by this account, make sure the initCode is included in the user operation.",
|
|
160
|
+
"• If the smart account is already supposed to be deployed, verify that you have selected the correct sender address for the user operation.",
|
|
161
|
+
"",
|
|
162
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
163
|
+
].join("\n"),
|
|
164
|
+
{
|
|
165
|
+
cause
|
|
166
|
+
}
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export type SmartAccountInsufficientFundsErrorType =
|
|
172
|
+
SmartAccountInsufficientFundsError & {
|
|
173
|
+
name: "SmartAccountInsufficientFundsError"
|
|
174
|
+
}
|
|
175
|
+
export class SmartAccountInsufficientFundsError extends BaseError {
|
|
176
|
+
static message = /aa21/
|
|
177
|
+
override name = "SmartAccountInsufficientFundsError" as const
|
|
178
|
+
constructor({
|
|
179
|
+
cause,
|
|
180
|
+
sender,
|
|
181
|
+
docsPath
|
|
182
|
+
}: {
|
|
183
|
+
cause?: BaseError
|
|
184
|
+
sender: Address
|
|
185
|
+
docsPath?: string
|
|
186
|
+
}) {
|
|
187
|
+
super(
|
|
188
|
+
[
|
|
189
|
+
`You are not using a paymaster, and the ${sender} address did not have enough native tokens to cover the gas costs associated with the user operation.`,
|
|
190
|
+
"",
|
|
191
|
+
"Possible solutions:",
|
|
192
|
+
"• If you are not using a paymaster, verify that the sender address has enough native tokens to cover the required prefund. Consider leveraging functions like getRequiredPrefund.",
|
|
193
|
+
"• If you are looking to use a paymaster to cover the gas fees, verify that the paymasterAndData field is set.",
|
|
194
|
+
"",
|
|
195
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
196
|
+
].join("\n"),
|
|
197
|
+
{
|
|
198
|
+
cause
|
|
199
|
+
}
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export type SmartAccountSignatureValidityPeriodErrorType =
|
|
205
|
+
SmartAccountSignatureValidityPeriodError & {
|
|
206
|
+
name: "SmartAccountSignatureValidityPeriodError"
|
|
207
|
+
}
|
|
208
|
+
export class SmartAccountSignatureValidityPeriodError extends BaseError {
|
|
209
|
+
static message = /aa22/
|
|
210
|
+
override name = "SmartAccountSignatureValidityPeriodError" as const
|
|
211
|
+
constructor({
|
|
212
|
+
cause,
|
|
213
|
+
docsPath
|
|
214
|
+
}: {
|
|
215
|
+
cause?: BaseError
|
|
216
|
+
docsPath?: string
|
|
217
|
+
}) {
|
|
218
|
+
super(
|
|
219
|
+
[
|
|
220
|
+
"The signature used in the user operation is not valid, because it is outside of the time range it specified.",
|
|
221
|
+
"",
|
|
222
|
+
"Possible reasons:",
|
|
223
|
+
"• This error occurs when the block.timestamp falls after the validUntil timestamp, or before the validAfter timestamp.",
|
|
224
|
+
"",
|
|
225
|
+
"Possible solutions:",
|
|
226
|
+
"• If you are looking to use time-based signatures, verify that the validAfter and validUntil fields are set correctly and that the user operation is sent within the specified range.",
|
|
227
|
+
"• If you are not looking to use time-based signatures, verify that the validAfter and validUntil fields are set to 0.",
|
|
228
|
+
"",
|
|
229
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
230
|
+
].join("\n"),
|
|
231
|
+
{
|
|
232
|
+
cause
|
|
233
|
+
}
|
|
234
|
+
)
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export type SmartAccountValidationRevertedErrorType =
|
|
239
|
+
SmartAccountValidationRevertedError & {
|
|
240
|
+
name: "SmartAccountValidationRevertedError"
|
|
241
|
+
}
|
|
242
|
+
export class SmartAccountValidationRevertedError extends BaseError {
|
|
243
|
+
static message = /aa23/
|
|
244
|
+
override name = "SmartAccountValidationRevertedError" as const
|
|
245
|
+
constructor({
|
|
246
|
+
cause,
|
|
247
|
+
sender,
|
|
248
|
+
docsPath
|
|
249
|
+
}: {
|
|
250
|
+
cause?: BaseError
|
|
251
|
+
sender: Address
|
|
252
|
+
docsPath?: string
|
|
253
|
+
}) {
|
|
254
|
+
super(
|
|
255
|
+
[
|
|
256
|
+
`The smart account ${sender} reverted or ran out of gas during the validation of the user operation.`,
|
|
257
|
+
"",
|
|
258
|
+
"Possible solutions:",
|
|
259
|
+
"• Verify that the verificationGasLimit is high enough to cover the validateUserOp function's gas costs.",
|
|
260
|
+
"• Make sure validateUserOp returns uint(1) for invalid signatures, and MUST NOT REVERT when the signature is invalid",
|
|
261
|
+
"• If you are not using a paymaster, verify that the sender address has enough native tokens to cover the required pre fund. Consider leveraging functions like getRequiredPrefund.",
|
|
262
|
+
"• Verify that the validateUserOp function is implemented with the correct logic, and that the user operation is supposed to be valid.",
|
|
263
|
+
"",
|
|
264
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
265
|
+
].join("\n"),
|
|
266
|
+
{
|
|
267
|
+
cause
|
|
268
|
+
}
|
|
269
|
+
)
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export type InvalidSmartAccountSignatureErrorType =
|
|
274
|
+
InvalidSmartAccountSignatureError & {
|
|
275
|
+
name: "InvalidSmartAccountSignatureError"
|
|
276
|
+
}
|
|
277
|
+
export class InvalidSmartAccountSignatureError extends BaseError {
|
|
278
|
+
static message = /aa24/
|
|
279
|
+
override name = "InvalidSmartAccountSignatureError" as const
|
|
280
|
+
constructor({
|
|
281
|
+
cause,
|
|
282
|
+
sender,
|
|
283
|
+
docsPath
|
|
284
|
+
}: {
|
|
285
|
+
cause?: BaseError
|
|
286
|
+
sender: Address
|
|
287
|
+
docsPath?: string
|
|
288
|
+
}) {
|
|
289
|
+
super(
|
|
290
|
+
[
|
|
291
|
+
`The smart account ${sender} signature is invalid.`,
|
|
292
|
+
"",
|
|
293
|
+
"Possible solutions:",
|
|
294
|
+
"• Verify that the user operation was correctly signed, and that the signature was correctly encoded in the signature field of the user operation.",
|
|
295
|
+
"• Most smart account implementations sign over the userOpHash. Make sure that the userOpHash is correctly computed. Consider leveraging functions like getUserOperationHash.",
|
|
296
|
+
"• Make sure you have selected the correct chainId and entryPointAddress when computing the userOpHash.",
|
|
297
|
+
"• Make sure the smart account signature verification function is correctly implemented.",
|
|
298
|
+
"",
|
|
299
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
300
|
+
].join("\n"),
|
|
301
|
+
{
|
|
302
|
+
cause
|
|
303
|
+
}
|
|
304
|
+
)
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export type InvalidSmartAccountNonceErrorType =
|
|
309
|
+
InvalidSmartAccountNonceError & {
|
|
310
|
+
name: "InvalidSmartAccountNonceError"
|
|
311
|
+
}
|
|
312
|
+
export class InvalidSmartAccountNonceError extends BaseError {
|
|
313
|
+
static message = /aa25/
|
|
314
|
+
override name = "InvalidSmartAccountNonceError" as const
|
|
315
|
+
constructor({
|
|
316
|
+
cause,
|
|
317
|
+
sender,
|
|
318
|
+
nonce,
|
|
319
|
+
docsPath
|
|
320
|
+
}: {
|
|
321
|
+
cause?: BaseError
|
|
322
|
+
sender: Address
|
|
323
|
+
docsPath?: string
|
|
324
|
+
nonce: bigint
|
|
325
|
+
}) {
|
|
326
|
+
const nonceKey = nonce >> 64n // first 192 bits of nonce
|
|
327
|
+
const nonceSequence = nonce & 0xffffffffffffffffn // last 64 bits of nonce
|
|
328
|
+
|
|
329
|
+
super(
|
|
330
|
+
[
|
|
331
|
+
`The smart account ${sender} nonce is invalid.`,
|
|
332
|
+
`Nonce sent: ${nonce} (key: ${nonceKey}, sequence: ${nonceSequence})`,
|
|
333
|
+
"",
|
|
334
|
+
"Possible solutions:",
|
|
335
|
+
"• Verify that you are using the correct nonce for the user operation. The nonce should be the current nonce of the smart account for the selected key. Consider leveraging functions like getAccountNonce.",
|
|
336
|
+
"• Verify that the nonce is formatted correctly.",
|
|
337
|
+
"",
|
|
338
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
339
|
+
].join("\n"),
|
|
340
|
+
{
|
|
341
|
+
cause
|
|
342
|
+
}
|
|
343
|
+
)
|
|
344
|
+
}
|
|
345
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { BaseError } from "viem"
|
|
2
|
+
|
|
3
|
+
export type InvalidBeneficiaryAddressErrorType =
|
|
4
|
+
InvalidBeneficiaryAddressError & {
|
|
5
|
+
name: "InvalidBeneficiaryAddressError"
|
|
6
|
+
}
|
|
7
|
+
export class InvalidBeneficiaryAddressError extends BaseError {
|
|
8
|
+
static message = /aa9[01]/
|
|
9
|
+
override name = "InvalidBeneficiaryAddressError"
|
|
10
|
+
constructor({
|
|
11
|
+
cause,
|
|
12
|
+
docsPath
|
|
13
|
+
}: {
|
|
14
|
+
cause?: BaseError
|
|
15
|
+
docsPath?: string
|
|
16
|
+
}) {
|
|
17
|
+
super(
|
|
18
|
+
[
|
|
19
|
+
"The bundler did not set a beneficiary address when bundling the user operation.",
|
|
20
|
+
"",
|
|
21
|
+
"Possible solutions:",
|
|
22
|
+
"• If you encounter this error when running self-hosted bundler, make sure you have configured the bundler correctly.",
|
|
23
|
+
"• If you are using a bundler provider, reach out to them.",
|
|
24
|
+
"",
|
|
25
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
26
|
+
].join("\n"),
|
|
27
|
+
{
|
|
28
|
+
cause
|
|
29
|
+
}
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type InvalidAggregatorErrorType = InvalidAggregatorError & {
|
|
35
|
+
name: "InvalidAggregatorError"
|
|
36
|
+
}
|
|
37
|
+
export class InvalidAggregatorError extends BaseError {
|
|
38
|
+
static message = /aa96/
|
|
39
|
+
override name = "InvalidAggregatorError"
|
|
40
|
+
constructor({
|
|
41
|
+
cause,
|
|
42
|
+
docsPath
|
|
43
|
+
}: {
|
|
44
|
+
cause?: BaseError
|
|
45
|
+
docsPath?: string
|
|
46
|
+
}) {
|
|
47
|
+
super(
|
|
48
|
+
[
|
|
49
|
+
"The bundler tried to bundle the user operation with an invalid aggregator.",
|
|
50
|
+
"",
|
|
51
|
+
"Possible solutions:",
|
|
52
|
+
"• If you are using your own bundler, configure it to use a valid aggregator.",
|
|
53
|
+
"• If you are using a bundler provider, reach out to them.",
|
|
54
|
+
"",
|
|
55
|
+
docsPath ? `Docs: ${docsPath}` : ""
|
|
56
|
+
].join("\n"),
|
|
57
|
+
{
|
|
58
|
+
cause
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { BaseError } from "viem"
|
|
2
|
+
import type { EstimateUserOperationGasParameters } from "../actions/bundler/estimateUserOperationGas.js"
|
|
3
|
+
import { prettyPrint } from "./utils.js"
|
|
4
|
+
|
|
5
|
+
export type EstimateUserOperationGasErrorType =
|
|
6
|
+
EstimateUserOperationGasError & {
|
|
7
|
+
name: "EstimateUserOperationGasError"
|
|
8
|
+
}
|
|
9
|
+
export class EstimateUserOperationGasError extends BaseError {
|
|
10
|
+
override cause: BaseError
|
|
11
|
+
|
|
12
|
+
override name = "EstimateUserOperationGasError"
|
|
13
|
+
|
|
14
|
+
constructor(
|
|
15
|
+
cause: BaseError,
|
|
16
|
+
{
|
|
17
|
+
userOperation,
|
|
18
|
+
entryPoint,
|
|
19
|
+
docsPath
|
|
20
|
+
}: EstimateUserOperationGasParameters & {
|
|
21
|
+
docsPath?: string
|
|
22
|
+
}
|
|
23
|
+
) {
|
|
24
|
+
const prettyArgs = prettyPrint({
|
|
25
|
+
sender: userOperation.sender,
|
|
26
|
+
nonce: userOperation.nonce,
|
|
27
|
+
initCode: userOperation.initCode,
|
|
28
|
+
callData: userOperation.callData,
|
|
29
|
+
callGasLimit: userOperation.callGasLimit,
|
|
30
|
+
verificationGasLimit: userOperation.verificationGasLimit,
|
|
31
|
+
preVerificationGas: userOperation.preVerificationGas,
|
|
32
|
+
maxFeePerGas: userOperation.maxFeePerGas,
|
|
33
|
+
maxPriorityFeePerGas: userOperation.maxPriorityFeePerGas,
|
|
34
|
+
paymasterAndData: userOperation.paymasterAndData,
|
|
35
|
+
signature: userOperation.signature,
|
|
36
|
+
entryPoint
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
super(cause.shortMessage, {
|
|
40
|
+
cause,
|
|
41
|
+
docsPath,
|
|
42
|
+
metaMessages: [
|
|
43
|
+
...(cause.metaMessages ? [...cause.metaMessages, " "] : []),
|
|
44
|
+
"Estimate Gas Arguments:",
|
|
45
|
+
prettyArgs
|
|
46
|
+
].filter(Boolean) as string[]
|
|
47
|
+
})
|
|
48
|
+
this.cause = cause
|
|
49
|
+
}
|
|
50
|
+
}
|
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
|
+
}
|