-
Notifications
You must be signed in to change notification settings - Fork 38
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(sdk): Support multiple contracts in ChainEventPoller
#2928
base: main
Are you sure you want to change the base?
Conversation
To address your point
We had a discussion on video meeting (me and Teo ofc), maybe better to leave out and have it as caller's responsibility (especially since it was like this before). On that front, regarding the |
address: uniq(this.listeners.map((l) => l.contractAddress)), | ||
topics: [uniq(this.listeners.map((l) => l.contractInterfaceFragment.topicHash))], |
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.
We need to check that this definitely works as we think it does
} | ||
|
||
const createEventLogItem = ( | ||
eventName: string, eventArgs: any[], blockNumber: number |
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.
eventName: string, eventArgs: any[], blockNumber: number | |
eventName: string, | |
eventArgs: any[], | |
blockNumber: number |
): Partial<Log> => { | ||
const contractInterface = new Interface(createAbi(eventName)) | ||
return { | ||
blockNumber: blockNumber, |
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.
blockNumber: blockNumber, | |
blockNumber, |
logger.debug('Polling', { fromBlock, eventNames }) | ||
events = await contract.queryFilter([eventNames], fromBlock) as EventLog[] | ||
const filter = { |
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.
Maybe worth commenting how the filtering logic here works, e.g.
address == (X OR Y OR Z) AND topic === (A OR B OR C)
Refactored
ChainEventPoller
to support multiple contracts simultaneously. Now the class is a singleton and we can define contract methods as a listener parameter. This optimizes log fetching as there needs to be only one poller running even if multiple contract events are listened.Also we don't now need to create a
Contract
instance just for adding event a listener. This allows us to simplify e.g.Operator
class (in a follow-up PR).