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

feat: implement get events #50

Merged
merged 14 commits into from
Oct 14, 2024
2 changes: 1 addition & 1 deletion apps/agent/src/config/schemas.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Caip2ChainId, Caip2Utils } from "@ebo-agent/blocknumber/src/index.js";
import { Caip2ChainId, Caip2Utils } from "@ebo-agent/blocknumber";
import { isAddress, isHex } from "viem";
import { z } from "zod";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export class DecodeLogDataFailure extends Error {
constructor(err: unknown) {
super(`Error decoding log data: ${err}`);

this.name = "DecodeLogDataFailure";
}
}
3 changes: 3 additions & 0 deletions packages/automated-dispute/src/exceptions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export * from "./responseAlreadyProposed.exception.js";
export * from "./rpcUrlsEmpty.exception.js";
export * from "./transactionExecutionError.exception.js";
export * from "./invalidAccountOnClient.exception.js";
export * from "./unsupportedEvent.exception.js";
export * from "./decodeLogDataFailure.js";
export * from "./invalidBlockRangeError.exception.js";
export * from "./unknownCustomError.exception.js";
export * from "./customContractError.js";
export * from "./errorFactory.js";
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export class InvalidBlockRangeError extends Error {
constructor(fromBlock: bigint, toBlock: bigint) {
super(
`Invalid block range: fromBlock (${fromBlock}) must be less than or equal to toBlock (${toBlock})`,
);
this.name = "InvalidBlockRangeError";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export class UnsupportedEvent extends Error {
constructor(message: string) {
super(message);
this.name = "UnsupportedEvent";
}
}
86 changes: 85 additions & 1 deletion packages/automated-dispute/src/interfaces/protocolProvider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { Caip2ChainId } from "@ebo-agent/blocknumber";
import { Address, Block } from "viem";

import type { Dispute, EboEvent, EboEventName, Epoch, Request, Response } from "../types/index.js";
import type {
Dispute,
EboEvent,
EboEventName,
Epoch,
Request,
RequestId,
Response,
} from "../types/index.js";
import { ProtocolContractsNames } from "../constants.js";

export type ProtocolContract = (typeof ProtocolContractsNames)[number];
Expand Down Expand Up @@ -194,3 +202,79 @@ export interface IProtocolProvider {
*/
read: IReadProvider;
}

/**
* @type DecodedLogArgsMap
* Represents the mapping of event names to their respective argument structures.
*/
export type DecodedLogArgsMap = {
/**
* Event arguments for the RequestCreated event.
* @property {RequestId} requestId - The ID of the request.
* @property {bigint} epoch - The epoch time when the request was created.
* @property {Caip2ChainId} chainId - The chain ID where the request was created.
*/
RequestCreated: {
requestId: RequestId;
epoch: bigint;
chainId: Caip2ChainId;
};

/**
* Event arguments for the ResponseProposed event.
* @property {RequestId} requestId - The ID of the request.
* @property {string} responseId - The ID of the response.
* @property {string} response - The response content.
*/
ResponseProposed: {
requestId: RequestId;
responseId: string;
response: string;
};

/**
* Event arguments for the ResponseDisputed event.
* @property {string} responseId - The ID of the response.
* @property {string} disputeId - The ID of the dispute.
* @property {string} dispute - The dispute content.
*/
ResponseDisputed: {
responseId: string;
disputeId: string;
dispute: string;
};

/**
* Event arguments for the DisputeStatusUpdated event.
* @property {string} disputeId - The ID of the dispute.
* @property {string} dispute - The dispute content.
* @property {number} status - The new status of the dispute.
*/
DisputeStatusUpdated: {
disputeId: string;
dispute: string;
status: number;
};

/**
* Event arguments for the DisputeEscalated event.
* @property {string} caller - The address of the caller who escalated the dispute.
* @property {string} disputeId - The ID of the dispute.
*/
DisputeEscalated: {
caller: string;
disputeId: string;
};

/**
* Event arguments for the OracleRequestFinalized event.
* @property {RequestId} requestId - The ID of the request.
* @property {string} responseId - The ID of the response.
* @property {string} caller - The address of the caller who finalized the request.
*/
OracleRequestFinalized: {
requestId: RequestId;
responseId: string;
caller: string;
};
};
Loading