-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
1,294 additions
and
598 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "agent", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "dist/index.js", | ||
"type": "module", | ||
"private": "true", | ||
"scripts": { | ||
"build": "tsc -p tsconfig.build.json", | ||
"check-types": "tsc --noEmit -p ./tsconfig.json", | ||
"clean": "rm -rf dist", | ||
"format": "prettier --check \"{src,test}/**/*.{js,ts,json}\"", | ||
"format:fix": "prettier --write \"{src,test}/**/*.{js,ts,json}\"", | ||
"lint": "eslint \"{src,test}/**/*.{js,ts,json}\"", | ||
"lint:fix": "pnpm lint --fix", | ||
"start": "node dist/index.js", | ||
"test": "vitest run --config vitest.config.ts --passWithNoTests", | ||
"test:cov": "vitest run --config vitest.config.ts --coverage" | ||
}, | ||
"dependencies": { | ||
"@ebo-agent/automated-dispute": "workspace:*", | ||
"@ebo-agent/blocknumber": "workspace:*", | ||
"@ebo-agent/shared": "workspace:*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { inspect } from "util"; | ||
import { EboActorsManager, EboProcessor } from "@ebo-agent/automated-dispute"; | ||
import { ProtocolProvider } from "@ebo-agent/automated-dispute/dist/providers/protocolProvider.js"; | ||
import { BlockNumberService } from "@ebo-agent/blocknumber"; | ||
import { Logger } from "@ebo-agent/shared"; | ||
|
||
// TODO: use env vars and validate config schema | ||
const config = { | ||
protocolProvider: { | ||
rpcUrls: ["localhost"], | ||
contracts: { | ||
oracle: "0x00", | ||
epochManager: "0x00", | ||
eboRequestCreator: "0x00", | ||
} as const, | ||
privateKey: "0xsecret" as const, | ||
}, | ||
blockNumberService: { | ||
chainRpcUrls: new Map([["eip155:1" as const, ["localhost"]]]), | ||
blockmetaConfig: { | ||
baseUrl: new URL("localhost:443"), | ||
servicePaths: { | ||
blockByTime: "/sf.blockmeta.v2.BlockByTime", | ||
block: "/sf.blockmeta.v2.Block", | ||
}, | ||
bearerToken: "secret-token", | ||
bearerTokenExpirationWindow: 365 * 24 * 60 * 60 * 1000, // 1 year | ||
}, | ||
}, | ||
processor: { | ||
msBetweenChecks: 1, | ||
}, | ||
}; | ||
|
||
const logger = Logger.getInstance(); | ||
|
||
const main = async (): Promise<void> => { | ||
const protocolProvider = new ProtocolProvider( | ||
config.protocolProvider.rpcUrls, | ||
config.protocolProvider.contracts, | ||
config.protocolProvider.privateKey, | ||
); | ||
|
||
const blockNumberService = new BlockNumberService( | ||
config.blockNumberService.chainRpcUrls, | ||
config.blockNumberService.blockmetaConfig, | ||
logger, | ||
); | ||
|
||
const actorsManager = new EboActorsManager(); | ||
|
||
const processor = new EboProcessor(protocolProvider, blockNumberService, actorsManager, logger); | ||
|
||
await processor.start(config.processor.msBetweenChecks); | ||
}; | ||
|
||
process.on("unhandledRejection", (reason, p) => { | ||
logger.error(`Unhandled Rejection at: \n${inspect(p, undefined, 100)}, \nreason: ${reason}`); | ||
|
||
process.exit(1); | ||
}); | ||
|
||
process.on("uncaughtException", (error: Error) => { | ||
logger.error(`An uncaught exception occurred: ${error}\n` + `Exception origin: ${error.stack}`); | ||
|
||
process.exit(1); | ||
}); | ||
|
||
main().catch((err) => { | ||
logger.error(`Error in main handler: ${err}`); | ||
|
||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "../../tsconfig.build.json", | ||
"compilerOptions": { | ||
"outDir": "dist" | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": ["node_modules", "dist", "tests"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["src/**/*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import path from "path"; | ||
import { configDefaults, defineConfig } from "vitest/config"; | ||
|
||
export default defineConfig({ | ||
test: { | ||
globals: true, // Use Vitest's global API without importing it in each file | ||
environment: "node", // Use the Node.js environment | ||
include: ["test/**/*.spec.ts"], // Include test files | ||
exclude: ["node_modules", "dist"], // Exclude certain directories | ||
coverage: { | ||
provider: "v8", | ||
reporter: ["text", "json", "html"], // Coverage reporters | ||
exclude: ["node_modules", "dist", "src/index.ts", ...configDefaults.exclude], // Files to exclude from coverage | ||
}, | ||
}, | ||
resolve: { | ||
alias: { | ||
// Setup path alias based on tsconfig paths | ||
"@": path.resolve(__dirname, "src"), | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { EboProcessor, EboActorsManager } from "./services/index.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from "./protocolProvider.js"; | ||
export * from "./external.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./protocolProvider.js"; |
Oops, something went wrong.