Ability to import event types
See original GitHub issueGreat tool, really really helpful 🙌 This is more of an info sharing issue than anything else, so feel free to close once you’ve seen it.
When using web3
, I wanted a way to be able to use the same typed event handling function for both new events and for historical events. This means that event handling function can not be defined in-line, and therefore the function parameters need to be explicitly typed. Because these types aren’t actually exported however, this is not easy to do.
To get at them, I’ve ended up with this EventType
type:
export type EventType<E extends ContractEvent<any>> = Parameters<
Extract<Parameters<E>[1], Function>
>[1]
which I use within my code like so:
type TransferEvent = EventType<Erc20Contract['events']['Transfer']>
I’m posting this issue as it may be helpful for other developers too. It may even make sense to make this, or something like it, directly available from the types.d.ts
file.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Custom event types after import becomes default events - Jira
Create a new Event with a custom Event type. Export as .ics. Import to Team Calendars. Expected behavior: The Event should have the...
Read more >Can't able to import cancelled type of events in my Calendar ...
But when I tried to cancel/delete those events on Outlook by importing the ics-cancel file, it gives me the message "Could't import calendar....
Read more >Import historical user events | Retail - Google Cloud
This page describes how to import user event data from past events in bulk. Retail API models require user event data for training....
Read more >Event Types | Okta Developer
Event types are the primary method of categorization within the Okta eventing platform. They allow consumers to easily group notable system ...
Read more >Import events to Google Calendar - Computer
You can transfer your events from a different calendar application or Google Account to Google Calendar. When you import an event, guests and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@AuHau I’ve added exactly this in https://github.com/ethereum-ts/TypeChain/pull/219 For now only for
web3v1
branch.I am gonna reopen this issue until it’s merged.
Thanks for sharing!
I also think it would be beneficial to export each event as a separate interface that people could import and us.