From 89bd9fefc2922b36eb2244a2b2ff71568add443d Mon Sep 17 00:00:00 2001 From: Thrilok kumar Date: Mon, 5 Feb 2024 00:27:47 +0530 Subject: [PATCH] added executePayload function --- contracts/Timelock.sol | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/contracts/Timelock.sol b/contracts/Timelock.sol index da422ac..9771a39 100644 --- a/contracts/Timelock.sol +++ b/contracts/Timelock.sol @@ -114,6 +114,23 @@ contract InstaTimelockV2 { return returnData; } + function executePayload(address target, string memory signature, bytes memory data) public returns (bytes memory) { + require(msg.sender == address(this), "Timelock::executePayload: Call must come from Timelock."); + bytes memory callData; + + if (bytes(signature).length == 0) { + callData = data; + } else { + callData = abi.encodePacked(bytes4(keccak256(bytes(signature))), data); + } + + // solium-disable-next-line security/no-call-value + (bool success, bytes memory returnData) = target.delegatecall(callData); + require(success, "Timelock::executePayload: Transaction execution reverted."); + + return returnData; + } + function getBlockTimestamp() internal view returns (uint) { // solium-disable-next-line security/no-block-members return block.timestamp;