monosux/ethereum-block-by-date

Ethers v6 compatibility

Closed this issue · 1 comments

wbt commented

Ethers v6 made some changes to where the providers are located, which leads to some type errors when trying to use this with ethers v6, that the passed provider isn't of the right type.

Changing import { providers as EthersProviders } from 'ethers'; to import { ethers } from 'ethers'; and changing the constructor param type portion from EthersProviders.Provider to ethers.provider seems to do the trick for me locally, but I don't personally have the bandwidth to go through a full investigation of backwards compatibility for updating types if folks are still using ethers v5.

Hi @wbt,

Ethers migration docs say:

all the ethers.providers.* being moved to ethers.*

So, instead of

const provider = new ethers.providers.CloudflareProvider();

You could use:

const provider = new ethers.CloudflareProvider();

I have updated my package documentation with the examples.

Let me know if you have any issues.