Giter VIP home page Giter VIP logo

hardhat's People

Contributors

gakonst avatar github-actions[bot] avatar klassicd avatar mattsse avatar mshakeg avatar onbjerg avatar shawnharmsen avatar tynes 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

hardhat's Issues

Add test task

Issue summary

  • Add test task that delegates to forge test

Tests Pass with Panic

See https://github.com/foundry-rs/hardhat/runs/6646586678?check_suite_focus=true

@foundry-rs/hardhat
 | thread 'main' panicked at 'error binding to 127.0.0.1:8545: error creating server listener: Address already in use (os error 98)', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.18/src/server/server.rs:87:17
 | note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@foundry-rs/hardhat-anvil
 |     ✔ can send transaction (386ms)
 |     ✔ can send transaction with env provider
 | 

It looks like anvil has already started and its trying to be started again?

Hardhat Artifact Source Name incorrect

Hardhat generates the source name in the format as a relative path to the file containing the source while this plugin adds the name of the source file with the name of the contract appended.

This plugin:

"sourceName": "L1CrossDomainMessenger.sol:L1CrossDomainMessenger"

Hardhat:

"sourceName": "contracts/L1/messaging/L1CrossDomainMessenger.sol"

The offending line is here:

sourceName: this._getFullyQualifiedNameFromPath(artifactPath),

hardhat-anvil does not allow connecting to anvil node running in docker

I'm trying to run a hardhat project that uses an anvil node in docker. So I set the url for the anvil network in the hardhat config to "http://anvil-1:8545/" where anvil-1 is the name of the service that contains the anvil node, instead of setting it to http://127.0.0.1:8545/ as this is required for the hardhat service to connect to the anvil-1 service.

Below is the error that the hardhat service fails with:

Error in plugin @foundry-rs/hardhat-anvil: Anvil network only works with localhost
2023-10-03 10:14:05 NomicLabsHardhatPluginError: Anvil network only works with localhost
2023-10-03 10:14:05     at Function.getCheckedArgs (/app/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/@foundry-rs/hardhat-anvil/src/anvil-service.ts:85:13)
2023-10-03 10:14:05     at async Function.create (/app/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/@foundry-rs/hardhat-anvil/src/anvil-service.ts:98:18)
2023-10-03 10:14:05     at async handlePluginTask (/app/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/@foundry-rs/hardhat-anvil/src/index.ts:207:24)
2023-10-03 10:14:05     at async Environment._runTaskDefinition (/app/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/hardhat/src/internal/core/runtime-environment.ts:333:14)
2023-10-03 10:14:05     at async Environment.run (/app/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/hardhat/src/internal/core/runtime-environment.ts:166:14)
2023-10-03 10:14:05     at async main (/app/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/hardhat/src/internal/cli/cli.ts:280:7)

Access default hardhat `compile` and `test` while still using this plugin

Is there some way to still access the native hardhat calls using this plugin?

I really like how this cleanly integrates into hardhat and replaces the compilation pipeline with forge and hardhat node with anvil as it gives a huge performance boost. And because it generates hardhat artifacts, all the hardhat scripts work well with foundry under the hood.

However, it would still be useful to do the default hardhat compile from time to time to be able to generate typechain artifacts that I can pass to the front-end. And similarly, I can't seem to figure out a way to run the native hardhat tests, as hardhat test only looks for forge tests.

Unable to resolve import: "INSERT_CONTRACT" with remappings when using NPM workspaces

The situation

I have Turborepo + pnpm project setup; a workspaces monorepo with a symlink dependency graph.

When running hardhat compile with the foundry-rs/hardhat-* plugins installed I get the following mapping errors.

[⠊] Compiling...
[⠒] Unable to resolve import: "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol" with remappings:
        contracts/=/Users/kames/workspace/kames/code/turbo-eth/contracts/
[⠢] Unable to resolve import: "@openzeppelin/contracts/access/Ownable.sol" with remappings:
        contracts/=/Users/kames/workspace/kames/code/turbo-eth/contracts/
[⠆] Unable to resolve import: "@openzeppelin/contracts/token/ERC20/IERC20.sol" with remappings:
        contracts/=/Users/kames/workspace/kames/code/turbo-eth/contracts/
...
...
...
[⠊] Unable to resolve import: "../../node_modules/zeppelin-solidity/contracts//math/SafeMath.sol" with remappings:
        contracts/=/Users/kames/workspace/kames/code/turbo-eth/contracts/

This is obviously a problem with my monorepo build system, but just wanted to flag this issue.

Maybe someone has an idea for a good work-around to get foundry-rs to work nicely in an NPM workspaces build setup?

Failed to install solc 0.8.15: Checksum mismatch for version 0.8.15

The Situation

Just finished installing foundryup and adding the hardhat plugins to an existing project.

When running hadhat compile I have gotten 2 different CLI outputs; only run 3 times.

However, the main issue I am reporting is the checksum mismatch for v0.8.15

1st and 3rd time

[⠘] installing solc version "0.5.8"
[⠃] Successfully installed solc 0.5.8
[⠊] installing solc version "0.8.15"
[⠒] Failed to install solc 0.8.15: Checksum mismatch for version 0.8.15

Error: 
   0: Checksum mismatch for version 0.8.15

Location:
   cli/src/compile.rs:100

2nd time

[⠢] installing solc version "0.7.6"
[⠔] Successfully installed solc 0.7.6
[⠒] installing solc version "0.4.26"
[⠆] Successfully installed solc 0.4.26
[⠆] installing solc version "0.7.3"
[⠰] Successfully installed solc 0.7.3
[⠰] installing solc version "0.5.17"
[⠆] Successfully installed solc 0.5.17
[⠢] installing solc version "0.6.12"
[⠢] Successfully installed solc 0.6.12
[⠆] installing solc version "0.8.15"
[⠔] Failed to install solc 0.8.15: Checksum mismatch for version 0.8.15

