Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Filters and getLogs supports only single address, not an array #38

Closed
drdaeman opened this issue Dec 21, 2017 · 1 comment
Closed

Filters and getLogs supports only single address, not an array #38

drdaeman opened this issue Dec 21, 2017 · 1 comment

Comments

@drdaeman
Copy link

It seems multiple addresses for eth_newFilter and eth_getLogs are not supported. Unlike geth (which has address: DATA|Array), ganache is only capable of filtering on a single address. If an array is passed (even with only a single item in it), ganache will always return an empty list, not matching anything.

Here's the relevant code:

https://github.com/trufflesuite/ganache-core/blob/d1646364d7e4ad667e4c522e0d7877bc962ba949/lib/statemanager.js#L601

As you can see, it only has equality check, so it would fail in presence of array. An obvious fix would be to check for type - e.g. do something in lines of

return expectedAddress == null || (
    Array.isArray(expectedAddress)
        ? expectedAddress.includes(log.address)
        : log.address == expectedAddress);

But - sorry - I'm to lazy to make a proper pull request.

(Copied from #322 (comment) where I've originally posted it. Found the relevant code in this project, so posting it here.)

drdaeman referenced this issue in drdaeman/django-ethereum-events Dec 21, 2017
I was using Ganache-CLI (rather than Pythonic eth-testrpc) as
a standalone node implementation to test things against, and
the tests had failed on it.

The reason is, it's limited and its eth_newFilter implementation
only recognizes a single address. To support simple cases, this
commit converts from array (list) to scalar value if there's
only one element. This should be perfectly harmless and would
also allow some simple tests to past against buggy software.
@mikeseese
Copy link
Contributor

The getLog implementation for this was fixed in #130

If you're still having issues with newFilter, that call is forwarded to https://github.com/MetaMask/provider-engine which should support multiple addresses

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants