cavanmflynn / ethers-multicall

Make multiple Ethereum network requests in a single HTTP query. ethcall for ethers v5.
MIT License
224 stars 99 forks source link

Strongly-typed contracts #9

Open janklimo opened 3 years ago

janklimo commented 3 years ago

Is there a way to currently (or in the future) make the contract aware of the functions it supports? Example:

Screen Shot 2021-05-09 at 01 36 19

Thanks to TypeChain we have a generated contract type which would be as follows for the example above:

start_time(
  overrides?: CallOverrides
): Promise<{
  0: BigNumber;
}>;

I'm thinking there might be a way to pass it to the Contract class if we make it generic — taking contract type as a type argument.

apoorvlathey commented 3 years ago

It would be great to see it natively supported by the package.

Till then, we can do like this:

const contract = new MulticallContract(address, ABI) as unknown as ContractType
ChrisChan888 commented 2 years ago

It would be great to see it natively supported by the package.

Till then, we can do like this:

const contract = new MulticallContract(address, ABI) as unknown as ContractType

Will return values with typed in this expression when calling provider.all?

apoorvlathey commented 2 years ago

It would be great to see it natively supported by the package. Till then, we can do like this:

const contract = new MulticallContract(address, ABI) as unknown as ContractType

Will return values with typed in this expression when calling provider.all?

image

Sadly no. You'd have to provide the return datatypes manually to .all as shown above