dethcrypto / TypeChain

🔌 TypeScript bindings for Ethereum smart contracts
MIT License
2.76k stars 361 forks source link

typechain-hardhat does not consider hardhat 'sources' config #881

Open FFdhorkin opened 11 months ago

FFdhorkin commented 11 months ago

Hardhat allows you to move your contracts folder: https://hardhat.org/hardhat-runner/docs/config#path-configuration

When config.paths.sources is nonstandard, typechain-hardhat refuses to generate types.

for example:

const config: HardhatUserConfig = {
  solidity: "0.8.18",
  paths: {
    artifacts: "./hardhatstuff/artifacts",
    cache: "./hardhatstuff/artifacts/cache",
    sources: "./hardhatstuff/contracts",
  },
  typechain: {
    discriminateTypes: true,
    outDir: "./hardhatstuff/artifacts/typechain-types",
  },
};
➜  /workspace git:(master) ✗ npx hardhat clean && npx hardhat compile
Generating typings for: 3 artifacts in dir: ./hardhatstuff/artifacts/typechain-types for target: ethers-v6
Successfully generated 0 typings!
Compiled 3 Solidity files successfully (evm target: paris).
Versions:
        "@nomicfoundation/hardhat-ethers": "^3.0.4",
        "@nomicfoundation/hardhat-toolbox": "^3.0.0",
        "@openzeppelin/contracts": "^4.9.3",
        "@typechain/ethers-v6": "^0.4.3",
        "@typechain/hardhat": "^8.0.3",
        "ethers": "^6.7.1",
        "hardhat": "^2.18.0",
        "typechain": "^8.3.1"

Incidentally, it appears if I move it to the default location, compile, then move it back, subsequent compiles properly do types...