@pimlico/alto 0.0.0-main.20240607T104359 → 0.0.0-staging.20240606T095015
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/lib/cli/config/bundler.js +73 -76
- package/lib/cli/config/bundler.js.map +1 -1
- package/lib/cli/config/index.js +2 -18
- package/lib/cli/config/index.js.map +1 -1
- package/lib/cli/config/options.js +10 -13
- package/lib/cli/config/options.js.map +1 -1
- package/lib/cli/customTransport.js +7 -11
- package/lib/cli/customTransport.js.map +1 -1
- package/lib/cli/handler.js +24 -28
- package/lib/cli/handler.js.map +1 -1
- package/lib/cli/index.d.ts +0 -1
- package/lib/cli/index.js +2 -19
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/instrumentation.js +20 -22
- package/lib/cli/instrumentation.js.map +1 -1
- package/lib/cli/setupServer.js +17 -21
- package/lib/cli/setupServer.js.map +1 -1
- package/lib/cli/util.js +1 -5
- package/lib/cli/util.js.map +1 -1
- package/lib/executor/executor.js +56 -90
- package/lib/executor/executor.js.map +1 -1
- package/lib/executor/executorManager.js +7 -12
- package/lib/executor/executorManager.js.map +1 -1
- package/lib/executor/index.js +4 -20
- package/lib/executor/index.js.map +1 -1
- package/lib/executor/senderManager.js +8 -12
- package/lib/executor/senderManager.js.map +1 -1
- package/lib/executor/test/utils.js +22 -28
- package/lib/executor/test/utils.js.map +1 -1
- package/lib/executor/utils.js +32 -64
- package/lib/executor/utils.js.map +1 -1
- package/lib/index.d.ts +5 -1
- package/lib/index.js +91 -3
- package/lib/index.js.map +1 -1
- package/lib/mempool/index.js +4 -20
- package/lib/mempool/index.js.map +1 -1
- package/lib/mempool/mempool.js +55 -59
- package/lib/mempool/mempool.js.map +1 -1
- package/lib/mempool/monitoring.js +1 -5
- package/lib/mempool/monitoring.js.map +1 -1
- package/lib/mempool/nullMempool.js +1 -5
- package/lib/mempool/nullMempool.js.map +1 -1
- package/lib/mempool/reputationManager.js +44 -49
- package/lib/mempool/reputationManager.js.map +1 -1
- package/lib/mempool/store.js +1 -5
- package/lib/mempool/store.js.map +1 -1
- package/lib/rpc/EntryPointSimulationsV07.js +44 -50
- package/lib/rpc/EntryPointSimulationsV07.js.map +1 -1
- package/lib/rpc/ExecuteSimulator.js +2 -5
- package/lib/rpc/ExecuteSimulator.js.map +1 -1
- package/lib/rpc/gasEstimation.js +62 -69
- package/lib/rpc/gasEstimation.js.map +1 -1
- package/lib/rpc/index.js +4 -20
- package/lib/rpc/index.js.map +1 -1
- package/lib/rpc/nonceQueuer.js +16 -20
- package/lib/rpc/nonceQueuer.js.map +1 -1
- package/lib/rpc/rpcHandler.js +76 -103
- package/lib/rpc/rpcHandler.js.map +1 -1
- package/lib/rpc/server.js +27 -58
- package/lib/rpc/server.js.map +1 -1
- package/lib/rpc/validation/BundlerCollectorTracerV06.js +1 -5
- package/lib/rpc/validation/BundlerCollectorTracerV06.js.map +1 -1
- package/lib/rpc/validation/BundlerCollectorTracerV07.js +1 -5
- package/lib/rpc/validation/BundlerCollectorTracerV07.js.map +1 -1
- package/lib/rpc/validation/SafeValidator.js +65 -69
- package/lib/rpc/validation/SafeValidator.js.map +1 -1
- package/lib/rpc/validation/TracerResultParserV06.js +26 -30
- package/lib/rpc/validation/TracerResultParserV06.js.map +1 -1
- package/lib/rpc/validation/TracerResultParserV07.js +29 -36
- package/lib/rpc/validation/TracerResultParserV07.js.map +1 -1
- package/lib/rpc/validation/UnsafeValidator.js +46 -73
- package/lib/rpc/validation/UnsafeValidator.js.map +1 -1
- package/lib/rpc/validation/index.js +2 -18
- package/lib/rpc/validation/index.js.map +1 -1
- package/lib/rpc/validation/tracer.js +7 -37
- package/lib/rpc/validation/tracer.js.map +1 -1
- package/lib/types/contracts/BundleBulker.js +1 -4
- package/lib/types/contracts/BundleBulker.js.map +1 -1
- package/lib/types/contracts/CallEngine.js +1 -4
- package/lib/types/contracts/CallEngine.js.map +1 -1
- package/lib/types/contracts/CodeHashGetter.js +2 -5
- package/lib/types/contracts/CodeHashGetter.js.map +1 -1
- package/lib/types/contracts/EntryPoint.js +4 -7
- package/lib/types/contracts/EntryPoint.js.map +1 -1
- package/lib/types/contracts/EntryPointSimulations.js +3 -6
- package/lib/types/contracts/EntryPointSimulations.js.map +1 -1
- package/lib/types/contracts/IOpInflator.js +1 -4
- package/lib/types/contracts/IOpInflator.js.map +1 -1
- package/lib/types/contracts/IPaymaster.js +1 -4
- package/lib/types/contracts/IPaymaster.js.map +1 -1
- package/lib/types/contracts/Inflator.js +1 -4
- package/lib/types/contracts/Inflator.js.map +1 -1
- package/lib/types/contracts/PerOpInflator.js +1 -4
- package/lib/types/contracts/PerOpInflator.js.map +1 -1
- package/lib/types/contracts/PimlicoEntryPointSimulations.js +2 -5
- package/lib/types/contracts/PimlicoEntryPointSimulations.js.map +1 -1
- package/lib/types/contracts/SenderCreator.js +2 -5
- package/lib/types/contracts/SenderCreator.js.map +1 -1
- package/lib/types/contracts/SimpleAccountFactory.js +2 -5
- package/lib/types/contracts/SimpleAccountFactory.js.map +1 -1
- package/lib/types/contracts/TestOpcodesAccount.js +2 -5
- package/lib/types/contracts/TestOpcodesAccount.js.map +1 -1
- package/lib/types/contracts/TestOpcodesAccountFactory.js +2 -5
- package/lib/types/contracts/TestOpcodesAccountFactory.js.map +1 -1
- package/lib/types/contracts/TestStorageAccount.js +2 -5
- package/lib/types/contracts/TestStorageAccount.js.map +1 -1
- package/lib/types/contracts/index.js +16 -32
- package/lib/types/contracts/index.js.map +1 -1
- package/lib/types/gasPrice.js +14 -17
- package/lib/types/gasPrice.js.map +1 -1
- package/lib/types/index.js +10 -26
- package/lib/types/index.js.map +1 -1
- package/lib/types/interfaces.js +1 -2
- package/lib/types/mempool.d.ts +1 -2
- package/lib/types/mempool.js +5 -10
- package/lib/types/mempool.js.map +1 -1
- package/lib/types/schemas.js +254 -284
- package/lib/types/schemas.js.map +1 -1
- package/lib/types/test/validationTestErrors.js +2 -5
- package/lib/types/test/validationTestErrors.js.map +1 -1
- package/lib/types/utils.js +5 -9
- package/lib/types/utils.js.map +1 -1
- package/lib/types/validation.js +139 -142
- package/lib/types/validation.js.map +1 -1
- package/lib/utils/bigInt.js +2 -7
- package/lib/utils/bigInt.js.map +1 -1
- package/lib/utils/compressionHandler.js +7 -11
- package/lib/utils/compressionHandler.js.map +1 -1
- package/lib/utils/gasPriceManager.js +30 -57
- package/lib/utils/gasPriceManager.js.map +1 -1
- package/lib/utils/helpers.js +5 -10
- package/lib/utils/helpers.js.map +1 -1
- package/lib/utils/index.js +9 -25
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/logger.js +10 -19
- package/lib/utils/logger.js.map +1 -1
- package/lib/utils/metrics.js +20 -24
- package/lib/utils/metrics.js.map +1 -1
- package/lib/utils/rpc-reply.js +1 -3
- package/lib/utils/rpc-reply.js.map +1 -1
- package/lib/utils/test.js +36 -67
- package/lib/utils/test.js.map +1 -1
- package/lib/utils/userop.js +62 -107
- package/lib/utils/userop.js.map +1 -1
- package/lib/utils/validation.js +64 -99
- package/lib/utils/validation.js.map +1 -1
- package/package.json +68 -70
- package/esm/cli/alto.d.ts +0 -6
- package/esm/cli/alto.js +0 -92
- package/esm/cli/alto.js.map +0 -1
- package/esm/cli/config/bundler.d.ts +0 -391
- package/esm/cli/config/bundler.js +0 -132
- package/esm/cli/config/bundler.js.map +0 -1
- package/esm/cli/config/index.d.ts +0 -3
- package/esm/cli/config/index.js +0 -3
- package/esm/cli/config/index.js.map +0 -1
- package/esm/cli/config/options.d.ts +0 -11
- package/esm/cli/config/options.js +0 -336
- package/esm/cli/config/options.js.map +0 -1
- package/esm/cli/customTransport.d.ts +0 -14
- package/esm/cli/customTransport.js +0 -53
- package/esm/cli/customTransport.js.map +0 -1
- package/esm/cli/handler.d.ts +0 -3
- package/esm/cli/handler.js +0 -116
- package/esm/cli/handler.js.map +0 -1
- package/esm/cli/index.d.ts +0 -4
- package/esm/cli/index.js +0 -4
- package/esm/cli/index.js.map +0 -1
- package/esm/cli/instrumentation.d.ts +0 -2
- package/esm/cli/instrumentation.js +0 -39
- package/esm/cli/instrumentation.js.map +0 -1
- package/esm/cli/setupServer.d.ts +0 -17
- package/esm/cli/setupServer.js +0 -155
- package/esm/cli/setupServer.js.map +0 -1
- package/esm/cli/util.d.ts +0 -22
- package/esm/cli/util.js +0 -30
- package/esm/cli/util.js.map +0 -1
- package/esm/executor/executor.d.ts +0 -54
- package/esm/executor/executor.js +0 -643
- package/esm/executor/executor.js.map +0 -1
- package/esm/executor/executorManager.d.ts +0 -34
- package/esm/executor/executorManager.js +0 -402
- package/esm/executor/executorManager.js.map +0 -1
- package/esm/executor/index.d.ts +0 -5
- package/esm/executor/index.js +0 -5
- package/esm/executor/index.js.map +0 -1
- package/esm/executor/senderManager.d.ts +0 -17
- package/esm/executor/senderManager.js +0 -160
- package/esm/executor/senderManager.js.map +0 -1
- 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/executor/utils.d.ts +0 -32
- package/esm/executor/utils.js +0 -241
- package/esm/executor/utils.js.map +0 -1
- package/esm/index.d.ts +0 -2
- package/esm/index.js +0 -2
- package/esm/index.js.map +0 -1
- package/esm/mempool/index.d.ts +0 -5
- package/esm/mempool/index.js +0 -5
- package/esm/mempool/index.js.map +0 -1
- package/esm/mempool/mempool.d.ts +0 -64
- package/esm/mempool/mempool.js +0 -489
- package/esm/mempool/mempool.js.map +0 -1
- package/esm/mempool/monitoring.d.ts +0 -10
- package/esm/mempool/monitoring.js +0 -34
- package/esm/mempool/monitoring.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/mempool/reputationManager.d.ts +0 -115
- package/esm/mempool/reputationManager.js +0 -397
- package/esm/mempool/reputationManager.js.map +0 -1
- package/esm/mempool/store.d.ts +0 -22
- package/esm/mempool/store.js +0 -123
- package/esm/mempool/store.js.map +0 -1
- package/esm/rpc/EntryPointSimulationsV07.d.ts +0 -58
- package/esm/rpc/EntryPointSimulationsV07.js +0 -407
- 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 -410
- package/esm/rpc/gasEstimation.js.map +0 -1
- package/esm/rpc/index.d.ts +0 -5
- package/esm/rpc/index.js +0 -5
- package/esm/rpc/index.js.map +0 -1
- package/esm/rpc/nonceQueuer.d.ts +0 -25
- package/esm/rpc/nonceQueuer.js +0 -135
- package/esm/rpc/nonceQueuer.js.map +0 -1
- package/esm/rpc/rpcHandler.d.ts +0 -64
- package/esm/rpc/rpcHandler.js +0 -727
- package/esm/rpc/rpcHandler.js.map +0 -1
- package/esm/rpc/server.d.ts +0 -31
- package/esm/rpc/server.js +0 -239
- package/esm/rpc/server.js.map +0 -1
- package/esm/rpc/validation/BundlerCollectorTracerV06.d.ts +0 -102
- package/esm/rpc/validation/BundlerCollectorTracerV06.js +0 -255
- package/esm/rpc/validation/BundlerCollectorTracerV06.js.map +0 -1
- package/esm/rpc/validation/BundlerCollectorTracerV07.d.ts +0 -102
- package/esm/rpc/validation/BundlerCollectorTracerV07.js +0 -254
- package/esm/rpc/validation/BundlerCollectorTracerV07.js.map +0 -1
- package/esm/rpc/validation/SafeValidator.d.ts +0 -35
- package/esm/rpc/validation/SafeValidator.js +0 -487
- package/esm/rpc/validation/SafeValidator.js.map +0 -1
- package/esm/rpc/validation/TracerResultParserV06.d.ts +0 -13
- package/esm/rpc/validation/TracerResultParserV06.js +0 -578
- package/esm/rpc/validation/TracerResultParserV06.js.map +0 -1
- package/esm/rpc/validation/TracerResultParserV07.d.ts +0 -33
- package/esm/rpc/validation/TracerResultParserV07.js +0 -557
- package/esm/rpc/validation/TracerResultParserV07.js.map +0 -1
- package/esm/rpc/validation/UnsafeValidator.d.ts +0 -63
- package/esm/rpc/validation/UnsafeValidator.js +0 -257
- package/esm/rpc/validation/UnsafeValidator.js.map +0 -1
- package/esm/rpc/validation/index.d.ts +0 -3
- package/esm/rpc/validation/index.js +0 -3
- package/esm/rpc/validation/index.js.map +0 -1
- package/esm/rpc/validation/tracer.d.ts +0 -122
- package/esm/rpc/validation/tracer.js +0 -82
- package/esm/rpc/validation/tracer.js.map +0 -1
- package/esm/types/contracts/BundleBulker.d.ts +0 -120
- package/esm/types/contracts/BundleBulker.js +0 -157
- package/esm/types/contracts/BundleBulker.js.map +0 -1
- package/esm/types/contracts/CallEngine.d.ts +0 -28
- package/esm/types/contracts/CallEngine.js +0 -37
- package/esm/types/contracts/CallEngine.js.map +0 -1
- package/esm/types/contracts/CodeHashGetter.d.ts +0 -37
- package/esm/types/contracts/CodeHashGetter.js +0 -45
- package/esm/types/contracts/CodeHashGetter.js.map +0 -1
- package/esm/types/contracts/EntryPoint.d.ts +0 -1789
- package/esm/types/contracts/EntryPoint.js +0 -2304
- package/esm/types/contracts/EntryPoint.js.map +0 -1
- package/esm/types/contracts/EntryPointSimulations.d.ts +0 -153
- package/esm/types/contracts/EntryPointSimulations.js +0 -15
- package/esm/types/contracts/EntryPointSimulations.js.map +0 -1
- package/esm/types/contracts/IOpInflator.d.ts +0 -61
- package/esm/types/contracts/IOpInflator.js +0 -80
- package/esm/types/contracts/IOpInflator.js.map +0 -1
- package/esm/types/contracts/IPaymaster.d.ts +0 -3
- package/esm/types/contracts/IPaymaster.js +0 -117
- package/esm/types/contracts/IPaymaster.js.map +0 -1
- package/esm/types/contracts/Inflator.d.ts +0 -65
- package/esm/types/contracts/Inflator.js +0 -84
- package/esm/types/contracts/Inflator.js.map +0 -1
- package/esm/types/contracts/PerOpInflator.d.ts +0 -176
- package/esm/types/contracts/PerOpInflator.js +0 -229
- package/esm/types/contracts/PerOpInflator.js.map +0 -1
- package/esm/types/contracts/PimlicoEntryPointSimulations.d.ts +0 -23
- package/esm/types/contracts/PimlicoEntryPointSimulations.js +0 -33
- package/esm/types/contracts/PimlicoEntryPointSimulations.js.map +0 -1
- package/esm/types/contracts/SenderCreator.d.ts +0 -4
- package/esm/types/contracts/SenderCreator.js +0 -23
- package/esm/types/contracts/SenderCreator.js.map +0 -1
- package/esm/types/contracts/SimpleAccountFactory.d.ts +0 -57
- package/esm/types/contracts/SimpleAccountFactory.js +0 -76
- package/esm/types/contracts/SimpleAccountFactory.js.map +0 -1
- package/esm/types/contracts/TestOpcodesAccount.d.ts +0 -4
- package/esm/types/contracts/TestOpcodesAccount.js +0 -281
- package/esm/types/contracts/TestOpcodesAccount.js.map +0 -1
- package/esm/types/contracts/TestOpcodesAccountFactory.d.ts +0 -4
- package/esm/types/contracts/TestOpcodesAccountFactory.js +0 -23
- package/esm/types/contracts/TestOpcodesAccountFactory.js.map +0 -1
- package/esm/types/contracts/TestStorageAccount.d.ts +0 -4
- package/esm/types/contracts/TestStorageAccount.js +0 -313
- package/esm/types/contracts/TestStorageAccount.js.map +0 -1
- package/esm/types/contracts/index.d.ts +0 -17
- package/esm/types/contracts/index.js +0 -17
- package/esm/types/contracts/index.js.map +0 -1
- package/esm/types/gasPrice.d.ts +0 -110
- package/esm/types/gasPrice.js +0 -52
- package/esm/types/gasPrice.js.map +0 -1
- package/esm/types/index.d.ts +0 -11
- package/esm/types/index.js +0 -11
- package/esm/types/index.js.map +0 -1
- package/esm/types/interfaces.d.ts +0 -26
- package/esm/types/interfaces.js +0 -2
- package/esm/types/interfaces.js.map +0 -1
- package/esm/types/mempool.d.ts +0 -79
- package/esm/types/mempool.js +0 -16
- package/esm/types/mempool.js.map +0 -1
- package/esm/types/schemas.d.ts +0 -4791
- package/esm/types/schemas.js +0 -497
- package/esm/types/schemas.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/types/utils.d.ts +0 -24
- package/esm/types/utils.js +0 -30
- package/esm/types/utils.js.map +0 -1
- package/esm/types/validation.d.ts +0 -14327
- package/esm/types/validation.js +0 -304
- package/esm/types/validation.js.map +0 -1
- package/esm/utils/bigInt.d.ts +0 -3
- package/esm/utils/bigInt.js +0 -9
- package/esm/utils/bigInt.js.map +0 -1
- package/esm/utils/compressionHandler.d.ts +0 -11
- package/esm/utils/compressionHandler.js +0 -39
- package/esm/utils/compressionHandler.js.map +0 -1
- package/esm/utils/gasPriceManager.d.ts +0 -34
- package/esm/utils/gasPriceManager.js +0 -338
- package/esm/utils/gasPriceManager.js.map +0 -1
- package/esm/utils/helpers.d.ts +0 -4
- package/esm/utils/helpers.js +0 -13
- package/esm/utils/helpers.js.map +0 -1
- package/esm/utils/index.d.ts +0 -11
- package/esm/utils/index.js +0 -10
- package/esm/utils/index.js.map +0 -1
- package/esm/utils/logger.d.ts +0 -6
- package/esm/utils/logger.js +0 -76
- package/esm/utils/logger.js.map +0 -1
- package/esm/utils/metrics.d.ts +0 -22
- package/esm/utils/metrics.js +0 -150
- package/esm/utils/metrics.js.map +0 -1
- package/esm/utils/rpc-reply.d.ts +0 -17
- package/esm/utils/rpc-reply.js +0 -41
- package/esm/utils/rpc-reply.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/esm/utils/userop.d.ts +0 -49
- package/esm/utils/userop.js +0 -408
- package/esm/utils/userop.js.map +0 -1
- package/esm/utils/validation.d.ts +0 -65
- package/esm/utils/validation.js +0 -461
- package/esm/utils/validation.js.map +0 -1
- package/lib/cli/alto.d.ts +0 -6
- package/lib/cli/alto.js +0 -123
- package/lib/cli/alto.js.map +0 -1
package/esm/rpc/gasEstimation.js
DELETED
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
import { EntryPointV06Abi, ExecutionErrors, RpcError, ValidationErrors, executionResultSchema, hexDataSchema, EntryPointV06SimulationsAbi, EntryPointV07SimulationsAbi, EntryPointV07Abi, targetCallResultSchema } from "../types/index.js";
|
|
2
|
-
import { deepHexlify, getUserOperationHash, isVersion06, toPackedUserOperation } from "../utils/index.js";
|
|
3
|
-
import { decodeErrorResult, encodeFunctionData, toHex, decodeAbiParameters, decodeFunctionResult, toFunctionSelector, toBytes, slice } from "viem";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import { ExecuteSimulatorDeployedBytecode } from "./ExecuteSimulator.js";
|
|
6
|
-
import { PimlicoEntryPointSimulationsAbi } from "../types/index.js";
|
|
7
|
-
function getStateOverrides({ userOperation, entryPoint, replacedEntryPoint, stateOverride = {} }) {
|
|
8
|
-
return replacedEntryPoint
|
|
9
|
-
? {
|
|
10
|
-
...stateOverride,
|
|
11
|
-
[userOperation.sender]: {
|
|
12
|
-
balance: toHex(100000000000000000000000n),
|
|
13
|
-
...(stateOverride
|
|
14
|
-
? deepHexlify(stateOverride?.[userOperation.sender])
|
|
15
|
-
: [])
|
|
16
|
-
},
|
|
17
|
-
[entryPoint]: {
|
|
18
|
-
code: ExecuteSimulatorDeployedBytecode
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
: {
|
|
22
|
-
...stateOverride,
|
|
23
|
-
[userOperation.sender]: {
|
|
24
|
-
balance: toHex(100000000000000000000000n),
|
|
25
|
-
...(stateOverride
|
|
26
|
-
? deepHexlify(stateOverride?.[userOperation.sender])
|
|
27
|
-
: [])
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export async function simulateHandleOpV06(userOperation, entryPoint, publicClient, targetAddress, targetCallData, finalParam = undefined, fixedGasLimitForEstimation) {
|
|
32
|
-
try {
|
|
33
|
-
await publicClient.request({
|
|
34
|
-
method: "eth_call",
|
|
35
|
-
params: [
|
|
36
|
-
{
|
|
37
|
-
to: entryPoint,
|
|
38
|
-
data: encodeFunctionData({
|
|
39
|
-
abi: EntryPointV06Abi,
|
|
40
|
-
functionName: "simulateHandleOp",
|
|
41
|
-
args: [userOperation, targetAddress, targetCallData]
|
|
42
|
-
}),
|
|
43
|
-
...(fixedGasLimitForEstimation !== undefined && {
|
|
44
|
-
gas: `0x${fixedGasLimitForEstimation.toString(16)}`
|
|
45
|
-
}),
|
|
46
|
-
},
|
|
47
|
-
"latest",
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
...(finalParam ? [finalParam] : [])
|
|
50
|
-
]
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
const err = e;
|
|
55
|
-
if (/return data out of bounds.*|EVM error OutOfOffset.*/.test(err.details)) {
|
|
56
|
-
// out of bound (low level evm error) occurs when paymaster reverts with less than 32bytes
|
|
57
|
-
return {
|
|
58
|
-
result: "failed",
|
|
59
|
-
data: "AA50 postOp revert (paymaster revert data out of bounds)"
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
const causeParseResult = z
|
|
63
|
-
.union([
|
|
64
|
-
z.object({
|
|
65
|
-
code: z.literal(3),
|
|
66
|
-
message: z.string().regex(/execution reverted.*/),
|
|
67
|
-
data: hexDataSchema
|
|
68
|
-
}),
|
|
69
|
-
/* fuse rpcs return weird values, this accounts for that. */
|
|
70
|
-
z.object({
|
|
71
|
-
code: z.number(),
|
|
72
|
-
message: z.string().regex(/VM execution error.*/),
|
|
73
|
-
data: z
|
|
74
|
-
.string()
|
|
75
|
-
.transform((data) => data.replace("Reverted ", ""))
|
|
76
|
-
.pipe(hexDataSchema)
|
|
77
|
-
})
|
|
78
|
-
])
|
|
79
|
-
.safeParse(err.cause);
|
|
80
|
-
if (!causeParseResult.success) {
|
|
81
|
-
throw new Error(JSON.stringify(err.cause));
|
|
82
|
-
}
|
|
83
|
-
const cause = causeParseResult.data;
|
|
84
|
-
if (cause.data === "0x") {
|
|
85
|
-
throw new RpcError("AA23 reverted: UserOperation called non-existant contract, or reverted with 0x", ValidationErrors.SimulateValidation);
|
|
86
|
-
}
|
|
87
|
-
const decodedError = decodeErrorResult({
|
|
88
|
-
abi: [...EntryPointV06Abi, ...EntryPointV06SimulationsAbi],
|
|
89
|
-
data: cause.data
|
|
90
|
-
});
|
|
91
|
-
if (decodedError &&
|
|
92
|
-
decodedError.errorName === "FailedOp" &&
|
|
93
|
-
decodedError.args) {
|
|
94
|
-
return {
|
|
95
|
-
result: "failed",
|
|
96
|
-
data: decodedError.args[1]
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
if (decodedError &&
|
|
100
|
-
decodedError.errorName === "Error" &&
|
|
101
|
-
decodedError.args) {
|
|
102
|
-
return {
|
|
103
|
-
result: "failed",
|
|
104
|
-
data: decodedError.args[0]
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
if (decodedError.errorName === "ExecutionResult") {
|
|
108
|
-
const parsedExecutionResult = executionResultSchema.parse(decodedError.args);
|
|
109
|
-
return {
|
|
110
|
-
result: "execution",
|
|
111
|
-
data: {
|
|
112
|
-
executionResult: parsedExecutionResult
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
throw new Error("Unexpected error");
|
|
118
|
-
}
|
|
119
|
-
async function callPimlicoEntryPointSimulations(publicClient, entryPoint, entryPointSimulationsCallData, entryPointSimulationsAddress, stateOverride, fixedGasLimitForEstimation) {
|
|
120
|
-
const callData = encodeFunctionData({
|
|
121
|
-
abi: PimlicoEntryPointSimulationsAbi,
|
|
122
|
-
functionName: "simulateEntryPoint",
|
|
123
|
-
args: [entryPoint, entryPointSimulationsCallData]
|
|
124
|
-
});
|
|
125
|
-
const result = (await publicClient.request({
|
|
126
|
-
method: "eth_call",
|
|
127
|
-
params: [
|
|
128
|
-
{
|
|
129
|
-
to: entryPointSimulationsAddress,
|
|
130
|
-
data: callData,
|
|
131
|
-
...(fixedGasLimitForEstimation !== undefined && {
|
|
132
|
-
gas: `0x${fixedGasLimitForEstimation.toString(16)}`
|
|
133
|
-
})
|
|
134
|
-
},
|
|
135
|
-
"latest",
|
|
136
|
-
// @ts-ignore
|
|
137
|
-
...(stateOverride ? [stateOverride] : [])
|
|
138
|
-
]
|
|
139
|
-
}));
|
|
140
|
-
const returnBytes = decodeAbiParameters([{ name: "ret", type: "bytes[]" }], result);
|
|
141
|
-
return returnBytes[0].map((data) => {
|
|
142
|
-
const decodedDelegateAndError = decodeErrorResult({
|
|
143
|
-
abi: EntryPointV07Abi,
|
|
144
|
-
data: data
|
|
145
|
-
});
|
|
146
|
-
if (!decodedDelegateAndError?.args?.[1]) {
|
|
147
|
-
throw new Error("Unexpected error");
|
|
148
|
-
}
|
|
149
|
-
return decodedDelegateAndError.args[1];
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
const panicCodes = {
|
|
153
|
-
// from https://docs.soliditylang.org/en/v0.8.0/control-structures.html
|
|
154
|
-
1: "assert(false)",
|
|
155
|
-
17: "arithmetic overflow/underflow",
|
|
156
|
-
18: "divide by zero",
|
|
157
|
-
33: "invalid enum value",
|
|
158
|
-
34: "storage byte array that is incorrectly encoded",
|
|
159
|
-
49: ".pop() on an empty array.",
|
|
160
|
-
50: "array sout-of-bounds or negative index",
|
|
161
|
-
65: "memory overflow",
|
|
162
|
-
81: "zero-initialized variable of internal function type"
|
|
163
|
-
};
|
|
164
|
-
export function parseFailedOpWithRevert(data) {
|
|
165
|
-
const methodSig = data.slice(0, 10);
|
|
166
|
-
const dataParams = `0x${data.slice(10)}`;
|
|
167
|
-
if (methodSig === "0x08c379a0") {
|
|
168
|
-
const [err] = decodeAbiParameters([
|
|
169
|
-
{
|
|
170
|
-
name: "err",
|
|
171
|
-
type: "string"
|
|
172
|
-
}
|
|
173
|
-
], dataParams);
|
|
174
|
-
return err;
|
|
175
|
-
}
|
|
176
|
-
if (methodSig === "0x4e487b71") {
|
|
177
|
-
const [code] = decodeAbiParameters([
|
|
178
|
-
{
|
|
179
|
-
name: "err",
|
|
180
|
-
type: "uint256"
|
|
181
|
-
}
|
|
182
|
-
], dataParams);
|
|
183
|
-
return panicCodes[Number(code)] ?? `${code}`;
|
|
184
|
-
}
|
|
185
|
-
return data;
|
|
186
|
-
}
|
|
187
|
-
function validateTargetCallDataResult(data) {
|
|
188
|
-
try {
|
|
189
|
-
const targetCallResult = decodeFunctionResult({
|
|
190
|
-
abi: EntryPointV07SimulationsAbi,
|
|
191
|
-
functionName: "simulateCallData",
|
|
192
|
-
data: data
|
|
193
|
-
});
|
|
194
|
-
const parsedTargetCallResult = targetCallResultSchema.parse(targetCallResult);
|
|
195
|
-
if (parsedTargetCallResult.success) {
|
|
196
|
-
return {
|
|
197
|
-
result: "success",
|
|
198
|
-
data: parsedTargetCallResult
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
return {
|
|
202
|
-
result: "failed",
|
|
203
|
-
data: parsedTargetCallResult.returnData,
|
|
204
|
-
code: ExecutionErrors.UserOperationReverted
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
catch (_e) {
|
|
208
|
-
// no error we go the result
|
|
209
|
-
return {
|
|
210
|
-
result: "failed",
|
|
211
|
-
data: "Unknown error, could not parse target call data result.",
|
|
212
|
-
code: ExecutionErrors.UserOperationReverted
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
function getSimulateHandleOpResult(data) {
|
|
217
|
-
try {
|
|
218
|
-
const decodedError = decodeErrorResult({
|
|
219
|
-
abi: EntryPointV07SimulationsAbi,
|
|
220
|
-
data: data
|
|
221
|
-
});
|
|
222
|
-
if (decodedError &&
|
|
223
|
-
decodedError.errorName === "FailedOp" &&
|
|
224
|
-
decodedError.args) {
|
|
225
|
-
return {
|
|
226
|
-
result: "failed",
|
|
227
|
-
data: decodedError.args[1],
|
|
228
|
-
code: ValidationErrors.SimulateValidation
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
if (decodedError &&
|
|
232
|
-
decodedError.errorName === "FailedOpWithRevert" &&
|
|
233
|
-
decodedError.args) {
|
|
234
|
-
return {
|
|
235
|
-
result: "failed",
|
|
236
|
-
data: parseFailedOpWithRevert(decodedError.args?.[2]),
|
|
237
|
-
code: ValidationErrors.SimulateValidation
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
catch {
|
|
242
|
-
// no error we go the result
|
|
243
|
-
const decodedResult = decodeFunctionResult({
|
|
244
|
-
abi: EntryPointV07SimulationsAbi,
|
|
245
|
-
functionName: "simulateHandleOp",
|
|
246
|
-
data
|
|
247
|
-
});
|
|
248
|
-
return {
|
|
249
|
-
result: "execution",
|
|
250
|
-
data: {
|
|
251
|
-
executionResult: decodedResult
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
throw new Error("Unexpected error");
|
|
256
|
-
}
|
|
257
|
-
export async function simulateHandleOpV07(userOperation, queuedUserOperations, entryPoint, publicClient, entryPointSimulationsAddress, chainId, finalParam = undefined, fixedGasLimitForEstimation) {
|
|
258
|
-
const userOperations = [...queuedUserOperations, userOperation];
|
|
259
|
-
const packedUserOperations = userOperations.map((uop) => ({
|
|
260
|
-
packedUserOperation: toPackedUserOperation(uop),
|
|
261
|
-
userOperation: uop,
|
|
262
|
-
userOperationHash: getUserOperationHash(uop, entryPoint, chainId)
|
|
263
|
-
}));
|
|
264
|
-
const entryPointSimulationsSimulateHandleOpCallData = encodeFunctionData({
|
|
265
|
-
abi: EntryPointV07SimulationsAbi,
|
|
266
|
-
functionName: "simulateHandleOpLast",
|
|
267
|
-
args: [packedUserOperations.map((uop) => uop.packedUserOperation)]
|
|
268
|
-
});
|
|
269
|
-
const entryPointSimulationsSimulateTargetCallData = encodeFunctionData({
|
|
270
|
-
abi: EntryPointV07SimulationsAbi,
|
|
271
|
-
functionName: "simulateCallDataLast",
|
|
272
|
-
args: [
|
|
273
|
-
packedUserOperations.map((uop) => uop.packedUserOperation),
|
|
274
|
-
packedUserOperations.map((packedUserOperation) => packedUserOperation.userOperation.sender),
|
|
275
|
-
packedUserOperations.map((packedUserOperation) => {
|
|
276
|
-
const executeUserOpAbi = [
|
|
277
|
-
{
|
|
278
|
-
inputs: [
|
|
279
|
-
{
|
|
280
|
-
components: [
|
|
281
|
-
{
|
|
282
|
-
internalType: "address",
|
|
283
|
-
name: "sender",
|
|
284
|
-
type: "address"
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
internalType: "uint256",
|
|
288
|
-
name: "nonce",
|
|
289
|
-
type: "uint256"
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
internalType: "bytes",
|
|
293
|
-
name: "initCode",
|
|
294
|
-
type: "bytes"
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
internalType: "bytes",
|
|
298
|
-
name: "callData",
|
|
299
|
-
type: "bytes"
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
internalType: "bytes32",
|
|
303
|
-
name: "accountGasLimits",
|
|
304
|
-
type: "bytes32"
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
internalType: "uint256",
|
|
308
|
-
name: "preVerificationGas",
|
|
309
|
-
type: "uint256"
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
internalType: "bytes32",
|
|
313
|
-
name: "gasFees",
|
|
314
|
-
type: "bytes32"
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
internalType: "bytes",
|
|
318
|
-
name: "paymasterAndData",
|
|
319
|
-
type: "bytes"
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
internalType: "bytes",
|
|
323
|
-
name: "signature",
|
|
324
|
-
type: "bytes"
|
|
325
|
-
}
|
|
326
|
-
],
|
|
327
|
-
internalType: "struct PackedUserOperation",
|
|
328
|
-
name: "userOp",
|
|
329
|
-
type: "tuple"
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
internalType: "bytes32",
|
|
333
|
-
name: "userOpHash",
|
|
334
|
-
type: "bytes32"
|
|
335
|
-
}
|
|
336
|
-
],
|
|
337
|
-
name: "executeUserOp",
|
|
338
|
-
outputs: [],
|
|
339
|
-
stateMutability: "nonpayable",
|
|
340
|
-
type: "function"
|
|
341
|
-
}
|
|
342
|
-
];
|
|
343
|
-
const executeUserOpMethodSig = toFunctionSelector(executeUserOpAbi[0]);
|
|
344
|
-
const callDataMethodSig = toHex(slice(toBytes(packedUserOperation.userOperation.callData), 0, 4));
|
|
345
|
-
if (executeUserOpMethodSig === callDataMethodSig) {
|
|
346
|
-
return encodeFunctionData({
|
|
347
|
-
abi: executeUserOpAbi,
|
|
348
|
-
functionName: "executeUserOp",
|
|
349
|
-
args: [
|
|
350
|
-
packedUserOperation.packedUserOperation,
|
|
351
|
-
getUserOperationHash(packedUserOperation.userOperation, entryPoint, chainId)
|
|
352
|
-
]
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
return packedUserOperation.userOperation.callData;
|
|
356
|
-
})
|
|
357
|
-
]
|
|
358
|
-
});
|
|
359
|
-
const cause = await callPimlicoEntryPointSimulations(publicClient, entryPoint, [
|
|
360
|
-
entryPointSimulationsSimulateHandleOpCallData,
|
|
361
|
-
entryPointSimulationsSimulateTargetCallData
|
|
362
|
-
], entryPointSimulationsAddress, finalParam, fixedGasLimitForEstimation);
|
|
363
|
-
try {
|
|
364
|
-
const executionResult = getSimulateHandleOpResult(cause[0]);
|
|
365
|
-
if (executionResult.result === "failed") {
|
|
366
|
-
return executionResult;
|
|
367
|
-
}
|
|
368
|
-
const targetCallValidationResult = validateTargetCallDataResult(cause[1]);
|
|
369
|
-
if (targetCallValidationResult.result === "failed") {
|
|
370
|
-
return targetCallValidationResult;
|
|
371
|
-
}
|
|
372
|
-
return {
|
|
373
|
-
result: "execution",
|
|
374
|
-
data: {
|
|
375
|
-
callDataResult: targetCallValidationResult.data,
|
|
376
|
-
executionResult: executionResult.data.executionResult
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
catch (e) {
|
|
381
|
-
return {
|
|
382
|
-
result: "failed",
|
|
383
|
-
data: "Unknown error, could not parse simulate handle op result.",
|
|
384
|
-
code: ValidationErrors.SimulateValidation
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
export function simulateHandleOp(userOperation, queuedUserOperations, entryPoint, publicClient, replacedEntryPoint, targetAddress, targetCallData, balanceOverrideEnabled, chainId, stateOverride = {}, entryPointSimulationsAddress, fixedGasLimitForEstimation) {
|
|
389
|
-
let finalStateOverride = undefined;
|
|
390
|
-
if (balanceOverrideEnabled) {
|
|
391
|
-
finalStateOverride = getStateOverrides({
|
|
392
|
-
userOperation,
|
|
393
|
-
entryPoint,
|
|
394
|
-
replacedEntryPoint,
|
|
395
|
-
stateOverride
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
if (isVersion06(userOperation)) {
|
|
399
|
-
return simulateHandleOpV06(userOperation, entryPoint, publicClient, targetAddress, targetCallData, finalStateOverride,
|
|
400
|
-
// Enable fixed gas limit for estimation only for Vanguard testnet and Vanar mainnet
|
|
401
|
-
chainId === 2040 || chainId === 78600 ? fixedGasLimitForEstimation : undefined);
|
|
402
|
-
}
|
|
403
|
-
if (!entryPointSimulationsAddress) {
|
|
404
|
-
throw new RpcError("entryPointSimulationsAddress must be provided for V07 UserOperation", ValidationErrors.InvalidFields);
|
|
405
|
-
}
|
|
406
|
-
return simulateHandleOpV07(userOperation, queuedUserOperations, entryPoint, publicClient, entryPointSimulationsAddress, chainId, finalStateOverride,
|
|
407
|
-
// Enable fixed gas limit for estimation only for Vanguard testnet and Vanar mainnet
|
|
408
|
-
chainId === 2040 || chainId === 78600 ? fixedGasLimitForEstimation : undefined);
|
|
409
|
-
}
|
|
410
|
-
//# sourceMappingURL=gasEstimation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gasEstimation.js","sourceRoot":"","sources":["../../rpc/gasEstimation.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAChB,eAAe,EAEf,QAAQ,EAER,gBAAgB,EAChB,qBAAqB,EACrB,aAAa,EACb,2BAA2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AC,0BAA0B,CAAC,CAAC,CAAC,SAAS,CAChF,CAAA;IACL,CAAC;IAED,IAAI,CAAC,4BAA4B,EAAE,CAAC;QAChC,MAAM,IAAI,QAAQ,CACd,qEAAqE,EACrE,gBAAgB,CAAC,aAAa,CACjC,CAAA;IACL,CAAC;IAED,OAAO,mBAAmB,CACtB,aAAa,EACb,oBAA0C,EAC1C,UAAU,EACV,YAAY,EACZ,4BAA4B,EAC5B,OAAO,EACP,kBAAkB;IAClB,oFAAoF;IACpF,OAAO,KAAK,IAAI,IAAI,OAAO,KAAI,KAAK,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,SAAS,CAChF,CAAA;AACL,CAAC"}
|
package/esm/rpc/index.d.ts
DELETED
package/esm/rpc/index.js
DELETED
package/esm/rpc/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../rpc/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA"}
|
package/esm/rpc/nonceQueuer.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { type MempoolUserOperation } from "../types/index.js";
|
|
2
|
-
import type { Logger } from "../utils/index.js";
|
|
3
|
-
import { type Address, type Chain, type Hash, type PublicClient, type Transport } from "viem";
|
|
4
|
-
import type { MemoryMempool } from "../mempool/index.js";
|
|
5
|
-
type QueuedUserOperation = {
|
|
6
|
-
entryPoint: Address;
|
|
7
|
-
userOperationHash: Hash;
|
|
8
|
-
mempoolUserOperation: MempoolUserOperation;
|
|
9
|
-
nonceKey: bigint;
|
|
10
|
-
nonceValue: bigint;
|
|
11
|
-
addedAt: number;
|
|
12
|
-
};
|
|
13
|
-
export declare class NonceQueuer {
|
|
14
|
-
queuedUserOperations: QueuedUserOperation[];
|
|
15
|
-
mempool: MemoryMempool;
|
|
16
|
-
publicClient: PublicClient<Transport, Chain>;
|
|
17
|
-
logger: Logger;
|
|
18
|
-
constructor(mempool: MemoryMempool, publicClient: PublicClient<Transport, Chain>, logger: Logger);
|
|
19
|
-
process(): Promise<void>;
|
|
20
|
-
add(mempoolUserOperation: MempoolUserOperation, entryPoint: Address): void;
|
|
21
|
-
resubmitUserOperation(mempoolUserOperation: MempoolUserOperation, entryPoint: Address): void;
|
|
22
|
-
getAvailableUserOperations(publicClient: PublicClient): Promise<QueuedUserOperation[]>;
|
|
23
|
-
}
|
|
24
|
-
export {};
|
|
25
|
-
//# sourceMappingURL=nonceQueuer.d.ts.map
|
package/esm/rpc/nonceQueuer.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { EntryPointV06Abi, deriveUserOperation, EntryPointV07Abi } from "../types/index.js";
|
|
2
|
-
import { getNonceKeyAndValue, getUserOperationHash, isVersion06 } from "../utils/index.js";
|
|
3
|
-
import { getContract } from "viem";
|
|
4
|
-
export class NonceQueuer {
|
|
5
|
-
queuedUserOperations = [];
|
|
6
|
-
mempool;
|
|
7
|
-
publicClient;
|
|
8
|
-
logger;
|
|
9
|
-
constructor(mempool, publicClient, logger) {
|
|
10
|
-
this.mempool = mempool;
|
|
11
|
-
this.publicClient = publicClient;
|
|
12
|
-
this.logger = logger;
|
|
13
|
-
setInterval(() => {
|
|
14
|
-
this.process();
|
|
15
|
-
}, 2000);
|
|
16
|
-
}
|
|
17
|
-
async process() {
|
|
18
|
-
// remove queued ops that have been in the queue for more than 15 minutes
|
|
19
|
-
this.queuedUserOperations = this.queuedUserOperations.filter((qop) => {
|
|
20
|
-
return qop.addedAt > Date.now() - 1000 * 60 * 15;
|
|
21
|
-
});
|
|
22
|
-
if (this.queuedUserOperations.length === 0) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const availableOps = await this.getAvailableUserOperations(this.publicClient);
|
|
26
|
-
if (availableOps.length === 0) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
this.queuedUserOperations = this.queuedUserOperations.filter((qop) => {
|
|
30
|
-
return !availableOps.some((op) => {
|
|
31
|
-
return op.userOperationHash === qop.userOperationHash;
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
availableOps.map((op) => {
|
|
35
|
-
this.resubmitUserOperation(op.mempoolUserOperation, op.entryPoint);
|
|
36
|
-
});
|
|
37
|
-
this.logger.info({ availableOps: availableOps.map((qop) => qop.userOperationHash) }, "submitted user operations from nonce queue");
|
|
38
|
-
}
|
|
39
|
-
add(mempoolUserOperation, entryPoint) {
|
|
40
|
-
const userOperation = deriveUserOperation(mempoolUserOperation);
|
|
41
|
-
const [nonceKey, nonceValue] = getNonceKeyAndValue(userOperation.nonce);
|
|
42
|
-
this.queuedUserOperations.push({
|
|
43
|
-
entryPoint,
|
|
44
|
-
userOperationHash: getUserOperationHash(deriveUserOperation(mempoolUserOperation), entryPoint, this.publicClient.chain.id),
|
|
45
|
-
mempoolUserOperation: mempoolUserOperation,
|
|
46
|
-
nonceKey: nonceKey,
|
|
47
|
-
nonceValue: nonceValue,
|
|
48
|
-
addedAt: Date.now()
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
resubmitUserOperation(mempoolUserOperation, entryPoint) {
|
|
52
|
-
const userOperation = mempoolUserOperation;
|
|
53
|
-
this.logger.info({ userOperation: userOperation }, "submitting user operation from nonce queue");
|
|
54
|
-
const result = this.mempool.add(mempoolUserOperation, entryPoint);
|
|
55
|
-
if (result) {
|
|
56
|
-
this.logger.info({ userOperation: userOperation, result: result }, "added user operation");
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
this.logger.error("error adding user operation");
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
async getAvailableUserOperations(publicClient) {
|
|
63
|
-
const queuedUserOperations = this.queuedUserOperations.slice();
|
|
64
|
-
let results;
|
|
65
|
-
try {
|
|
66
|
-
results = await publicClient.multicall({
|
|
67
|
-
contracts: queuedUserOperations.map((qop) => {
|
|
68
|
-
const userOperation = deriveUserOperation(qop.mempoolUserOperation);
|
|
69
|
-
const isUserOpV06 = isVersion06(userOperation);
|
|
70
|
-
return {
|
|
71
|
-
address: qop.entryPoint,
|
|
72
|
-
abi: isUserOpV06 ? EntryPointV06Abi : EntryPointV07Abi,
|
|
73
|
-
functionName: "getNonce",
|
|
74
|
-
args: [userOperation.sender, qop.nonceKey]
|
|
75
|
-
};
|
|
76
|
-
}),
|
|
77
|
-
blockTag: "latest"
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
catch (error) {
|
|
81
|
-
this.logger.error({ error: JSON.stringify(error) }, "error fetching with multiCall");
|
|
82
|
-
results = await Promise.all(queuedUserOperations.map(async (qop) => {
|
|
83
|
-
const userOperation = deriveUserOperation(qop.mempoolUserOperation);
|
|
84
|
-
try {
|
|
85
|
-
const isUserOpV06 = isVersion06(userOperation);
|
|
86
|
-
const entryPointContract = isUserOpV06
|
|
87
|
-
? getContract({
|
|
88
|
-
abi: EntryPointV06Abi,
|
|
89
|
-
address: qop.entryPoint,
|
|
90
|
-
client: {
|
|
91
|
-
public: publicClient
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
: getContract({
|
|
95
|
-
abi: EntryPointV07Abi,
|
|
96
|
-
address: qop.entryPoint,
|
|
97
|
-
client: {
|
|
98
|
-
public: publicClient
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
const nonce = await entryPointContract.read.getNonce([userOperation.sender, qop.nonceKey], { blockTag: "latest" });
|
|
102
|
-
return {
|
|
103
|
-
result: nonce,
|
|
104
|
-
status: "success"
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
catch (e) {
|
|
108
|
-
return {
|
|
109
|
-
error: e,
|
|
110
|
-
status: "failure"
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
}));
|
|
114
|
-
}
|
|
115
|
-
if (results.length !== queuedUserOperations.length) {
|
|
116
|
-
this.logger.error("error fetching nonces");
|
|
117
|
-
return [];
|
|
118
|
-
}
|
|
119
|
-
const currentOutstandingOps = [];
|
|
120
|
-
for (let i = 0; i < queuedUserOperations.length; i++) {
|
|
121
|
-
const qop = queuedUserOperations[i];
|
|
122
|
-
const result = results[i];
|
|
123
|
-
if (result.status !== "success") {
|
|
124
|
-
this.logger.error({ error: result.error }, "error fetching nonce");
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
const onchainNonceValue = result.result;
|
|
128
|
-
if (onchainNonceValue === qop.nonceValue) {
|
|
129
|
-
currentOutstandingOps.push(qop);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return currentOutstandingOps;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
//# sourceMappingURL=nonceQueuer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nonceQueuer.js","sourceRoot":"","sources":["../../rpc/nonceQueuer.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAEhB,mBAAmB,EACnB,gBAAgB,EACnB,MAAM,aAAa,CAAA;AAEpB,OAAO,EACH,mBAAmB,EACnB,oBAAoB,EACpB,WAAW,EACd,MAAM,aAAa,CAAA;AACpB,OAAO,EAOH,WAAW,EACd,MAAM,MAAM,CAAA;AAYb,MAAM,OAAO,WAAW;IACpB,oBAAoB,GAA0B,EAAE,CAAA;IAEhD,OAAO,CAAe;IACtB,YAAY,CAAgC;IAC5C,MAAM,CAAQ;IAEd,YACI,OAAsB,EACtB,YAA4C,EAC5C,MAAc;QAEd,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QAEpB,WAAW,CAAC,GAAG,EAAE;YACb,IAAI,CAAC,OAAO,EAAE,CAAA;QAClB,CAAC,EAAE,IAAI,CAAC,CAAA;IACZ,CAAC;IAED,KAAK,CAAC,OAAO;QACT,yEAAyE;QACzE,IAAI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