[ethers-v5] Generate and export typed events - #457
Conversation
馃 Changeset detectedLatest commit: b1d079f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
c410820 to
af89cba
Compare
af89cba to
e4edd2c
Compare
krzkaczor
left a comment
There was a problem hiding this comment.
-
Does this implementation work with overloaded events (events with the same name but different signatures)? I don't think so as there would be a name conflict. I think we need to dump the whole signature into the type name if we detect multiple events with the same name (I think that there is already a function that does this).
-
I think it makes sense to use these pregenerated exported types in the event filters code here: https://github.com/ethereum-ts/TypeChain/pull/457/files#diff-a783a7ebd19f6659f4d15eafcb5014e2881776e245845089383b47e5b4758f99R231
| @@ -0,0 +1,6 @@ | |||
| --- | |||
| '@typechain/ethers-v5': minor | |||
| '@typechain/ethers-v5-test': minor | |||
There was a problem hiding this comment.
We don't version -test packages as they are not published. You can simply remove this line.
There was a problem hiding this comment.
Does this implementation work with overloaded events (events with the same name but different signatures)?
Just noticed that it doesn't generate filters properly due to events overloading.
I think it makes sense to use these pregenerated exported types in the event filters code here https://github.com/ethereum-ts/TypeChain/pull/457/files#diff-a783a7ebd19f6659f4d15eafcb5014e2881776e245845089383b47e5b4758f99R231
I am not able to see the highlighted code from this PR link above. Do you see it or can you pls give me link from the repo code instead of from the PR diff?
There was a problem hiding this comment.
Sorry. New link: https://github.com/ethereum-ts/TypeChain/blob/master/packages/target-ethers-v5-test/types/Events.d.ts#L211
Basically this return type and extracted Event type represent the same event. I wonder if these could be somehow reused?
| [BigNumber] & { value1: BigNumber } | ||
| >; | ||
|
|
||
| export type Event1_TypedEvent = TypedEvent< |
There was a problem hiding this comment.
Can we simply use AnonEvent1Event instead of AnonEvent1_TypedEvent in a happy case? Where there are overloads let's use Event3_bool_uint256_Event instead of Event3_bool_uint256_TypedEvent. So basically just drop Typed.
| filters: { | ||
| "AnonEvent1(uint256)"( | ||
| value1?: BigNumberish | null | ||
| ): TypedEventFilter<[BigNumber], { value1: BigNumber }>; |
There was a problem hiding this comment.
Here it would be perfect to reuse the already generated type ie:
TypedEventFilter<AnonEvent1Event>; but I think it's not that simple so we can ship initial implementation without this and later improve.
There was a problem hiding this comment.
I agree we should, that may involve some refactor to the TypedEventFilter generics. Maybe we can clean up the code in another PR.
Usage
#440