-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: base for agent app #41
Changes from all commits
3e4b22c
588cda6
9fb7eab
42bda79
552b0da
9e7e342
aa03013
e3ade31
7c8979a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "agent", | ||
"version": "1.0.0", | ||
"description": "", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. some other things we could add here would be license: MIT and private: true (though we should add these on our other packages as well to avoid accidental publishing) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the |
||
"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:*" | ||
} | ||
} |
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); | ||
}); |
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"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["src/**/*"] | ||
} |
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"), | ||
}, | ||
}, | ||
}); |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2,8 +2,15 @@ | |||||||||||||||||
"name": "@ebo-agent/automated-dispute", | ||||||||||||||||||
"version": "1.0.0", | ||||||||||||||||||
"description": "", | ||||||||||||||||||
"main": "index.ts", | ||||||||||||||||||
"main": "./dist/index.js", | ||||||||||||||||||
"type": "module", | ||||||||||||||||||
"types": "./dist/index.d.ts", | ||||||||||||||||||
"files": [ | ||||||||||||||||||
"dist/*", | ||||||||||||||||||
"package.json", | ||||||||||||||||||
"!**/*.tsbuildinfo" | ||||||||||||||||||
], | ||||||||||||||||||
"private": "true", | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
"scripts": { | ||||||||||||||||||
"build": "tsc -p tsconfig.build.json", | ||||||||||||||||||
"lint": "eslint .", | ||||||||||||||||||
|
@@ -15,7 +22,6 @@ | |||||||||||||||||
}, | ||||||||||||||||||
"keywords": [], | ||||||||||||||||||
"author": "", | ||||||||||||||||||
"license": "ISC", | ||||||||||||||||||
"dependencies": { | ||||||||||||||||||
"@ebo-agent/blocknumber": "workspace:*", | ||||||||||||||||||
"@ebo-agent/shared": "workspace:*", | ||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -4,6 +4,13 @@ | |||||||||||||||||
"description": "", | ||||||||||||||||||
"main": "./dist/index.js", | ||||||||||||||||||
"type": "module", | ||||||||||||||||||
"types": "./dist/index.d.ts", | ||||||||||||||||||
"files": [ | ||||||||||||||||||
"dist/*", | ||||||||||||||||||
"package.json", | ||||||||||||||||||
"!**/*.tsbuildinfo" | ||||||||||||||||||
], | ||||||||||||||||||
"private": "true", | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
"scripts": { | ||||||||||||||||||
"build": "tsc -p tsconfig.build.json", | ||||||||||||||||||
"lint": "eslint .", | ||||||||||||||||||
|
@@ -15,7 +22,6 @@ | |||||||||||||||||
}, | ||||||||||||||||||
"keywords": [], | ||||||||||||||||||
"author": "", | ||||||||||||||||||
"license": "ISC", | ||||||||||||||||||
"dependencies": { | ||||||||||||||||||
"@ebo-agent/shared": "workspace:*", | ||||||||||||||||||
"axios": "1.7.7", | ||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -4,6 +4,13 @@ | |||||||||||||||||
"description": "", | ||||||||||||||||||
"main": "./dist/index.js", | ||||||||||||||||||
"type": "module", | ||||||||||||||||||
"types": "./dist/index.d.ts", | ||||||||||||||||||
"files": [ | ||||||||||||||||||
"dist/*", | ||||||||||||||||||
"package.json", | ||||||||||||||||||
"!**/*.tsbuildinfo" | ||||||||||||||||||
], | ||||||||||||||||||
"private": "true", | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
"scripts": { | ||||||||||||||||||
"build": "tsc -p tsconfig.build.json", | ||||||||||||||||||
"lint": "eslint .", | ||||||||||||||||||
|
@@ -15,7 +22,6 @@ | |||||||||||||||||
}, | ||||||||||||||||||
"keywords": [], | ||||||||||||||||||
"author": "", | ||||||||||||||||||
"license": "ISC", | ||||||||||||||||||
"dependencies": { | ||||||||||||||||||
"winston": "3.13.1" | ||||||||||||||||||
} | ||||||||||||||||||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
packages: | ||
- "apps/**" | ||
- "packages/**" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you need a
dev
script for running it with hot reload?tsx
is the one we used in chainhubThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I'll see how the development goes with this particular app. We'll probably end up needing it during some debugging sessions and such.