Skip to content

Commit

Permalink
minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
nischitpra committed Dec 12, 2024
1 parent fc390ef commit 8dd2de0
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/server/schemas/event.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
import { BigNumber } from "ethers";

export type ContractEventV5 = {
eventName: string;
args: Record<string, any>;
address: string;
topic: string[];
data: string;
blockNumber: bigint;
transactionHash: string;
transactionIndex: number;
blockHash: string;
logIndex: number;
removed: boolean;
};

export type ContractEventV4 = {
eventName: string;
data: Record<string, any>;
transaction: {
blockNumber: bigint;
blockNumber: number;
blockHash: string;
transactionIndex: number;
removed: boolean;
Expand All @@ -28,15 +14,31 @@ export type ContractEventV4 = {
transactionHash: string;
logIndex: number;
event: string;
eventSignature: string | undefined;
eventSignature?: string;
};
};

export type ContractEventV5 = {
eventName: string;
args: Record<string, any>;
address: string;
topic: string[];
data: string;
blockNumber: bigint;
transactionHash: string;
transactionIndex: number;
blockHash: string;
logIndex: number;
removed: boolean;
};

/**
* Mapping of events v5 response to v4 for backward compatiblity.
* Clients may be using this api and dont want to break things.
*/
export function toContractEventV4Schema(eventV5: ContractEventV5) {
export function toContractEventV4Schema(
eventV5: ContractEventV5,
): ContractEventV4 {
const eventName = eventV5.eventName;

// backwards compatibility of BigInt(v5) to BigNumber(v4)
Expand Down

0 comments on commit 8dd2de0

Please sign in to comment.