Commit 8677175c authored by Mark Tyneway's avatar Mark Tyneway

contracts-bedrock: fix deploy script

parent 2e1fb209
...@@ -103,8 +103,8 @@ abstract contract Deployer is Script { ...@@ -103,8 +103,8 @@ abstract contract Deployer is Script {
string memory deploymentName = deployments[i].name; string memory deploymentName = deployments[i].name;
string memory deployTx = _getDeployTransactionByContractAddress(addr); string memory deployTx = _getDeployTransactionByContractAddress(addr);
string memory contractName = stdJson.readString(deployTx, ".contractName"); string memory contractName = _getContractNameFromDeployTransaction(deployTx);
console.log("Syncing %s", deploymentName); console.log("Syncing %s: %s", deploymentName, contractName);
string memory fqn = getFullyQualifiedName(contractName); string memory fqn = getFullyQualifiedName(contractName);
string[] memory args = getDeployTransactionConstructorArguments(deployTx); string[] memory args = getDeployTransactionConstructorArguments(deployTx);
...@@ -261,6 +261,18 @@ abstract contract Deployer is Script { ...@@ -261,6 +261,18 @@ abstract contract Deployer is Script {
return string(res); return string(res);
} }
/// @notice Returns the contract name from a deploy transaction. Removes the semver from the contract
// name if present.
function _getContractNameFromDeployTransaction(string memory _deployTx) internal returns (string memory) {
string memory contractName = stdJson.readString(_deployTx, ".contractName");
string[] memory cmd = new string[](3);
cmd[0] = Executables.bash;
cmd[1] = "-c";
cmd[2] = string.concat(Executables.echo, " ", contractName, " | ", Executables.sed, " -E 's/[.][0-9]+\\.[0-9]+\\.[0-9]+//g'");
bytes memory res = vm.ffi(cmd);
return string(res);
}
/// @notice Returns the constructor arguent of a deployment transaction given a transaction json. /// @notice Returns the constructor arguent of a deployment transaction given a transaction json.
function getDeployTransactionConstructorArguments(string memory _transaction) internal returns (string[] memory) { function getDeployTransactionConstructorArguments(string memory _transaction) internal returns (string[] memory) {
string[] memory cmd = new string[](3); string[] memory cmd = new string[](3);
......
...@@ -8,4 +8,6 @@ library Executables { ...@@ -8,4 +8,6 @@ library Executables {
string internal constant bash = "bash"; string internal constant bash = "bash";
string internal constant jq = "jq"; string internal constant jq = "jq";
string internal constant forge = "forge"; string internal constant forge = "forge";
string internal constant echo = "echo";
string internal constant sed = "sed";
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment