From be97948188a0c2d568b99a4e2f195d31bbba176b Mon Sep 17 00:00:00 2001 From: 0xyaco Date: Fri, 2 Aug 2024 13:21:57 -0300 Subject: [PATCH] chore: base EboActor implementation (#16) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # 🤖 Linear Closes GRT-80 ## Description Implements base class for `EboActor` --- packages/automated-dispute/package.json | 3 +- packages/automated-dispute/src/eboActor.ts | 66 +++++++++++++++++++ .../automated-dispute/src/types/events.ts | 12 ++++ .../automated-dispute/tests/eboActor.spec.ts | 10 +++ packages/blocknumber/package.json | 2 +- packages/blocknumber/src/index.ts | 1 + pnpm-lock.yaml | 3 + 7 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 packages/automated-dispute/src/eboActor.ts create mode 100644 packages/automated-dispute/tests/eboActor.spec.ts diff --git a/packages/automated-dispute/package.json b/packages/automated-dispute/package.json index aa463d5..1fc9a72 100644 --- a/packages/automated-dispute/package.json +++ b/packages/automated-dispute/package.json @@ -17,6 +17,7 @@ "author": "", "license": "ISC", "dependencies": { - "viem": "2.17.11" + "viem": "2.17.11", + "@ebo-agent/blocknumber": "workspace:*" } } diff --git a/packages/automated-dispute/src/eboActor.ts b/packages/automated-dispute/src/eboActor.ts new file mode 100644 index 0000000..898dedc --- /dev/null +++ b/packages/automated-dispute/src/eboActor.ts @@ -0,0 +1,66 @@ +import { BlockNumberService } from "@ebo-agent/blocknumber"; + +import { ProtocolProvider } from "./protocolProvider.js"; +import { + DisputeStatusChanged, + RequestCreated, + RequestFinalizable, + ResponseDisputed, +} from "./types/events.js"; +import { Dispute, Response } from "./types/prophet.js"; + +export class EboActor { + private requestActivity: unknown[]; + + constructor( + private readonly protocolProvider: ProtocolProvider, + private readonly blockNumberService: BlockNumberService, + private readonly requestId: string, + ) { + this.requestActivity = []; + } + + public async onRequestCreated(_event: RequestCreated): Promise { + // TODO: implement + return; + } + + public async onResponseProposed(_event: ResponseDisputed): Promise { + // TODO: implement + return; + } + + public async onResponseDisputed(_event: ResponseDisputed): Promise { + // TODO: implement + return; + } + + private async proposeResponse(_response: Response): Promise { + // TODO: implement + return; + } + + private async disputeProposal(_dispute: Dispute): Promise { + // TODO: implement + return; + } + + private async isValidDispute(_dispute: Dispute): Promise { + // TODO: implement + return true; + } + + public async onFinalizeRequest(_event: RequestFinalizable): Promise { + // TODO: implement + return; + } + + public async onDisputeStatusChanged(_event: DisputeStatusChanged): Promise { + // TODO: implement + return; + } + + public async onDisputeEscalated(_event: Dispute): Promise { + return; + } +} diff --git a/packages/automated-dispute/src/types/events.ts b/packages/automated-dispute/src/types/events.ts index 8a16529..c80735f 100644 --- a/packages/automated-dispute/src/types/events.ts +++ b/packages/automated-dispute/src/types/events.ts @@ -26,6 +26,18 @@ export type DisputeStatusChanged = BaseEvent & { metadata: { disputeId: string; status: string; blockNumber: bigint }; }; +export type DisputeEscalated = BaseEvent & { + metadata: { caller: string; disputeId: string; blockNumber: bigint }; +}; + +export type RequestFinalizable = BaseEvent & { + metadata: { requestId: string }; +}; + +export type RequestFinalized = BaseEvent & { + metadata: { requestId: string; responseId: string; caller: string; blockNumber: bigint }; +}; + export type EboEvent = | NewEpoch | RequestCreated diff --git a/packages/automated-dispute/tests/eboActor.spec.ts b/packages/automated-dispute/tests/eboActor.spec.ts new file mode 100644 index 0000000..96a7345 --- /dev/null +++ b/packages/automated-dispute/tests/eboActor.spec.ts @@ -0,0 +1,10 @@ +import { describe } from "vitest"; + +describe("EboActor", () => { + describe.skip("onRequestCreated"); + describe.skip("onResponseProposed"); + describe.skip("onResponseDisputed"); + describe.skip("onFinalizeRequest"); + describe.skip("onDisputeStatusChanged"); + describe.skip("onDisputeEscalated"); +}); diff --git a/packages/blocknumber/package.json b/packages/blocknumber/package.json index 1173e7c..53e6369 100644 --- a/packages/blocknumber/package.json +++ b/packages/blocknumber/package.json @@ -2,7 +2,7 @@ "name": "@ebo-agent/blocknumber", "version": "1.0.0", "description": "", - "main": "index.ts", + "main": "./dist/index.js", "type": "module", "scripts": { "build": "tsc -p tsconfig.build.json", diff --git a/packages/blocknumber/src/index.ts b/packages/blocknumber/src/index.ts index e69de29..7801d3e 100644 --- a/packages/blocknumber/src/index.ts +++ b/packages/blocknumber/src/index.ts @@ -0,0 +1 @@ +export * from "./services/index.js"; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 27d3911..97fa462 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -65,6 +65,9 @@ importers: packages/automated-dispute: dependencies: + "@ebo-agent/blocknumber": + specifier: workspace:* + version: link:../blocknumber viem: specifier: 2.17.11 version: 2.17.11(typescript@5.5.3)