diff --git a/packages/automated-dispute/src/eboActor.ts b/packages/automated-dispute/src/eboActor.ts index b7f0f3c..24111e3 100644 --- a/packages/automated-dispute/src/eboActor.ts +++ b/packages/automated-dispute/src/eboActor.ts @@ -1,22 +1,27 @@ import { BlockNumberService } from "@ebo-agent/blocknumber"; +import { EboRegistry } from "./eboRegistry.js"; import { RequestMismatch } from "./exceptions/requestMismatch.js"; import { ProtocolProvider } from "./protocolProvider.js"; import { EboEvent } from "./types/events.js"; import { Dispute, Response } from "./types/prophet.js"; export class EboActor { + private registry: EboRegistry; + constructor( private readonly protocolProvider: ProtocolProvider, private readonly blockNumberService: BlockNumberService, private readonly requestId: string, - ) {} + ) { + this.registry = new EboRegistry(); + } public async onRequestCreated(event: EboEvent<"RequestCreated">): Promise { if (event.metadata.requestId != this.requestId) throw new RequestMismatch(this.requestId, event.metadata.requestId); - // TODO: Update registry with the new event.metadata.request + this.registry.addRequest(event.metadata.requestId, event.metadata.request); const { chainId } = event.metadata; const { currentEpoch, currentEpochTimestamp } = diff --git a/packages/automated-dispute/src/eboRegistry.ts b/packages/automated-dispute/src/eboRegistry.ts index bb4d669..873bd07 100644 --- a/packages/automated-dispute/src/eboRegistry.ts +++ b/packages/automated-dispute/src/eboRegistry.ts @@ -1,9 +1,17 @@ import { Dispute, Request, Response } from "./types/prophet.js"; -class EboRegistry { +export class EboRegistry { private requests: Map; private responses: Map; private dispute: Map; - constructor() {} + constructor() { + this.requests = new Map(); + this.responses = new Map(); + this.dispute = new Map(); + } + + public addRequest(requestId: string, request: Request) { + this.requests.set(requestId, request); + } } diff --git a/packages/automated-dispute/src/types/events.ts b/packages/automated-dispute/src/types/events.ts index 6c46f5a..999245a 100644 --- a/packages/automated-dispute/src/types/events.ts +++ b/packages/automated-dispute/src/types/events.ts @@ -1,7 +1,7 @@ import { Caip2ChainId } from "@ebo-agent/blocknumber/dist/types.js"; import { Log } from "viem"; -import { Dispute, Response } from "./prophet.js"; +import { Dispute, Request, Response } from "./prophet.js"; export type EboEventName = | "NewEpoch" @@ -27,6 +27,7 @@ export interface ResponseProposed { export interface RequestCreated { epoch: bigint; chainId: Caip2ChainId; + request: Request; requestId: string; }