Extending Hardhat2 with npx hardhat flatten:all and npx hardhat typechain:fix.
Since this library is intended to use with Hardhat2 only, this repo shall not receive updates if not necessary.
Consider using Hardhat3 and hh3-tasks as Hardhat3 is now production ready.
-
Hardhat2
-
Glob ( >= 13.0.6 )
-
Ethers ( == 6.16.0, optional, install if using hh2-tasks/fixtures )
-
Ethers-Opt ( == 1.0.10, optional, install if using hh2-tasks/fixtures/signers )
hh2-tasks shall add those following tasks
-
npx hardhat flatten:all -
npx hardhat typechain:fix
as well as the following keys for hardhat config on hardhat.config.cts
import 'hh2-tasks';
import { getRemappingsTransformerFunc } from 'hh2-tasks/remappings';
const config = {
hh2Tasks: {
flattenAll: true,
typechainFix: true,
},
// Uses remappings.txt to remap import paths (like foundry)
preprocess: {
eachLine: async () => {
const { transform } = await getRemappingsTransformerFunc();
return {
transform,
}
},
},
}
export default config;Flattens all Solidity (.sol) files found under a specified contracts source directory, then outputs the flattened versions into a parallel directory tree under a specified output directory.
-
npx hardhat flatten:all --input ./contracts --output ./flatten
-
(Both 'input' and 'output' parameters are optional. They default to './contracts' and './flatten'.)
Fixes Typechain definitions for ESM generated by Hardhat compile
Brings remappings.ts support for Hardhat2 as well, see https://hardhat.org/docs/reference/foundry-compatibility for more info about remappings on the contract.