@pimlico/alto 0.0.19 → 0.0.21
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/contracts/EIP712.sol/EIP712.json +1 -1
- package/contracts/ERC165.sol/ERC165.json +1 -1
- package/contracts/ERC20.sol/ERC20.json +1 -1
- package/contracts/Eip7702Support.sol/Eip7702Support.json +1 -1
- package/contracts/EntryPoint.sol/EntryPoint.json +1 -1
- package/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride06.json +1 -1
- package/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride07.json +1 -1
- package/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride08.json +1 -1
- package/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride09.json +1 -0
- package/contracts/EntryPointGasEstimationOverride.sol/EntryPointGasEstimationOverride06.json +1 -1
- package/contracts/EntryPointSimulations.sol/EntryPointSimulations07.json +1 -1
- package/contracts/EntryPointSimulations.sol/EntryPointSimulations08.json +1 -1
- package/contracts/EntryPointSimulations.sol/EntryPointSimulations09.json +1 -0
- package/contracts/Exec.sol/Exec.json +1 -1
- package/contracts/IAccount.sol/IAccount.json +1 -1
- package/contracts/IAccountExecute.sol/IAccountExecute.json +1 -1
- package/contracts/IAggregator.sol/IAggregator.json +1 -1
- package/contracts/IERC165.sol/IERC165.json +1 -1
- package/contracts/IERC5267.sol/IERC5267.json +1 -1
- package/contracts/IEntryPoint.sol/IEntryPoint.json +1 -1
- package/contracts/IEntryPointFilterOpsOverride.sol/IEntryPointFilterOpsOverride08.json +1 -0
- package/contracts/IEntryPointFilterOpsOverride.sol/IEntryPointFilterOpsOverride09.json +1 -0
- package/contracts/IEntryPointSimulations.sol/IEntryPointSimulations.json +1 -1
- package/contracts/INonceManager.sol/INonceManager.json +1 -1
- package/contracts/IPaymaster.sol/IPaymaster.json +1 -1
- package/contracts/ISenderCreator.sol/ISenderCreator.json +1 -1
- package/contracts/IStakeManager.sol/IStakeManager.json +1 -1
- package/contracts/LibBytes.sol/LibBytes.json +1 -1
- package/contracts/Math.sol/Math.json +1 -1
- package/contracts/MessageHashUtils.sol/MessageHashUtils.json +1 -1
- package/contracts/NonceManager.sol/NonceManager.json +1 -1
- package/contracts/Panic.sol/Panic.json +1 -1
- package/contracts/PimlicoSimulations.sol/PimlicoSimulations.json +1 -1
- package/contracts/ReentrancyGuard.sol/ReentrancyGuard.json +1 -1
- package/contracts/ReentrancyGuardTransient.sol/ReentrancyGuardTransient.json +1 -1
- package/contracts/SafeCast.sol/SafeCast.json +1 -1
- package/contracts/SenderCreator.sol/SenderCreator.json +1 -1
- package/contracts/ShortStrings.sol/ShortStrings.json +1 -1
- package/contracts/SignedMath.sol/SignedMath.json +1 -1
- package/contracts/SimulationOverrideHelper.sol/SimulationOverrideHelper.json +1 -0
- package/contracts/StakeManager.sol/StakeManager.json +1 -1
- package/contracts/StorageSlot.sol/StorageSlot.json +1 -1
- package/contracts/Strings.sol/Strings.json +1 -1
- package/contracts/TransientSlot.sol/TransientSlot.json +1 -1
- package/contracts/UserOperation.sol/UserOperationLib.json +1 -1
- package/contracts/UserOperationLib.sol/UserOperationLib.json +1 -1
- package/contracts/account-abstraction-v9/contracts/interfaces/IAggregator.sol/IAggregator.json +1 -0
- package/contracts/account-abstraction-v9/contracts/interfaces/IEntryPoint.sol/IEntryPoint.json +1 -0
- package/contracts/account-abstraction-v9/contracts/interfaces/INonceManager.sol/INonceManager.json +1 -0
- package/contracts/account-abstraction-v9/contracts/interfaces/IStakeManager.sol/IStakeManager.json +1 -0
- package/contracts/build-info/{880955d5786bfdae.json → 031b289b93191224.json} +1 -1
- package/contracts/build-info/181f3522c3744403.json +1 -0
- package/contracts/build-info/a2db592afab5c9de.json +1 -0
- package/contracts/contracts/interfaces/IAggregator.sol/IAggregator.json +1 -1
- package/contracts/contracts/interfaces/IEntryPoint.sol/IEntryPoint.json +1 -1
- package/contracts/contracts/interfaces/INonceManager.sol/INonceManager.json +1 -1
- package/contracts/contracts/interfaces/IStakeManager.sol/IStakeManager.json +1 -1
- package/contracts/core/Eip7702Support.sol/Eip7702Support.json +1 -0
- package/contracts/core/NonceManager.sol/NonceManager.json +1 -0
- package/contracts/core/SenderCreator.sol/SenderCreator.json +1 -0
- package/contracts/core/StakeManager.sol/StakeManager.json +1 -0
- package/contracts/core/UserOperationLib.sol/UserOperationLib.json +1 -0
- package/contracts/interfaces/IAccount.sol/IAccount.json +1 -0
- package/contracts/interfaces/IAccountExecute.sol/IAccountExecute.json +1 -0
- package/contracts/interfaces/IAggregator.sol/IAggregator.json +1 -1
- package/contracts/interfaces/IEntryPoint.sol/IEntryPoint.json +1 -1
- package/contracts/interfaces/INonceManager.sol/INonceManager.json +1 -1
- package/contracts/interfaces/IPaymaster.sol/IPaymaster.json +1 -0
- package/contracts/interfaces/ISenderCreator.sol/ISenderCreator.json +1 -0
- package/contracts/interfaces/IStakeManager.sol/IStakeManager.json +1 -1
- package/contracts/overrides/Eip7702Support.sol/Eip7702Support.json +1 -0
- package/contracts/overrides/NonceManager.sol/NonceManager.json +1 -0
- package/contracts/overrides/SenderCreator.sol/SenderCreator.json +1 -0
- package/contracts/overrides/StakeManager.sol/StakeManager.json +1 -0
- package/contracts/overrides/UserOperationLib.sol/UserOperationLib.json +1 -0
- package/contracts/utils/Exec.sol/Exec.json +1 -1
- package/contracts/utils/StorageSlot.sol/StorageSlot.json +1 -0
- package/contracts/v09/EntryPoint.sol/EntryPoint.json +1 -0
- package/esm/cli/alto.js +17 -6
- package/esm/cli/alto.js.map +1 -1
- package/esm/cli/config/bundler.d.ts +459 -321
- package/esm/cli/config/bundler.js +125 -91
- package/esm/cli/config/bundler.js.map +1 -1
- package/esm/cli/config/options.d.ts +4 -1
- package/esm/cli/config/options.js +233 -106
- package/esm/cli/config/options.js.map +1 -1
- package/esm/cli/customTransport.d.ts +3 -3
- package/esm/cli/deploySimulationsContract.d.ts +1 -0
- package/esm/cli/deploySimulationsContract.js +41 -5
- package/esm/cli/deploySimulationsContract.js.map +1 -1
- package/esm/cli/handler.js +76 -80
- package/esm/cli/handler.js.map +1 -1
- package/esm/cli/multiRpcTransport.d.ts +7 -0
- package/esm/cli/multiRpcTransport.js +52 -0
- package/esm/cli/multiRpcTransport.js.map +1 -0
- package/esm/cli/setupServer.js +92 -70
- package/esm/cli/setupServer.js.map +1 -1
- package/esm/cli/shutDown.d.ts +20 -0
- package/esm/cli/shutDown.js +285 -0
- package/esm/cli/shutDown.js.map +1 -0
- package/esm/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride06.json +1 -1
- package/esm/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride07.json +1 -1
- package/esm/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride08.json +1 -1
- package/esm/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride09.json +1 -0
- package/esm/contracts/EntryPointGasEstimationOverride.sol/EntryPointGasEstimationOverride06.json +1 -1
- package/esm/contracts/EntryPointSimulations.sol/EntryPointSimulations07.json +1 -1
- package/esm/contracts/EntryPointSimulations.sol/EntryPointSimulations08.json +1 -1
- package/esm/contracts/EntryPointSimulations.sol/EntryPointSimulations09.json +1 -0
- package/esm/contracts/PimlicoSimulations.sol/PimlicoSimulations.json +1 -1
- package/esm/createConfig.d.ts +9 -2
- package/esm/createConfig.js.map +1 -1
- package/esm/executor/{userOpMonitor.d.ts → bundleManager.d.ts} +56 -37
- package/esm/executor/bundleManager.js +393 -0
- package/esm/executor/bundleManager.js.map +1 -0
- package/esm/executor/executor.d.ts +4 -3
- package/esm/executor/executor.js +47 -23
- package/esm/executor/executor.js.map +1 -1
- package/esm/executor/executorManager.d.ts +20 -15
- package/esm/executor/executorManager.js +248 -67
- package/esm/executor/executorManager.js.map +1 -1
- package/esm/executor/filterOpsAndEstimateGas.d.ts +17 -2
- package/esm/executor/filterOpsAndEstimateGas.js +100 -77
- package/esm/executor/filterOpsAndEstimateGas.js.map +1 -1
- package/esm/executor/getBundleStatus.d.ts +5 -1
- package/esm/executor/getBundleStatus.js.map +1 -1
- package/esm/executor/index.d.ts +1 -0
- package/esm/executor/index.js +1 -0
- package/esm/executor/index.js.map +1 -1
- package/esm/executor/senderManager/createMemorySenderManager.js +13 -0
- package/esm/executor/senderManager/createMemorySenderManager.js.map +1 -1
- package/esm/executor/senderManager/createRedisSenderManager.d.ts +2 -1
- package/esm/executor/senderManager/createRedisSenderManager.js +45 -26
- package/esm/executor/senderManager/createRedisSenderManager.js.map +1 -1
- package/esm/executor/senderManager/flushOnStartUp.js +7 -5
- package/esm/executor/senderManager/flushOnStartUp.js.map +1 -1
- package/esm/executor/senderManager/index.d.ts +1 -0
- package/esm/executor/senderManager/index.js +6 -2
- package/esm/executor/senderManager/index.js.map +1 -1
- package/esm/executor/senderManager/validateAndRefill.js +268 -85
- package/esm/executor/senderManager/validateAndRefill.js.map +1 -1
- package/esm/executor/utils.d.ts +8 -3
- package/esm/executor/utils.js +59 -27
- package/esm/executor/utils.js.map +1 -1
- package/esm/handlers/arbitrumGasPriceManager.d.ts +3 -2
- package/esm/handlers/arbitrumGasPriceManager.js +6 -2
- package/esm/handlers/arbitrumGasPriceManager.js.map +1 -1
- package/esm/handlers/citreaManager.d.ts +10 -0
- package/esm/handlers/citreaManager.js +17 -0
- package/esm/handlers/citreaManager.js.map +1 -0
- package/esm/handlers/eventManager.d.ts +9 -9
- package/esm/handlers/eventManager.js +59 -60
- package/esm/handlers/eventManager.js.map +1 -1
- package/esm/handlers/gasPriceManager.d.ts +17 -10
- package/esm/handlers/gasPriceManager.js +245 -99
- package/esm/handlers/gasPriceManager.js.map +1 -1
- package/esm/handlers/mantleGasPriceManager.d.ts +4 -4
- package/esm/handlers/mantleGasPriceManager.js +4 -4
- package/esm/handlers/mantleGasPriceManager.js.map +1 -1
- package/esm/handlers/optimismManager.d.ts +1 -1
- package/esm/handlers/optimismManager.js +1 -1
- package/esm/handlers/optimismManager.js.map +1 -1
- package/esm/mempool/index.d.ts +1 -1
- package/esm/mempool/index.js +1 -1
- package/esm/mempool/index.js.map +1 -1
- package/esm/mempool/mempool.d.ts +61 -22
- package/esm/mempool/mempool.js +223 -133
- package/esm/mempool/mempool.js.map +1 -1
- package/esm/mempool/reputationManager.d.ts +14 -14
- package/esm/mempool/reputationManager.js +36 -39
- package/esm/mempool/reputationManager.js.map +1 -1
- package/esm/mempool/statusManager.d.ts +20 -0
- package/esm/mempool/statusManager.js +143 -0
- package/esm/mempool/statusManager.js.map +1 -0
- package/esm/receiptCache/createMemoryReceiptCache.d.ts +3 -0
- package/esm/receiptCache/createMemoryReceiptCache.js +30 -0
- package/esm/receiptCache/createMemoryReceiptCache.js.map +1 -0
- package/esm/receiptCache/createRedisReceiptCache.d.ts +10 -0
- package/esm/receiptCache/createRedisReceiptCache.js +56 -0
- package/esm/receiptCache/createRedisReceiptCache.js.map +1 -0
- package/esm/receiptCache/index.d.ts +11 -0
- package/esm/receiptCache/index.js +21 -0
- package/esm/receiptCache/index.js.map +1 -0
- package/esm/rpc/createMethodHandler.js.map +1 -1
- package/esm/rpc/estimation/gasEstimationHandler.d.ts +2 -4
- package/esm/rpc/estimation/gasEstimationHandler.js.map +1 -1
- package/esm/rpc/estimation/gasEstimations06.d.ts +6 -7
- package/esm/rpc/estimation/gasEstimations06.js +1 -5
- package/esm/rpc/estimation/gasEstimations06.js.map +1 -1
- package/esm/rpc/estimation/gasEstimations07.d.ts +13 -41
- package/esm/rpc/estimation/gasEstimations07.js +27 -34
- package/esm/rpc/estimation/gasEstimations07.js.map +1 -1
- package/esm/{utils/preVerificationGasCalulator.d.ts → rpc/estimation/preVerificationGasCalculator.d.ts} +20 -6
- package/esm/{utils/preVerificationGasCalulator.js → rpc/estimation/preVerificationGasCalculator.js} +134 -48
- package/esm/rpc/estimation/preVerificationGasCalculator.js.map +1 -0
- package/esm/rpc/estimation/types.d.ts +4 -2
- package/esm/rpc/estimation/utils.d.ts +10 -8
- package/esm/rpc/estimation/utils.js +56 -53
- package/esm/rpc/estimation/utils.js.map +1 -1
- package/esm/rpc/methods/boost_sendUserOperation.d.ts +304 -0
- package/esm/rpc/methods/boost_sendUserOperation.js +1 -1
- package/esm/rpc/methods/boost_sendUserOperation.js.map +1 -1
- package/esm/rpc/methods/debug_bundler_clearReputation.js +1 -1
- package/esm/rpc/methods/debug_bundler_clearReputation.js.map +1 -1
- package/esm/rpc/methods/debug_bundler_clearState.js +1 -1
- package/esm/rpc/methods/debug_bundler_clearState.js.map +1 -1
- package/esm/rpc/methods/debug_bundler_dumpMempool.d.ts +338 -0
- package/esm/rpc/methods/debug_bundler_dumpReputation.js +1 -1
- package/esm/rpc/methods/debug_bundler_dumpReputation.js.map +1 -1
- package/esm/rpc/methods/eth_estimateUserOperationGas.d.ts +622 -14
- package/esm/rpc/methods/eth_estimateUserOperationGas.js +61 -30
- package/esm/rpc/methods/eth_estimateUserOperationGas.js.map +1 -1
- package/esm/rpc/methods/eth_getUserOperationByHash.d.ts +621 -11
- package/esm/rpc/methods/eth_getUserOperationByHash.js.map +1 -1
- package/esm/rpc/methods/eth_getUserOperationReceipt.d.ts +34 -34
- package/esm/rpc/methods/eth_getUserOperationReceipt.js +1 -1
- package/esm/rpc/methods/eth_sendUserOperation.d.ts +307 -3
- package/esm/rpc/methods/eth_sendUserOperation.js +153 -48
- package/esm/rpc/methods/eth_sendUserOperation.js.map +1 -1
- package/esm/rpc/methods/pimlico_getUserOperationStatus.js +1 -1
- package/esm/rpc/methods/pimlico_getUserOperationStatus.js.map +1 -1
- package/esm/rpc/methods/pimlico_sendUserOperationNow.d.ts +338 -34
- package/esm/rpc/methods/pimlico_sendUserOperationNow.js +26 -29
- package/esm/rpc/methods/pimlico_sendUserOperationNow.js.map +1 -1
- package/esm/rpc/methods/pimlico_simulateAssetChange.d.ts +620 -12
- package/esm/rpc/methods/pimlico_simulateAssetChange.js +14 -19
- package/esm/rpc/methods/pimlico_simulateAssetChange.js.map +1 -1
- package/esm/rpc/rpcHandler.d.ts +38 -26
- package/esm/rpc/rpcHandler.js +97 -44
- package/esm/rpc/rpcHandler.js.map +1 -1
- package/esm/rpc/server.d.ts +5 -5
- package/esm/rpc/server.js +15 -11
- package/esm/rpc/server.js.map +1 -1
- package/esm/rpc/validation/BundlerCollectorTracerV06.js +1 -1
- package/esm/rpc/validation/BundlerCollectorTracerV06.js.map +1 -1
- package/esm/rpc/validation/BundlerCollectorTracerV07.js +1 -1
- package/esm/rpc/validation/BundlerCollectorTracerV07.js.map +1 -1
- package/esm/rpc/validation/SafeValidator.d.ts +13 -14
- package/esm/rpc/validation/SafeValidator.js +24 -24
- package/esm/rpc/validation/SafeValidator.js.map +1 -1
- package/esm/rpc/validation/TracerResultParserV06.d.ts +2 -2
- package/esm/rpc/validation/TracerResultParserV06.js +11 -11
- package/esm/rpc/validation/TracerResultParserV06.js.map +1 -1
- package/esm/rpc/validation/TracerResultParserV07.d.ts +2 -2
- package/esm/rpc/validation/TracerResultParserV07.js +13 -13
- package/esm/rpc/validation/TracerResultParserV07.js.map +1 -1
- package/esm/rpc/validation/UnsafeValidator.d.ts +18 -14
- package/esm/rpc/validation/UnsafeValidator.js +76 -41
- package/esm/rpc/validation/UnsafeValidator.js.map +1 -1
- package/esm/store/createMempoolStore.d.ts +1 -1
- package/esm/store/createMempoolStore.js +79 -140
- package/esm/store/createMempoolStore.js.map +1 -1
- package/esm/store/index.d.ts +4 -75
- package/esm/store/index.js +4 -1
- package/esm/store/index.js.map +1 -1
- package/esm/store/outstanding/index.d.ts +13 -0
- package/esm/store/outstanding/index.js +16 -0
- package/esm/store/outstanding/index.js.map +1 -0
- package/esm/store/{createMemoryOutstandingStore.d.ts → outstanding/memory.d.ts} +14 -13
- package/esm/store/outstanding/memory.js +263 -0
- package/esm/store/outstanding/memory.js.map +1 -0
- package/esm/store/outstanding/redis.d.ts +11 -0
- package/esm/store/outstanding/redis.js +229 -0
- package/esm/store/outstanding/redis.js.map +1 -0
- package/esm/store/outstanding/types.d.ts +19 -0
- package/esm/store/outstanding/types.js +2 -0
- package/esm/store/outstanding/types.js.map +1 -0
- package/esm/store/processing/index.d.ts +11 -0
- package/esm/store/processing/index.js +17 -0
- package/esm/store/processing/index.js.map +1 -0
- package/esm/store/processing/memory.d.ts +19 -0
- package/esm/store/processing/memory.js +83 -0
- package/esm/store/processing/memory.js.map +1 -0
- package/esm/store/processing/redis.d.ts +26 -0
- package/esm/store/processing/redis.js +123 -0
- package/esm/store/processing/redis.js.map +1 -0
- package/esm/store/processing/types.d.ts +12 -0
- package/esm/store/processing/types.js +2 -0
- package/esm/store/processing/types.js.map +1 -0
- package/esm/store/types.d.ts +52 -0
- package/esm/store/types.js +2 -0
- package/esm/store/types.js.map +1 -0
- package/esm/types/contracts/Multicall3.d.ts +34 -0
- package/esm/types/contracts/Multicall3.js +31 -0
- package/esm/types/contracts/Multicall3.js.map +1 -0
- package/esm/types/contracts/PimlicoSimulations.d.ts +81 -0
- package/esm/types/contracts/PimlicoSimulations.js +105 -0
- package/esm/types/contracts/PimlicoSimulations.js.map +1 -1
- package/esm/types/contracts/index.d.ts +1 -1
- package/esm/types/contracts/index.js +1 -1
- package/esm/types/contracts/index.js.map +1 -1
- package/esm/types/gasPrice.js +0 -18
- package/esm/types/gasPrice.js.map +1 -1
- package/esm/types/interfaces.d.ts +15 -10
- package/esm/types/mempool.d.ts +3 -0
- package/esm/types/schemas.d.ts +13184 -4741
- package/esm/types/schemas.js +116 -27
- package/esm/types/schemas.js.map +1 -1
- package/esm/types/utils.d.ts +2 -5
- package/esm/types/utils.js +16 -18
- package/esm/types/utils.js.map +1 -1
- package/esm/types/validation.d.ts +7646 -6912
- package/esm/types/validation.js +122 -152
- package/esm/types/validation.js.map +1 -1
- package/esm/utils/eip7702.d.ts +2 -1
- package/esm/utils/eip7702.js +14 -8
- package/esm/utils/eip7702.js.map +1 -1
- package/esm/utils/entryPointOverrides.js +18 -4
- package/esm/utils/entryPointOverrides.js.map +1 -1
- package/esm/utils/helpers.d.ts +7 -1
- package/esm/utils/helpers.js +36 -11
- package/esm/utils/helpers.js.map +1 -1
- package/esm/utils/index.d.ts +0 -1
- package/esm/utils/index.js +0 -1
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/metrics.d.ts +4 -1
- package/esm/utils/metrics.js +34 -7
- package/esm/utils/metrics.js.map +1 -1
- package/esm/utils/minMaxQueue/createMemoryMinMaxQueue.js +8 -9
- package/esm/utils/minMaxQueue/createMemoryMinMaxQueue.js.map +1 -1
- package/esm/utils/minMaxQueue/createRedisMinMaxQueue.d.ts +24 -2
- package/esm/utils/minMaxQueue/createRedisMinMaxQueue.js +85 -64
- package/esm/utils/minMaxQueue/createRedisMinMaxQueue.js.map +1 -1
- package/esm/utils/minMaxQueue/index.d.ts +2 -2
- package/esm/utils/minMaxQueue/index.js +4 -3
- package/esm/utils/minMaxQueue/index.js.map +1 -1
- package/esm/utils/rpc-reply.d.ts +3 -3
- package/esm/utils/rpc-reply.js.map +1 -1
- package/esm/utils/toViemStateOverrides.js +7 -7
- package/esm/utils/toViemStateOverrides.js.map +1 -1
- package/esm/utils/userop.d.ts +110 -56
- package/esm/utils/userop.js +161 -249
- package/esm/utils/userop.js.map +1 -1
- package/package.json +4 -2
- package/contracts/build-info/7710b5a048396e70.json +0 -1
- package/esm/executor/userOpMonitor.js +0 -326
- package/esm/executor/userOpMonitor.js.map +0 -1
- package/esm/executor/utilityWalletMonitor.d.ts +0 -19
- package/esm/executor/utilityWalletMonitor.js +0 -38
- package/esm/executor/utilityWalletMonitor.js.map +0 -1
- package/esm/mempool/monitoring.d.ts +0 -15
- package/esm/mempool/monitoring.js +0 -118
- package/esm/mempool/monitoring.js.map +0 -1
- package/esm/store/createMemoryOutstandingStore.js +0 -240
- package/esm/store/createMemoryOutstandingStore.js.map +0 -1
- package/esm/store/createRedisOutstandingStore.d.ts +0 -27
- package/esm/store/createRedisOutstandingStore.js +0 -344
- package/esm/store/createRedisOutstandingStore.js.map +0 -1
- package/esm/store/createRedisStore.d.ts +0 -9
- package/esm/store/createRedisStore.js +0 -131
- package/esm/store/createRedisStore.js.map +0 -1
- package/esm/store/createStore.d.ts +0 -6
- package/esm/store/createStore.js +0 -66
- package/esm/store/createStore.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/utils/preVerificationGasCalulator.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ERC7769Errors, RpcError, pimlicoSimulateAssetChangeSchema, pimlicoSimulationsAbi } from "../../types/index.js";
|
|
2
2
|
import { isVersion06, isVersion07, isVersion08, toPackedUserOp } from "../../utils/index.js";
|
|
3
3
|
import { getContract } from "viem";
|
|
4
4
|
import { getFilterOpsStateOverride } from "../../utils/entryPointOverrides.js";
|
|
@@ -18,7 +18,7 @@ export const pimlicoSimulateAssetChangeHandler = createMethodHandler({
|
|
|
18
18
|
// Check if pimlico simulation contract is configured
|
|
19
19
|
if (!rpcHandler.config.pimlicoSimulationContract) {
|
|
20
20
|
logger.warn("pimlicoSimulation must be provided");
|
|
21
|
-
throw new RpcError("pimlicoSimulation must be provided",
|
|
21
|
+
throw new RpcError("pimlicoSimulation must be provided", ERC7769Errors.InvalidFields);
|
|
22
22
|
}
|
|
23
23
|
const is07 = isVersion07(userOp);
|
|
24
24
|
const is08 = isVersion08(userOp, entryPoint);
|
|
@@ -27,31 +27,20 @@ export const pimlicoSimulateAssetChangeHandler = createMethodHandler({
|
|
|
27
27
|
address: rpcHandler.config.pimlicoSimulationContract,
|
|
28
28
|
client: rpcHandler.config.publicClient
|
|
29
29
|
});
|
|
30
|
-
let epSimulationsAddress;
|
|
31
|
-
if (is08) {
|
|
32
|
-
epSimulationsAddress =
|
|
33
|
-
rpcHandler.config.entrypointSimulationContractV8;
|
|
34
|
-
}
|
|
35
|
-
else if (is07) {
|
|
36
|
-
epSimulationsAddress =
|
|
37
|
-
rpcHandler.config.entrypointSimulationContractV7;
|
|
38
|
-
}
|
|
39
30
|
// Prepare state override based on version
|
|
40
31
|
let stateOverride;
|
|
41
32
|
if (isVersion06(userOp) && rpcHandler.config.codeOverrideSupport) {
|
|
42
33
|
stateOverride = getFilterOpsStateOverride({
|
|
43
34
|
version: "0.6",
|
|
44
35
|
entryPoint,
|
|
45
|
-
baseFeePerGas: await rpcHandler.gasPriceManager
|
|
46
|
-
.getBaseFee()
|
|
47
|
-
.catch(() => 0n)
|
|
36
|
+
baseFeePerGas: await rpcHandler.gasPriceManager.getBaseFee()
|
|
48
37
|
});
|
|
49
38
|
}
|
|
50
39
|
else if (is07 || is08) {
|
|
51
40
|
stateOverride = await prepareSimulationOverrides07({
|
|
52
41
|
userOp: userOp,
|
|
53
42
|
queuedUserOps: [],
|
|
54
|
-
|
|
43
|
+
entryPoint,
|
|
55
44
|
gasPriceManager: rpcHandler.gasPriceManager,
|
|
56
45
|
userStateOverrides: stateOverrides,
|
|
57
46
|
config: rpcHandler.config
|
|
@@ -60,11 +49,14 @@ export const pimlicoSimulateAssetChangeHandler = createMethodHandler({
|
|
|
60
49
|
try {
|
|
61
50
|
let result;
|
|
62
51
|
if (is08) {
|
|
52
|
+
if (!rpcHandler.config.entrypointSimulationContractV8) {
|
|
53
|
+
throw new RpcError("missing entrypointSimulationContractV8", ERC7769Errors.InvalidFields);
|
|
54
|
+
}
|
|
63
55
|
// For EntryPoint v0.8
|
|
64
56
|
const { result: simResult } = await pimlicoSimulation.simulate.simulateAssetChange08([
|
|
65
57
|
toPackedUserOp(userOp),
|
|
66
58
|
entryPoint,
|
|
67
|
-
|
|
59
|
+
rpcHandler.config.entrypointSimulationContractV8,
|
|
68
60
|
addresses,
|
|
69
61
|
tokens
|
|
70
62
|
], {
|
|
@@ -73,11 +65,14 @@ export const pimlicoSimulateAssetChangeHandler = createMethodHandler({
|
|
|
73
65
|
result = [...simResult];
|
|
74
66
|
}
|
|
75
67
|
else if (is07) {
|
|
68
|
+
if (!rpcHandler.config.entrypointSimulationContractV7) {
|
|
69
|
+
throw new RpcError("missing entrypointSimulationContractV7", ERC7769Errors.InvalidFields);
|
|
70
|
+
}
|
|
76
71
|
// For EntryPoint v0.7
|
|
77
72
|
const { result: simResult } = await pimlicoSimulation.simulate.simulateAssetChange07([
|
|
78
73
|
toPackedUserOp(userOp),
|
|
79
74
|
entryPoint,
|
|
80
|
-
|
|
75
|
+
rpcHandler.config.entrypointSimulationContractV7,
|
|
81
76
|
addresses,
|
|
82
77
|
tokens
|
|
83
78
|
], {
|
|
@@ -108,10 +103,10 @@ export const pimlicoSimulateAssetChangeHandler = createMethodHandler({
|
|
|
108
103
|
catch (error) {
|
|
109
104
|
const decodedError = decodeSimulateHandleOpError(error, logger);
|
|
110
105
|
if (decodedError.result === "failed") {
|
|
111
|
-
throw new RpcError(`UserOperation reverted during simulation with reason: ${decodedError.data}`,
|
|
106
|
+
throw new RpcError(`UserOperation reverted during simulation with reason: ${decodedError.data}`, ERC7769Errors.UserOperationReverted);
|
|
112
107
|
}
|
|
113
108
|
logger.warn("Failed to decode simulation error");
|
|
114
|
-
throw new RpcError("Failed to decode simulation error",
|
|
109
|
+
throw new RpcError("Failed to decode simulation error", ERC7769Errors.InvalidFields);
|
|
115
110
|
}
|
|
116
111
|
}
|
|
117
112
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pimlico_simulateAssetChange.js","sourceRoot":"","sources":["../../../rpc/methods/pimlico_simulateAssetChange.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,
|
|
1
|
+
{"version":3,"file":"pimlico_simulateAssetChange.js","sourceRoot":"","sources":["../../../rpc/methods/pimlico_simulateAssetChange.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EACb,QAAQ,EAIR,gCAAgC,EAChC,qBAAqB,EACxB,MAAM,aAAa,CAAA;AACpB,OAAO,EACH,WAAW,EACX,WAAW,EACX,WAAW,EACX,cAAc,EACjB,MAAM,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AQ,CACd,mCAAmC,EACnC,aAAa,CAAC,aAAa,CAC9B,CAAA;QACL,CAAC;IACL,CAAC;CACJ,CAAC,CAAA"}
|
package/esm/rpc/rpcHandler.d.ts
CHANGED
|
@@ -1,36 +1,35 @@
|
|
|
1
1
|
import { type Executor, type ExecutorManager } from "../executor/index.js";
|
|
2
2
|
import type { EventManager, GasPriceManager } from "../handlers/index.js";
|
|
3
|
-
import type { InterfaceReputationManager, Mempool,
|
|
4
|
-
import type
|
|
5
|
-
import { type
|
|
6
|
-
import type { Logger, Metrics } from "../utils/index.js";
|
|
3
|
+
import type { InterfaceReputationManager, Mempool, StatusManager } from "../mempool/index.js";
|
|
4
|
+
import { type Address, type ApiVersion, type BundlerRequest, type InterfaceValidator, type UserOperation } from "../types/index.js";
|
|
5
|
+
import { type Logger, type Metrics } from "../utils/index.js";
|
|
7
6
|
import type { AltoConfig } from "../createConfig.js";
|
|
8
|
-
import type {
|
|
7
|
+
import type { BundleManager } from "../executor/bundleManager.js";
|
|
9
8
|
import type { MethodHandler } from "./createMethodHandler.js";
|
|
10
9
|
export declare class RpcHandler {
|
|
11
|
-
config: AltoConfig;
|
|
12
|
-
validator: InterfaceValidator;
|
|
13
|
-
mempool: Mempool;
|
|
14
|
-
executor: Executor;
|
|
15
|
-
|
|
16
|
-
executorManager: ExecutorManager;
|
|
17
|
-
reputationManager: InterfaceReputationManager;
|
|
18
|
-
metrics: Metrics;
|
|
19
|
-
eventManager: EventManager;
|
|
20
|
-
gasPriceManager: GasPriceManager;
|
|
21
|
-
|
|
22
|
-
logger: Logger;
|
|
23
|
-
private methodHandlers;
|
|
24
|
-
private eip7702CodeCache;
|
|
25
|
-
constructor({ config, validator, mempool, executor,
|
|
10
|
+
readonly config: AltoConfig;
|
|
11
|
+
readonly validator: InterfaceValidator;
|
|
12
|
+
readonly mempool: Mempool;
|
|
13
|
+
readonly executor: Executor;
|
|
14
|
+
readonly statusManager: StatusManager;
|
|
15
|
+
readonly executorManager: ExecutorManager;
|
|
16
|
+
readonly reputationManager: InterfaceReputationManager;
|
|
17
|
+
readonly metrics: Metrics;
|
|
18
|
+
readonly eventManager: EventManager;
|
|
19
|
+
readonly gasPriceManager: GasPriceManager;
|
|
20
|
+
readonly bundleManager: BundleManager;
|
|
21
|
+
readonly logger: Logger;
|
|
22
|
+
private readonly methodHandlers;
|
|
23
|
+
private readonly eip7702CodeCache;
|
|
24
|
+
constructor({ config, validator, mempool, executor, statusManager, executorManager, reputationManager, bundleManager, metrics, eventManager, gasPriceManager }: {
|
|
26
25
|
config: AltoConfig;
|
|
27
26
|
validator: InterfaceValidator;
|
|
28
27
|
mempool: Mempool;
|
|
29
28
|
executor: Executor;
|
|
30
|
-
|
|
29
|
+
statusManager: StatusManager;
|
|
31
30
|
executorManager: ExecutorManager;
|
|
32
31
|
reputationManager: InterfaceReputationManager;
|
|
33
|
-
|
|
32
|
+
bundleManager: BundleManager;
|
|
34
33
|
metrics: Metrics;
|
|
35
34
|
eventManager: EventManager;
|
|
36
35
|
gasPriceManager: GasPriceManager;
|
|
@@ -39,14 +38,27 @@ export declare class RpcHandler {
|
|
|
39
38
|
handleMethod(request: BundlerRequest, apiVersion: ApiVersion): Promise<any>;
|
|
40
39
|
ensureEntryPointIsSupported(entryPoint: Address): void;
|
|
41
40
|
ensureDebugEndpointsAreEnabled(methodName: string): void;
|
|
42
|
-
|
|
43
|
-
validateEip7702Auth({ userOp, validateSender }: {
|
|
41
|
+
validateUserOpFields({ userOp, entryPoint, isBoosted, isEstimation }: {
|
|
44
42
|
userOp: UserOperation;
|
|
45
|
-
|
|
43
|
+
entryPoint: Address;
|
|
44
|
+
isBoosted?: boolean;
|
|
45
|
+
isEstimation?: boolean;
|
|
46
|
+
}): [boolean, string];
|
|
47
|
+
validateUserOpGasPrice({ userOp, apiVersion, isBoosted }: {
|
|
48
|
+
userOp: UserOperation;
|
|
49
|
+
apiVersion: ApiVersion;
|
|
50
|
+
isBoosted?: boolean;
|
|
51
|
+
}): Promise<[boolean, string]>;
|
|
52
|
+
validateEip7702Auth({ userOp, validateSignature }: {
|
|
53
|
+
userOp: UserOperation;
|
|
54
|
+
validateSignature: boolean;
|
|
46
55
|
}): Promise<[
|
|
47
56
|
boolean,
|
|
48
57
|
string
|
|
49
58
|
]>;
|
|
50
|
-
getNonceSeq(userOp
|
|
59
|
+
getNonceSeq({ userOp, entryPoint }: {
|
|
60
|
+
userOp: UserOperation;
|
|
61
|
+
entryPoint: Address;
|
|
62
|
+
}): Promise<bigint>;
|
|
51
63
|
}
|
|
52
64
|
//# sourceMappingURL=rpcHandler.d.ts.map
|
package/esm/rpc/rpcHandler.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
import { calculateAA95GasFloor } from "../executor/index.js";
|
|
2
|
-
import { EntryPointV06Abi, EntryPointV07Abi, RpcError
|
|
3
|
-
import { getNonceKeyAndSequence, isVersion06, isVersion07 } from "../utils/index.js";
|
|
2
|
+
import { ERC7769Errors, EntryPointV06Abi, EntryPointV07Abi, RpcError } from "../types/index.js";
|
|
3
|
+
import { getNonceKeyAndSequence, isVersion06, isVersion07, scaleBigIntByPercent, validatePaymasterSignature } from "../utils/index.js";
|
|
4
4
|
import { getContract, zeroAddress } from "viem";
|
|
5
|
-
import { generatePrivateKey, privateKeyToAddress } from "viem/accounts";
|
|
6
5
|
import { recoverAuthorizationAddress } from "viem/utils";
|
|
6
|
+
import { getEip7702AuthAddress } from "../utils/eip7702.js";
|
|
7
7
|
import { registerHandlers } from "./methods/index.js";
|
|
8
8
|
export class RpcHandler {
|
|
9
9
|
config;
|
|
10
10
|
validator;
|
|
11
11
|
mempool;
|
|
12
12
|
executor;
|
|
13
|
-
|
|
13
|
+
statusManager;
|
|
14
14
|
executorManager;
|
|
15
15
|
reputationManager;
|
|
16
16
|
metrics;
|
|
17
17
|
eventManager;
|
|
18
18
|
gasPriceManager;
|
|
19
|
-
|
|
19
|
+
bundleManager;
|
|
20
20
|
logger;
|
|
21
21
|
methodHandlers;
|
|
22
22
|
eip7702CodeCache;
|
|
23
|
-
constructor({ config, validator, mempool, executor,
|
|
23
|
+
constructor({ config, validator, mempool, executor, statusManager, executorManager, reputationManager, bundleManager, metrics, eventManager, gasPriceManager }) {
|
|
24
24
|
this.config = config;
|
|
25
25
|
this.validator = validator;
|
|
26
26
|
this.mempool = mempool;
|
|
27
27
|
this.executor = executor;
|
|
28
|
-
this.
|
|
28
|
+
this.statusManager = statusManager;
|
|
29
29
|
this.executorManager = executorManager;
|
|
30
30
|
this.reputationManager = reputationManager;
|
|
31
31
|
this.metrics = metrics;
|
|
32
32
|
this.eventManager = eventManager;
|
|
33
33
|
this.gasPriceManager = gasPriceManager;
|
|
34
|
-
this.
|
|
34
|
+
this.bundleManager = bundleManager;
|
|
35
35
|
this.logger = config.getLogger({ module: "rpc" }, {
|
|
36
36
|
level: config.rpcLogLevel || config.logLevel
|
|
37
37
|
});
|
|
@@ -45,7 +45,7 @@ export class RpcHandler {
|
|
|
45
45
|
async handleMethod(request, apiVersion) {
|
|
46
46
|
const handler = this.methodHandlers.get(request.method);
|
|
47
47
|
if (!handler) {
|
|
48
|
-
throw new RpcError("Method not supported",
|
|
48
|
+
throw new RpcError("Method not supported", ERC7769Errors.InvalidFields);
|
|
49
49
|
}
|
|
50
50
|
return await handler.handler({
|
|
51
51
|
rpcHandler: this,
|
|
@@ -55,7 +55,7 @@ export class RpcHandler {
|
|
|
55
55
|
}
|
|
56
56
|
ensureEntryPointIsSupported(entryPoint) {
|
|
57
57
|
if (!this.config.entrypoints.includes(entryPoint)) {
|
|
58
|
-
throw new RpcError(`EntryPoint ${entryPoint} not supported, supported EntryPoints: ${this.config.entrypoints.join(", ")}`,
|
|
58
|
+
throw new RpcError(`EntryPoint ${entryPoint} not supported, supported EntryPoints: ${this.config.entrypoints.join(", ")}`, ERC7769Errors.InvalidFields);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
ensureDebugEndpointsAreEnabled(methodName) {
|
|
@@ -63,7 +63,29 @@ export class RpcHandler {
|
|
|
63
63
|
throw new RpcError(`${methodName} is only available in development environment`);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
validateUserOpFields({ userOp, entryPoint, isBoosted = false, isEstimation = false }) {
|
|
67
|
+
// Check for 0x7702 factory without eip7702Auth
|
|
68
|
+
if (!userOp.eip7702Auth &&
|
|
69
|
+
isVersion07(userOp) &&
|
|
70
|
+
(userOp.factory === "0x7702" ||
|
|
71
|
+
userOp.factory === "0x7702000000000000000000000000000000000000")) {
|
|
72
|
+
return [
|
|
73
|
+
false,
|
|
74
|
+
"Invalid EIP-7702 userOperation: factory is 0x7702 but eip7702Auth is not provided."
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
// Skip gas/field checks during estimation
|
|
78
|
+
if (isEstimation) {
|
|
79
|
+
return [true, ""];
|
|
80
|
+
}
|
|
81
|
+
// Validate paymaster signature for EntryPoint 0.9
|
|
82
|
+
const paymasterSignatureError = validatePaymasterSignature({
|
|
83
|
+
userOp,
|
|
84
|
+
entryPoint
|
|
85
|
+
});
|
|
86
|
+
if (paymasterSignatureError) {
|
|
87
|
+
return [false, paymasterSignatureError];
|
|
88
|
+
}
|
|
67
89
|
if (this.config.legacyTransactions &&
|
|
68
90
|
userOp.maxFeePerGas !== userOp.maxPriorityFeePerGas) {
|
|
69
91
|
return [
|
|
@@ -71,27 +93,10 @@ export class RpcHandler {
|
|
|
71
93
|
"maxPriorityFeePerGas must equal maxFeePerGas on chains that don't support EIP-1559"
|
|
72
94
|
];
|
|
73
95
|
}
|
|
74
|
-
if (apiVersion !== "v1" && !this.config.safeMode && !boost) {
|
|
75
|
-
const { lowestMaxFeePerGas, lowestMaxPriorityFeePerGas } = await this.gasPriceManager.getLowestValidGasPrices();
|
|
76
|
-
const maxFeePerGas = userOp.maxFeePerGas;
|
|
77
|
-
const maxPriorityFeePerGas = userOp.maxPriorityFeePerGas;
|
|
78
|
-
if (maxFeePerGas < lowestMaxFeePerGas) {
|
|
79
|
-
return [
|
|
80
|
-
false,
|
|
81
|
-
`maxFeePerGas must be at least ${lowestMaxFeePerGas} (current maxFeePerGas: ${maxFeePerGas}) - use pimlico_getUserOperationGasPrice to get the current gas price`
|
|
82
|
-
];
|
|
83
|
-
}
|
|
84
|
-
if (maxPriorityFeePerGas < lowestMaxPriorityFeePerGas) {
|
|
85
|
-
return [
|
|
86
|
-
false,
|
|
87
|
-
`maxPriorityFeePerGas must be at least ${lowestMaxPriorityFeePerGas} (current maxPriorityFeePerGas: ${maxPriorityFeePerGas}) - use pimlico_getUserOperationGasPrice to get the current gas price`
|
|
88
|
-
];
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
96
|
if (userOp.verificationGasLimit < 10000n) {
|
|
92
97
|
return [false, "verificationGasLimit must be at least 10000"];
|
|
93
98
|
}
|
|
94
|
-
if (!
|
|
99
|
+
if (!isBoosted && userOp.preVerificationGas === 0n) {
|
|
95
100
|
return [
|
|
96
101
|
false,
|
|
97
102
|
"userOperation preVerification gas must be larger than 0"
|
|
@@ -103,32 +108,79 @@ export class RpcHandler {
|
|
|
103
108
|
"userOperation verification gas limit must be larger than 0"
|
|
104
109
|
];
|
|
105
110
|
}
|
|
106
|
-
const
|
|
111
|
+
const gasFloor = calculateAA95GasFloor({
|
|
107
112
|
userOps: [userOp],
|
|
108
|
-
beneficiary:
|
|
113
|
+
beneficiary: this.config.utilityWalletAddress
|
|
109
114
|
});
|
|
110
|
-
|
|
115
|
+
// The executor scales the bundle's tx.gasLimit by executorGasMultiplier,
|
|
116
|
+
// compare against the scaled value to reject userOps that would
|
|
117
|
+
// produce a transaction that can't fit in a block.
|
|
118
|
+
const txGasLimit = scaleBigIntByPercent(gasFloor, this.config.executorGasMultiplier);
|
|
119
|
+
if (txGasLimit > this.config.maxGasPerUserOp) {
|
|
111
120
|
return [
|
|
112
121
|
false,
|
|
113
|
-
`User operation gas limits exceed the max gas per
|
|
122
|
+
`User operation gas limits exceed the max gas per userOp: ${txGasLimit} > ${this.config.maxGasPerUserOp}`
|
|
114
123
|
];
|
|
115
124
|
}
|
|
116
125
|
return [true, ""];
|
|
117
126
|
}
|
|
118
|
-
async
|
|
127
|
+
async validateUserOpGasPrice({ userOp, apiVersion, isBoosted = false }) {
|
|
128
|
+
if (apiVersion === "v1" || this.config.safeMode || isBoosted) {
|
|
129
|
+
return [true, ""];
|
|
130
|
+
}
|
|
131
|
+
const { lowestMaxFeePerGas, lowestMaxPriorityFeePerGas } = await this.gasPriceManager.getLowestValidGasPrices();
|
|
132
|
+
const maxFeePerGas = userOp.maxFeePerGas;
|
|
133
|
+
const maxPriorityFeePerGas = userOp.maxPriorityFeePerGas;
|
|
134
|
+
if (maxFeePerGas < lowestMaxFeePerGas) {
|
|
135
|
+
return [
|
|
136
|
+
false,
|
|
137
|
+
`maxFeePerGas must be at least ${lowestMaxFeePerGas} (current maxFeePerGas: ${maxFeePerGas}) - use pimlico_getUserOperationGasPrice to get the current gas price`
|
|
138
|
+
];
|
|
139
|
+
}
|
|
140
|
+
if (maxPriorityFeePerGas < lowestMaxPriorityFeePerGas) {
|
|
141
|
+
return [
|
|
142
|
+
false,
|
|
143
|
+
`maxPriorityFeePerGas must be at least ${lowestMaxPriorityFeePerGas} (current maxPriorityFeePerGas: ${maxPriorityFeePerGas}) - use pimlico_getUserOperationGasPrice to get the current gas price`
|
|
144
|
+
];
|
|
145
|
+
}
|
|
146
|
+
return [true, ""];
|
|
147
|
+
}
|
|
148
|
+
async validateEip7702Auth({ userOp, validateSignature }) {
|
|
119
149
|
if (!userOp.eip7702Auth) {
|
|
120
150
|
return [true, ""];
|
|
121
151
|
}
|
|
122
|
-
if (!this.config.codeOverrideSupport) {
|
|
123
|
-
return [
|
|
152
|
+
if (!this.config.codeOverrideSupport || !this.config.eip7702Support) {
|
|
153
|
+
return [
|
|
154
|
+
false,
|
|
155
|
+
"EIP-7702 user operations are not supported on this chain"
|
|
156
|
+
];
|
|
124
157
|
}
|
|
125
158
|
// Check that auth is valid.
|
|
126
|
-
const delegationDesignator =
|
|
127
|
-
|
|
128
|
-
|
|
159
|
+
const delegationDesignator = getEip7702AuthAddress(userOp.eip7702Auth);
|
|
160
|
+
// Validate ECDSA signature components during submission only
|
|
161
|
+
// (during estimation, users send stub authorizations with dummy r/s)
|
|
162
|
+
if (validateSignature) {
|
|
163
|
+
const SECP256K1_N = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;
|
|
164
|
+
const r = BigInt(userOp.eip7702Auth.r);
|
|
165
|
+
const s = BigInt(userOp.eip7702Auth.s);
|
|
166
|
+
if (r < 1n || r >= SECP256K1_N || s < 1n || s >= SECP256K1_N) {
|
|
167
|
+
return [
|
|
168
|
+
false,
|
|
169
|
+
"Invalid EIP-7702 authorization: Invalid ECDSA signature (r and s must be in [1, secp256k1.n))"
|
|
170
|
+
];
|
|
171
|
+
}
|
|
172
|
+
// Enforce EIP-2 low-S: signatures with s > secp256k1n/2 are invalid.
|
|
173
|
+
// https://github.com/ethereum/EIPs/blob/bbc3f958/EIPS/eip-7702.md#L111
|
|
174
|
+
if (s > SECP256K1_N / 2n) {
|
|
175
|
+
return [
|
|
176
|
+
false,
|
|
177
|
+
"Invalid EIP-7702 authorization: Invalid ECDSA signature (s must be <= secp256k1.n/2)"
|
|
178
|
+
];
|
|
179
|
+
}
|
|
180
|
+
}
|
|
129
181
|
// Fetch onchain data in parallel
|
|
130
182
|
const [sender, nonceOnChain, delegateCode] = await Promise.all([
|
|
131
|
-
|
|
183
|
+
validateSignature
|
|
132
184
|
? recoverAuthorizationAddress({
|
|
133
185
|
authorization: {
|
|
134
186
|
address: delegationDesignator,
|
|
@@ -140,12 +192,12 @@ export class RpcHandler {
|
|
|
140
192
|
yParity: userOp.eip7702Auth.yParity
|
|
141
193
|
}
|
|
142
194
|
})
|
|
143
|
-
:
|
|
195
|
+
: userOp.sender,
|
|
144
196
|
this.config.publicClient.getTransactionCount({
|
|
145
197
|
address: userOp.sender
|
|
146
198
|
}),
|
|
147
199
|
this.eip7702CodeCache.has(delegationDesignator)
|
|
148
|
-
?
|
|
200
|
+
? "has-code"
|
|
149
201
|
: this.config.publicClient.getCode({
|
|
150
202
|
address: delegationDesignator
|
|
151
203
|
})
|
|
@@ -183,10 +235,11 @@ export class RpcHandler {
|
|
|
183
235
|
}
|
|
184
236
|
if (isVersion07(userOp) &&
|
|
185
237
|
userOp.factory !== "0x7702" &&
|
|
238
|
+
userOp.factory !== "0x7702000000000000000000000000000000000000" &&
|
|
186
239
|
userOp.factory !== null) {
|
|
187
240
|
return [
|
|
188
241
|
false,
|
|
189
|
-
"Invalid EIP-7702 authorization:
|
|
242
|
+
"Invalid EIP-7702 authorization: factory must be null or 0x7702."
|
|
190
243
|
];
|
|
191
244
|
}
|
|
192
245
|
// Check delegation designator
|
|
@@ -209,7 +262,7 @@ export class RpcHandler {
|
|
|
209
262
|
}
|
|
210
263
|
return [true, ""];
|
|
211
264
|
}
|
|
212
|
-
async getNonceSeq(userOp, entryPoint) {
|
|
265
|
+
async getNonceSeq({ userOp, entryPoint }) {
|
|
213
266
|
const entryPointContract = getContract({
|
|
214
267
|
address: entryPoint,
|
|
215
268
|
abi: isVersion06(userOp) ? EntryPointV06Abi : EntryPointV07Abi,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpcHandler.js","sourceRoot":"","sources":["../../rpc/rpcHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,qBAAqB,EACxB,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"rpcHandler.js","sourceRoot":"","sources":["../../rpc/rpcHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,qBAAqB,EACxB,MAAM,gBAAgB,CAAA;AAOvB,OAAO,EAIH,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAEhB,QAAQ,EAEX,MAAM,aAAa,CAAA;AACpB,OAAO,EAGH,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,oBAAoB,EACpB,0BAA0B,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AC,MAAM,CAAC,YAAY;aACnC;SACJ,CAAC,CAAA;QAEF,MAAM,CAAC,QAAQ,CAAC,GAAG,sBAAsB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAEvD,MAAM,cAAc,GAAG,MAAM,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CACzD,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EACzB;YACI,QAAQ,EAAE,QAAQ;SACrB,CACJ,CAAA;QAED,MAAM,CAAC,CAAC,EAAE,eAAe,CAAC,GAAG,sBAAsB,CAAC,cAAc,CAAC,CAAA;QAEnE,OAAO,eAAe,CAAA;IAC1B,CAAC;CACJ"}
|
package/esm/rpc/server.d.ts
CHANGED
|
@@ -4,11 +4,11 @@ import type { Registry } from "prom-client";
|
|
|
4
4
|
import type { AltoConfig } from "../createConfig.js";
|
|
5
5
|
import type { RpcHandler } from "./rpcHandler.js";
|
|
6
6
|
export declare class Server {
|
|
7
|
-
private config;
|
|
8
|
-
private fastify;
|
|
9
|
-
private rpcEndpoint;
|
|
10
|
-
private registry;
|
|
11
|
-
private metrics;
|
|
7
|
+
private readonly config;
|
|
8
|
+
private readonly fastify;
|
|
9
|
+
private readonly rpcEndpoint;
|
|
10
|
+
private readonly registry;
|
|
11
|
+
private readonly metrics;
|
|
12
12
|
constructor({ config, rpcEndpoint, registry, metrics }: {
|
|
13
13
|
config: AltoConfig;
|
|
14
14
|
rpcEndpoint: RpcHandler;
|
package/esm/rpc/server.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ERC7769Errors, RpcError, altoVersions, bundlerRequestSchema, jsonRpcSchema } from "../types/index.js";
|
|
2
|
+
import cors from "@fastify/cors";
|
|
2
3
|
import websocket from "@fastify/websocket";
|
|
3
4
|
import * as sentry from "@sentry/node";
|
|
4
5
|
import Fastify from "fastify";
|
|
@@ -49,6 +50,9 @@ export class Server {
|
|
|
49
50
|
requestTimeout: config.timeout,
|
|
50
51
|
disableRequestLogging: true
|
|
51
52
|
});
|
|
53
|
+
if (config.enableCors) {
|
|
54
|
+
this.fastify.register(cors, { origin: true });
|
|
55
|
+
}
|
|
52
56
|
this.fastify.register(rpcDecorators);
|
|
53
57
|
this.fastify.register(websocket, {
|
|
54
58
|
options: {
|
|
@@ -113,14 +117,14 @@ export class Server {
|
|
|
113
117
|
try {
|
|
114
118
|
request.body = JSON.parse(msgBuffer.toString());
|
|
115
119
|
}
|
|
116
|
-
catch
|
|
120
|
+
catch {
|
|
117
121
|
socket.send(JSON.stringify({
|
|
118
122
|
jsonrpc: "2.0",
|
|
119
123
|
id: null,
|
|
120
124
|
error: {
|
|
121
125
|
message: "invalid JSON-RPC request",
|
|
122
126
|
data: msgBuffer.toString(),
|
|
123
|
-
code:
|
|
127
|
+
code: ERC7769Errors.InvalidFields
|
|
124
128
|
}
|
|
125
129
|
}));
|
|
126
130
|
return;
|
|
@@ -135,24 +139,24 @@ export class Server {
|
|
|
135
139
|
const versionParsingResult = altoVersions.safeParse(request.params?.version ?? this.config.defaultApiVersion);
|
|
136
140
|
if (!versionParsingResult.success) {
|
|
137
141
|
const error = fromZodError(versionParsingResult.error);
|
|
138
|
-
throw new RpcError(`invalid version ${error.message}`,
|
|
142
|
+
throw new RpcError(`invalid version ${error.message}`, ERC7769Errors.InvalidFields);
|
|
139
143
|
}
|
|
140
144
|
const apiVersion = versionParsingResult.data;
|
|
141
|
-
if (this.config.apiVersion.
|
|
142
|
-
throw new RpcError(`unsupported version ${apiVersion}`,
|
|
145
|
+
if (!this.config.apiVersion.includes(apiVersion)) {
|
|
146
|
+
throw new RpcError(`unsupported version ${apiVersion}`, ERC7769Errors.InvalidFields);
|
|
143
147
|
}
|
|
144
148
|
try {
|
|
145
149
|
const contentTypeHeader = request.headers["content-type"];
|
|
146
150
|
// Common browser websocket API does not allow setting custom headers
|
|
147
151
|
if (contentTypeHeader !== "application/json" &&
|
|
148
152
|
request.ws === false) {
|
|
149
|
-
throw new RpcError("invalid content-type, content-type must be application/json",
|
|
153
|
+
throw new RpcError("invalid content-type, content-type must be application/json", ERC7769Errors.InvalidFields);
|
|
150
154
|
}
|
|
151
155
|
this.fastify.log.trace({ body: JSON.stringify(request.body) }, "received request");
|
|
152
156
|
const jsonRpcParsing = jsonRpcSchema.safeParse(request.body);
|
|
153
157
|
if (!jsonRpcParsing.success) {
|
|
154
158
|
const validationError = fromZodError(jsonRpcParsing.error);
|
|
155
|
-
throw new RpcError(`invalid JSON-RPC request ${validationError.message}`,
|
|
159
|
+
throw new RpcError(`invalid JSON-RPC request ${validationError.message}`, ERC7769Errors.InvalidFields);
|
|
156
160
|
}
|
|
157
161
|
const jsonRpcRequest = jsonRpcParsing.data;
|
|
158
162
|
requestId = jsonRpcRequest.id;
|
|
@@ -160,15 +164,15 @@ export class Server {
|
|
|
160
164
|
if (!bundlerRequestParsing.success) {
|
|
161
165
|
const validationError = fromZodError(bundlerRequestParsing.error);
|
|
162
166
|
if (validationError.message.includes("Missing/invalid userOpHash")) {
|
|
163
|
-
throw new RpcError("Missing/invalid userOpHash",
|
|
167
|
+
throw new RpcError("Missing/invalid userOpHash", ERC7769Errors.InvalidFields);
|
|
164
168
|
}
|
|
165
|
-
throw new RpcError(validationError.message,
|
|
169
|
+
throw new RpcError(validationError.message, ERC7769Errors.InvalidRequest);
|
|
166
170
|
}
|
|
167
171
|
const bundlerRequest = bundlerRequestParsing.data;
|
|
168
172
|
request.rpcMethod = bundlerRequest.method;
|
|
169
173
|
if (this.config.rpcMethods !== null &&
|
|
170
174
|
!this.config.rpcMethods.includes(bundlerRequest.method)) {
|
|
171
|
-
throw new RpcError(`Method not supported: ${bundlerRequest.method}`,
|
|
175
|
+
throw new RpcError(`Method not supported: ${bundlerRequest.method}`, ERC7769Errors.InvalidRequest);
|
|
172
176
|
}
|
|
173
177
|
this.fastify.log.info({
|
|
174
178
|
data: JSON.stringify(bundlerRequest, null),
|