Skip to content

cpuchain/hh2-tasks

Repository files navigation

hh2-tasks

NPM Version Statements

Extending Hardhat2 with npx hardhat flatten:all and npx hardhat typechain:fix.

Notice

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.

Requirements

  • 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 )

Usage

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;

flatten:all

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.

Usage:

  • npx hardhat flatten:all --input ./contracts --output ./flatten

  • (Both 'input' and 'output' parameters are optional. They default to './contracts' and './flatten'.)

typechain:fix

Fixes Typechain definitions for ESM generated by Hardhat compile

hh2-tasks/remappings

Brings remappings.ts support for Hardhat2 as well, see https://hardhat.org/docs/reference/foundry-compatibility for more info about remappings on the contract.

About

Extending Hardhat2 with flatten:all and typechain:fix

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages