@pimlico/alto 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.
Files changed (117) hide show
  1. package/esm/cli/config/bundler.d.ts +52 -34
  2. package/esm/cli/config/bundler.js +12 -1
  3. package/esm/cli/config/bundler.js.map +1 -1
  4. package/esm/cli/config/options.d.ts +2 -1
  5. package/esm/cli/config/options.js +14 -0
  6. package/esm/cli/config/options.js.map +1 -1
  7. package/esm/cli/setupServer.js +2 -2
  8. package/esm/cli/setupServer.js.map +1 -1
  9. package/esm/executor/executorManager.js +13 -3
  10. package/esm/executor/executorManager.js.map +1 -1
  11. package/esm/handlers/gasPriceManager.d.ts +14 -0
  12. package/esm/handlers/gasPriceManager.js +71 -1
  13. package/esm/handlers/gasPriceManager.js.map +1 -1
  14. package/esm/rpc/estimation/gasEstimationHandler.d.ts +24 -0
  15. package/esm/rpc/estimation/gasEstimationHandler.js +64 -0
  16. package/esm/rpc/estimation/gasEstimationHandler.js.map +1 -0
  17. package/esm/rpc/estimation/gasEstimationsV06.d.ts +19 -0
  18. package/esm/rpc/estimation/gasEstimationsV06.js +115 -0
  19. package/esm/rpc/estimation/gasEstimationsV06.js.map +1 -0
  20. package/esm/rpc/estimation/gasEstimationsV07.d.ts +93 -0
  21. package/esm/rpc/estimation/gasEstimationsV07.js +417 -0
  22. package/esm/rpc/estimation/gasEstimationsV07.js.map +1 -0
  23. package/esm/rpc/estimation/types.d.ts +113 -0
  24. package/esm/rpc/estimation/types.js +122 -0
  25. package/esm/rpc/estimation/types.js.map +1 -0
  26. package/esm/rpc/rpcHandler.js +11 -7
  27. package/esm/rpc/rpcHandler.js.map +1 -1
  28. package/esm/rpc/server.js +2 -3
  29. package/esm/rpc/server.js.map +1 -1
  30. package/esm/rpc/validation/SafeValidator.d.ts +1 -1
  31. package/esm/rpc/validation/SafeValidator.js +6 -7
  32. package/esm/rpc/validation/SafeValidator.js.map +1 -1
  33. package/esm/rpc/validation/UnsafeValidator.d.ts +4 -6
  34. package/esm/rpc/validation/UnsafeValidator.js +25 -17
  35. package/esm/rpc/validation/UnsafeValidator.js.map +1 -1
  36. package/esm/types/contracts/EntryPointSimulations.d.ts +1369 -143
  37. package/esm/types/contracts/EntryPointSimulations.js +196 -372
  38. package/esm/types/contracts/EntryPointSimulations.js.map +1 -1
  39. package/esm/types/contracts/IAccountExecute.d.ts +53 -0
  40. package/esm/types/contracts/IAccountExecute.js +68 -0
  41. package/esm/types/contracts/IAccountExecute.js.map +1 -0
  42. package/esm/types/contracts/PimlicoEntryPointSimulations.d.ts +1 -1
  43. package/esm/types/contracts/PimlicoEntryPointSimulations.js +1 -1
  44. package/esm/types/contracts/PimlicoEntryPointSimulations.js.map +1 -1
  45. package/esm/types/interfaces.d.ts +1 -1
  46. package/esm/types/schemas.d.ts +68 -68
  47. package/esm/utils/validation.d.ts +1 -1
  48. package/esm/utils/validation.js +19 -7
  49. package/esm/utils/validation.js.map +1 -1
  50. package/lib/cli/config/bundler.d.ts +52 -34
  51. package/lib/cli/config/bundler.js +13 -2
  52. package/lib/cli/config/bundler.js.map +1 -1
  53. package/lib/cli/config/options.d.ts +2 -1
  54. package/lib/cli/config/options.js +15 -1
  55. package/lib/cli/config/options.js.map +1 -1
  56. package/lib/cli/setupServer.js +2 -2
  57. package/lib/cli/setupServer.js.map +1 -1
  58. package/lib/executor/executorManager.js +13 -3
  59. package/lib/executor/executorManager.js.map +1 -1
  60. package/lib/handlers/gasPriceManager.d.ts +14 -0
  61. package/lib/handlers/gasPriceManager.js +70 -0
  62. package/lib/handlers/gasPriceManager.js.map +1 -1
  63. package/lib/rpc/estimation/gasEstimationHandler.d.ts +24 -0
  64. package/lib/rpc/estimation/gasEstimationHandler.js +68 -0
  65. package/lib/rpc/estimation/gasEstimationHandler.js.map +1 -0
  66. package/lib/rpc/estimation/gasEstimationsV06.d.ts +19 -0
  67. package/lib/rpc/estimation/gasEstimationsV06.js +119 -0
  68. package/lib/rpc/estimation/gasEstimationsV06.js.map +1 -0
  69. package/lib/rpc/estimation/gasEstimationsV07.d.ts +93 -0
  70. package/lib/rpc/estimation/gasEstimationsV07.js +423 -0
  71. package/lib/rpc/estimation/gasEstimationsV07.js.map +1 -0
  72. package/lib/rpc/estimation/types.d.ts +113 -0
  73. package/lib/rpc/estimation/types.js +125 -0
  74. package/lib/rpc/estimation/types.js.map +1 -0
  75. package/lib/rpc/rpcHandler.js +10 -6
  76. package/lib/rpc/rpcHandler.js.map +1 -1
  77. package/lib/rpc/server.js +2 -3
  78. package/lib/rpc/server.js.map +1 -1
  79. package/lib/rpc/validation/SafeValidator.d.ts +1 -1
  80. package/lib/rpc/validation/SafeValidator.js +7 -8
  81. package/lib/rpc/validation/SafeValidator.js.map +1 -1
  82. package/lib/rpc/validation/UnsafeValidator.d.ts +4 -6
  83. package/lib/rpc/validation/UnsafeValidator.js +25 -17
  84. package/lib/rpc/validation/UnsafeValidator.js.map +1 -1
  85. package/lib/types/contracts/EntryPointSimulations.d.ts +1369 -143
  86. package/lib/types/contracts/EntryPointSimulations.js +196 -372
  87. package/lib/types/contracts/EntryPointSimulations.js.map +1 -1
  88. package/lib/types/contracts/IAccountExecute.d.ts +53 -0
  89. package/lib/types/contracts/IAccountExecute.js +71 -0
  90. package/lib/types/contracts/IAccountExecute.js.map +1 -0
  91. package/lib/types/contracts/PimlicoEntryPointSimulations.d.ts +1 -1
  92. package/lib/types/contracts/PimlicoEntryPointSimulations.js +1 -1
  93. package/lib/types/contracts/PimlicoEntryPointSimulations.js.map +1 -1
  94. package/lib/types/interfaces.d.ts +1 -1
  95. package/lib/types/schemas.d.ts +68 -68
  96. package/lib/utils/validation.d.ts +1 -1
  97. package/lib/utils/validation.js +18 -6
  98. package/lib/utils/validation.js.map +1 -1
  99. package/package.json +1 -1
  100. package/esm/rpc/EntryPointSimulationsV07.d.ts +0 -62
  101. package/esm/rpc/EntryPointSimulationsV07.js +0 -410
  102. package/esm/rpc/EntryPointSimulationsV07.js.map +0 -1
  103. package/esm/rpc/ExecuteSimulator.d.ts +0 -37
  104. package/esm/rpc/ExecuteSimulator.js +0 -48
  105. package/esm/rpc/ExecuteSimulator.js.map +0 -1
  106. package/esm/rpc/gasEstimation.d.ts +0 -17
  107. package/esm/rpc/gasEstimation.js +0 -419
  108. package/esm/rpc/gasEstimation.js.map +0 -1
  109. package/lib/rpc/EntryPointSimulationsV07.d.ts +0 -62
  110. package/lib/rpc/EntryPointSimulationsV07.js +0 -417
  111. package/lib/rpc/EntryPointSimulationsV07.js.map +0 -1
  112. package/lib/rpc/ExecuteSimulator.d.ts +0 -37
  113. package/lib/rpc/ExecuteSimulator.js +0 -51
  114. package/lib/rpc/ExecuteSimulator.js.map +0 -1
  115. package/lib/rpc/gasEstimation.d.ts +0 -17
  116. package/lib/rpc/gasEstimation.js +0 -426
  117. package/lib/rpc/gasEstimation.js.map +0 -1
