From 329dc6db5b9ca1dd4829b36ee86b9d82b26ea3a8 Mon Sep 17 00:00:00 2001 From: juanbono Date: Mon, 16 Dec 2024 19:13:24 -0300 Subject: [PATCH 1/3] add makefile target --- claim_contracts/Makefile | 6 +++ .../script/DeployAlignedToken.s.sol | 40 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/claim_contracts/Makefile b/claim_contracts/Makefile index abe1c8a640..c3bce0a9a2 100644 --- a/claim_contracts/Makefile +++ b/claim_contracts/Makefile @@ -30,6 +30,12 @@ deploy-token: ## 🚀 Deploy the token contract --broadcast \ --verbosity 3 + +update_token_proxy: + @NEW_TOKEN_PROXY=$$(jq -r '.tokenProxy' "script-out/deployed_contracts.json") && \ + jq --arg new_proxy "$$NEW_TOKEN_PROXY" '.tokenProxy = $$new_proxy' $(CONFIG) > $(CONFIG).tmp \ + && mv $(CONFIG).tmp $(CONFIG) \ + upgrade-token: ## 🚀 Upgrade the token contract cd script && \ forge script UpgradeToken.s.sol \ diff --git a/claim_contracts/script/DeployAlignedToken.s.sol b/claim_contracts/script/DeployAlignedToken.s.sol index ba135abfd6..8282c9801b 100644 --- a/claim_contracts/script/DeployAlignedToken.s.sol +++ b/claim_contracts/script/DeployAlignedToken.s.sol @@ -47,6 +47,46 @@ contract DeployAlignedToken is Script { vm.toString(_safe) ) ); + + string memory deployedAddressesJson = "deployedAddressesJson"; + + string memory tokenProxyKey = "tokenProxy"; + vm.serializeAddress( + deployedAddressesJson, + tokenProxyKey, + address(_tokenProxy) + ); + string memory proxyAdminKey = "proxyAdmin"; + vm.serializeAddress( + deployedAddressesJson, + proxyAdminKey, + Utils.getAdminAddress(address(_tokenProxy)) + ); + string memory safeKey = "safe"; + vm.serializeAddress( + deployedAddressesJson, + safeKey, + address(_safe) + ); + + // serialize all the data + string memory finalJson = + vm.serializeString(deployedAddressesJson, "aligned", "deployed contracts"); + + vm.writeJson(finalJson, _getOutputPath("deployed_contracts.json")); + } + + function _getOutputPath( + string memory fileName + ) internal returns (string memory) { + string memory outputDir = "script-out/"; + + // Create output directory if it doesn't exist + if (!vm.exists(outputDir)) { + vm.createDir(outputDir, true); + } + + return string.concat(outputDir, fileName); } function deployAlignedTokenProxy( From 64c61b7c0b1b9fd32bf5629bf31339e945c7d4c9 Mon Sep 17 00:00:00 2001 From: juanbono Date: Mon, 16 Dec 2024 19:36:52 -0300 Subject: [PATCH 2/3] fixes --- claim_contracts/Makefile | 2 +- .../script/DeployAlignedToken.s.sol | 68 ++++--------------- 2 files changed, 13 insertions(+), 57 deletions(-) diff --git a/claim_contracts/Makefile b/claim_contracts/Makefile index c3bce0a9a2..d642987d2a 100644 --- a/claim_contracts/Makefile +++ b/claim_contracts/Makefile @@ -32,7 +32,7 @@ deploy-token: ## 🚀 Deploy the token contract update_token_proxy: - @NEW_TOKEN_PROXY=$$(jq -r '.tokenProxy' "script-out/deployed_contracts.json") && \ + @NEW_TOKEN_PROXY=$$(jq -r '.tokenProxy' "script-out/deployed_token_addresses.json") && \ jq --arg new_proxy "$$NEW_TOKEN_PROXY" '.tokenProxy = $$new_proxy' $(CONFIG) > $(CONFIG).tmp \ && mv $(CONFIG).tmp $(CONFIG) \ diff --git a/claim_contracts/script/DeployAlignedToken.s.sol b/claim_contracts/script/DeployAlignedToken.s.sol index 8282c9801b..45a87dc610 100644 --- a/claim_contracts/script/DeployAlignedToken.s.sol +++ b/claim_contracts/script/DeployAlignedToken.s.sol @@ -12,30 +12,17 @@ import {Utils} from "./Utils.sol"; contract DeployAlignedToken is Script { function run(string memory config) public { string memory root = vm.projectRoot(); - string memory path = string.concat( - root, - "/script-config/config.", - config, - ".json" - ); + string memory path = string.concat(root, "/script-config/config.", config, ".json"); string memory config_json = vm.readFile(path); address _safe = stdJson.readAddress(config_json, ".safe"); bytes32 _salt = stdJson.readBytes32(config_json, ".salt"); address _deployer = stdJson.readAddress(config_json, ".deployer"); address _foundation = stdJson.readAddress(config_json, ".foundation"); - address _claimSupplier = stdJson.readAddress( - config_json, - ".claimSupplier" - ); + address _claimSupplier = stdJson.readAddress(config_json, ".claimSupplier"); - TransparentUpgradeableProxy _tokenProxy = deployAlignedTokenProxy( - _safe, - _salt, - _deployer, - _foundation, - _claimSupplier - ); + TransparentUpgradeableProxy _tokenProxy = + deployAlignedTokenProxy(_safe, _salt, _deployer, _foundation, _claimSupplier); console.log( string.concat( @@ -49,36 +36,14 @@ contract DeployAlignedToken is Script { ); string memory deployedAddressesJson = "deployedAddressesJson"; + vm.serializeAddress(deployedAddressesJson, "tokenProxy", address(_tokenProxy)); + vm.serializeAddress(deployedAddressesJson, "proxyAdmin", Utils.getAdminAddress(address(_tokenProxy))); + string memory finalJson = vm.serializeAddress(deployedAddressesJson, "safe", address(_safe)); - string memory tokenProxyKey = "tokenProxy"; - vm.serializeAddress( - deployedAddressesJson, - tokenProxyKey, - address(_tokenProxy) - ); - string memory proxyAdminKey = "proxyAdmin"; - vm.serializeAddress( - deployedAddressesJson, - proxyAdminKey, - Utils.getAdminAddress(address(_tokenProxy)) - ); - string memory safeKey = "safe"; - vm.serializeAddress( - deployedAddressesJson, - safeKey, - address(_safe) - ); - - // serialize all the data - string memory finalJson = - vm.serializeString(deployedAddressesJson, "aligned", "deployed contracts"); - - vm.writeJson(finalJson, _getOutputPath("deployed_contracts.json")); + vm.writeJson(finalJson, _getOutputPath("deployed_token_addresses.json")); } - function _getOutputPath( - string memory fileName - ) internal returns (string memory) { + function _getOutputPath(string memory fileName) internal returns (string memory) { string memory outputDir = "script-out/"; // Create output directory if it doesn't exist @@ -99,18 +64,9 @@ contract DeployAlignedToken is Script { vm.broadcast(); AlignedToken _token = new AlignedToken(); - bytes memory _alignedTokenDeploymentData = Utils - .alignedTokenProxyDeploymentData( - _proxyAdmin, - address(_token), - _foundation, - _claim - ); - address _alignedTokenProxy = Utils.deployWithCreate2( - _alignedTokenDeploymentData, - _salt, - _deployer - ); + bytes memory _alignedTokenDeploymentData = + Utils.alignedTokenProxyDeploymentData(_proxyAdmin, address(_token), _foundation, _claim); + address _alignedTokenProxy = Utils.deployWithCreate2(_alignedTokenDeploymentData, _salt, _deployer); return TransparentUpgradeableProxy(payable(_alignedTokenProxy)); } } From fe26d8f06dd77874ab05591bc3245cdb4904f975 Mon Sep 17 00:00:00 2001 From: juanbono Date: Mon, 16 Dec 2024 19:39:17 -0300 Subject: [PATCH 3/3] remove fields --- claim_contracts/Makefile | 2 +- claim_contracts/script/DeployAlignedToken.s.sol | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/claim_contracts/Makefile b/claim_contracts/Makefile index d642987d2a..7a67507710 100644 --- a/claim_contracts/Makefile +++ b/claim_contracts/Makefile @@ -34,7 +34,7 @@ deploy-token: ## 🚀 Deploy the token contract update_token_proxy: @NEW_TOKEN_PROXY=$$(jq -r '.tokenProxy' "script-out/deployed_token_addresses.json") && \ jq --arg new_proxy "$$NEW_TOKEN_PROXY" '.tokenProxy = $$new_proxy' $(CONFIG) > $(CONFIG).tmp \ - && mv $(CONFIG).tmp $(CONFIG) \ + && mv $(CONFIG).tmp $(CONFIG) upgrade-token: ## 🚀 Upgrade the token contract cd script && \ diff --git a/claim_contracts/script/DeployAlignedToken.s.sol b/claim_contracts/script/DeployAlignedToken.s.sol index 45a87dc610..9a96f434a6 100644 --- a/claim_contracts/script/DeployAlignedToken.s.sol +++ b/claim_contracts/script/DeployAlignedToken.s.sol @@ -36,9 +36,7 @@ contract DeployAlignedToken is Script { ); string memory deployedAddressesJson = "deployedAddressesJson"; - vm.serializeAddress(deployedAddressesJson, "tokenProxy", address(_tokenProxy)); - vm.serializeAddress(deployedAddressesJson, "proxyAdmin", Utils.getAdminAddress(address(_tokenProxy))); - string memory finalJson = vm.serializeAddress(deployedAddressesJson, "safe", address(_safe)); + string memory finalJson = vm.serializeAddress(deployedAddressesJson, "tokenProxy", address(_tokenProxy)); vm.writeJson(finalJson, _getOutputPath("deployed_token_addresses.json")); }