diff --git a/src/app.ts b/src/app.ts index 50d037e..e066670 100644 --- a/src/app.ts +++ b/src/app.ts @@ -5,6 +5,7 @@ import { CONFIG, ConfigSchema, loadConfig } from "./config"; import { Logger, LoggerInterface } from "./log"; import { AddressProviderService } from "./services/AddressProviderService"; import { AMPQService } from "./services/ampqService"; +import ExecutorService from "./services/ExecutorService"; import { HealthChecker } from "./services/healthChecker"; import { OptimisticResults } from "./services/liquidate"; import { IOptimisticOutputWriter, OUTPUT_WRITER } from "./services/output"; @@ -43,6 +44,9 @@ class App { @Inject() redstone: RedstoneServiceV3; + @Inject() + executor: ExecutorService; + @Inject(OUTPUT_WRITER) outputWriter: IOptimisticOutputWriter; @@ -63,6 +67,7 @@ class App { .join(" "); this.log.info(msg); + await this.executor.launch(); await this.addressProvider.launch(); this.redstone.launch(); diff --git a/src/services/ExecutorService.ts b/src/services/ExecutorService.ts index d22af98..2aa28a4 100644 --- a/src/services/ExecutorService.ts +++ b/src/services/ExecutorService.ts @@ -7,6 +7,7 @@ import { providers, Wallet } from "ethers"; import { Inject, Service } from "typedi"; import { Logger, LoggerInterface } from "../log"; +import { mine } from "./utils"; @Service() export default class ExecutorService { @@ -21,6 +22,18 @@ export default class ExecutorService { // #flashbots?: FlashbotsBundleProvider; + public async launch(): Promise { + try { + const resp = await (this.provider as providers.JsonRpcProvider).send( + "anvil_nodeInfo", + [], + ); + this.logger.debug(resp, "anvil node info"); + } catch { + this.logger.debug("running on real rpc"); + } + } + public async sendPrivate( txData: PopulatedTransaction, ): Promise { @@ -54,7 +67,7 @@ export default class ExecutorService { const signedTx = await this.wallet.signTransaction(req); const tx = await this.provider.sendTransaction(signedTx); this.logger.debug(`sent transaction ${tx.hash}`); - return tx.wait(1); + return mine(this.provider as providers.JsonRpcProvider, tx); } // private async getFlashbots(): Promise {