Hi @ricmoo ,
WebSockets events are being received perfectly.
However, when an event comes in, the following returns null:
block = await jsonRpcProvider.getBlock(event.blockNumber); // block is null; the regular provider apparently doesn't know about this block yet.
const creationTime = block.timestamp; // Block is null, so this fails.
Any ideas on how to get the block timestamp when a Websocket event is received? Thanks for your help!
The polling-based providers track this extra state internally to prevent this from happening. I didn't properly cache the block emitted event in the WebSocketProvider to leverage this behaviour from the BaseProvider.
I've got a fix locally and it should be published tomorrow. I'll update this ticket with the progress.
Thanks! :)
This should be fixed now in 5.0.0-beta.189. Please try it out and let me know if you still have any problems. :)
I'm going to close this now, since I think it is fixed. If not, please re-open.
Thanks! :)
Thanks @ricmoo ; all is good on my end!
Most helpful comment
The polling-based providers track this extra state internally to prevent this from happening. I didn't properly cache the block emitted event in the WebSocketProvider to leverage this behaviour from the BaseProvider.
I've got a fix locally and it should be published tomorrow. I'll update this ticket with the progress.
Thanks! :)