Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: e2e agent process #74

Merged
merged 13 commits into from
Oct 28, 2024
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ out/
build
dist
cache
tmp/


# Coverage
Expand Down
1 change: 1 addition & 0 deletions apps/agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"devDependencies": {
"execa": "9.4.0",
"prool": "0.0.16",
"tsx": "4.19.1",
"viem": "2.21.10",
"vitest": "2.0.3"
}
Expand Down
1 change: 0 additions & 1 deletion apps/agent/src/config/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ const blockNumberServiceSchema = z.object({
const processorSchema = z.object({
msBetweenChecks: z.number().int().positive(),
accountingModules: z.object({
requestModule: addressSchema,
responseModule: addressSchema,
escalationModule: addressSchema,
}),
Expand Down
40 changes: 31 additions & 9 deletions apps/agent/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,60 @@
import { inspect } from "util";
import { isNativeError } from "util/types";
import {
DiscordNotifier,
EboActorsManager,
EboProcessor,
NotificationService,
ProtocolProvider,
} from "@ebo-agent/automated-dispute";
import { BlockNumberService } from "@ebo-agent/blocknumber";
import { Logger } from "@ebo-agent/shared";
import { Logger, stringify } from "@ebo-agent/shared";

import { config } from "./config/index.js";

const logger = Logger.getInstance();

const main = async (): Promise<void> => {
logger.debug("Initializing agent...");

logger.debug("Initializing block number service...");
logger.debug(stringify(config.blockNumberService));

const blockNumberService = new BlockNumberService(
config.blockNumberService.chainRpcUrls,
config.blockNumberService.blockmetaConfig,
logger,
);

logger.debug("Block number service initialized.");

logger.debug("Initializing protocol provider...");
logger.debug(stringify(config.protocolProvider));

const protocolProvider = new ProtocolProvider(
config.protocolProvider.rpcsConfig,
config.protocolProvider.contracts,
config.protocolProvider.privateKey,
blockNumberService,
);

logger.debug("Protocol provider initialized.");

const discordConfig = {
discordBotToken: config.DISCORD_BOT_TOKEN,
discordChannelId: config.DISCORD_CHANNEL_ID,
};

logger.debug("Initializing notifier...");
logger.debug(stringify(discordConfig));

// const notifier = await DiscordNotifier.create(discordConfig, logger);
// FIXME: during E2E DiscordNotifier is not able to start even if setting a valid token
const notifier = { notifyError: (_e, _ctx) => {} } as NotificationService;

const actorsManager = new EboActorsManager();

const notifier = await DiscordNotifier.create(
{
discordBotToken: config.DISCORD_BOT_TOKEN,
discordChannelId: config.DISCORD_CHANNEL_ID,
},
logger,
);
logger.debug("Initializing EBO processor...");
logger.debug(stringify(config.processor));

const processor = new EboProcessor(
config.processor.accountingModules,
Expand All @@ -46,6 +65,9 @@ const main = async (): Promise<void> => {
notifier,
);

logger.debug("EBO processor initialized.");
logger.debug("Starting processing...");

await processor.start(config.processor.msBetweenChecks);
};

Expand Down
Loading