This PR refactors the way the events coroutines are used and introduces breaking changes.
IMO there were always a few problems with the way that events were always set up:
using the filterId is dumb, it's sufficient to just use eth_getLogs if you know what you're doing. We already did this in hs-web3 when we decided we couldn't rely on being able to install filters on infura or even our own geth node (reliably).
The current coroutines library is limited in the kind of "middle" pipes you can make (between producer and consumer). It was impossible to do certain kinds of effectful processing in the middle. see this issue which inspired the coroutine-transducers library. NOTE: If we agree to merge this PR, I will move that over to a f-o-a-m repo.
In the event that a coroutine terminated early, you didn't necessarily know why. It could have been because the original filter only spanned blocks n to k and we are now on block k+1 so it's run its course. It could also be because the handler told you to TerminateEvent. With these changes you can tell because the coroutine will terminate by yielding a value of type
Where Left will come from the filter running its course and Right will come from the event handler.
I have locally tested this against purescript-web3-tests, but havent pushed eveything because it's a big pain to do everything in unison. If we agree here, I will start to push everything.
This PR refactors the way the events coroutines are used and introduces breaking changes.
IMO there were always a few problems with the way that events were always set up:
using the filterId is dumb, it's sufficient to just use
eth_getLogs
if you know what you're doing. We already did this in hs-web3 when we decided we couldn't rely on being able to install filters on infura or even our own geth node (reliably).The current coroutines library is limited in the kind of "middle" pipes you can make (between producer and consumer). It was impossible to do certain kinds of effectful processing in the middle. see this issue which inspired the coroutine-transducers library. NOTE: If we agree to merge this PR, I will move that over to a
f-o-a-m
repo.In the event that a coroutine terminated early, you didn't necessarily know why. It could have been because the original filter only spanned blocks
n
tok
and we are now on blockk+1
so it's run its course. It could also be because the handler told you toTerminateEvent
. With these changes you can tell because the coroutine will terminate by yielding a value of typewhere
Where
Left
will come from the filter running its course andRight
will come from the event handler.I have locally tested this against purescript-web3-tests, but havent pushed eveything because it's a big pain to do everything in unison. If we agree here, I will start to push everything.