Open naps62 opened 2 years ago
Requires changes in ethers-solc
Since Foundry sort of supports Hardhat-style artifacts (read only, not all cases IIRC) we could have a config setting to choose artifact flavor.
you might be interested in this https://github.com/foundry-rs/hardhat/pull/16 which bakes forge directly into hardhat and also uses an artifacts handler that's compatible with hardhat
@naps62 Let us know if using the Foundry Hardhat plugin solves this for you :)
@onbjerg sorry for taking so long. I am mostly away from the project where this was an issue, so didn't have time to check until now. I'm still interested in figuring this out though, regardless of the project
So here's where I'm at: I tested that plugin. but maybe I misunderstood it's functionality, or didn't find some configuration I should add.
Running hardhat test
seems to now runs forge test
only. What I actually wanted was to keep both test suites in place, but sharing compilation artifacts, so as not to cause conflicting artifacts, and to keep CI times where they are
Seems like this was on the roadmap and then removed? I really don't want to go back to Hardhat at this point but there's legacy tooling that still utilizes HH artifact files so this would be a great add.
Component
Forge
Describe the feature you would like
Foundry has a hardhat-compatibility flag (which from my understanding, sets
libs
andsrc
config values)It also seems to detect existing hardhat projects. When calling
forge init --force
in an existing hardhat repo, I noticed it filled out those same configs as--hh
would. But it also setout = 'artifacts'
, which is the directory used by hardhat.When seeing that, I took it as having the ability to share compilation artifacts with hardhat. Which is a great thing to have, since it means I could do a single compilation, and run both
forge test
andhardhat test
However, the artifacts generated by foundry are apparently not compatible, due to the directory structure generated. It flattens all contracts into a subdir of
artifacts
, whereas hardhat mimics the structure ofcontracts
So for the following project:
Hardhat would give me:
but apparently foundry gives me:
Besides breaking the original expectation (which would be very cool to have, if possible), it also means that
forge init --force
actually creates a broken setup, since artifacts will end up duplicated inside theartifacts
directory. If hardhat is using typechain to infer typings from those, compilation errors will be thrown due to all the duplicatesAdditional context
This is the PR where I tried adding foundry to an existing project: https://github.com/subvisual/discoveryDAO/pull/149
I had to explicitly remove
out = 'artifacts'
due to the described issues. CI is currently set to run two independent compilations