Bug - newFilter result and getFilterChanges params incompatible
kumavis opened this issue · 6 comments
const filterId = await eth.newFilter({ address: contractAddress, topics: [targetTopic], fromBlock: blockNumber, toBlock: 'latest' })
const filterChanges = await eth.getFilterChanges(filterId)
eth.newFilter
returns a BN
eth.getFilterChanges
converts BN to hex but does not use 'quantity' format
<BN: 1>
becomes 0x1
instead of 0x01
suggestion, do either or both:
- fix hex format in
getFilterChanges
- just return hex string from
newFilter
Actually it gets worse:
as a workaround i tried
const filterId = ethUtil.intToHex((await eth.newFilter(filterParams)).toNumber())
but eth.getFilterChanges
still converts the correct 0x01
to 0x1
So I believe to fix this, I will switch newFilter / newBlockFilter and eth_newPendingTransactionFilter to return a bytes data, instead of quantity.
Then I will switch getFilterChanges to data as well, as to not convert it down to a quantity.
However, this would break the spec, and I don't want to. I'm gonna look into a shim for getFilterChanges and logs.
Instead, I will update for the formatting module: https://github.com/ethjs/ethjs-format/blob/master/src/index.js
@kumavis is there a disparity between what geth / parity and TestRPC want for this value?
Is testrpc fine with 0x1 and geth is not? I'll choose whatever mainnet clients are supporting, if its 0x01, then I'll do the next push.
you fixed this