-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: generic ebo events #17
Conversation
GRT-79 Wrap events with predefined structure
In order to have a consistent way to handle events and to be able to create "synthetic" events on our end we need a way to represent blockchain events in a normalized way. Draft idea to wrap events coming from type EboEvent = "ResponseCreated" | "RequestCreated";
type EboEventData <EboEvent> = EboEvent extends "ResponseCreated" ? ResponseCreated : RequestCreated;
interface ResponseCreated {
id: string;
response: string;
request_id: string;
}
type Event<T extends EboEvent> = {
name: T;
blocknumber: bigint;
data: EventData<T>;
}; AC:
|
@@ -73,7 +67,7 @@ export class ProtocolProvider { | |||
}; | |||
} | |||
|
|||
async getEvents(_fromBlock: bigint, _toBlock: bigint): Promise<EboEvent[]> { | |||
async getEvents(_fromBlock: bigint, _toBlock: bigint): Promise<AnyEboEvent[]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only weird thing regarding this new approach, I had to declare a new type to be used with an array of EBO events.
There might be another way to do this that I don't know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async getEvents(_fromBlock: bigint, _toBlock: bigint): Promise<AnyEboEvent[]> { | |
async getEvents(_fromBlock: bigint, _toBlock: bigint): Promise<EboEvent<EventName>[]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
a86b663
to
c07b536
Compare
The base branch was changed.
🤖 Linear
Closes GRT-79
Description
Refactors EBO events for strict type checking.