@@ -0,0 +1,93 @@
1
+ import type { Hex } from "viem";
2
+ import { type Address, type PublicClient } from "viem";
3
+ import { type StateOverrides, type UserOperationV07, type ValidationResultV07 } from "../../types/index.js";
4
+ import { type SimulateHandleOpResult } from "./types.js";
5
+ export declare class GasEstimatorV07 {
6
+ binarySearchToleranceDelta: bigint;
7
+ binarySearchGasAllowance: bigint;
8
+ chainId: number;
9
+ publicClient: PublicClient;
10
+ entryPointSimulationsAddress: Address | undefined;
11
+ blockTagSupport: boolean;
12
+ utilityWalletAddress: Address;
13
+ fixedGasLimitForEstimation?: bigint;
14
+ constructor(binarySearchToleranceDelta: bigint, binarySearchGasAllowance: bigint, chainId: number, publicClient: PublicClient, entryPointSimulationsAddress: Address | undefined, blockTagSupport: boolean, utilityWalletAddress: Address, fixedGasLimitForEstimation?: bigint);
15
+ simulateValidation({ entryPoint, userOperation, queuedUserOperations }: {
16
+ entryPoint: Address;
17
+ userOperation: UserOperationV07;
18
+ queuedUserOperations: UserOperationV07[];
19
+ }): Promise<{
20
+ simulateValidationResult: {
21
+ status: "validation" | "failed";
22
+ data: string | {
23
+ returnInfo: {
24
+ preOpGas: bigint;
25
+ prefund: bigint;
26
+ paymasterContext: `0x${string}`;
27
+ accountValidationData: bigint;
28
+ paymasterValidationData: bigint;
29
+ accountSigFailed?: boolean | undefined;
30
+ paymasterSigFailed?: boolean | undefined;
31
+ validAfter?: number | undefined;
32
+ validUntil?: number | undefined;
33
+ };
34
+ senderInfo: {
35
+ stake: bigint;
36
+ unstakeDelaySec: bigint;
37
+ addr?: string | undefined;
38
+ };
39
+ factoryInfo: {
40
+ stake: bigint;
41
+ unstakeDelaySec: bigint;
42
+ addr?: string | undefined;
43
+ } | undefined;
44
+ paymasterInfo: {
45
+ stake: bigint;
46
+ unstakeDelaySec: bigint;
47
+ addr?: string | undefined;
48
+ } | undefined;
49
+ };
50
+ };
51
+ }>;
52
+ encodeUserOperationCalldata({ op, entryPoint }: {
53
+ op: UserOperationV07;
54
+ entryPoint: Address;
55
+ }): `0x${string}`;
56
+ encodeSimulateHandleOpLast({ userOperation, queuedUserOperations, entryPoint }: {
57
+ userOperation: UserOperationV07;
58
+ queuedUserOperations: UserOperationV07[];
59
+ entryPoint: Address;
60
+ }): Hex;
61
+ encodeSimulateCallData({ userOperation, queuedUserOperations, entryPoint, gasAllowance, initialMinGas }: {
62
+ userOperation: UserOperationV07;
63
+ queuedUserOperations: UserOperationV07[];
64
+ entryPoint: Address;
65
+ initialMinGas?: bigint;
66
+ gasAllowance?: bigint;
67
+ }): Hex;
68
+ retryGetCallDataGas({ entryPoint, optimalGas, minGas, targetOp, queuedOps, simulateHandleOpLastResult }: {
69
+ entryPoint: Address;
70
+ optimalGas: bigint;
71
+ minGas: bigint;
72
+ targetOp: UserOperationV07;
73
+ queuedOps: UserOperationV07[];
74
+ simulateHandleOpLastResult: SimulateHandleOpResult<"execution">;
75
+ }): Promise<SimulateHandleOpResult>;
76
+ simulateHandleOpV07({ entryPoint, userOperation, queuedUserOperations, stateOverrides }: {
77
+ entryPoint: Address;
78
+ userOperation: UserOperationV07;
79
+ queuedUserOperations: UserOperationV07[];
80
+ stateOverrides?: StateOverrides | undefined;
81
+ }): Promise<SimulateHandleOpResult>;
82
+ callPimlicoEntryPointSimulations({ entryPoint, entryPointSimulationsCallData, stateOverrides }: {
83
+ entryPoint: Address;
84
+ entryPointSimulationsCallData: Hex[];
85
+ stateOverrides?: StateOverrides;
86
+ }): Promise<readonly `0x${string}`[]>;
87
+ }
88
+ export declare function parseFailedOpWithRevert(data: Hex): string;
89
+ export declare function getSimulateValidationResult(errorData: Hex): {
90
+ status: "failed" | "validation";
91
+ data: ValidationResultV07 | Hex | string;
92
+ };
93
+ //# sourceMappingURL=gasEstimationsV07.d.ts.map
@@ -0,0 +1,417 @@
1
+ import { decodeErrorResult, encodeFunctionData, toHex, decodeAbiParameters, decodeFunctionResult, toFunctionSelector, slice } from "viem";
2
+ import { EntryPointV07Abi, EntryPointV07SimulationsAbi, PimlicoEntryPointSimulationsAbi, ValidationErrors, ExecutionErrors, targetCallResultSchema, RpcError } from "../../types/index.js";
3
+ import { getUserOperationHash, toPackedUserOperation } from "../../utils/index.js";
4
+ import { simulationValidationResultStruct } from "./types.js";
5
+ import { AccountExecuteAbi } from "../../types/contracts/IAccountExecute.js";
6
+ export class GasEstimatorV07 {
7
+ binarySearchToleranceDelta;
8
+ binarySearchGasAllowance;
9
+ chainId;
10
+ publicClient;
11
+ entryPointSimulationsAddress;
12
+ blockTagSupport;
13
+ utilityWalletAddress;
14
+ fixedGasLimitForEstimation;
15
+ constructor(binarySearchToleranceDelta, binarySearchGasAllowance, chainId, publicClient, entryPointSimulationsAddress, blockTagSupport, utilityWalletAddress, fixedGasLimitForEstimation) {
16
+ this.binarySearchToleranceDelta = binarySearchToleranceDelta;
17
+ this.binarySearchGasAllowance = binarySearchGasAllowance;
18
+ this.chainId = chainId;
19
+ this.publicClient = publicClient;
20
+ this.entryPointSimulationsAddress = entryPointSimulationsAddress;
21
+ this.blockTagSupport = blockTagSupport;
22
+ this.utilityWalletAddress = utilityWalletAddress;
23
+ this.fixedGasLimitForEstimation = fixedGasLimitForEstimation;
24
+ }
25
+ async simulateValidation({ entryPoint, userOperation, queuedUserOperations }) {
26
+ const userOperations = [...queuedUserOperations, userOperation];
27
+ const packedUserOperations = userOperations.map((uo) => toPackedUserOperation(uo));
28
+ const simulateValidationLast = encodeFunctionData({
29
+ abi: EntryPointV07SimulationsAbi,
30
+ functionName: "simulateValidationLast",
31
+ args: [packedUserOperations]
32
+ });
33
+ const errorResult = await this.callPimlicoEntryPointSimulations({
34
+ entryPoint,
35
+ entryPointSimulationsCallData: [simulateValidationLast]
36
+ });
37
+ return {
38
+ simulateValidationResult: getSimulateValidationResult(errorResult[0])
39
+ };
40
+ }
41
+ encodeUserOperationCalldata({ op, entryPoint }) {
42
+ const packedOp = toPackedUserOperation(op);
43
+ const executeUserOpMethodSig = toFunctionSelector(AccountExecuteAbi[0]);
44
+ const callDataMethodSig = slice(packedOp.callData, 0, 4);
45
+ if (executeUserOpMethodSig === callDataMethodSig) {
46
+ return encodeFunctionData({
47
+ abi: AccountExecuteAbi,
48
+ functionName: "executeUserOp",
49
+ args: [
50
+ packedOp,
51
+ getUserOperationHash(op, entryPoint, this.chainId)
52
+ ]
53
+ });
54
+ }
55
+ return packedOp.callData;
56
+ }
57
+ encodeSimulateHandleOpLast({ userOperation, queuedUserOperations, entryPoint }) {
58
+ const userOperations = [...queuedUserOperations, userOperation];
59
+ const packedUserOperations = userOperations.map((uop) => ({
60
+ packedUserOperation: toPackedUserOperation(uop),
61
+ userOperation: uop,
62
+ userOperationHash: getUserOperationHash(uop, entryPoint, this.chainId)
63
+ }));
64
+ const simulateHandleOpCallData = encodeFunctionData({
65
+ abi: EntryPointV07SimulationsAbi,
66
+ functionName: "simulateHandleOpLast",
67
+ args: [packedUserOperations.map((uop) => uop.packedUserOperation)]
68
+ });
69
+ return simulateHandleOpCallData;
70
+ }
71
+ encodeSimulateCallData({ userOperation, queuedUserOperations, entryPoint, gasAllowance = this.binarySearchGasAllowance, initialMinGas = 0n }) {
72
+ const queuedOps = queuedUserOperations.map((op) => ({
73
+ op: toPackedUserOperation(op),
74
+ target: op.sender,
75
+ targetCallData: this.encodeUserOperationCalldata({
76
+ op,
77
+ entryPoint
78
+ })
79
+ }));
80
+ const targetOp = {
81
+ op: toPackedUserOperation(userOperation),
82
+ target: userOperation.sender,
83
+ targetCallData: this.encodeUserOperationCalldata({
84
+ op: userOperation,
85
+ entryPoint
86
+ })
87
+ };
88
+ const simulateTargetCallData = encodeFunctionData({
89
+ abi: EntryPointV07SimulationsAbi,
90
+ functionName: "simulateCallData",
91
+ args: [
92
+ queuedOps,
93
+ targetOp,
94
+ entryPoint,
95
+ initialMinGas,
96
+ this.binarySearchToleranceDelta,
97
+ gasAllowance
98
+ ]
99
+ });
100
+ return simulateTargetCallData;
101
+ }
102
+ // Try to get the calldata gas again if the initial simulation reverted due to hitting the eth_call gasLimit.
103
+ async retryGetCallDataGas({ entryPoint, optimalGas, minGas, targetOp, queuedOps, simulateHandleOpLastResult }) {
104
+ const maxRetries = 3;
105
+ let retryCount = 0;
106
+ let currentOptimalGas = optimalGas;
107
+ let currentMinGas = minGas;
108
+ while (retryCount < maxRetries) {
109
+ // OptimalGas represents the current lowest gasLimit, so we set the gasAllowance to search range minGas <-> optimalGas
110
+ const gasAllowance = currentOptimalGas - currentMinGas;
111
+ const simulateCallData = this.encodeSimulateCallData({
112
+ entryPoint,
113
+ userOperation: targetOp,
114
+ queuedUserOperations: queuedOps,
115
+ initialMinGas: currentMinGas,
116
+ gasAllowance
117
+ });
118
+ let cause = await this.callPimlicoEntryPointSimulations({
119
+ entryPoint,
120
+ entryPointSimulationsCallData: [simulateCallData]
121
+ });
122
+ cause = cause.map((data) => {
123
+ const decodedDelegateAndError = decodeErrorResult({
124
+ abi: EntryPointV07Abi,
125
+ data: data
126
+ });
127
+ if (!decodedDelegateAndError?.args?.[1]) {
128
+ throw new Error("Unexpected error");
129
+ }
130
+ return decodedDelegateAndError.args[1];
131
+ });
132
+ const simulateCallDataResult = validateTargetCallDataResult(cause[0]);
133
+ if (simulateCallDataResult.result === "failed") {
134
+ return simulateCallDataResult;
135
+ }
136
+ if (simulateCallDataResult.result === "retry") {
137
+ currentOptimalGas = simulateCallDataResult.optimalGas;
138
+ currentMinGas = simulateCallDataResult.minGas;
139
+ retryCount++;
140
+ continue;
141
+ }
142
+ // If we reach here, it means we have a successful result
143
+ return {
144
+ result: "execution",
145
+ data: {
146
+ callDataResult: simulateCallDataResult.data,
147
+ executionResult: simulateHandleOpLastResult.data.executionResult
148
+ }
149
+ };
150
+ }
151
+ // If we've exhausted all retries, return a failure result
152
+ return {
153
+ result: "failed",
154
+ data: "Max retries reached for getting call data gas",
155
+ code: ValidationErrors.SimulateValidation
156
+ };
157
+ }
158
+ async simulateHandleOpV07({ entryPoint, userOperation, queuedUserOperations, stateOverrides = undefined }) {
159
+ const simulateHandleOpLast = this.encodeSimulateHandleOpLast({
160
+ entryPoint,
161
+ userOperation,
162
+ queuedUserOperations
163
+ });
164
+ const simulateCallData = this.encodeSimulateCallData({
165
+ entryPoint,
166
+ userOperation,
167
+ queuedUserOperations
168
+ });
169
+ let cause = await this.callPimlicoEntryPointSimulations({
170
+ entryPoint,
171
+ entryPointSimulationsCallData: [
172
+ simulateHandleOpLast,
173
+ simulateCallData
174
+ ],
175
+ stateOverrides
176
+ });
177
+ cause = cause.map((data) => {
178
+ const decodedDelegateAndError = decodeErrorResult({
179
+ abi: EntryPointV07Abi,
180
+ data: data
181
+ });
182
+ const delegateAndRevertResponseBytes = decodedDelegateAndError?.args?.[1];
183
+ if (!delegateAndRevertResponseBytes) {
184
+ throw new Error("Unexpected error");
185
+ }
186
+ return delegateAndRevertResponseBytes;
187
+ });
188
+ try {
189
+ const simulateHandleOpLastResult = getSimulateHandleOpResult(cause[0]);
190
+ if (simulateHandleOpLastResult.result === "failed") {
191
+ return simulateHandleOpLastResult;
192
+ }
193
+ const simulateCallDataResult = validateTargetCallDataResult(cause[1]);
194
+ if (simulateCallDataResult.result === "failed") {
195
+ return simulateCallDataResult;
196
+ }
197
+ if (simulateCallDataResult.result === "retry") {
198
+ const { optimalGas, minGas } = simulateCallDataResult;
199
+ return await this.retryGetCallDataGas({
200
+ entryPoint,
201
+ optimalGas,
202
+ minGas,
203
+ targetOp: userOperation,
204
+ queuedOps: queuedUserOperations,
205
+ simulateHandleOpLastResult: simulateHandleOpLastResult
206
+ });
207
+ }
208
+ return {
209
+ result: "execution",
210
+ data: {
211
+ callDataResult: simulateCallDataResult.data,
212
+ executionResult: simulateHandleOpLastResult.data.executionResult
213
+ }
214
+ };
215
+ }
216
+ catch (_e) {
217
+ return {
218
+ result: "failed",
219
+ data: "Unknown error, could not parse simulate handle op result.",
220
+ code: ValidationErrors.SimulateValidation
221
+ };
222
+ }
223
+ }
224
+ async callPimlicoEntryPointSimulations({ entryPoint, entryPointSimulationsCallData, stateOverrides }) {
225
+ const { publicClient, blockTagSupport, utilityWalletAddress, entryPointSimulationsAddress, fixedGasLimitForEstimation } = this;
226
+ if (!entryPointSimulationsAddress) {
227
+ throw new RpcError("entryPointSimulationsAddress must be provided for V07 UserOperation", ValidationErrors.InvalidFields);
228
+ }
229
+ const callData = encodeFunctionData({
230
+ abi: PimlicoEntryPointSimulationsAbi,
231
+ functionName: "simulateEntryPoint",
232
+ args: [entryPoint, entryPointSimulationsCallData]
233
+ });
234
+ const result = (await publicClient.request({
235
+ method: "eth_call",
236
+ params: [
237
+ {
238
+ to: entryPointSimulationsAddress,
239
+ from: utilityWalletAddress,
240
+ data: callData,
241
+ ...(fixedGasLimitForEstimation !== undefined && {
242
+ gas: `0x${fixedGasLimitForEstimation.toString(16)}`
243
+ })
244
+ },
245
+ blockTagSupport
246
+ ? "latest"
247
+ : toHex(await publicClient.getBlockNumber()),
248
+ // @ts-ignore
249
+ ...(stateOverrides ? [stateOverrides] : [])
250
+ ]
251
+ }));
252
+ const returnBytes = decodeAbiParameters([{ name: "ret", type: "bytes[]" }], result);
253
+ return returnBytes[0];
254
+ }
255
+ }
256
+ const panicCodes = {
257
+ // from https://docs.soliditylang.org/en/v0.8.0/control-structures.html
258
+ 1: "assert(false)",
259
+ 17: "arithmetic overflow/underflow",
260
+ 18: "divide by zero",
261
+ 33: "invalid enum value",
262
+ 34: "storage byte array that is incorrectly encoded",
263
+ 49: ".pop() on an empty array.",
264
+ 50: "array sout-of-bounds or negative index",
265
+ 65: "memory overflow",
266
+ 81: "zero-initialized variable of internal function type"
267
+ };
268
+ export function parseFailedOpWithRevert(data) {
269
+ const methodSig = data.slice(0, 10);
270
+ const dataParams = `0x${data.slice(10)}`;
271
+ if (methodSig === "0x08c379a0") {
272
+ const [err] = decodeAbiParameters([
273
+ {
274
+ name: "err",
275
+ type: "string"
276
+ }
277
+ ], dataParams);
278
+ return err;
279
+ }
280
+ if (methodSig === "0x4e487b71") {
281
+ const [code] = decodeAbiParameters([
282
+ {
283
+ name: "err",
284
+ type: "uint256"
285
+ }
286
+ ], dataParams);
287
+ return panicCodes[Number(code)] ?? `${code}`;
288
+ }
289
+ return data;
290
+ }
291
+ export function getSimulateValidationResult(errorData) {
292
+ const decodedDelegateAndError = decodeErrorResult({
293
+ abi: EntryPointV07Abi,
294
+ data: errorData
295
+ });
296
+ if (!decodedDelegateAndError?.args?.[1]) {
297
+ throw new Error("Unexpected error");
298
+ }
299
+ try {
300
+ const decodedError = decodeErrorResult({
301
+ abi: EntryPointV07SimulationsAbi,
302
+ data: decodedDelegateAndError.args[1]
303
+ });
304
+ if (decodedError &&
305
+ decodedError.errorName === "FailedOp" &&
306
+ decodedError.args) {
307
+ return {
308
+ status: "failed",
309
+ data: decodedError.args[1]
310
+ };
311
+ }
312
+ if (decodedError &&
313
+ decodedError.errorName === "FailedOpWithRevert" &&
314
+ decodedError.args) {
315
+ return {
316
+ status: "failed",
317
+ data: `${decodedError.args?.[1]} - ${parseFailedOpWithRevert(decodedError.args?.[2])}`
318
+ };
319
+ }
320
+ }
321
+ catch {
322
+ const decodedResult = decodeAbiParameters(simulationValidationResultStruct, decodedDelegateAndError.args[1])[0];
323
+ return {
324
+ status: "validation",
325
+ data: decodedResult
326
+ };
327
+ }
328
+ throw new Error("Unexpected error - errorName is not ValidationResult or ValidationResultWithAggregation");
329
+ }
330
+ function validateTargetCallDataResult(data) {
331
+ try {
332
+ const targetCallResult = decodeFunctionResult({
333
+ abi: EntryPointV07SimulationsAbi,
334
+ functionName: "simulateCallData",
335
+ data: data
336
+ });
337
+ const parsedTargetCallResult = targetCallResultSchema.parse(targetCallResult);
338
+ if (parsedTargetCallResult.success) {
339
+ return {
340
+ result: "success",
341
+ data: parsedTargetCallResult
342
+ };
343
+ }
344
+ return {
345
+ result: "failed",
346
+ data: parsedTargetCallResult.returnData,
347
+ code: ExecutionErrors.UserOperationReverted
348
+ };
349
+ }
350
+ catch (_e) {
351
+ // Check if the result hit eth_call gasLimit.
352
+ const simulationOutOfGasSelector = toFunctionSelector("SimulationOutOfGas(uint256 optimalGas, uint256 minGas, uint256 maxGas)");
353
+ if (slice(data, 0, 4) === simulationOutOfGasSelector) {
354
+ const res = decodeErrorResult({
355
+ abi: EntryPointV07SimulationsAbi,
356
+ data: data
357
+ });
358
+ if (res.errorName === "SimulationOutOfGas") {
359
+ const [optimalGas, minGas, maxGas] = res.args;
360
+ return {
361
+ result: "retry",
362
+ optimalGas,
363
+ minGas,
364
+ maxGas
365
+ };
366
+ }
367
+ }
368
+ // no error we go the result
369
+ return {
370
+ result: "failed",
371
+ data: "Unknown error, could not parse target call data result.",
372
+ code: ExecutionErrors.UserOperationReverted
373
+ };
374
+ }
375
+ }
376
+ function getSimulateHandleOpResult(data) {
377
+ try {
378
+ const decodedError = decodeErrorResult({
379
+ abi: EntryPointV07SimulationsAbi,
380
+ data: data
381
+ });
382
+ if (decodedError &&
383
+ decodedError.errorName === "FailedOp" &&
384
+ decodedError.args) {
385
+ return {
386
+ result: "failed",
387
+ data: decodedError.args[1],
388
+ code: ValidationErrors.SimulateValidation
389
+ };
390
+ }
391
+ if (decodedError &&
392
+ decodedError.errorName === "FailedOpWithRevert" &&
393
+ decodedError.args) {
394
+ return {
395
+ result: "failed",
396
+ data: parseFailedOpWithRevert(decodedError.args?.[2]),
397
+ code: ValidationErrors.SimulateValidation
398
+ };
399
+ }
400
+ }
401
+ catch {
402
+ // no error we go the result
403
+ const decodedResult = decodeFunctionResult({
404
+ abi: EntryPointV07SimulationsAbi,
405
+ functionName: "simulateHandleOp",
406
+ data
407
+ });
408
+ return {
409
+ result: "execution",
410
+ data: {
411
+ executionResult: decodedResult
412
+ }
413
+ };
414
+ }
415
+ throw new Error("Unexpected error");
416
+ }
417
+ //# sourceMappingURL=gasEstimationsV07.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gasEstimationsV07.js","sourceRoot":"","sources":["../../../rpc/estimation/gasEstimationsV07.ts"],"names":[],"mappings":"AACA,OAAO,EAGH,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,EACL,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,KAAK,EACR,MAAM,MAAM,CAAA;AACb,OAAO,EAMH,gBAAgB,EAChB,2BAA2B,EAC3B,+BAA+B,EAC/B,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,QAAQ,EACX,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACzE,OAAO,EACH,gCAAgC,EAEnC,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAA;AAEzE,MAAM,OAAO,eAAe;IACxB,0BAA0B,CAAQ;IAClC,wBAAwB,CAAQ;IAChC,OAAO,CAAQ;IACf,YAAY,CAAc;IAC1B,4BAA4B,CAAqB;IACjD,eAAe,CAAS;IACxB,oBAAoB,CAAS;IAC7B,0BAA0B,CAAS;IAEnC,YACI,0BAAkC,EAClC,wBAAgC,EAChC,OAAe,EACf,YAA0B,EAC1B,4BAAiD,EACjD,eAAwB,EACxB,oBAA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AAG,EAAE,2BAA2B;YAChC,YAAY,EAAE,kBAAkB;YAChC,IAAI;SACP,CAA+B,CAAA;QAEhC,OAAO;YACH,MAAM,EAAE,WAAW;YACnB,IAAI,EAAE;gBACF,eAAe,EAAE,aAAa;aACxB;SACb,CAAA;IACL,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;AACvC,CAAC"}
@@ -0,0 +1,113 @@
1
+ import type { Address, ExecutionResult, PackedUserOperation, TargetCallResult } from "../../types/index.js";
2
+ import type { Hex } from "viem";
3
+ export type SimulateHandleOpResult<TypeResult extends "failed" | "execution" = "failed" | "execution"> = {
4
+ result: TypeResult;
5
+ data: TypeResult extends "failed" ? string : {
6
+ callDataResult?: TargetCallResult;
7
+ executionResult: ExecutionResult;
8
+ };
9
+ code?: TypeResult extends "failed" ? number : undefined;
10
+ };
11
+ export type CallDataSimulationArgs = {
12
+ op: PackedUserOperation;
13
+ target: Address;
14
+ targetCallData: Hex;
15
+ };
16
+ export type SimulationOutOfGasResult = {
17
+ optimalGas: bigint;
18
+ minGas: bigint;
19
+ maxGas: bigint;
20
+ };
21
+ export declare const simulationValidationResultStruct: readonly [{
22
+ readonly components: readonly [{
23
+ readonly components: readonly [{
24
+ readonly internalType: "uint256";
25
+ readonly name: "preOpGas";
26
+ readonly type: "uint256";
27
+ }, {
28
+ readonly internalType: "uint256";
29
+ readonly name: "prefund";
30
+ readonly type: "uint256";
31
+ }, {
32
+ readonly internalType: "uint256";
33
+ readonly name: "accountValidationData";
34
+ readonly type: "uint256";
35
+ }, {
36
+ readonly internalType: "uint256";
37
+ readonly name: "paymasterValidationData";
38
+ readonly type: "uint256";
39
+ }, {
40
+ readonly internalType: "bytes";
41
+ readonly name: "paymasterContext";
42
+ readonly type: "bytes";
43
+ }];
44
+ readonly internalType: "struct IEntryPoint.ReturnInfo";
45
+ readonly name: "returnInfo";
46
+ readonly type: "tuple";
47
+ }, {
48
+ readonly components: readonly [{
49
+ readonly internalType: "uint256";
50
+ readonly name: "stake";
51
+ readonly type: "uint256";
52
+ }, {
53
+ readonly internalType: "uint256";
54
+ readonly name: "unstakeDelaySec";
55
+ readonly type: "uint256";
56
+ }];
57
+ readonly internalType: "struct IStakeManager.StakeInfo";
58
+ readonly name: "senderInfo";
59
+ readonly type: "tuple";
60
+ }, {
61
+ readonly components: readonly [{
62
+ readonly internalType: "uint256";
63
+ readonly name: "stake";
64
+ readonly type: "uint256";
65
+ }, {
66
+ readonly internalType: "uint256";
67
+ readonly name: "unstakeDelaySec";
68
+ readonly type: "uint256";
69
+ }];
70
+ readonly internalType: "struct IStakeManager.StakeInfo";
71
+ readonly name: "factoryInfo";
72
+ readonly type: "tuple";
73
+ }, {
74
+ readonly components: readonly [{
75
+ readonly internalType: "uint256";
76
+ readonly name: "stake";
77
+ readonly type: "uint256";
78
+ }, {
79
+ readonly internalType: "uint256";
80
+ readonly name: "unstakeDelaySec";
81
+ readonly type: "uint256";
82
+ }];
83
+ readonly internalType: "struct IStakeManager.StakeInfo";
84
+ readonly name: "paymasterInfo";
85
+ readonly type: "tuple";
86
+ }, {
87
+ readonly components: readonly [{
88
+ readonly internalType: "address";
89
+ readonly name: "aggregator";
90
+ readonly type: "address";
91
+ }, {
92
+ readonly components: readonly [{
93
+ readonly internalType: "uint256";
94
+ readonly name: "stake";
95
+ readonly type: "uint256";
96
+ }, {
97
+ readonly internalType: "uint256";
98
+ readonly name: "unstakeDelaySec";
99
+ readonly type: "uint256";
100
+ }];
101
+ readonly internalType: "struct IStakeManager.StakeInfo";
102
+ readonly name: "stakeInfo";
103
+ readonly type: "tuple";
104
+ }];
105
+ readonly internalType: "struct IEntryPoint.AggregatorStakeInfo";
106
+ readonly name: "aggregatorInfo";
107
+ readonly type: "tuple";
108
+ }];
109
+ readonly internalType: "struct IEntryPointSimulations.ValidationResult";
110
+ readonly name: "";
111
+ readonly type: "tuple";
112
+ }];
113
+ //# sourceMappingURL=types.d.ts.map