@@ -573,17 +573,15 @@ function gas_report_to_json
573
573
cat - | " ${REPO_ROOT} /scripts/externalTests/parse_eth_gas_report.py" | jq ' {gas: .}'
574
574
}
575
575
576
- function detect_hardhat_artifact_dir
577
- {
578
- if [[ -e build/ && -e artifacts/ ]]; then
579
- fail " Cannot determine Hardhat artifact location. Both build/ and artifacts/ exist"
580
- elif [[ -e build/ ]]; then
581
- echo -n build/artifacts
582
- elif [[ -e artifacts/ ]]; then
583
- echo -n artifacts
584
- else
585
- fail " Hardhat build artifacts not found."
586
- fi
576
+ function detect_hardhat_artifact_dirs
577
+ {
578
+ # NOTE: The artifacts path is a configured parameter in Hardhat, so the below may fail for new external tests
579
+ # See: https://hardhat.org/hardhat-runner/docs/config#path-configuration
580
+ local artifact_dir=()
581
+ [[ -e build/artifacts ]] && artifact_dir+=(" build/artifacts" )
582
+ [[ -e artifacts/ ]] && artifact_dir+=(" artifacts" )
583
+ (( ${# artifact_dir[@]} != 0 )) || assertFail
584
+ echo -n " ${artifact_dir[@]} "
587
585
}
588
586
589
587
function bytecode_size_json_from_truffle_artifacts
@@ -608,16 +606,17 @@ function bytecode_size_json_from_truffle_artifacts
608
606
function bytecode_size_json_from_hardhat_artifacts
609
607
{
610
608
# NOTE: The output of this function is a series of concatenated JSON dicts rather than a list.
611
-
612
- for artifact in " $( detect_hardhat_artifact_dir) " /build-info/* .json; do
613
- # Each artifact contains Standard JSON output under the `output` key.
614
- # Process it into a dict of the form `{"<file>": {"<contract>": <size>}}`,
615
- # Note that one Hardhat artifact often represents multiple input files.
616
- jq ' .output.contracts | to_entries[] | {
617
- "\(.key)": .value | to_entries[] | {
618
- "\(.key)": (.value.evm.bytecode.object | length / 2)
619
- }
620
- }' " $artifact "
609
+ for artifact_dir in $( detect_hardhat_artifact_dirs) ; do
610
+ for artifact in " $artifact_dir " /build-info/* .json; do
611
+ # Each artifact contains Standard JSON output under the `output` key.
612
+ # Process it into a dict of the form `{"<file>": {"<contract>": <size>}}`,
613
+ # Note that one Hardhat artifact often represents multiple input files.
614
+ jq ' .output.contracts | to_entries[] | {
615
+ "\(.key)": .value | to_entries[] | {
616
+ "\(.key)": (.value.evm.bytecode.object | length / 2)
617
+ }
618
+ }' " $artifact "
619
+ done
621
620
done
622
621
}
623
622
0 commit comments