dethcrypto / dethcrypto/TypeChain

Bug: Typechain does not populate warnings/errors if hardhat config has improper import setting

Open
#733 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
2.8k
Forks
376
PR merge metrics
No merged PRs in 30d

Description

Not sure if this belongs to hardhat or typechain repo, or even if it is a 'bug' as it involves incorrectly importing a hardhat plugin, but might be noteworthy. TLDR: duplicate definition warnings not populated back to the tty

Example wrong config:

```typescript
import * as dotenv from "dotenv";

import type { HardhatUserConfig, task } from "hardhat/config";
import "@nomiclabs/hardhat-ethers";
import "@typechain/hardhat";
import * as abiExporter from "hardhat-abi-exporter";

dotenv.config();

const config: HardhatUserConfig = {
solidity: {
version: '0.8.15',
settings: {
metadata: {
bytecodeHash: 'none',
},
optimizer: {
enabled: true,
runs: 1_000,
details: {
yul: false,
},
},
outputSelection: {
'*': {
'*': [
'abi',
'evm.bytecode',
'evm.deployedBytecode',
'evm.methodIdentifiers',
'metadata',
],
'': ['ast'],
},
},
},
},
networks: {
hardhat: {
allowUnlimitedContractSize: false,
},
mainnet: {
url: `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`,
},
rinkeby: {
url: `https://rinkeby.infura.io/v3/${process.env.INFURA_API_KEY}`,
},
goerli: {
url: `https://goerli.infura.io/v3/${process.env.GOERLI_RPC}`,
},
},
paths: {
sources: './contracts',
tests: './test',
cache: './cache',
artifacts: './artifacts',
},
typechain: {
outDir: 'types/',
target: 'ethers-v5',
},
abiExporter: {
path: "./abis",
runOnCompile: true,
clear: true,
flat: false,
only: [],
spacing: 2,
pretty: true,
},
};

export default config;
```

Correct config:
```ts
import * as dotenv from "dotenv";

import type { HardhatUserConfig, task } from "hardhat/config";
import "@nomiclabs/hardhat-ethers";
import "@typechain/hardhat";
import "hardhat-abi-exporter";

dotenv.config();

const config: HardhatUserConfig = {
solidity: {
version: '0.8.15',
settings: {
metadata: {
bytecodeHash: 'none',
},
optimizer: {
enabled: true,
runs: 1_000,
details: {
yul: false,
},
},
outputSelection: {
'*': {
'*': [
'abi',
'evm.bytecode',
'evm.deployedBytecode',
'evm.methodIdentifiers',
'metadata',
],
'': ['ast'],
},
},
},
},
networks: {
hardhat: {
allowUnlimitedContractSize: false,
},
mainnet: {
url: `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`,
},
rinkeby: {
url: `https://rinkeby.infura.io/v3/${process.env.INFURA_API_KEY}`,
},
goerli: {
url: `https://goerli.infura.io/v3/${process.env.GOERLI_RPC}`,
},
},
paths: {
sources: './contracts',
tests: './test',
cache: './cache',
artifacts: './artifacts',
},
typechain: {
outDir: 'types/',
target: 'ethers-v5',
},
abiExporter: {
path: "./abis",
runOnCompile: true,
clear: true,
flat: false,
only: [],
spacing: 2,
pretty: true,
},
};

export default config;
```

When compiling with the first config:
```shell
Solidity 0.8.15 is not fully supported yet. You can still use Hardhat, but some features, like stack traces, might not work correctly.

Learn more at https://hardhat.org/reference/solidity-support

Generating typings for: 20 artifacts in dir: types/ for target: ethers-v5
Successfully generated 42 typings!
Compiled 18 Solidity files successfully
```

When compiling with the second config
```shell
Solidity 0.8.15 is not fully supported yet. You can still use Hardhat, but some features, like stack traces, might not work correctly.

Learn more at https://hardhat.org/reference/solidity-support

Generating typings for: 20 artifacts in dir: types/ for target: ethers-v5
Successfully generated 42 typings!
Compiled 18 Solidity files successfully
duplicate definition - InsufficientLiquidity()
duplicate definition - InsufficientLiquidity()
duplicate definition - InvalidPath()
duplicate definition - ZeroAddress()
```

no `duplicate definition` warning is emitted

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.