@kodex-data/flat-zeppelin
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-rc.4 • Public • Published

@kodex-data/flat-zeppelin

@kodex-data/flat-zeppelin is a hardhat plugin that allows you to minify your complex solidity projects, reducing bundle size and optimizing module structure. It is especially useful for projects that rely on large libraries like OpenZeppelin.

Installation

You can install the plugin using Yarn or npm:

yarn add @kodex-data/flat-zeppelin 
# or
npm install @kodex-data/flat-zeppelin 

Configuration

To use the plugin, add the following line at the top of your hardhat.config.ts file:

import '@kodex-data/flat-zeppelin'

Then, add the following configuration object to your hardhat.config.ts file:

export default <HardhatUserConfig>{
  flatZeppelin: {
    /** License added to the cleaned content */
    license: 'MIT',
    /** if provided, flatted solidity file will be saved to given path */
    outputFile: 'flatted.sol',
    /** Temporary directory for storing intermediate files */
    tempDir: './.flat-zeppelin',
    /** Directory to saved flatted typechain types */
    targetDir: './typechain-types',
    /** Whether to keep the temporary directory after running */
    keepTemp: false,
    /** Version to add to the flattened solidity content */
    version: '0.8.4',
    /** Whether to enable debug mode */
    debug: false
  },
  // ...
}

Usage

To flat compile your contracts, run the following command:

npx hardhat flat-build

optimized output:

typechain-types
├── ERC165.ts
├── ERC20.ts
├── ERC20Permit.ts
├── ERC20PermitToken.ts
├── ERC721.ts
├── IERC20.ts
├── IERC20Metadata.ts
├── IERC20Permit.ts
├── IERC721.ts
├── IERC721Enumerable.ts
├── IERC721Metadata.ts
├── IERC721Receiver.ts
├── IGovernor.ts
├── IVotes.ts
├── Multicall2.ts
├── Ownable.ts
├── PhxCollectible.ts
├── Treasury.ts
├── Votes.ts
├── common.ts
├── factories
│   ├── ERC165__factory.ts
│   ├── ERC20PermitToken__factory.ts
│   ├── ERC20Permit__factory.ts
│   ├── ERC20__factory.ts
│   ├── ERC721__factory.ts
│   ├── IERC20Permit__factory.ts
│   ├── IERC20__factory.ts
│   └── index.ts
├── hardhat.d.ts
└── index.ts

normal typechain output:

typechain-types
├── @openzeppelin
│   └── contracts
│       └── token
│           ├── ERC20
│           │   ├── ERC20.ts
│           │   ├── IERC20.ts
│           │   └── extensions
│           │       └── draft-ERC20Permit.sol
│           │           └── ERC20Permit.ts
│           └── ERC721
│               ├── ERC721.ts
│               └── IERC721.ts
├── ERC20.ts
├── ERC20Permit.ts
├── ERC20PermitToken.ts
├── ERC721.ts
├── IERC20.ts
├── IERC721.ts
├── common.ts
├── contracts
│   ├── ERC20PermitToken.ts
├── factories
│   ├── @openzeppelin
│   │   └── contracts
│   │       └── token
│   │           ├── ERC20
│   │           │   ├── ERC20__factory.ts
│   │           │   ├── IERC20__factory.ts
│   │           │   └── extensions
│   │           │       └── draft-ERC20Permit.sol
│   │           │           └── ERC20Permit__factory.ts
│   │           └── ERC721
│   │               ├── ERC721__factory.ts
│   │               └── IERC721__factory.ts
│   ├── ERC20PermitToken__factory.ts
│   ├── ERC20Permit__factory.ts
│   ├── ERC20__factory.ts
│   ├── ERC721__factory.ts
│   ├── IERC20__factory.ts
│   ├── IERC721__factory.ts
│   └── contracts
│       └── ERC20PermitToken__factory.ts
└── index.ts

Package Sidebar

Install

npm i @kodex-data/flat-zeppelin

Weekly Downloads

1

Version

0.0.1-rc.4

License

MIT

Unpacked Size

80.3 kB

Total Files

13

Last publish

Collaborators

  • wizardsorb
  • brittanneica
  • oldcryptogeek