Skip to content

Commit

Permalink
feat: update base class to faciliate fetching envvars
Browse files Browse the repository at this point in the history
  • Loading branch information
nadir-akhtar committed Oct 30, 2024
1 parent a223cb2 commit 0e91e5e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
6 changes: 1 addition & 5 deletions src/release-template/2-multisig.s.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

import {
MultisigCall,
MultisigCallUtils,
OpsTimelockBuilder
} from "../templates/OpsTimelockBuilder.sol";
import {MultisigCall, MultisigCallUtils, OpsTimelockBuilder} from "../templates/OpsTimelockBuilder.sol";

contract Queue is OpsTimelockBuilder {
using MultisigCallUtils for MultisigCall[];
Expand Down
4 changes: 2 additions & 2 deletions src/templates/EOADeployer.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

import {Script} from "forge-std/Script.sol";
import {ZeusScript} from "../utils/ZeusScript.sol";

/**
* @title EOADeployer
* @notice Template for an Externally Owned Account (EOA) deploy script.
*/
abstract contract EOADeployer is Script {
abstract contract EOADeployer is ZeusScript {
/**
* @notice Struct for deployment information.
* @param deployedTo The address where the contract is deployed.
Expand Down
9 changes: 6 additions & 3 deletions src/templates/MultisigBuilder.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

import {Script} from "forge-std/Script.sol";
import {ZeusScript} from "../utils/ZeusScript.sol";
import {MultisigCall, MultisigCallUtils} from "../utils/MultisigCallUtils.sol";
import {SafeTx, EncGnosisSafe} from "../utils/SafeTxUtils.sol";

/**
* @title MultisigBuilder
* @dev Abstract contract for building arbitrary multisig scripts.
*/
abstract contract MultisigBuilder is Script {
abstract contract MultisigBuilder is ZeusScript {
using MultisigCallUtils for MultisigCall[];

string internal constant multiSendCallOnlyName = "MultiSendCallOnly";

/**
* @notice Constructs a SafeTx object for a Gnosis Safe to ingest.
* @return A SafeTx struct containing the transaction data to post to the Safe API.
Expand All @@ -26,7 +28,8 @@ abstract contract MultisigBuilder is Script {
// creates and return SafeTx object
// assumes 0 value (ETH) being sent to multisig

address multiSendCallOnly = vm.envAddress("ZEUS_DEPLOYED_MultiSendCallOnly");
address multiSendCallOnly = zeusAddress(multiSendCallOnlyName);

return SafeTx({to: multiSendCallOnly, value: 0, data: data, op: EncGnosisSafe.Operation.DelegateCall});
}

Expand Down
21 changes: 21 additions & 0 deletions src/utils/ZeusScript.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

import {StringUtils} from "./StringUtils.sol";
import {Script} from "forge-std/Script.sol";

contract ZeusScript is Script {
using StringUtils for string;

string internal constant addressPrefix = "ZEUS_DEPLOYED_";

/**
* @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")
* @return The address of the contract associated with the provided key. Reverts if envvar not found.
*/
function zeusAddress(string memory key) internal view returns (address) {
string memory envvar = addressPrefix.concat(key);
return vm.envAddress(envvar);
}
}

0 comments on commit 0e91e5e

Please sign in to comment.