Merge pull request #50 from propeller-heads/fp/fix-build-runtime-script

fix(script): Fix build runtime script to handle empty constructor
This commit is contained in:
Zizou
2024-07-17 13:12:17 +02:00
committed by GitHub

View File

@@ -5,12 +5,32 @@ import "forge-std/Script.sol";
contract buildRuntime is Script {
function run() external {
bytes memory args = vm.envBytes("__PROPELLER_DEPLOY_ARGS");
string memory contractRef = vm.envString("__PROPELLER_CONTRACT");
bytes memory deployArgs = getDeployArgs();
string memory contractName = vm.envString("__PROPELLER_CONTRACT");
string memory outFilePath = vm.envString("__PROPELLER_OUT_FILE");
address deployedContract = deployCode(contractRef, args);
address deployedContract = deployContract(contractName, deployArgs);
bytes memory deployedCode = deployedContract.code;
vm.writeFileBinary(outFilePath, deployedCode);
}
function getDeployArgs() internal view returns (bytes memory) {
try vm.envBytes("__PROPELLER_DEPLOY_ARGS") returns (bytes memory args) {
return args;
} catch {
return "";
}
}
function deployContract(string memory contractName, bytes memory args)
internal
returns (address)
{
if (args.length == 0) {
return deployCode(contractName);
} else {
return deployCode(contractName, args);
}
}
}