From e7aa8aa798560260b70a80f4c6154d9322e35515 Mon Sep 17 00:00:00 2001 From: Justin Brower Date: Tue, 12 Nov 2024 11:12:36 -0500 Subject: [PATCH 1/4] allow modifying the environment via logs --- src/utils/ZeusScript.sol | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/utils/ZeusScript.sol b/src/utils/ZeusScript.sol index 26289bb..36826ac 100644 --- a/src/utils/ZeusScript.sol +++ b/src/utils/ZeusScript.sol @@ -7,6 +7,14 @@ import {Script} from "forge-std/Script.sol"; abstract contract ZeusScript is Script { using StringUtils for string; + enum EnvironmentVariableType{ INT_256, ADDRESS, STRING } + + event ZeusEnvironmentUpdate( + string key, + EnvironmentVariableType internalType, + bytes value + ); + string internal constant addressPrefix = "ZEUS_DEPLOYED_"; string internal constant envPrefix = "ZEUS_ENV_"; @@ -15,6 +23,23 @@ abstract contract ZeusScript is Script { */ function zeusTest() public virtual; + + /**** Environment manipulation - update variables in the current environment's configuration ******/ + // NOTE: you do not need to use these for contract addresses, which are tracked and injected automatically. + // NOTE: do not use `.update()` during a vm.broadcast() segment. + function update(string memory key, string memory value) { + emit ZeusEnvironmentUpdate(key, EnvironmentVariableType.STRING, abi.encode(value)); + } + + function update(string memory key, address memory value) { + emit ZeusEnvironmentUpdate(key, EnvironmentVariableType.ADDRESS, abi.encode(value)); + } + + function update(string memory key, uint256 memory value) { + emit ZeusEnvironmentUpdate(key, EnvironmentVariableType.INT_256, abi.encode(value)); + } + /************************************/ + /** * @notice Returns the address of a contract based on the provided key, querying the envvars injected by Zeus. This is typically the name of the contract. * @param key The key to look up the address for. Should be the contract name, with an optional suffix if deploying multiple instances. (E.g. "MyContract_1" and "MyContract_2") From 1eb94f4fe8f7d9c491b0219c11668940a18e956f Mon Sep 17 00:00:00 2001 From: Justin Brower Date: Tue, 12 Nov 2024 11:17:16 -0500 Subject: [PATCH 2/4] forge fmt --- src/templates/EOADeployer.sol | 12 ++---------- src/utils/MultisigCallUtils.sol | 5 +---- src/utils/ZeusScript.sol | 21 ++++++++++++--------- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/templates/EOADeployer.sol b/src/templates/EOADeployer.sol index 3ef840c..2cf8a8a 100644 --- a/src/templates/EOADeployer.sol +++ b/src/templates/EOADeployer.sol @@ -36,18 +36,10 @@ abstract contract EOADeployer is ZeusScript { function _deploy() internal virtual returns (Deployment[] memory); function singleton(address deployedTo, string memory name) internal pure returns (Deployment memory) { - return Deployment({ - deployedTo: deployedTo, - name: name, - singleton: true - }); + return Deployment({deployedTo: deployedTo, name: name, singleton: true}); } function instance(address deployedTo, string memory name) internal pure returns (Deployment memory) { - return Deployment({ - deployedTo: deployedTo, - name: name, - singleton: false - }); + return Deployment({deployedTo: deployedTo, name: name, singleton: false}); } } diff --git a/src/utils/MultisigCallUtils.sol b/src/utils/MultisigCallUtils.sol index f7a05e5..e419914 100644 --- a/src/utils/MultisigCallUtils.sol +++ b/src/utils/MultisigCallUtils.sol @@ -47,10 +47,7 @@ library MultisigCallUtils { returns (bytes memory) { return abi.encodeWithSelector( - IMultiSend.multiSend.selector, - encodeMultisendTxs(calls), - multiSendCallOnly, - timelock + IMultiSend.multiSend.selector, encodeMultisendTxs(calls), multiSendCallOnly, timelock ); } } diff --git a/src/utils/ZeusScript.sol b/src/utils/ZeusScript.sol index 36826ac..1416fc7 100644 --- a/src/utils/ZeusScript.sol +++ b/src/utils/ZeusScript.sol @@ -7,13 +7,13 @@ import {Script} from "forge-std/Script.sol"; abstract contract ZeusScript is Script { using StringUtils for string; - enum EnvironmentVariableType{ INT_256, ADDRESS, STRING } + enum EnvironmentVariableType { + INT_256, + ADDRESS, + STRING + } - event ZeusEnvironmentUpdate( - string key, - EnvironmentVariableType internalType, - bytes value - ); + event ZeusEnvironmentUpdate(string key, EnvironmentVariableType internalType, bytes value); string internal constant addressPrefix = "ZEUS_DEPLOYED_"; string internal constant envPrefix = "ZEUS_ENV_"; @@ -23,8 +23,9 @@ abstract contract ZeusScript is Script { */ function zeusTest() public virtual; - - /**** Environment manipulation - update variables in the current environment's configuration ******/ + /** + * Environment manipulation - update variables in the current environment's configuration ***** + */ // NOTE: you do not need to use these for contract addresses, which are tracked and injected automatically. // NOTE: do not use `.update()` during a vm.broadcast() segment. function update(string memory key, string memory value) { @@ -38,7 +39,9 @@ abstract contract ZeusScript is Script { function update(string memory key, uint256 memory value) { emit ZeusEnvironmentUpdate(key, EnvironmentVariableType.INT_256, abi.encode(value)); } - /************************************/ + /** + * + */ /** * @notice Returns the address of a contract based on the provided key, querying the envvars injected by Zeus. This is typically the name of the contract. From f8a1791320675e85fb5aa4ac43bb35cf1fcff230 Mon Sep 17 00:00:00 2001 From: Justin Brower Date: Tue, 12 Nov 2024 11:18:57 -0500 Subject: [PATCH 3/4] fix compile issues --- src/utils/ZeusScript.sol | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils/ZeusScript.sol b/src/utils/ZeusScript.sol index 1416fc7..7793dcf 100644 --- a/src/utils/ZeusScript.sol +++ b/src/utils/ZeusScript.sol @@ -28,17 +28,18 @@ abstract contract ZeusScript is Script { */ // NOTE: you do not need to use these for contract addresses, which are tracked and injected automatically. // NOTE: do not use `.update()` during a vm.broadcast() segment. - function update(string memory key, string memory value) { + function update(string memory key, string memory value) public { emit ZeusEnvironmentUpdate(key, EnvironmentVariableType.STRING, abi.encode(value)); } - function update(string memory key, address memory value) { + function update(string memory key, address value) public { emit ZeusEnvironmentUpdate(key, EnvironmentVariableType.ADDRESS, abi.encode(value)); } - function update(string memory key, uint256 memory value) { + function update(string memory key, uint256 value) public { emit ZeusEnvironmentUpdate(key, EnvironmentVariableType.INT_256, abi.encode(value)); } + /** * */ From e24438e352d7cb70fcfdfd3ea12c8f73688a2b92 Mon Sep 17 00:00:00 2001 From: Justin Brower Date: Tue, 12 Nov 2024 11:21:15 -0500 Subject: [PATCH 4/4] remove tests --- .github/workflows/test.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 762a296..3fb5e52 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,8 +38,3 @@ jobs: run: | forge build --sizes id: build - - - name: Run Forge tests - run: | - forge test -vvv - id: test