wighawag / hardhat-deploy

hardhat deployment plugin
MIT License
1.19k stars 292 forks source link

Generates a deployment that does not match the `Deployment` type at `receipt.at` #305

Open alefbragin opened 2 years ago

alefbragin commented 2 years ago

Describe the bug Hardhat Deploy generates a deployment that does not match the Deployment type. Receipt has string or undefined type for to property, but plugin generates null. This cause error when assign imported deployment JSON to variable of Deployment type:

ERROR in src/contracts/greeter.ts:8:7
TS2322: Type '{ address: string; abi: ({ inputs: { internalType: string; name: string; type: string; }[]; stateMutability: string; type: string; name?: undefined; outputs?: undefined; } | { inputs: never[]; name: string; outputs: { ...; }[]; stateMutability: string; type: string; } | { ...; })[]; ... 10 more ...; storageLayout: {...' is not assignable to type 'Deployment'.
  The types of 'receipt.to' are incompatible between these types.
    Type 'null' is not assignable to type 'string | undefined'.
     6 |
     7 | import greeterDeploymentJson from '../hardhat/deployments/current/Greeter.json';
  >  8 | const greeterDeployment: Deployment = greeterDeploymentJson;
       |       ^^^^^^^^^^^^^^^^^

To Reproduce Steps to reproduce the behavior:

  1. Prepare basic scaffold:
    yarn add --dev hardhat
    yarn exec hardhat  # Create an advanced sample project that uses TypeScript
    yarn add --dev hardhat-deploy @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers ethers
    # and so on...
  2. Deploy Greeter contract: yarn hardhat deploy
  3. Find deployment file Greeter.json and see:
    {
    // ...
    "receipt": {
      "to": null,
      // ...
    }
    // ...
    }

Expected behavior If there are no receipt.to do not generate this property at all.

versions