network icon indicating copy to clipboard operation
network copied to clipboard

refactor(sdk): Support multiple contracts in `ChainEventPoller`

Open teogeb opened this issue 1 year ago • 1 comments

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

teogeb avatar Dec 04 '24 07:12 teogeb

To address your point

Added try-catch around the event listener so that the polling doesn't stop if a listener throws an error.

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 async case, maybe eslint rule that giving async callback to place where (sync) callback is expected would be an error?

harbu avatar Dec 04 '24 15:12 harbu