Bug: installed from npm and have "valid main entry" error

summary

  • after installing the deps, cannot do npx hardhat actions because of valid main entry error
  • for hardhat-anvil can work around that error by changing node_modules/@foundry-rs/hardhat-anvil/package.json and change main from dist/index.js to dist/src/index.js

Steps to reproduce

install in sample hardhat project / existing project

npm i --save-dev @foundry-rs/hardhat

using @foundry-rs/hardhat

hardhat.config.js

require("@foundry-rs/hardhat");
// require("@foundry-rs/hardhat-anvil");
// require("@foundry-rs/hardhat-forge");
// require("@foundry-rs/easy-foundryup");


/**
 * @type import('hardhat/config').HardhatUserConfig
 */
module.exports = {
  defaultNetwork: "anvil",
  anvil: {
    url: "http://127.0.0.1:8545/",
    launch: false,
  },
  solidity: "0.8.4",
};

try to run node with anvil

➜  integration git:(master) ✗ npx hardhat node
An unexpected error occurred:

Error: Cannot find module '/Users/m1/Desktop/integration/node_modules/@foundry-rs/hardhat/dist/index.js'. Please verify that the package.json has a valid "main" entry

try just hardhat

➜  integration git:(master) ✗ npx hardhat
An unexpected error occurred:

Error: Cannot find module '/Users/m1/Desktop/integration/node_modules/@foundry-rs/hardhat/dist/index.js'. Please verify that the package.json has a valid "main" entry

using @foundry-rs/hardhat-anvil

try using anvil

//hardhat.config.js
// require("@foundry-rs/hardhat");
require("@foundry-rs/hardhat-anvil");
// require("@foundry-rs/hardhat-forge");
// require("@foundry-rs/easy-foundryup");


/**
 * @type import('hardhat/config').HardhatUserConfig
 */
module.exports = {
  defaultNetwork: "anvil",
  anvil: {
    url: "http://127.0.0.1:8545/",
    launch: false,
  },
  solidity: "0.8.4",
};
npm i --save-dev @foundry-rs/hardhat-anvil
➜  integration git:(master) ✗ npx hardhat node                          
An unexpected error occurred:

Error: Cannot find module '/Users/m1/Desktop/integration/node_modules/@foundry-rs/hardhat-anvil/dist/index.js'. Please verify that the package.json has a valid "main" entry

go to node_modules/@foundry-rs/hardhat-anvil/package.json and change main from dist/index.js to dist/src/index.js

{
  "name": "@foundry-rs/hardhat-anvil",
  "version": "0.1.2",
  "description": "Hardhat plugin for managing Anvil",
  "homepage": "https://github.com/foundry-rs/hardhat",
  "repository": "github:foundry-rs/hardhat",
  "license": "MIT",
  "main": "dist/src/index.js",

and get the value.url is missing error

➜  integration git:(master) ✗ npx hardhat node
Error in plugin @nomiclabs/hardhat-anvil: Anvil network config is invalid: value.url is missing

For more info run Hardhat with --show-stack-traces

hardhat-anvil allowUnlimitedContractSize doesn't work

Description

I've set allowUnlimitedContractSize to true in my anvil hardhat network config, however I still get the following error when trying to deploy contracts that exceed the default 24KB.

ProviderError: max initcode size exceeded

Looking through the code it doesn't seem like the allowUnlimitedContractSize is being considered for the --code-size-limit anvil flag

Suggestion

If allowUnlimitedContractSizeis true set --code-size-limit to usize::MAX i.e. 2**32

Error HH108: Cannot connect to the network anvil

I am importing hardhat-anvil, but the additional params (ex: launch) aren't recognized by typescript. It also is not using the accounts I specify (I've tried accounts: { mnemonic: ... } as well as the array of private keys).

image
image

Stripped-down version of my config:

import '@nomiclabs/hardhat-ethers';
import '@nomiclabs/hardhat-etherscan';
import '@nomiclabs/hardhat-solhint';
import '@nomiclabs/hardhat-waffle';
import '@openzeppelin/hardhat-upgrades';
import '@typechain/hardhat';
import '@foundry-rs/hardhat-anvil';
import 'hardhat-deploy';

import * as dotenv from 'dotenv';
import { HardhatUserConfig } from 'hardhat/config';

const config: HardhatUserConfig = {
  networks: {
    anvil: {
      url: 'http://localhost:8545',
      chainId: 1337,
      accounts: [process.env.ADMIN_PRIVATE_KEY!],
      launch: true,
    },
  },
};

export default config;

I can get it to connect if I start anvil in a separate terminal, but I still need to be able to deploy from the ADMIN_PRIVATE_KEY account. Any ideas?

Error Message when `forge` not installed

The error message for hardhat compile when forge is not installed does not tell users this fact. This could help users debug the build process more easily. The following error is produced:

An unexpected error occurred:

TypeError: Cannot read properties of null (reading 'code')
    at analyzeModuleNotFoundError (/home/circleci/project/node_modules/hardhat/src/internal/core/config/config-loading.ts:161:13)
    at Environment.run (/home/circleci/project/node_modules/hardhat/src/internal/core/runtime-environment.ts:136:33)
    at async main (/home/circleci/project/node_modules/hardhat/src/internal/cli/cli.ts:218:5)
error Command failed with exit code 1.

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.