Skip to content

Commit

Permalink
handle log getter error
Browse files Browse the repository at this point in the history
  • Loading branch information
vrtnd committed Nov 17, 2024
1 parent 3584a0d commit 87b26d5
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions src/helpers/processTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const getTxDataFromEVMEventLogs = async (
argGetters,
logGetters,
} = params;
const targetValue = target
const targetValue = target;
// if this is ever used, need to also overwrite fromBlock and toBlock
const overriddenChain = chain ? chain : chainContractsAreOn;
if (isTransfer) {
Expand Down Expand Up @@ -138,8 +138,11 @@ export const getTxDataFromEVMEventLogs = async (
).output;
//console.log(logs)
if (logs.length === 0) {
console.info(`No logs received for ${adapterName} from ${fromBlock} to ${toBlock} with topic ${topic} (${isDeposit ? 'Deposit': 'Withdrawal'}) for ${targetValue}.`);

console.info(
`No logs received for ${adapterName} from ${fromBlock} to ${toBlock} with topic ${topic} (${
isDeposit ? "Deposit" : "Withdrawal"
}) for ${targetValue}.`
);
}
break;
} catch (e) {
Expand All @@ -158,18 +161,26 @@ export const getTxDataFromEVMEventLogs = async (
.process(async (txLog: any, i) => {
data[i] = data[i] || {};
data[i]["isDeposit"] = isDeposit;
await Promise.all(Object.entries(logKeys!).map(async ([eventKey, logKey]) => {
// @ts-ignore
const value = await logGetters?.[eventKey]?.(provider, iface, txLog) || txLog[logKey];
if (typeof value !== EventKeyTypes[eventKey]) {
throw new Error(
`Type of ${eventKey} retrieved using ${logKey} is ${typeof value} when it must be ${
EventKeyTypes[eventKey]
}.`
);
}
data[i][eventKey] = value;
}));
try {
await Promise.all(
Object.entries(logKeys!).map(async ([eventKey, logKey]) => {
// @ts-ignore
const value = (await logGetters?.[eventKey]?.(provider, iface, txLog)) || txLog[logKey];
if (typeof value !== EventKeyTypes[eventKey]) {
throw new Error(
`Type of ${eventKey} retrieved using ${logKey} is ${typeof value} when it must be ${
EventKeyTypes[eventKey]
}.`
);
}
data[i][eventKey] = value;
})
);
} catch (e) {
console.error(
`Unable to get log keys for ${adapterName} with log keys ${logKeys}. SKIPPING TX with hash ${txLog.transactionHash} ${chainContractsAreOn}`
);
}
let parsedLog = {} as any;
try {
parsedLog = iface.parseLog({
Expand Down

0 comments on commit 87b26d5

Please sign in to comment.