hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

Build info functions are inconsistent

Open ItsNickBarry opened this issue 9 months ago • 3 comments

Feedback

The getBuildInfoPath and getBuildInfoOutputPath functions defined in artifact-manager.ts do not behave as described in the ArtifactManager interface in artifacts.ts. Their declared types do not match, and neither returns undefined if the build info id does not exist.

ItsNickBarry avatar May 28 '25 06:05 ItsNickBarry

Note that the build info may exist, but it's output may not.

Maybe elaborate on this in the getBuildInfoOutputPath description? Why wouldn't it exist if outputSelection is passed to solc?

ItsNickBarry avatar May 28 '25 07:05 ItsNickBarry

Thank you for reporting! This is a great catch! Our artifact manager implementation should match the descriptions present in the interface. We'll definitely update it - adding it to our TODOs

Maybe elaborate on this in the getBuildInfoOutputPath description? Why wouldn't it exist if outputSelection is passed to solc?

Noted! Will do! One reason for that to happen is if, let's say, the hardhat process crashes after one is written but other is not created yet.

galargh avatar May 28 '25 15:05 galargh

It also opens the possibility of cleaning up the artifacts folder if it grows too much

alcuadrado avatar May 29 '25 14:05 alcuadrado

Why do the source name keys in the build info json now start with project/?

edit: Never mind. See artifact.inputSourceName for the key associated with a particular contract.

ItsNickBarry avatar Jul 13 '25 23:07 ItsNickBarry