EventFilter type doesn't have fromBlock and toBlock fields, even though those are processed and necessary
See original GitHub issueUsing this filter:
const filter = myContract.filters.MyEvent();
const events = await myProvider.getLogs(filter);
I only get the latest event, but if I do this…
const filter = myContract.filters.MyEvent() as any;
filter.fromBlock = 0;
filter.toBlock = "latest";
const events = await myProvider.getLogs(filter);
I correctly get all events.
The cast to any
is necessary because the type EventFilter
doesn’t have fromBlock
and toBlock
fields.
Unless I’m misunderstanding something, this seems wrong.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Event filter not returning correct events web3js
I have just 2 events with different values of the "epc" field. The response I get is the latest event but with the...
Read more >Everything You Ever Wanted to Know About Events and Logs ...
Understand Events and Logs in Ethereum, how to make an event scraper, and how to implement event pagination.
Read more >EventFilters and EventFilter.Item - SAP Community
Hi, I have 2 questions about using EventFilter and the EventFilter.item method. ... forms does not open when you click them if the...
Read more >Documentation - Ethers.js
Returns the number of transactions address has ever sent, as of blockTag. This value is required to be the nonce for the next...
Read more >web3.js Documentation - Read the Docs
After that you need to create a web3 instance and set a provider. ... indexed: true if the field is part of the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@felixwatts Heya! Sorry for the late reply.
Those docs are out of date, and I will get redirects configured for them this week. The docs you are looking for are here: https://docs.ethers.io/v5/api/contract/contract/#Contract-queryFilter
Thanks @zemse !
This should work. And about the
provider.getLogs
, I wanted to bring that up before, but I forgot.It returns empty array instead of error. I unfortunately ran into this when I was demonstrating in an event 😜 and needed to look at old working code. I suggest that if
fromBlock
andtoBlock
is not passed then it should fill in the blanks.filter.fromBlock = 0; filter.toBlock = "latest";
or at least give an error that this key wasn’t passed.Edit: I see that typescript might point that out, but the JS should also do that (I actually demo in browser console using the exposed
window._ethers
).