Skip to content

Commit

Permalink
Merge pull request #1 from Layr-Labs/jb/environment
Browse files Browse the repository at this point in the history
Allow modifying the environment via events
  • Loading branch information
jbrower95 authored Nov 12, 2024
2 parents 66f7f78 + e24438e commit 42f23e6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 19 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,3 @@ jobs:
run: |
forge build --sizes
id: build

- name: Run Forge tests
run: |
forge test -vvv
id: test
12 changes: 2 additions & 10 deletions src/templates/EOADeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}
}
5 changes: 1 addition & 4 deletions src/utils/MultisigCallUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
29 changes: 29 additions & 0 deletions src/utils/ZeusScript.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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_";

Expand All @@ -15,6 +23,27 @@ 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) public {
emit ZeusEnvironmentUpdate(key, EnvironmentVariableType.STRING, abi.encode(value));
}

function update(string memory key, address value) public {
emit ZeusEnvironmentUpdate(key, EnvironmentVariableType.ADDRESS, abi.encode(value));
}

function update(string memory key, uint256 value) public {
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")
Expand Down

0 comments on commit 42f23e6

Please sign in to comment.