question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to import event types

See original GitHub issue

Great 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:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
krzkaczorcommented, Apr 5, 2020

@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.

2reactions
AuHaucommented, Apr 2, 2020

Thanks for sharing!

I also think it would be beneficial to export each event as a separate interface that people could import and us.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found