Skip to content
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

Add Filter Support with Infura provider implementation for fetching events #1830

Closed

Conversation

kshinn
Copy link

@kshinn kshinn commented Aug 2, 2021

This PR addresses #1814 & #1798

With regards to getLogs calls in general, Infura prefers clients use getFilterChanges it ends up being more efficient than the vanilla getLogs and since it is cursor based it ends up being a more consistent set of data.

The changes enable these methods to become generally available to the providers to use as:

let filterId = await provider.newFilter({ topics: [...] });
let updatedLogs = await provider.getFilterChanges(filterId);

Additionally, I've extended the Infura provider to utilize these methods in the event emitter system in order to better service the Contract convenience methods.

@kenerwin88
Copy link

Need this desperately. Any chance it can get merged?

@zemse
Copy link
Collaborator

zemse commented Dec 19, 2021

These methods are used internally in provider.on. While this PR is being looked at, you may use the send API for now.

let filterId = await provider.send('eth_newFilter', [{ topics: [...] }]);
let updatedLogs = await provider.send('eth_getFilterChanges', [filterId]);

@ricmoo
Copy link
Member

ricmoo commented Mar 10, 2022

I didn't add filter support in v5 (it is the default in v6), but I've made changes that should accomplish the same goal in v5.6.

The main reason to hold off on switching to filter ID is that it affects how the FallbackProvider works. In v6, the entire event model has been redesigned so things like filter ID are more friendly.

Please try it out and let me know if you still have any problems. :)

@ricmoo ricmoo added enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published. labels Mar 10, 2022
@kenerwin88
Copy link

Wow, thank you so much @ricmoo! Really appreciate it, and will try it out ASAP!

@ricmoo
Copy link
Member

ricmoo commented May 14, 2022

Closing this now; the issue has been fixed by keeping a larger window to capture getLogs results with no entries which solves the underlying problem for v5 and in v6, uses a solution similar to the one proposed in this PR. :)

Thanks! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants