|
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"; |
2 | 3 | import { ethers } from "ethers"; |
3 | 4 | import { Chain } from "@defillama/sdk/build/general"; |
4 | 5 | import { get } from "lodash"; |
@@ -125,17 +126,16 @@ export const getTxDataFromEVMEventLogs = async ( |
125 | 126 | let logs = [] as any[]; |
126 | 127 | for (let i = 0; i < 5; i++) { |
127 | 128 | 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 | + }); |
139 | 139 | //console.log(logs) |
140 | 140 | break; |
141 | 141 | } catch (e) { |
@@ -197,7 +197,10 @@ export const getTxDataFromEVMEventLogs = async ( |
197 | 197 | } |
198 | 198 | Object.entries(argKeys).map(([eventKey, argKey]) => { |
199 | 199 | // @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 | + } |
201 | 204 | if (typeof value !== EventKeyTypes[eventKey] && !Array.isArray(value)) { |
202 | 205 | throw new Error( |
203 | 206 | `Type of ${eventKey} retrieved using ${argKey} is ${typeof value} when it must be ${ |
|
0 commit comments