question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Events returned by WebSocketProvider inconsistent with getLogs

See original GitHub issue

Hi @ricmoo ,

When I receive an event via Websockets, the event.blockNumber appears in hex (but otherwise seems to work fine).

However, when I do provider.getLogs() (using normal Infura provider), the log.blockNumber is in decimal format.

My assumption has been that a log (using normal provider) and a Websocket event are the same type of object. Is that correct? Should both be returning decimal blockNumber?

Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
ricmoocommented, Apr 21, 2020

Both should be returning a decimal. You are right, the subscribed events in the WebSocketProvider is skipping the regular wrapping for block, but logs are still wrapped properly. I’ll fix it shortly. And double check everything else is being normalized correctly. 😃

1reaction
bbartoncommented, Apr 22, 2020

I can confirm that the block numbers are returned correctly for your code snippets above.

The issue I’m encountering is when listening for events:

    // Listen for all contract events.
    wsContract.on("*", (event) => {
      console.log("New event from block: ", event.blockNumber); // Returns a hex value
    });

Read more comments on GitHub >

github_iconTop Results From Across the Web

ethers.js Why aren't logs filtering? (query returned more than ...
Yes, I was filtering the logs very wrong. Let's look at this amazing oopsie from the code block above: const logs = await...
Read more >
Documentation - Ethers.js
Receive an event when ANY transfer occurs daiContract.on("Transfer", (from, to, amount, ... Returns a new WebSocketProvider connected to url as the network.
Read more >
Release Notes — Web3.py 5.31.3 documentation
Doc fix: Pending transaction filter returns a TransactionFilter not a ... Fixed issues with parsing tuples and nested tuples in event logs (#2211) ......
Read more >
getPastEvents throws errors with websocket provider but not ...
The websocket provider seems to error out. I know there is a limit of 10000 events returned from a call, I start at...
Read more >
Everything You Ever Wanted to Know About Events and Logs ...
Understand Events and Logs in Ethereum, how to make an event scraper, ... Just calling getLogs would return logs from the entire chain, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found