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