Skip to content

Commit 268ae37

Browse files
authored
use indexer (#449)
1 parent 1de90d5 commit 268ae37

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

src/helpers/processTransactions.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { getLogs } from "@defillama/sdk/build/util";
1+
import { getLogs } from "@defillama/sdk/build/util/logs";
2+
import { isIndexerEnabled } from "@defillama/sdk/build/util/indexer";
23
import { ethers } from "ethers";
34
import { Chain } from "@defillama/sdk/build/general";
45
import { get } from "lodash";
@@ -125,17 +126,16 @@ export const getTxDataFromEVMEventLogs = async (
125126
let logs = [] as any[];
126127
for (let i = 0; i < 5; i++) {
127128
try {
128-
logs = (
129-
await getLogs({
130-
target: target!,
131-
topic: topic,
132-
keys: [],
133-
fromBlock: fromBlock,
134-
toBlock: toBlock,
135-
topics: topics as string[],
136-
chain: overriddenChain,
137-
})
138-
).output;
129+
const startTime = Date.now();
130+
logs = await getLogs({
131+
target: target ?? undefined,
132+
topic: topic,
133+
fromBlock: fromBlock,
134+
toBlock: toBlock,
135+
topics: topics as string[],
136+
chain: overriddenChain,
137+
noTarget: !target,
138+
});
139139
//console.log(logs)
140140
break;
141141
} catch (e) {
@@ -197,7 +197,10 @@ export const getTxDataFromEVMEventLogs = async (
197197
}
198198
Object.entries(argKeys).map(([eventKey, argKey]) => {
199199
// @ts-ignore
200-
const value = argGetters?.[eventKey]?.(args) || get(args, argKey);
200+
let value = argGetters?.[eventKey]?.(args) || get(args, argKey);
201+
if (eventKey === "amount" && (typeof value === "string" || typeof value === "bigint")) {
202+
value = ethers.BigNumber.from(value);
203+
}
201204
if (typeof value !== EventKeyTypes[eventKey] && !Array.isArray(value)) {
202205
throw new Error(
203206
`Type of ${eventKey} retrieved using ${argKey} is ${typeof value} when it must be ${

0 commit comments

Comments
 (0)