Coder Social home page Coder Social logo

itsnickbarry / hardhat-dependency-compiler Goto Github PK

View Code? Open in Web Editor NEW
36.0 3.0 5.0 70 KB

๐Ÿ“ฆ Compile Solidity sources directly from NPM dependencies

License: MIT License

JavaScript 100.00%
hardhat buidler solidity solc npm yarn dependency dependencies smart-contracts ethereum

hardhat-dependency-compiler's Introduction

Hardhat Dependency Compiler

Compile Solidity sources directly from NPM dependencies.

Installation

npm install --save-dev hardhat-dependency-compiler
# or
yarn add --dev hardhat-dependency-compiler

Usage

Load plugin in Hardhat config:

require('hardhat-dependency-compiler');

Add configuration under the dependencyCompiler key:

option description default
paths Array of dependency paths to compile []
path path to temporary directory where dependencies are imported (relative to Hardhat sources directory) './hardhat-dependency-compiler'
keep whether to keep temporary file directory after compilation is complete (directory will still be deleted and regenerated on each compilation) false
dependencyCompiler: {
  paths: [
    '@openzeppelin/contracts/token/ERC20/IERC20.sol',
  ],
}

hardhat-dependency-compiler's People

Contributors

6str avatar ffoxdd avatar itsnickbarry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hardhat-dependency-compiler's Issues

Error HH306: The 'file' parameter expects a value, but none was passed.

I'm getting this error when passing a .sol file,

dependencyCompiler: { paths: [ '@zircon/periphery/contracts/Token.sol', '@zircon/periphery/contracts/WETH.sol', // '@zircon/energy/contracts/*', '@zircon/energy/contracts/interfaces/IZirconEnergyRevenue.sol', '@zircon/energy/contracts/interfaces/IZirconEnergyFactory.sol', '@zircon/energy/contracts/ZirconEnergyFactory.sol', ], },

the error is invoked only in the last contract

Unexpected hardhat test workflow

When I try to test only one test file with hardhat test test/something.sol it passes 0 tests skipped all of them.
And when I try to test all test files with hardhat test some tests run without their before(() => { ... }) block and variables inited in that blocks are with undefined values.
It will be useful to possible use hardhat args for the test command.

does not take into account dependency resolution

hi there, i am working with a contract that depends on @uniswap/v3-periphery, which in turn depends on @openzeppelin/[email protected] which has a pragma solidity declaration of >=6, <8.

However my project uses 0.8.9 and the @openzeppelin/[email protected] which uses a different structure, and fails when the dependency compiler path is used. I have installed the node_module in the sub directory, at project-root/node_modules/@uniswap/v3-periphery/node_modules/@openzeppelin/contracts, using the resolutions key as defined by yarn, and that seemed to work (i can see the folder) but dependency compiler does not seem to see the resolutions folder or that there is a node_modules in the uniswap periphery folder.

All this to ask, does it make sense to utilize sub / localized dependencies when compiling dependencies?

'dependencyCompiler' does not exist in type 'HardhatUserConfig'

hardhat.config.ts(17,7): error TS2322: Type '{ defaultNetwork: string; networks: any; solidity: string; dependencyCompiler: { paths: string[]; }; }' is not assignable to type 'HardhatUserConfig'.
  Object literal may only specify known properties, and 'dependencyCompiler' does not exist in type 'HardhatUserConfig'.

Error: temporary source directory must have been generated by hardhat-dependency-compiler

Steps to reproduce:

  • Interrupt during compilation (Cmd + C)
  • Delete the files which are untracked in git
  • Try to compile again. Compilation gets locked until this is fixed.

Some hint how to reset this in the error msg would save some time.

To get rid of this error: There is empty directory hardhat-dependency-compiler in the contracts folder. And just have to delete that.

Get artifact of solidity file in external GitHub repository

I want the artifact of https://github.com/ZeframLou/create3-factory/blob/18cfad8d118b25a5092cdfed6bea9c932ca5b6eb/src/CREATE3Factory.sol to use in my hardhat scripts.

I tried

yarn add -D https://github.com/ZeframLou/create3-factory/#18cfad8d118b25a5092cdfed6bea9c932ca5b6eb

which added "create3-factory": "https://github.com/ZeframLou/create3-factory#18cfad8d118b25a5092cdfed6bea9c932ca5b6eb" into dependencies in package.json, and the create3-factory directory was created with all the repository files under node_modules directory.

Then I added the path for dependencyCompiler:

  dependencyCompiler: {
    paths: [
      "create3-factory/src/CREATE3Factory.sol",
    ],
  }

When I try to compile this error appears:

Error HH411: The library create3-factory, imported from contracts/hardhat-dependency-compiler/create3-factory/src/CREATE3Factory.sol, is not installed. Try installing it using npm.

What can be done?

Doesn't work with GitHub actions

This works fine on my local machine, but fails when I run my tests on GitHub actions:

yarn run v1.17.3
$ hardhat typechain
An unexpected error occurred:

{ Error: ENOTEMPTY: directory not empty, rmdir '/github/workspace/contracts/hardhat-dependency-compiler'
    at Object.rmdirSync (fs.js:684:3)
    at OverriddenTaskDefinition._action (/github/workspace/node_modules/hardhat-dependency-compiler/index.js:48:10)
    at Environment._runTaskDefinition (/github/workspace/node_modules/hardhat/src/internal/core/runtime-environment.ts:217:35)
    at Environment.run (/github/workspace/node_modules/hardhat/src/internal/core/runtime-environment.ts:130:25)
    at SimpleTaskDefinition.config_1.task.setAction [as action] (/github/workspace/node_modules/@typechain/hardhat/src/index.ts:58:9)
    at Environment._runTaskDefinition (/github/workspace/node_modules/hardhat/src/internal/core/runtime-environment.ts:217:35)
    at Environment.run (/github/workspace/node_modules/hardhat/src/internal/core/runtime-environment.ts:130:25)
    at main (/github/workspace/node_modules/hardhat/src/internal/cli/cli.ts:188:15)
  errno: -39,
  syscall: 'rmdir',
  code: 'ENOTEMPTY',
  path: '/github/workspace/contracts/hardhat-dependency-compiler' }
error Command failed with exit code 1.

Error: resolved path must be inside of sources directory

Trying to use verification on okc network, configured in hardhat.config.ts

npx hardhat verify --network oktcTestnet --contract contracts/HMToken.sol:HMToken --constructor-args scripts/arguments.js  0x854EC65E9e5e973C458FC2c92F6E0CbD403f5b95

But got :

Error in plugin hardhat-dependency-compiler: resolved path must be inside of sources directory

This is my folder architecture
image

And I'm launching the command from the core folder

Any idea what could cause this issue? I tried without the args not working either. I don't understand the error message as my file are there

Here is the import in HMToken in case it's useful:
image

Doesn't work with `slither`

When trying to run slither it seems that the plugin breaks something with the compilation.

I opened an issue on slither as well as not sure whether the issue with the plugin or slither.

crytic/slither#743

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.