wighawag / hardhat-deploy-ethers

MIT License
70 stars 25 forks source link

helpers default generic type should be `Contract` instead of `BaseContact` ? #36

Open technophile-04 opened 7 months ago

technophile-04 commented 7 months ago

Description :

Example :

getContract: <ContractType extends ethers.BaseContract = ethers.BaseContract>(name: string, signer?: ethers.Signer | string) => Promise<ContractType>;

Any reason why we are using the default generic slot as ethers.BaseContract instead of ethers.Contract similar to other utilities functions too?

I mean when working with typescript repo you always have your contract type instance (generated from typechain and it could be passed in the generic slot) but there might be some cases where you might don't have types generated and want to interact with contract example, using write or read method while deploying contract :

  await deploy("YourContract", {
    from: deployer,
    args: [deployer],
  });

  // Get the deployed contract
  const yourContract = await hre.ethers.getContract("YourContract", deployer);
  await yourContract.setGreeting("Hello world");
  console.log("Curr greetings", await yourContract.greeting());

Currently this would result in TS error that setGreeting doesn't exist on BaseContract but maybe lol we could be less forgiving as before in ethers v5 I think ?

Tysm !! I am sure there might be some reason why we chose BaseContract and would love to know it 🙌

Raskolnikofff commented 6 months ago

It would be cool for typescript to return the contract type "YourContract" as it do hardhat with getContractAt method