ethers.js
ethers.js copied to clipboard
Add multiple addresses support to Provider#getLogs
Describe the Feature
ETH RPC allows multiple contract addresses to be passes to eth_getLogs method - documentation. However, typescript types describe address as string | undefined: https://github.com/ethers-io/ethers.js/blob/master/packages/contracts/src.ts/index.ts#L66
Please add support for an array of contract addresses
Code Example
provider.getLogs({
fromBlock: 2883822,
toBlock: 2884900,
address: ['0x049aba7510f45BA5b64ea9E658E342F904DB358D', '0x7fb83000B8eD59D3eAD22f0D584Df3a85fBC0086']
});
I probably won't be adding this in v5, but it is already present in my local version of v6 I'm working on, hoping to get out a beta release soon.
The reason it wasn't added in v5 originally is because the EtherscanProvider doesn't support filtering by multiple addresses. But these days, it is not as essential provider as it once was as there are myriad other community providers to work from. :)
I think throwing an exception for the case of EtherscanProvider can be an OK idea. It is definetelly possible for some providers to not support it. But as far as it is part of the spec, I think exception is the best thing to do.
That's exactly what v6 does. :)
@ricmoo I'm in need of this feature.
Do you think it would be feasible to backport it to 5.7? I believe I can take on this task.
(Congrats on 5.7!)