Skip to content

Commit

Permalink
Tooling fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shahthepro committed Jun 7, 2024
1 parent 5806608 commit 810e129
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions contracts/utils/GovFive.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,27 @@ library GovFive {
GovFiveAction memory propAction = prop.actions[i];

targets[i] = propAction.receiver;
payloads[i] =
abi.encodePacked(abi.encodePacked(bytes4(keccak256(bytes(propAction.fullsig)))), propAction.data);
payloads[i] = abi.encodePacked(bytes4(keccak256(bytes(propAction.fullsig))), propAction.data);
}

bytes32 salt = keccak256(bytes(prop.description));

TimelockController timelock = TimelockController(payable(Addresses.TIMELOCK));
receiver = Addresses.TIMELOCK;

opHash = timelock.hashOperationBatch(targets, values, payloads, hex"", salt);
opHash = timelock.hashOperationBatch(targets, values, payloads, bytes32(0), salt);

if (timelock.isOperation(opHash)) {
bytes4 executeSig = bytes4(keccak256(bytes("executeBatch(address[],uint256[],bytes[],bytes32,bytes32)")));

payload = abi.encodePacked(executeSig, abi.encode(targets, values, payloads, hex"", salt));
console.log("Yet to be exeucted.");
payload = abi.encodePacked(executeSig, abi.encode(targets, values, payloads, bytes32(0), salt));
} else {
bytes4 scheduleSig =
bytes4(keccak256(bytes("scheduleBatch(address[],uint256[],bytes[],bytes32,bytes32,delay)")));
bytes4(keccak256(bytes("scheduleBatch(address[],uint256[],bytes[],bytes32,bytes32,uint256)")));

payload = abi.encodePacked(scheduleSig, abi.encode(targets, values, payloads, hex"", salt, 2 days));
console.log("Yet to be scheduled.");
payload = abi.encodePacked(scheduleSig, abi.encode(targets, values, payloads, bytes32(0), salt, 2 days));
}
}

Expand Down Expand Up @@ -112,6 +113,10 @@ library GovFive {
console.log("Scheduling...");
(bool success, bytes memory data) = receiver.call(payload);

if (!success || !timelock.isOperationDone(opHash)) {
revert("Failed to schedule");
}

(receiver, payload, opHash) = getSafeTxData(prop);
}

Expand All @@ -124,6 +129,12 @@ library GovFive {

(bool success, bytes memory data) = receiver.call(payload);

if (!success || !timelock.isOperationDone(opHash)) {
revert("Failed to execute");
}

console.log("Executed");

vm.stopPrank();
}

Expand Down

0 comments on commit 810e129

Please sign in to comment.