Skip to content

Generate and export named event responses for ethers v5 #440

Description

@Siegrift

Currently TypeChain generates types similar to the following:

class ContractAbc extends Contract {
...
  filters: {
    TemplateCreated(
      templateId: BytesLike | null,
      airnodeId: null,
      endpointId: null,
      parameters: null
    ): TypedEventFilter<
      [string, string, string, string],
      {
        templateId: string;
        airnodeId: string;
        endpointId: string;
        parameters: string;
      }
    >;
    ...

The problem is that I can't use filters to query my event. Instead I want to pass tx.hash, and parse the logs myself. However at that point I would like to cast my event response to the Type generated by TypeChain.

For example, this code:

    contractAbc.provider.once(tx.hash, (tx) => {
      const parsedLog = airnodeRrp.interface.parseLog(tx.logs[0]);
      resolve(parsedLog.args.templateId); // This is untyped (args is basically any)
    })

Instead I would like to have a code like this:

    contractAbc.provider.once(tx.hash, (tx) => {
      const parsedLog = airnodeRrp.interface.parseLog(tx.logs[0]).args as TemplateCreatedEvent;
      resolve(parsedLog.templateId); // parsedLog should be typed
    })

Slightly related: #249

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions