Skip to content

Commit

Permalink
fix: ignore parse log errors (#116)
Browse files Browse the repository at this point in the history
# What ❔

- show logs without parsed event if it fails.

## Why ❔

- currently it shows no logs at all if even one of many logs is failed
to parse.

This is a quick fix for now. The issue can be reproduced with proxy
contracts if there are some events emitted which are defined in the
implementation contract. To properly fix it we should use both proxy and
implementation ABI.
  • Loading branch information
Romsters authored Dec 11, 2023
1 parent b7f8060 commit ad69966
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions packages/app/src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,24 @@ export const mapOrder = (array: any[], order: string[], key: string) => {
});
};

export function decodeLogWithABI(log: TransactionLogEntry, abi: AbiFragment[]): TransactionEvent {
export function decodeLogWithABI(log: TransactionLogEntry, abi: AbiFragment[]): TransactionEvent | undefined {
const contractInterface = new utils.Interface(abi);
const decodedLog = contractInterface.parseLog({
topics: log.topics,
data: log.data,
});
return {
name: decodedLog.name,
inputs: decodedLog.eventFragment.inputs.map((input) => ({
name: input.name,
type: input.type as InputType,
value: decodedLog.args[input.name]?.toString(),
})),
};
try {
const decodedLog = contractInterface.parseLog({
topics: log.topics,
data: log.data,
});
return {
name: decodedLog.name,
inputs: decodedLog.eventFragment.inputs.map((input) => ({
name: input.name,
type: input.type as InputType,
value: decodedLog.args[input.name]?.toString(),
})),
};
} catch {
return undefined;
}
}

export function sortTokenTransfers(transfers: TokenTransfer[]): TokenTransfer[] {
Expand Down

0 comments on commit ad69966

Please sign in to comment.