dethcrypto / dethcrypto/TypeChain

Why doesn't decodeEventLog return a typed result?

Open
#736 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
2.8k
Forks
376
PR merge metrics
No merged PRs in 30d

Description

For a bit of context, [queryFilter()](https://docs.ethers.io/v5/api/contract/contract/#Contract-queryFilter) results are typed, I believe by this code:
https://github.com/dethcrypto/TypeChain/blob/47ab6513aaf960ce2a0425fdf6e0561ca482b182/packages/target-ethers-v5/src/codegen/events.ts#L92
For example, in my use case of interacting with the AaveV3 Pool contract, I can
```
const events: LiquidationCallEvent[] = await AaveV3Pool.queryFilter(AaveV3Pool.filters.LiquidationCall());
```
and then I can type-safely have access to the liquidation [call event args](LiquidationCallEvent[]). For example, `events[0].args.liquidator` works.

But for some reason (maybe there is a good reason?) they aren't used for `decodeEventLog` results. So for example, if instead I get the logs manually and parse them for the LiquidationCall event:
```
const liquidationCallFilterWithBlockRanges = {
...AaveV3Pool.filters.LiquidationCall(),
fromBlock: 0,
toBlock: "latest"
};
const liquidationLogs = await ethers.provider.getLogs(liquidationCallFilterWithBlockRanges);
const parsedLiquidationLogs = liquidationLogs.map(log => {
return AaveV3Pool.interface.decodeEventLog(AaveV3Pool.interface.events["LiquidationCall(address,address,address,uint256,uint256,address,bool)"], log.data, log.topics);
})
```
then `parsedLiquidationLogs` has type `Result[]`. Is there a reason for this? Why can't `AaveV3Pool.interface`'s parsing methods return typed objects like `queryFilter`?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.