Skip to content

Commit

Permalink
fix: anvil checks
Browse files Browse the repository at this point in the history
  • Loading branch information
doomsower committed Apr 16, 2024
1 parent bb63c36 commit 464f45e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -43,6 +44,9 @@ class App {
@Inject()
redstone: RedstoneServiceV3;

@Inject()
executor: ExecutorService;

@Inject(OUTPUT_WRITER)
outputWriter: IOptimisticOutputWriter;

Expand All @@ -63,6 +67,7 @@ class App {
.join(" ");
this.log.info(msg);

await this.executor.launch();
await this.addressProvider.launch();

this.redstone.launch();
Expand Down
15 changes: 14 additions & 1 deletion src/services/ExecutorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -21,6 +22,18 @@ export default class ExecutorService {

// #flashbots?: FlashbotsBundleProvider;

public async launch(): Promise<void> {
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<providers.TransactionReceipt> {
Expand Down Expand Up @@ -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<FlashbotsBundleProvider> {
Expand Down

0 comments on commit 464f45e

Please sign in to comment.