Store event topics in separate columns in db

This commit is contained in:
Prathamesh Musale 2024-09-18 11:07:24 +05:30
parent d413d724c7
commit b69116b2bf
3 changed files with 44 additions and 0 deletions

View File

@ -37,6 +37,40 @@ columns:
columnOptions: columnOptions:
- option: length - option: length
value: 42 value: 42
- name: topic0
pgType: varchar
tsType: string
columnType: Column
columnOptions:
- option: length
value: 66
- name: topic1
pgType: varchar
tsType: string | null
columnType: Column
columnOptions:
- option: length
value: 66
- option: nullable
value: true
- name: topic2
pgType: varchar
tsType: string | null
columnType: Column
columnOptions:
- option: length
value: 66
- option: nullable
value: true
- name: topic3
pgType: varchar
tsType: string | null
columnType: Column
columnOptions:
- option: length
value: 66
- option: nullable
value: true
- name: eventName - name: eventName
pgType: varchar pgType: varchar
tsType: string tsType: string

View File

@ -672,6 +672,8 @@ export class Indexer {
const tx = transactionMap[txHash]; const tx = transactionMap[txHash];
const extraInfo: { [key: string]: any } = { topics, data, tx, logIndex }; const extraInfo: { [key: string]: any } = { topics, data, tx, logIndex };
const [topic0, topic1, topic2, topic3] = topics as string[];
const contract = ethers.utils.getAddress(address); const contract = ethers.utils.getAddress(address);
const watchedContracts = this.isContractAddressWatched(contract); const watchedContracts = this.isContractAddressWatched(contract);
@ -693,6 +695,10 @@ export class Indexer {
index: this._upstreamConfig.ethServer.isFEVM ? li : logIndex, index: this._upstreamConfig.ethServer.isFEVM ? li : logIndex,
txHash, txHash,
contract, contract,
topic0,
topic1,
topic2,
topic3,
eventName, eventName,
eventInfo: JSONbigNative.stringify(eventInfo), eventInfo: JSONbigNative.stringify(eventInfo),
extraInfo: JSONbigNative.stringify(extraInfo), extraInfo: JSONbigNative.stringify(extraInfo),

View File

@ -61,6 +61,10 @@ export interface EventInterface {
txHash: string; txHash: string;
index: number; index: number;
contract: string; contract: string;
topic0: string;
topic1: string | null;
topic2: string | null;
topic3: string | null;
eventName: string; eventName: string;
eventInfo: string; eventInfo: string;
extraInfo: string; extraInfo: string;