@pimlico/alto 0.0.3 → 0.0.5
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/alto.js +0 -4
- package/esm/cli/alto.js.map +1 -1
- package/esm/cli/config/bundler.d.ts +2302 -22
- package/esm/cli/config/bundler.js +32 -4
- package/esm/cli/config/bundler.js.map +1 -1
- package/esm/cli/config/options.js +59 -4
- package/esm/cli/config/options.js.map +1 -1
- package/esm/cli/customTransport.js +5 -1
- package/esm/cli/customTransport.js.map +1 -1
- package/esm/cli/handler.js +39 -4
- package/esm/cli/handler.js.map +1 -1
- package/esm/cli/instrumentation.js +2 -2
- package/esm/cli/instrumentation.js.map +1 -1
- package/esm/cli/setupServer.d.ts +2 -1
- package/esm/cli/setupServer.js +51 -27
- package/esm/cli/setupServer.js.map +1 -1
- package/esm/executor/executor.d.ts +7 -14
- package/esm/executor/executor.js +139 -128
- package/esm/executor/executor.js.map +1 -1
- package/esm/executor/executorManager.d.ts +58 -4
- package/esm/executor/executorManager.js +206 -52
- package/esm/executor/executorManager.js.map +1 -1
- package/esm/executor/senderManager.d.ts +2 -1
- package/esm/executor/senderManager.js +3 -0
- package/esm/executor/senderManager.js.map +1 -1
- package/esm/executor/utilityWalletMonitor.d.ts +15 -0
- package/esm/executor/utilityWalletMonitor.js +38 -0
- package/esm/executor/utilityWalletMonitor.js.map +1 -0
- package/esm/executor/utils.d.ts +1 -2
- package/esm/executor/utils.js +49 -38
- package/esm/executor/utils.js.map +1 -1
- package/esm/handlers/compressionHandler.js.map +1 -0
- package/esm/handlers/eventManager.d.ts +21 -0
- package/esm/handlers/eventManager.js +166 -0
- package/esm/handlers/eventManager.js.map +1 -0
- package/{lib/utils → esm/handlers}/gasPriceManager.d.ts +19 -5
- package/esm/{utils → handlers}/gasPriceManager.js +58 -13
- package/esm/handlers/gasPriceManager.js.map +1 -0
- package/esm/handlers/index.d.ts +4 -0
- package/esm/handlers/index.js +4 -0
- package/esm/handlers/index.js.map +1 -0
- package/esm/mempool/index.d.ts +0 -1
- package/esm/mempool/index.js +0 -1
- package/esm/mempool/index.js.map +1 -1
- package/esm/mempool/mempool.d.ts +4 -2
- package/esm/mempool/mempool.js +70 -26
- package/esm/mempool/mempool.js.map +1 -1
- package/esm/mempool/reputationManager.js +7 -3
- package/esm/mempool/reputationManager.js.map +1 -1
- package/esm/rpc/EntryPointSimulationsV07.d.ts +7 -3
- package/esm/rpc/EntryPointSimulationsV07.js +12 -9
- package/esm/rpc/EntryPointSimulationsV07.js.map +1 -1
- package/esm/rpc/gasEstimation.d.ts +3 -3
- package/esm/rpc/gasEstimation.js +23 -14
- package/esm/rpc/gasEstimation.js.map +1 -1
- package/esm/rpc/nonceQueuer.d.ts +4 -1
- package/esm/rpc/nonceQueuer.js +9 -3
- package/esm/rpc/nonceQueuer.js.map +1 -1
- package/esm/rpc/rpcHandler.d.ts +53 -3
- package/esm/rpc/rpcHandler.js +150 -238
- package/esm/rpc/rpcHandler.js.map +1 -1
- package/esm/rpc/server.d.ts +2 -1
- package/esm/rpc/server.js +10 -1
- package/esm/rpc/server.js.map +1 -1
- package/esm/rpc/validation/SafeValidator.d.ts +5 -8
- package/esm/rpc/validation/SafeValidator.js +51 -208
- package/esm/rpc/validation/SafeValidator.js.map +1 -1
- package/esm/rpc/validation/TracerResultParserV07.js +6 -2
- package/esm/rpc/validation/TracerResultParserV07.js.map +1 -1
- package/esm/rpc/validation/UnsafeValidator.d.ts +7 -3
- package/esm/rpc/validation/UnsafeValidator.js +52 -48
- package/esm/rpc/validation/UnsafeValidator.js.map +1 -1
- package/esm/rpc/validation/tracer.js +1 -0
- package/esm/rpc/validation/tracer.js.map +1 -1
- package/esm/types/contracts/EntryPointSimulations.d.ts +0 -1
- package/esm/types/contracts/EntryPointSimulations.js +1941 -2
- package/esm/types/contracts/EntryPointSimulations.js.map +1 -1
- 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/schemas.d.ts +1029 -333
- package/esm/types/schemas.js +94 -20
- package/esm/types/schemas.js.map +1 -1
- package/esm/types/utils.d.ts +1 -1
- package/esm/types/validation.js +7 -2
- package/esm/types/validation.js.map +1 -1
- package/esm/utils/bigInt.d.ts +1 -0
- package/esm/utils/bigInt.js +4 -0
- package/esm/utils/bigInt.js.map +1 -1
- package/esm/utils/helpers.d.ts +1 -0
- package/esm/utils/helpers.js +6 -0
- package/esm/utils/helpers.js.map +1 -1
- package/esm/utils/index.d.ts +0 -3
- package/esm/utils/index.js +0 -3
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/metrics.d.ts +4 -0
- package/esm/utils/metrics.js +29 -1
- package/esm/utils/metrics.js.map +1 -1
- package/esm/utils/rpc-reply.d.ts +1 -1
- package/esm/utils/rpc-reply.js +2 -1
- package/esm/utils/rpc-reply.js.map +1 -1
- package/esm/utils/userop.d.ts +66 -6
- package/esm/utils/userop.js +182 -95
- package/esm/utils/userop.js.map +1 -1
- package/esm/utils/validation.d.ts +1 -1
- package/esm/utils/validation.js +9 -13
- package/esm/utils/validation.js.map +1 -1
- package/lib/cli/alto.js +0 -4
- package/lib/cli/alto.js.map +1 -1
- package/lib/cli/config/bundler.d.ts +2302 -22
- package/lib/cli/config/bundler.js +31 -3
- package/lib/cli/config/bundler.js.map +1 -1
- package/lib/cli/config/options.js +59 -4
- package/lib/cli/config/options.js.map +1 -1
- package/lib/cli/customTransport.js +5 -1
- package/lib/cli/customTransport.js.map +1 -1
- package/lib/cli/handler.js +38 -3
- package/lib/cli/handler.js.map +1 -1
- package/lib/cli/instrumentation.js +2 -2
- package/lib/cli/instrumentation.js.map +1 -1
- package/lib/cli/setupServer.d.ts +2 -1
- package/lib/cli/setupServer.js +52 -28
- package/lib/cli/setupServer.js.map +1 -1
- package/lib/executor/executor.d.ts +7 -14
- package/lib/executor/executor.js +138 -128
- package/lib/executor/executor.js.map +1 -1
- package/lib/executor/executorManager.d.ts +58 -4
- package/lib/executor/executorManager.js +204 -50
- package/lib/executor/executorManager.js.map +1 -1
- package/lib/executor/senderManager.d.ts +2 -1
- package/lib/executor/senderManager.js +3 -0
- package/lib/executor/senderManager.js.map +1 -1
- package/lib/executor/utilityWalletMonitor.d.ts +15 -0
- package/lib/executor/utilityWalletMonitor.js +42 -0
- package/lib/executor/utilityWalletMonitor.js.map +1 -0
- package/lib/executor/utils.d.ts +1 -2
- package/lib/executor/utils.js +48 -37
- package/lib/executor/utils.js.map +1 -1
- package/lib/handlers/compressionHandler.js.map +1 -0
- package/lib/handlers/eventManager.d.ts +21 -0
- package/lib/handlers/eventManager.js +196 -0
- package/lib/handlers/eventManager.js.map +1 -0
- package/{esm/utils → lib/handlers}/gasPriceManager.d.ts +19 -5
- package/lib/{utils → handlers}/gasPriceManager.js +58 -13
- package/lib/handlers/gasPriceManager.js.map +1 -0
- package/lib/handlers/index.d.ts +4 -0
- package/lib/handlers/index.js +20 -0
- package/lib/handlers/index.js.map +1 -0
- package/lib/mempool/index.d.ts +0 -1
- package/lib/mempool/index.js +0 -1
- package/lib/mempool/index.js.map +1 -1
- package/lib/mempool/mempool.d.ts +4 -2
- package/lib/mempool/mempool.js +70 -26
- package/lib/mempool/mempool.js.map +1 -1
- package/lib/mempool/reputationManager.js +7 -3
- package/lib/mempool/reputationManager.js.map +1 -1
- package/lib/rpc/EntryPointSimulationsV07.d.ts +7 -3
- package/lib/rpc/EntryPointSimulationsV07.js +13 -9
- package/lib/rpc/EntryPointSimulationsV07.js.map +1 -1
- package/lib/rpc/gasEstimation.d.ts +3 -3
- package/lib/rpc/gasEstimation.js +23 -14
- package/lib/rpc/gasEstimation.js.map +1 -1
- package/lib/rpc/nonceQueuer.d.ts +4 -1
- package/lib/rpc/nonceQueuer.js +9 -3
- package/lib/rpc/nonceQueuer.js.map +1 -1
- package/lib/rpc/rpcHandler.d.ts +53 -3
- package/lib/rpc/rpcHandler.js +147 -258
- package/lib/rpc/rpcHandler.js.map +1 -1
- package/lib/rpc/server.d.ts +2 -1
- package/lib/rpc/server.js +10 -1
- package/lib/rpc/server.js.map +1 -1
- package/lib/rpc/validation/SafeValidator.d.ts +5 -8
- package/lib/rpc/validation/SafeValidator.js +50 -207
- package/lib/rpc/validation/SafeValidator.js.map +1 -1
- package/lib/rpc/validation/TracerResultParserV07.js +6 -2
- package/lib/rpc/validation/TracerResultParserV07.js.map +1 -1
- package/lib/rpc/validation/UnsafeValidator.d.ts +7 -3
- package/lib/rpc/validation/UnsafeValidator.js +52 -48
- package/lib/rpc/validation/UnsafeValidator.js.map +1 -1
- package/lib/rpc/validation/tracer.js +1 -0
- package/lib/rpc/validation/tracer.js.map +1 -1
- package/lib/types/contracts/EntryPointSimulations.d.ts +0 -1
- package/lib/types/contracts/EntryPointSimulations.js +1942 -3
- package/lib/types/contracts/EntryPointSimulations.js.map +1 -1
- package/lib/types/contracts/PimlicoEntryPointSimulations.d.ts +1 -1
- package/lib/types/contracts/PimlicoEntryPointSimulations.js +2 -2
- package/lib/types/contracts/PimlicoEntryPointSimulations.js.map +1 -1
- package/lib/types/schemas.d.ts +1029 -333
- package/lib/types/schemas.js +93 -19
- package/lib/types/schemas.js.map +1 -1
- package/lib/types/utils.d.ts +1 -1
- package/lib/types/validation.js +7 -2
- package/lib/types/validation.js.map +1 -1
- package/lib/utils/bigInt.d.ts +1 -0
- package/lib/utils/bigInt.js +6 -1
- package/lib/utils/bigInt.js.map +1 -1
- package/lib/utils/helpers.d.ts +1 -0
- package/lib/utils/helpers.js +8 -1
- package/lib/utils/helpers.js.map +1 -1
- package/lib/utils/index.d.ts +0 -3
- package/lib/utils/index.js +0 -3
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/metrics.d.ts +4 -0
- package/lib/utils/metrics.js +29 -1
- package/lib/utils/metrics.js.map +1 -1
- package/lib/utils/rpc-reply.d.ts +1 -1
- package/lib/utils/rpc-reply.js +2 -1
- package/lib/utils/rpc-reply.js.map +1 -1
- package/lib/utils/userop.d.ts +66 -6
- package/lib/utils/userop.js +184 -95
- package/lib/utils/userop.js.map +1 -1
- package/lib/utils/validation.d.ts +1 -1
- package/lib/utils/validation.js +9 -36
- package/lib/utils/validation.js.map +1 -1
- package/package.json +16 -14
- package/esm/executor/test/utils.d.ts +0 -13
- package/esm/executor/test/utils.js +0 -75
- package/esm/executor/test/utils.js.map +0 -1
- package/esm/mempool/nullMempool.d.ts +0 -15
- package/esm/mempool/nullMempool.js +0 -36
- package/esm/mempool/nullMempool.js.map +0 -1
- package/esm/types/test/validationTestErrors.d.ts +0 -3
- package/esm/types/test/validationTestErrors.js +0 -229
- package/esm/types/test/validationTestErrors.js.map +0 -1
- package/esm/utils/compressionHandler.js.map +0 -1
- package/esm/utils/gasPriceManager.js.map +0 -1
- package/esm/utils/test.d.ts +0 -17
- package/esm/utils/test.js +0 -130
- package/esm/utils/test.js.map +0 -1
- package/lib/executor/test/utils.d.ts +0 -13
- package/lib/executor/test/utils.js +0 -81
- package/lib/executor/test/utils.js.map +0 -1
- package/lib/mempool/nullMempool.d.ts +0 -15
- package/lib/mempool/nullMempool.js +0 -40
- package/lib/mempool/nullMempool.js.map +0 -1
- package/lib/types/test/validationTestErrors.d.ts +0 -3
- package/lib/types/test/validationTestErrors.js +0 -232
- package/lib/types/test/validationTestErrors.js.map +0 -1
- package/lib/utils/compressionHandler.js.map +0 -1
- package/lib/utils/gasPriceManager.js.map +0 -1
- package/lib/utils/test.d.ts +0 -17
- package/lib/utils/test.js +0 -161
- package/lib/utils/test.js.map +0 -1
- /package/esm/{utils → handlers}/compressionHandler.d.ts +0 -0
- /package/esm/{utils → handlers}/compressionHandler.js +0 -0
- /package/lib/{utils → handlers}/compressionHandler.d.ts +0 -0
- /package/lib/{utils → handlers}/compressionHandler.js +0 -0
package/lib/rpc/rpcHandler.js
CHANGED
|
@@ -1,35 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.RpcHandler = void 0;
|
|
27
4
|
const types_1 = require("../types/index.js");
|
|
28
5
|
const utils_1 = require("../utils/index.js");
|
|
29
6
|
const viem_1 = require("viem");
|
|
30
|
-
const
|
|
31
|
-
const zod_1 = require("zod");
|
|
32
|
-
const zod_validation_error_1 = require("zod-validation-error");
|
|
7
|
+
const chains_1 = require("viem/chains");
|
|
33
8
|
class RpcHandler {
|
|
34
9
|
entryPoints;
|
|
35
10
|
publicClient;
|
|
@@ -53,7 +28,9 @@ class RpcHandler {
|
|
|
53
28
|
gasPriceManager;
|
|
54
29
|
gasPriceMultipliers;
|
|
55
30
|
paymasterGasLimitMultiplier;
|
|
56
|
-
|
|
31
|
+
eventManager;
|
|
32
|
+
enableInstantBundlingEndpoint;
|
|
33
|
+
constructor(entryPoints, publicClient, validator, mempool, executor, monitor, nonceQueuer, executorManager, reputationManager, usingTenderly, rpcMaxBlockRange, logger, metrics, enableDebugEndpoints, compressionHandler, legacyTransactions, gasPriceManager, gasPriceMultipliers, chainType, paymasterGasLimitMultiplier, eventManager, enableInstantBundlingEndpoint, dangerousSkipUserOperationValidation = false) {
|
|
57
34
|
this.entryPoints = entryPoints;
|
|
58
35
|
this.publicClient = publicClient;
|
|
59
36
|
this.validator = validator;
|
|
@@ -77,6 +54,8 @@ class RpcHandler {
|
|
|
77
54
|
this.chainType = chainType;
|
|
78
55
|
this.gasPriceManager = gasPriceManager;
|
|
79
56
|
this.paymasterGasLimitMultiplier = paymasterGasLimitMultiplier;
|
|
57
|
+
this.enableInstantBundlingEndpoint = enableInstantBundlingEndpoint;
|
|
58
|
+
this.eventManager = eventManager;
|
|
80
59
|
}
|
|
81
60
|
async handleMethod(request, apiVersion) {
|
|
82
61
|
// call the method with the params
|
|
@@ -167,6 +146,47 @@ class RpcHandler {
|
|
|
167
146
|
method,
|
|
168
147
|
result: await this.pimlico_sendCompressedUserOperation(apiVersion, ...request.params)
|
|
169
148
|
};
|
|
149
|
+
case "pimlico_sendUserOperationNow":
|
|
150
|
+
return {
|
|
151
|
+
method,
|
|
152
|
+
result: await this.pimlico_sendUserOperationNow(apiVersion, ...request.params)
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
ensureEntryPointIsSupported(entryPoint) {
|
|
157
|
+
if (!this.entryPoints.includes(entryPoint)) {
|
|
158
|
+
throw new Error(`EntryPoint ${entryPoint} not supported, supported EntryPoints: ${this.entryPoints.join(", ")}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
ensureDebugEndpointsAreEnabled(methodName) {
|
|
162
|
+
if (!this.enableDebugEndpoints) {
|
|
163
|
+
throw new types_1.RpcError(`${methodName} is only available in development environment`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
async preMempoolChecks(opHash, userOperation, apiVersion, entryPoint) {
|
|
167
|
+
if (this.legacyTransactions &&
|
|
168
|
+
userOperation.maxFeePerGas !== userOperation.maxPriorityFeePerGas) {
|
|
169
|
+
const reason = "maxPriorityFeePerGas must equal maxFeePerGas on chains that don't support EIP-1559";
|
|
170
|
+
this.eventManager.emitFailedValidation(opHash, reason);
|
|
171
|
+
throw new types_1.RpcError(reason);
|
|
172
|
+
}
|
|
173
|
+
if (apiVersion !== "v1") {
|
|
174
|
+
await this.gasPriceManager.validateGasPrice({
|
|
175
|
+
maxFeePerGas: userOperation.maxFeePerGas,
|
|
176
|
+
maxPriorityFeePerGas: userOperation.maxPriorityFeePerGas
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
if (userOperation.verificationGasLimit < 10000n) {
|
|
180
|
+
const reason = "verificationGasLimit must be at least 10000";
|
|
181
|
+
this.eventManager.emitFailedValidation(opHash, reason);
|
|
182
|
+
throw new types_1.RpcError(reason);
|
|
183
|
+
}
|
|
184
|
+
this.logger.trace({ userOperation, entryPoint }, "beginning validation");
|
|
185
|
+
if (userOperation.preVerificationGas === 0n ||
|
|
186
|
+
userOperation.verificationGasLimit === 0n) {
|
|
187
|
+
const reason = "user operation gas limits must be larger than 0";
|
|
188
|
+
this.eventManager.emitFailedValidation(opHash, reason);
|
|
189
|
+
throw new types_1.RpcError(reason);
|
|
170
190
|
}
|
|
171
191
|
}
|
|
172
192
|
eth_chainId() {
|
|
@@ -176,10 +196,7 @@ class RpcHandler {
|
|
|
176
196
|
return this.entryPoints;
|
|
177
197
|
}
|
|
178
198
|
async eth_estimateUserOperationGas(apiVersion, userOperation, entryPoint, stateOverrides) {
|
|
179
|
-
|
|
180
|
-
if (!this.entryPoints.includes(entryPoint)) {
|
|
181
|
-
throw new Error(`EntryPoint ${entryPoint} not supported, supported EntryPoints: ${this.entryPoints.join(", ")}`);
|
|
182
|
-
}
|
|
199
|
+
this.ensureEntryPointIsSupported(entryPoint);
|
|
183
200
|
if (userOperation.maxFeePerGas === 0n) {
|
|
184
201
|
throw new types_1.RpcError("user operation max fee per gas must be larger than 0 during gas estimation");
|
|
185
202
|
}
|
|
@@ -189,14 +206,9 @@ class RpcHandler {
|
|
|
189
206
|
userOperation.preVerificationGas = 1000000n;
|
|
190
207
|
userOperation.verificationGasLimit = 10000000n;
|
|
191
208
|
userOperation.callGasLimit = 10000000n;
|
|
192
|
-
if (this.chainId ===
|
|
209
|
+
if (this.chainId === chains_1.base.id) {
|
|
193
210
|
userOperation.verificationGasLimit = 5000000n;
|
|
194
211
|
}
|
|
195
|
-
if (this.chainId === chains.celoAlfajores.id ||
|
|
196
|
-
this.chainId === chains.celo.id) {
|
|
197
|
-
userOperation.verificationGasLimit = 1000000n;
|
|
198
|
-
userOperation.callGasLimit = 1000000n;
|
|
199
|
-
}
|
|
200
212
|
if ((0, utils_1.isVersion07)(userOperation)) {
|
|
201
213
|
userOperation.paymasterPostOpGasLimit = 2000000n;
|
|
202
214
|
userOperation.paymasterVerificationGasLimit = 5000000n;
|
|
@@ -247,12 +259,10 @@ class RpcHandler {
|
|
|
247
259
|
paymasterPostOpGasLimit =
|
|
248
260
|
(paymasterPostOpGasLimit * multiplier) / 100n;
|
|
249
261
|
}
|
|
250
|
-
if (this.chainId ===
|
|
251
|
-
this.chainId === chains.baseSepolia.id) {
|
|
262
|
+
if (this.chainId === chains_1.base.id || this.chainId === chains_1.baseSepolia.id) {
|
|
252
263
|
callGasLimit += 10000n;
|
|
253
264
|
}
|
|
254
|
-
if (this.chainId ===
|
|
255
|
-
this.chainId === chains.optimism.id) {
|
|
265
|
+
if (this.chainId === chains_1.base.id || this.chainId === chains_1.optimism.id) {
|
|
256
266
|
callGasLimit = (0, utils_1.maxBigInt)(callGasLimit, 120000n);
|
|
257
267
|
}
|
|
258
268
|
if (userOperation.callData === "0x") {
|
|
@@ -282,10 +292,11 @@ class RpcHandler {
|
|
|
282
292
|
};
|
|
283
293
|
}
|
|
284
294
|
async eth_sendUserOperation(apiVersion, userOperation, entryPoint) {
|
|
295
|
+
const hash = (0, utils_1.getUserOperationHash)(userOperation, entryPoint, this.chainId);
|
|
296
|
+
this.eventManager.emitReceived(hash);
|
|
285
297
|
let status = "rejected";
|
|
286
298
|
try {
|
|
287
299
|
status = await this.addToMempoolIfValid(userOperation, entryPoint, apiVersion);
|
|
288
|
-
const hash = (0, utils_1.getUserOperationHash)(userOperation, entryPoint, this.chainId);
|
|
289
300
|
return hash;
|
|
290
301
|
}
|
|
291
302
|
catch (error) {
|
|
@@ -349,27 +360,38 @@ class RpcHandler {
|
|
|
349
360
|
if (!tx.to) {
|
|
350
361
|
return null;
|
|
351
362
|
}
|
|
352
|
-
let op
|
|
363
|
+
let op;
|
|
353
364
|
try {
|
|
354
365
|
const decoded = (0, viem_1.decodeFunctionData)({
|
|
355
|
-
abi: types_1.EntryPointV06Abi,
|
|
366
|
+
abi: [...types_1.EntryPointV06Abi, ...types_1.EntryPointV07Abi],
|
|
356
367
|
data: tx.input
|
|
357
368
|
});
|
|
358
369
|
if (decoded.functionName !== "handleOps") {
|
|
359
370
|
return null;
|
|
360
371
|
}
|
|
361
372
|
const ops = decoded.args[0];
|
|
362
|
-
|
|
373
|
+
const foundOp = ops.find((op) => op.sender === userOperationEvent.args.sender &&
|
|
363
374
|
op.nonce === userOperationEvent.args.nonce);
|
|
375
|
+
if (foundOp === undefined) {
|
|
376
|
+
return null;
|
|
377
|
+
}
|
|
378
|
+
const handleOpsV07AbiItem = (0, viem_1.getAbiItem)({
|
|
379
|
+
abi: types_1.EntryPointV07Abi,
|
|
380
|
+
name: "handleOps"
|
|
381
|
+
});
|
|
382
|
+
const handleOpsV07Selector = (0, viem_1.toFunctionSelector)(handleOpsV07AbiItem);
|
|
383
|
+
if ((0, viem_1.slice)(tx.input, 0, 4) === handleOpsV07Selector) {
|
|
384
|
+
op = (0, utils_1.toUnpackedUserOperation)(foundOp);
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
op = foundOp;
|
|
388
|
+
}
|
|
364
389
|
}
|
|
365
390
|
catch {
|
|
366
391
|
return null;
|
|
367
392
|
}
|
|
368
|
-
if (op === undefined) {
|
|
369
|
-
return null;
|
|
370
|
-
}
|
|
371
393
|
const result = {
|
|
372
|
-
userOperation:
|
|
394
|
+
userOperation: op,
|
|
373
395
|
entryPoint: (0, viem_1.getAddress)(tx.to),
|
|
374
396
|
transactionHash: txHash,
|
|
375
397
|
blockHash: tx.blockHash ?? "0x",
|
|
@@ -377,211 +399,53 @@ class RpcHandler {
|
|
|
377
399
|
};
|
|
378
400
|
return result;
|
|
379
401
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
abi: types_1.EntryPointV06Abi,
|
|
383
|
-
name: "UserOperationEvent"
|
|
384
|
-
});
|
|
385
|
-
let fromBlock = undefined;
|
|
386
|
-
let toBlock = undefined;
|
|
387
|
-
if (this.rpcMaxBlockRange !== undefined) {
|
|
388
|
-
const latestBlock = await this.publicClient.getBlockNumber();
|
|
389
|
-
fromBlock = latestBlock - BigInt(this.rpcMaxBlockRange);
|
|
390
|
-
if (fromBlock < 0n) {
|
|
391
|
-
fromBlock = 0n;
|
|
392
|
-
}
|
|
393
|
-
toBlock = "latest";
|
|
394
|
-
}
|
|
395
|
-
const filterResult = await this.publicClient.getLogs({
|
|
396
|
-
address: this.entryPoints,
|
|
397
|
-
event: userOperationEventAbiItem,
|
|
398
|
-
fromBlock,
|
|
399
|
-
toBlock,
|
|
400
|
-
args: {
|
|
401
|
-
userOpHash: userOperationHash
|
|
402
|
-
}
|
|
403
|
-
});
|
|
404
|
-
if (filterResult.length === 0) {
|
|
405
|
-
return null;
|
|
406
|
-
}
|
|
407
|
-
const userOperationEvent = filterResult[0];
|
|
408
|
-
// throw if any of the members of userOperationEvent are undefined
|
|
409
|
-
if (userOperationEvent.args.actualGasCost === undefined ||
|
|
410
|
-
userOperationEvent.args.sender === undefined ||
|
|
411
|
-
userOperationEvent.args.nonce === undefined ||
|
|
412
|
-
userOperationEvent.args.userOpHash === undefined ||
|
|
413
|
-
userOperationEvent.args.success === undefined ||
|
|
414
|
-
userOperationEvent.args.paymaster === undefined ||
|
|
415
|
-
userOperationEvent.args.actualGasUsed === undefined) {
|
|
416
|
-
throw new Error("userOperationEvent has undefined members");
|
|
417
|
-
}
|
|
418
|
-
const txHash = userOperationEvent.transactionHash;
|
|
419
|
-
if (txHash === null) {
|
|
420
|
-
// transaction pending
|
|
421
|
-
return null;
|
|
422
|
-
}
|
|
423
|
-
const getTransactionReceipt = async (txHash) => {
|
|
424
|
-
while (true) {
|
|
425
|
-
try {
|
|
426
|
-
return await this.publicClient.getTransactionReceipt({
|
|
427
|
-
hash: txHash
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
catch (e) {
|
|
431
|
-
if (e instanceof viem_1.TransactionReceiptNotFoundError) {
|
|
432
|
-
continue;
|
|
433
|
-
}
|
|
434
|
-
throw e;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
};
|
|
438
|
-
const receipt = await getTransactionReceipt(txHash);
|
|
439
|
-
const logs = receipt.logs;
|
|
440
|
-
if (logs.some((log) => log.blockHash === null ||
|
|
441
|
-
log.blockNumber === null ||
|
|
442
|
-
log.transactionIndex === null ||
|
|
443
|
-
log.transactionHash === null ||
|
|
444
|
-
log.logIndex === null ||
|
|
445
|
-
log.topics.length === 0)) {
|
|
446
|
-
// transaction pending
|
|
447
|
-
return null;
|
|
448
|
-
}
|
|
449
|
-
const userOperationRevertReasonAbi = (0, viem_1.parseAbi)([
|
|
450
|
-
"event UserOperationRevertReason(bytes32 indexed userOpHash, address indexed sender, uint256 nonce, bytes revertReason)"
|
|
451
|
-
]);
|
|
452
|
-
const userOperationRevertReasonTopicEvent = (0, viem_1.encodeEventTopics)({
|
|
453
|
-
abi: userOperationRevertReasonAbi
|
|
454
|
-
})[0];
|
|
455
|
-
let entryPoint = viem_1.zeroAddress;
|
|
456
|
-
let revertReason = undefined;
|
|
457
|
-
let startIndex = -1;
|
|
458
|
-
let endIndex = -1;
|
|
459
|
-
logs.forEach((log, index) => {
|
|
460
|
-
if (log?.topics[0] === userOperationEvent.topics[0]) {
|
|
461
|
-
// process UserOperationEvent
|
|
462
|
-
if (log.topics[1] === userOperationEvent.topics[1]) {
|
|
463
|
-
// it's our userOpHash. save as end of logs array
|
|
464
|
-
endIndex = index;
|
|
465
|
-
entryPoint = log.address;
|
|
466
|
-
}
|
|
467
|
-
else if (endIndex === -1) {
|
|
468
|
-
// it's a different hash. remember it as beginning index, but only if we didn't find our end index yet.
|
|
469
|
-
startIndex = index;
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
if (log?.topics[0] === userOperationRevertReasonTopicEvent) {
|
|
473
|
-
// process UserOperationRevertReason
|
|
474
|
-
if (log.topics[1] === userOperationEvent.topics[1]) {
|
|
475
|
-
// it's our userOpHash. capture revert reason.
|
|
476
|
-
const decodedLog = (0, viem_1.decodeEventLog)({
|
|
477
|
-
abi: userOperationRevertReasonAbi,
|
|
478
|
-
data: log.data,
|
|
479
|
-
topics: log.topics
|
|
480
|
-
});
|
|
481
|
-
revertReason = decodedLog.args.revertReason;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
});
|
|
485
|
-
if (endIndex === -1) {
|
|
486
|
-
throw new Error("fatal: no UserOperationEvent in logs");
|
|
487
|
-
}
|
|
488
|
-
const filteredLogs = logs.slice(startIndex + 1, endIndex);
|
|
489
|
-
const logsParsing = zod_1.z.array(types_1.logSchema).safeParse(filteredLogs);
|
|
490
|
-
if (!logsParsing.success) {
|
|
491
|
-
const err = (0, zod_validation_error_1.fromZodError)(logsParsing.error);
|
|
492
|
-
throw err;
|
|
493
|
-
}
|
|
494
|
-
const receiptParsing = types_1.receiptSchema.safeParse({
|
|
495
|
-
...receipt,
|
|
496
|
-
status: receipt.status === "success" ? 1 : 0
|
|
497
|
-
});
|
|
498
|
-
if (!receiptParsing.success) {
|
|
499
|
-
const err = (0, zod_validation_error_1.fromZodError)(receiptParsing.error);
|
|
500
|
-
throw err;
|
|
501
|
-
}
|
|
502
|
-
let paymaster = userOperationEvent.args.paymaster;
|
|
503
|
-
paymaster = paymaster === viem_1.zeroAddress ? undefined : paymaster;
|
|
504
|
-
const userOperationReceipt = {
|
|
505
|
-
userOpHash: userOperationHash,
|
|
506
|
-
entryPoint,
|
|
507
|
-
sender: userOperationEvent.args.sender,
|
|
508
|
-
nonce: userOperationEvent.args.nonce,
|
|
509
|
-
paymaster,
|
|
510
|
-
actualGasUsed: userOperationEvent.args.actualGasUsed,
|
|
511
|
-
actualGasCost: userOperationEvent.args.actualGasCost,
|
|
512
|
-
success: userOperationEvent.args.success,
|
|
513
|
-
reason: revertReason,
|
|
514
|
-
logs: logsParsing.data,
|
|
515
|
-
receipt: receiptParsing.data
|
|
516
|
-
};
|
|
517
|
-
return userOperationReceipt;
|
|
402
|
+
eth_getUserOperationReceipt(userOperationHash) {
|
|
403
|
+
return this.executorManager.getUserOperationReceipt(userOperationHash);
|
|
518
404
|
}
|
|
519
405
|
debug_bundler_clearState() {
|
|
520
|
-
|
|
521
|
-
throw new types_1.RpcError("debug_bundler_clearState is only available in development environment");
|
|
522
|
-
}
|
|
406
|
+
this.ensureDebugEndpointsAreEnabled("debug_bundler_clearState");
|
|
523
407
|
this.mempool.clear();
|
|
524
408
|
this.reputationManager.clear();
|
|
525
409
|
return "ok";
|
|
526
410
|
}
|
|
527
411
|
debug_bundler_clearMempool() {
|
|
528
|
-
|
|
529
|
-
throw new types_1.RpcError("debug_bundler_clearMempool is only available in development environment");
|
|
530
|
-
}
|
|
412
|
+
this.ensureDebugEndpointsAreEnabled("debug_bundler_clearMempool");
|
|
531
413
|
this.mempool.clear();
|
|
532
414
|
this.reputationManager.clearEntityCount();
|
|
533
415
|
return "ok";
|
|
534
416
|
}
|
|
535
417
|
async debug_bundler_dumpMempool(entryPoint) {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
}
|
|
539
|
-
if (!this.entryPoints.includes(entryPoint)) {
|
|
540
|
-
throw new types_1.RpcError(`EntryPoint ${entryPoint} not supported, supported EntryPoints: ${this.entryPoints.join(", ")}`);
|
|
541
|
-
}
|
|
418
|
+
this.ensureDebugEndpointsAreEnabled("debug_bundler_dumpMempool");
|
|
419
|
+
this.ensureEntryPointIsSupported(entryPoint);
|
|
542
420
|
return this.mempool
|
|
543
421
|
.dumpOutstanding()
|
|
544
422
|
.map((userOpInfo) => (0, types_1.deriveUserOperation)(userOpInfo.mempoolUserOperation));
|
|
545
423
|
}
|
|
546
424
|
async debug_bundler_sendBundleNow() {
|
|
547
|
-
|
|
548
|
-
throw new types_1.RpcError("debug_bundler_sendBundleNow is only available in development environment");
|
|
549
|
-
}
|
|
425
|
+
this.ensureDebugEndpointsAreEnabled("debug_bundler_sendBundleNow");
|
|
550
426
|
const transactions = await this.executorManager.bundleNow();
|
|
551
427
|
return transactions[0];
|
|
552
428
|
}
|
|
553
429
|
debug_bundler_setBundlingMode(bundlingMode) {
|
|
554
|
-
|
|
555
|
-
throw new types_1.RpcError("debug_bundler_setBundlingMode is only available in development environment");
|
|
556
|
-
}
|
|
430
|
+
this.ensureDebugEndpointsAreEnabled("debug_bundler_setBundlingMode");
|
|
557
431
|
this.executorManager.setBundlingMode(bundlingMode);
|
|
558
432
|
return "ok";
|
|
559
433
|
}
|
|
560
434
|
debug_bundler_dumpReputation(entryPoint) {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
}
|
|
564
|
-
if (!this.entryPoints.includes(entryPoint)) {
|
|
565
|
-
throw new types_1.RpcError(`EntryPoint ${entryPoint} not supported, supported EntryPoints: ${this.entryPoints.join(", ")}`);
|
|
566
|
-
}
|
|
435
|
+
this.ensureDebugEndpointsAreEnabled("debug_bundler_setReputation");
|
|
436
|
+
this.ensureEntryPointIsSupported(entryPoint);
|
|
567
437
|
return this.reputationManager.dumpReputations(entryPoint);
|
|
568
438
|
}
|
|
569
439
|
async debug_bundler_getStakeStatus(address, entryPoint) {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
}
|
|
573
|
-
if (!this.entryPoints.includes(entryPoint)) {
|
|
574
|
-
throw new types_1.RpcError(`EntryPoint ${entryPoint} not supported, supported EntryPoints: ${this.entryPoints.join(", ")}`);
|
|
575
|
-
}
|
|
440
|
+
this.ensureDebugEndpointsAreEnabled("debug_bundler_getStakeStatus");
|
|
441
|
+
this.ensureEntryPointIsSupported(entryPoint);
|
|
576
442
|
return types_1.bundlerGetStakeStatusResponseSchema.parse({
|
|
577
443
|
method: "debug_bundler_getStakeStatus",
|
|
578
444
|
result: await this.reputationManager.getStakeStatus(entryPoint, address)
|
|
579
445
|
}).result;
|
|
580
446
|
}
|
|
581
447
|
debug_bundler_setReputation(args) {
|
|
582
|
-
|
|
583
|
-
throw new types_1.RpcError("debug_bundler_setReputation is only available in development environment");
|
|
584
|
-
}
|
|
448
|
+
this.ensureDebugEndpointsAreEnabled("debug_bundler_setReputation");
|
|
585
449
|
this.reputationManager.setReputation(args[1], args[0]);
|
|
586
450
|
return "ok";
|
|
587
451
|
}
|
|
@@ -589,57 +453,44 @@ class RpcHandler {
|
|
|
589
453
|
return this.monitor.getUserOperationStatus(userOperationHash);
|
|
590
454
|
}
|
|
591
455
|
async pimlico_getUserOperationGasPrice() {
|
|
592
|
-
|
|
456
|
+
let { maxFeePerGas, maxPriorityFeePerGas } = await this.gasPriceManager.getGasPrice();
|
|
457
|
+
if (this.chainType === "hedera") {
|
|
458
|
+
maxFeePerGas /= 10n ** 9n;
|
|
459
|
+
maxPriorityFeePerGas /= 10n ** 9n;
|
|
460
|
+
}
|
|
593
461
|
const { slow, standard, fast } = this.gasPriceMultipliers;
|
|
594
462
|
return {
|
|
595
463
|
slow: {
|
|
596
|
-
maxFeePerGas: (
|
|
597
|
-
maxPriorityFeePerGas: (
|
|
464
|
+
maxFeePerGas: (maxFeePerGas * slow) / 100n,
|
|
465
|
+
maxPriorityFeePerGas: (maxPriorityFeePerGas * slow) / 100n
|
|
598
466
|
},
|
|
599
467
|
standard: {
|
|
600
|
-
maxFeePerGas: (
|
|
601
|
-
maxPriorityFeePerGas: (
|
|
468
|
+
maxFeePerGas: (maxFeePerGas * standard) / 100n,
|
|
469
|
+
maxPriorityFeePerGas: (maxPriorityFeePerGas * standard) / 100n
|
|
602
470
|
},
|
|
603
471
|
fast: {
|
|
604
|
-
maxFeePerGas: (
|
|
605
|
-
maxPriorityFeePerGas: (
|
|
472
|
+
maxFeePerGas: (maxFeePerGas * fast) / 100n,
|
|
473
|
+
maxPriorityFeePerGas: (maxPriorityFeePerGas * fast) / 100n
|
|
606
474
|
}
|
|
607
475
|
};
|
|
608
476
|
}
|
|
609
477
|
// check if we want to bundle userOperation. If yes, add to mempool
|
|
610
478
|
async addToMempoolIfValid(op, entryPoint, apiVersion) {
|
|
479
|
+
this.ensureEntryPointIsSupported(entryPoint);
|
|
611
480
|
const userOperation = (0, types_1.deriveUserOperation)(op);
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
}
|
|
615
|
-
if (this.chainId === chains.celoAlfajores.id ||
|
|
616
|
-
this.chainId === chains.celo.id) {
|
|
617
|
-
if (userOperation.maxFeePerGas !==
|
|
618
|
-
userOperation.maxPriorityFeePerGas) {
|
|
619
|
-
throw new types_1.RpcError("maxPriorityFeePerGas must equal maxFeePerGas on Celo chains");
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
if (apiVersion !== "v1") {
|
|
623
|
-
await this.gasPriceManager.validateGasPrice({
|
|
624
|
-
maxFeePerGas: userOperation.maxFeePerGas,
|
|
625
|
-
maxPriorityFeePerGas: userOperation.maxPriorityFeePerGas
|
|
626
|
-
});
|
|
627
|
-
}
|
|
628
|
-
if (userOperation.verificationGasLimit < 10000n) {
|
|
629
|
-
throw new types_1.RpcError("verificationGasLimit must be at least 10000");
|
|
630
|
-
}
|
|
631
|
-
this.logger.trace({ userOperation, entryPoint }, "beginning validation");
|
|
632
|
-
if (userOperation.preVerificationGas === 0n ||
|
|
633
|
-
userOperation.verificationGasLimit === 0n) {
|
|
634
|
-
throw new types_1.RpcError("user operation gas limits must be larger than 0");
|
|
635
|
-
}
|
|
481
|
+
const opHash = (0, utils_1.getUserOperationHash)(userOperation, entryPoint, this.chainId);
|
|
482
|
+
await this.preMempoolChecks(opHash, userOperation, apiVersion, entryPoint);
|
|
636
483
|
const currentNonceValue = await this.getNonceValue(userOperation, entryPoint);
|
|
637
484
|
const [, userOperationNonceValue] = (0, utils_1.getNonceKeyAndValue)(userOperation.nonce);
|
|
638
485
|
if (userOperationNonceValue < currentNonceValue) {
|
|
639
|
-
|
|
486
|
+
const reason = "UserOperation failed validation with reason: AA25 invalid account nonce";
|
|
487
|
+
this.eventManager.emitFailedValidation(opHash, reason, "AA25");
|
|
488
|
+
throw new types_1.RpcError(reason, types_1.ValidationErrors.InvalidFields);
|
|
640
489
|
}
|
|
641
490
|
if (userOperationNonceValue > currentNonceValue + 10n) {
|
|
642
|
-
|
|
491
|
+
const reason = "UserOperation failed validaiton with reason: AA25 invalid account nonce";
|
|
492
|
+
this.eventManager.emitFailedValidation(opHash, reason, "AA25");
|
|
493
|
+
throw new types_1.RpcError(reason, types_1.ValidationErrors.InvalidFields);
|
|
643
494
|
}
|
|
644
495
|
let queuedUserOperations = [];
|
|
645
496
|
if (userOperationNonceValue > currentNonceValue &&
|
|
@@ -649,9 +500,10 @@ class RpcHandler {
|
|
|
649
500
|
if (userOperationNonceValue ===
|
|
650
501
|
currentNonceValue + BigInt(queuedUserOperations.length)) {
|
|
651
502
|
if (this.dangerousSkipUserOperationValidation) {
|
|
652
|
-
const success = this.mempool.add(op, entryPoint);
|
|
503
|
+
const [success, errorReason] = this.mempool.add(op, entryPoint);
|
|
653
504
|
if (!success) {
|
|
654
|
-
|
|
505
|
+
this.eventManager.emitFailedValidation(opHash, errorReason, (0, utils_1.getAAError)(errorReason));
|
|
506
|
+
throw new types_1.RpcError(`UserOperation reverted during simulation with reason: ${errorReason}`, types_1.ValidationErrors.InvalidFields);
|
|
655
507
|
}
|
|
656
508
|
}
|
|
657
509
|
else {
|
|
@@ -661,9 +513,10 @@ class RpcHandler {
|
|
|
661
513
|
const validationResult = await this.validator.validateUserOperation(apiVersion !== "v1", userOperation, queuedUserOperations, entryPoint);
|
|
662
514
|
await this.reputationManager.checkReputation(userOperation, entryPoint, validationResult);
|
|
663
515
|
await this.mempool.checkEntityMultipleRoleViolation(userOperation);
|
|
664
|
-
const success = this.mempool.add(op, entryPoint, validationResult.referencedContracts);
|
|
516
|
+
const [success, errorReason] = this.mempool.add(op, entryPoint, validationResult.referencedContracts);
|
|
665
517
|
if (!success) {
|
|
666
|
-
|
|
518
|
+
this.eventManager.emitFailedValidation(opHash, errorReason, (0, utils_1.getAAError)(errorReason));
|
|
519
|
+
throw new types_1.RpcError(`UserOperation reverted during simulation with reason: ${errorReason}`, types_1.ValidationErrors.InvalidFields);
|
|
667
520
|
}
|
|
668
521
|
return "added";
|
|
669
522
|
}
|
|
@@ -671,10 +524,47 @@ class RpcHandler {
|
|
|
671
524
|
this.nonceQueuer.add(op, entryPoint);
|
|
672
525
|
return "queued";
|
|
673
526
|
}
|
|
527
|
+
async pimlico_sendUserOperationNow(apiVersion, userOperation, entryPoint) {
|
|
528
|
+
if (!this.enableInstantBundlingEndpoint) {
|
|
529
|
+
throw new types_1.RpcError("pimlico_sendUserOperationNow endpoint is not enabled", types_1.ValidationErrors.InvalidFields);
|
|
530
|
+
}
|
|
531
|
+
this.ensureEntryPointIsSupported(entryPoint);
|
|
532
|
+
const opHash = (0, utils_1.getUserOperationHash)(userOperation, entryPoint, this.chainId);
|
|
533
|
+
await this.preMempoolChecks(opHash, userOperation, apiVersion, entryPoint);
|
|
534
|
+
const result = (await this.executor.bundle(entryPoint, [userOperation]))[0];
|
|
535
|
+
if (result.status === "failure") {
|
|
536
|
+
const { userOpHash, reason } = result.error;
|
|
537
|
+
this.monitor.setUserOperationStatus(userOpHash, {
|
|
538
|
+
status: "rejected",
|
|
539
|
+
transactionHash: null
|
|
540
|
+
});
|
|
541
|
+
this.logger.warn({
|
|
542
|
+
userOperation: JSON.stringify(result.error.userOperation, (_k, v) => (typeof v === "bigint" ? v.toString() : v)),
|
|
543
|
+
userOpHash,
|
|
544
|
+
reason
|
|
545
|
+
}, "user operation rejected");
|
|
546
|
+
this.metrics.userOperationsSubmitted
|
|
547
|
+
.labels({ status: "failed" })
|
|
548
|
+
.inc();
|
|
549
|
+
const { error } = result;
|
|
550
|
+
throw new types_1.RpcError(`userOperation reverted during simulation with reason: ${error.reason}`);
|
|
551
|
+
}
|
|
552
|
+
const res = result;
|
|
553
|
+
// wait for receipt
|
|
554
|
+
const receipt = await this.publicClient.waitForTransactionReceipt({
|
|
555
|
+
hash: res.value.transactionInfo.transactionHash,
|
|
556
|
+
pollingInterval: 100
|
|
557
|
+
});
|
|
558
|
+
const userOperationReceipt = (0, utils_1.parseUserOperationReceipt)(opHash, receipt);
|
|
559
|
+
return userOperationReceipt;
|
|
560
|
+
}
|
|
674
561
|
async pimlico_sendCompressedUserOperation(apiVersion, compressedCalldata, inflatorAddress, entryPoint) {
|
|
562
|
+
const receivedTimestamp = Date.now();
|
|
675
563
|
let status = "rejected";
|
|
676
564
|
try {
|
|
677
565
|
const { inflatedOp, inflatorId } = await this.validateAndInflateCompressedUserOperation(inflatorAddress, compressedCalldata);
|
|
566
|
+
const hash = (0, utils_1.getUserOperationHash)(inflatedOp, entryPoint, this.chainId);
|
|
567
|
+
this.eventManager.emitReceived(hash, receivedTimestamp);
|
|
678
568
|
const compressedUserOp = {
|
|
679
569
|
compressedCalldata,
|
|
680
570
|
inflatedOp,
|
|
@@ -683,7 +573,6 @@ class RpcHandler {
|
|
|
683
573
|
};
|
|
684
574
|
// check userOps inputs.
|
|
685
575
|
status = await this.addToMempoolIfValid(compressedUserOp, entryPoint, apiVersion);
|
|
686
|
-
const hash = (0, utils_1.getUserOperationHash)(inflatedOp, entryPoint, this.chainId);
|
|
687
576
|
return hash;
|
|
688
577
|
}
|
|
689
578
|
catch (error) {
|