Skip to content

Commit

Permalink
added helloWorld config
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidu28 committed Oct 28, 2024
1 parent 14ba354 commit 32b86aa
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions contracts/script/HelloWorldDeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ contract HelloWorldDeployer is Script {
IStrategy helloWorldStrategy;
CoreDeploymentLib.DeploymentData coreDeployment;
HelloWorldDeploymentLib.DeploymentData helloWorldDeployment;
HelloWorldDeploymentLib.DeploymentConfigData helloWorldConfig;
Quorum internal quorum;
ERC20Mock token;
function setUp() public virtual {
deployer = vm.rememberKey(vm.envUint("PRIVATE_KEY"));
vm.label(deployer, "Deployer");

helloWorldConfig = HelloWorldDeploymentLib.readDeploymentConfigValues("deployments/hello-world/", block.chainid);

coreDeployment = CoreDeploymentLib.readDeploymentJson("deployments/core/", block.chainid);

token = new ERC20Mock();
Expand Down
32 changes: 32 additions & 0 deletions contracts/script/utils/HelloWorldDeploymentLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ library HelloWorldDeploymentLib {
address token;
}

struct DeploymentConfigData {
address rewardsOwner;
address rewardsInitiator;
}

function deployContracts(
address proxyAdmin,
CoreDeploymentLib.DeploymentData memory core,
Expand Down Expand Up @@ -86,6 +91,7 @@ library HelloWorldDeploymentLib {

return data;
}


/// write to default output path
function writeDeploymentJson(
Expand All @@ -112,6 +118,32 @@ library HelloWorldDeploymentLib {
vm.writeFile(fileName, deploymentData);
console2.log("Deployment artifacts written to:", fileName);
}


function readDeploymentConfigValues(
string memory directoryPath,
string memory fileName
) internal returns (DeploymentConfigData memory) {
string memory pathToFile = string.concat(directoryPath, fileName);

require(vm.exists(pathToFile), "Deployment file does not exist");

string memory json = vm.readFile(pathToFile);

DeploymentConfigData memory data;

data.rewardsOwner = json.readAddress(".rewardsOwner");
data.rewardsInitiator = json.readAddress(".rewardsInitiator");
return data;
}

function readDeploymentConfigValues(
string memory directoryPath,
uint256 chainId
) internal returns (DeploymentConfigData memory) {
return
readDeploymentConfigValues(directoryPath, string.concat(vm.toString(chainId), ".json"));
}

function _generateDeploymentJson(
DeploymentData memory data,
Expand Down
4 changes: 4 additions & 0 deletions contracts/test/mockData/config/hello-world/1337.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"rewardsOwner": "0x",
"rewardsInitiator": "0x"
}
4 changes: 4 additions & 0 deletions contracts/test/mockData/deployments/hello-world/1337.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"rewardsOwner": "0x3C4293F66941ECa00f4950C10d4255d5c271bAe1",
"rewardsInitiator": "0x3C4293F66941ECa00f4950C10d4255d5c271bAe1"
}

0 comments on commit 32b86aa

Please sign in to comment.