ethers.js icon indicating copy to clipboard operation
ethers.js copied to clipboard

Add multiple addresses support to Provider#getLogs

Open bogdan opened this issue 3 years ago • 4 comments

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']
});

bogdan avatar Mar 29 '22 13:03 bogdan

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. :)

ricmoo avatar Mar 30 '22 09:03 ricmoo

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.

bogdan avatar Mar 30 '22 11:03 bogdan

That's exactly what v6 does. :)

ricmoo avatar Mar 30 '22 11:03 ricmoo

@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!)

egorFiNE avatar Aug 22 '22 08:08 egorFiNE