diff --git a/indexer/src/types/log.test.ts b/indexer/src/types/log.test.ts index 401ac4387..c35aa21b7 100644 --- a/indexer/src/types/log.test.ts +++ b/indexer/src/types/log.test.ts @@ -1,6 +1,7 @@ import { assertEquals } from "https://deno.land/std@0.213.0/assert/mod.ts"; import { fromJsonRpcLog, IGNORED_KEYS, JsonRpcLog, toEthLog } from "./log.ts"; import { bigIntToHex, Event, JsonRpcTx } from "../deps.ts"; +import { KAKAROT_ADDRESS } from "../constants.ts"; // Mock for hexToBytes const mockHexToBytes = (hex: string): Uint8Array => { @@ -101,7 +102,7 @@ Deno.test("toEthLog with valid input", () => { const event: Event = { index: 1, - fromAddress: "0x123456", + fromAddress: KAKAROT_ADDRESS as `0x${string}`, keys: ["0x1234", "0x5678", "0x9abc", "0xdef0", "0x1111"], data: ["0x01", "0x02", "0x03"], }; @@ -233,7 +234,7 @@ Deno.test("toEthLog with empty event data", () => { // No data in the event. const event: Event = { index: 1, - fromAddress: "0x123456", + fromAddress: KAKAROT_ADDRESS as `0x${string}`, keys: ["0x1234", "0x5678", "0x9abc", "0xdef0", "0x1111"], data: [], }; @@ -286,7 +287,7 @@ Deno.test("toEthLog with pending block", () => { const event: Event = { index: 1, - fromAddress: "0x123456", + fromAddress: KAKAROT_ADDRESS as `0x${string}`, keys: ["0x1234", "0x5678", "0x9abc", "0xdef0", "0x1111"], data: ["0x01", "0x02", "0x03"], }; diff --git a/indexer/src/types/log.ts b/indexer/src/types/log.ts index d86d78655..7a852146f 100644 --- a/indexer/src/types/log.ts +++ b/indexer/src/types/log.ts @@ -2,7 +2,7 @@ import { padBigint } from "../utils/hex.ts"; // Constants -import { NULL_BLOCK_HASH } from "../constants.ts"; +import { KAKAROT_ADDRESS, NULL_BLOCK_HASH } from "../constants.ts"; // Starknet import { Event, hash } from "../deps.ts"; @@ -47,9 +47,14 @@ export function toEthLog({ blockHash: PrefixedHexString; isPendingBlock: boolean; }): JsonRpcLog | null { - const { keys, data } = event; + const { keys, data, fromAddress } = event; const { transactionIndex, hash } = transaction; + // Log events originated from kakarot address only + if (BigInt(fromAddress) !== BigInt(KAKAROT_ADDRESS)) { + return null; + } + // The event must have at least one key (since the first key is the address) // and an odd number of keys (since each topic is split into two keys). //