diff --git a/contracts/Timelock.sol b/contracts/Timelock.sol index 69dcf3c1c..51a6bf740 100644 --- a/contracts/Timelock.sol +++ b/contracts/Timelock.sol @@ -1,10 +1,7 @@ // SPDX-License-Identifier: BSD-3-Clause pragma solidity ^0.8.10; -import "./SafeMath.sol"; - contract Timelock { - using SafeMath for uint; event NewAdmin(address indexed newAdmin); event NewPendingAdmin(address indexed newPendingAdmin); @@ -24,7 +21,7 @@ contract Timelock { mapping (bytes32 => bool) public queuedTransactions; - constructor(address admin_, uint delay_) public { + constructor(address admin_, uint delay_) { require(delay_ >= MINIMUM_DELAY, "Timelock::constructor: Delay must exceed minimum delay."); require(delay_ <= MAXIMUM_DELAY, "Timelock::setDelay: Delay must not exceed maximum delay."); @@ -60,7 +57,7 @@ contract Timelock { function queueTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public returns (bytes32) { require(msg.sender == admin, "Timelock::queueTransaction: Call must come from admin."); - require(eta >= getBlockTimestamp().add(delay), "Timelock::queueTransaction: Estimated execution block must satisfy delay."); + require(eta >= getBlockTimestamp() + delay, "Timelock::queueTransaction: Estimated execution block must satisfy delay."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); queuedTransactions[txHash] = true; @@ -73,6 +70,8 @@ contract Timelock { require(msg.sender == admin, "Timelock::cancelTransaction: Call must come from admin."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); + require(queuedTransactions[txHash], "Timelock::cancelTransaction: Transaction hasn't been queued."); + queuedTransactions[txHash] = false; emit CancelTransaction(txHash, target, value, signature, data, eta); @@ -84,7 +83,7 @@ contract Timelock { bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); require(queuedTransactions[txHash], "Timelock::executeTransaction: Transaction hasn't been queued."); require(getBlockTimestamp() >= eta, "Timelock::executeTransaction: Transaction hasn't surpassed time lock."); - require(getBlockTimestamp() <= eta.add(GRACE_PERIOD), "Timelock::executeTransaction: Transaction is stale."); + require(getBlockTimestamp() <= eta + GRACE_PERIOD, "Timelock::executeTransaction: Transaction is stale."); queuedTransactions[txHash] = false;