Skip to content

Commit

Permalink
refactor: remove OpsTimelockBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
nadir-akhtar committed Oct 30, 2024
1 parent 0e91e5e commit 5f2207a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 93 deletions.
37 changes: 33 additions & 4 deletions src/release-template/2-multisig.s.sol
Original file line number Diff line number Diff line change
@@ -1,18 +1,47 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

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

contract Queue is OpsTimelockBuilder {
contract Queue is MultisigBuilder {
using MultisigCallUtils for MultisigCall[];

MultisigCall[] internal _executorCalls;
MultisigCall[] private _executorCalls;
MultisigCall[] private _opsCalls;

function _queue() internal returns (MultisigCall[] memory) {

function queue() public override returns (MultisigCall[] memory) {
//////////////////////////
// construct executor data here
//////////////////////////

return _executorCalls;
}

/**
* @dev Can be overridden so that executing script can inherit this contract.
*/
function _execute() internal virtual override returns (MultisigCall[] memory) {
// get the queue data
MultisigCall[] memory calls = _queue();

address multiSendCallOnly = zeusAddress("MultiSendCallOnly");
address timelock = zeusAddress("Timelock");

// encode calls for executor
bytes memory executorCalldata = calls.makeExecutorCalldata(multiSendCallOnly, timelock);

address executorMultisig = zeusAddress("ExecutorMultisig");

// encode executor data for timelock
bytes memory timelockCalldata = abi.encodeWithSelector(
ITimelock.queueTransaction.selector, executorMultisig, 0, "", executorCalldata, type(uint256).max
);

_opsCalls.append(timelock, timelockCalldata);

// encode timelock data for ops multisig
return _opsCalls;
}
}
17 changes: 9 additions & 8 deletions src/release-template/3-multisig.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@ import {SafeTx, SafeTxUtils} from "../utils/SafeTxUtils.sol";
import {ITimelock} from "../interfaces/ITimelock.sol";
import {Queue} from "./2-multisig.s.sol";

contract Execute is MultisigBuilder {
contract Execute is Queue {
using MultisigCallUtils for MultisigCall[];
using SafeTxUtils for SafeTx;

MultisigCall[] internal _opsCalls;
MultisigCall[] private _opsCalls;

/**
* @dev Overrides the previous _execute function to execute the queued transactions.
*/
function _execute() internal override returns (MultisigCall[] memory) {
Queue queue = new Queue();

MultisigCall[] memory _executorCalls = queue.queue();
MultisigCall[] memory _executorCalls = _queue();

address multiSendCallOnly = vm.envAddress("ZEUS_DEPLOYED_MultiSendCallOnly");
address multiSendCallOnly = zeusAddress("MultiSendCallOnly");
address timelock = zeusAddress("Timelock");

address timelock = vm.envAddress("ZEUS_DEPLOYED_Timelock");

bytes memory executorCalldata = queue.makeExecutorCalldata(_executorCalls, multiSendCallOnly, timelock);
bytes memory executorCalldata = _executorCalls.makeExecutorCalldata(multiSendCallOnly, timelock);

// execute queued transaction
_opsCalls.append({
Expand Down
81 changes: 0 additions & 81 deletions src/templates/OpsTimelockBuilder.sol

This file was deleted.

13 changes: 13 additions & 0 deletions src/utils/MultisigCallUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,17 @@ library MultisigCallUtils {

return abi.encodeWithSelector(IMultiSend.multiSend.selector, ret);
}

function makeExecutorCalldata(MultisigCall[] memory calls, address multiSendCallOnly, address timelock)
internal
pure
returns (bytes memory)
{
return abi.encodeWithSelector(
IMultiSend.multiSend.selector,
encodeMultisendTxs(calls),
multiSendCallOnly,
timelock
);
}
}

0 comments on commit 5f2207a

Please sign in to comment.