Skip to content

Commit 037e932

Browse files
authored
fix: VerifyAll fails when contract name differs from source file name (#411)
1 parent 57a7296 commit 037e932

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

.changeset/slow-files-pay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-eth": patch
3+
---
4+
5+
foundry: fix verfiyAll script

templates/solidity-frameworks/foundry/packages/foundry/script/VerifyAll.s.sol

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,22 @@ contract VerifyAll is Script {
9090
}
9191
}
9292

93-
function _getCompiledBytecode(string memory contractName) internal view returns (string memory compiledBytecode) {
93+
function _getCompiledBytecode(string memory contractName) internal returns (string memory compiledBytecode) {
9494
string memory root = vm.projectRoot();
95-
string memory path = string.concat(root, "/out/", contractName, ".sol/", contractName, ".json");
96-
compiledBytecode = vm.readFile(path);
95+
string memory defaultPath = string.concat(root, "/out/", contractName, ".sol/", contractName, ".json");
96+
97+
try vm.readFile(defaultPath) returns (string memory content) {
98+
compiledBytecode = content;
99+
} catch {
100+
string[] memory inputs = new string[](3);
101+
inputs[0] = "bash";
102+
inputs[1] = "-c";
103+
inputs[2] = string.concat(
104+
"find '", root, "/out' -name '", contractName, ".json' -not -path '*/build-info/*' -print -quit | tr -d '\\n'"
105+
);
106+
FfiResult memory f = tempVm(address(vm)).tryFfi(inputs);
107+
compiledBytecode = vm.readFile(string(f.stdout));
108+
}
97109
}
98110

99111
function searchStr(uint96 idx, string memory searchKey) internal pure returns (string memory) {

0 commit comments

Comments
 (0)