mirror of
https://github.com/Instadapp/dsa-governance.git
synced 2024-07-29 22:27:52 +00:00
added guardian logics
This commit is contained in:
parent
c68386bf7f
commit
23421b1f08
|
@ -2,12 +2,13 @@ pragma solidity ^0.7.0;
|
||||||
|
|
||||||
import "./SafeMath.sol";
|
import "./SafeMath.sol";
|
||||||
|
|
||||||
contract InstaTimelock {
|
contract InstaTimelockV2 {
|
||||||
using SafeMath for uint;
|
using SafeMath for uint;
|
||||||
|
|
||||||
event NewAdmin(address indexed newAdmin);
|
event NewAdmin(address indexed newAdmin);
|
||||||
event NewPendingAdmin(address indexed newPendingAdmin);
|
event NewPendingAdmin(address indexed newPendingAdmin);
|
||||||
event NewDelay(uint indexed newDelay);
|
event NewDelay(uint indexed newDelay);
|
||||||
|
event NewGuardian(address indexed newGuardian);
|
||||||
event CancelTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta);
|
event CancelTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta);
|
||||||
event ExecuteTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta);
|
event ExecuteTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta);
|
||||||
event QueueTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta);
|
event QueueTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta);
|
||||||
|
@ -18,17 +19,19 @@ contract InstaTimelock {
|
||||||
|
|
||||||
address public admin;
|
address public admin;
|
||||||
address public pendingAdmin;
|
address public pendingAdmin;
|
||||||
|
address pubic guardian;
|
||||||
uint public delay;
|
uint public delay;
|
||||||
|
|
||||||
mapping (bytes32 => bool) public queuedTransactions;
|
mapping (bytes32 => bool) public queuedTransactions;
|
||||||
|
|
||||||
|
|
||||||
constructor(address admin_, uint delay_) {
|
constructor(address admin_, uint delay_, address guardian_) {
|
||||||
require(delay_ >= MINIMUM_DELAY, "Timelock::constructor: Delay must exceed minimum delay.");
|
require(delay_ >= MINIMUM_DELAY, "Timelock::constructor: Delay must exceed minimum delay.");
|
||||||
require(delay_ <= MAXIMUM_DELAY, "Timelock::setDelay: Delay must not exceed maximum delay.");
|
require(delay_ <= MAXIMUM_DELAY, "Timelock::setDelay: Delay must not exceed maximum delay.");
|
||||||
|
|
||||||
admin = admin_;
|
admin = admin_;
|
||||||
delay = delay_;
|
delay = delay_;
|
||||||
|
guardian = guardian_;
|
||||||
}
|
}
|
||||||
|
|
||||||
fallback() external payable { }
|
fallback() external payable { }
|
||||||
|
@ -42,6 +45,13 @@ contract InstaTimelock {
|
||||||
emit NewDelay(delay);
|
emit NewDelay(delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setGuardian(address guardian_) public {
|
||||||
|
require(msg.sender == address(this), "Timelock::setGuardian: Call must come from Timelock.");
|
||||||
|
guardian = guardian_;
|
||||||
|
|
||||||
|
emit NewGuardian(guardian_);
|
||||||
|
}
|
||||||
|
|
||||||
function acceptAdmin() public {
|
function acceptAdmin() public {
|
||||||
require(msg.sender == pendingAdmin, "Timelock::acceptAdmin: Call must come from pendingAdmin.");
|
require(msg.sender == pendingAdmin, "Timelock::acceptAdmin: Call must come from pendingAdmin.");
|
||||||
admin = msg.sender;
|
admin = msg.sender;
|
||||||
|
@ -69,7 +79,7 @@ contract InstaTimelock {
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancelTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public {
|
function cancelTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public {
|
||||||
require(msg.sender == admin, "Timelock::cancelTransaction: Call must come from admin.");
|
require(msg.sender == admin || msg.sender == guardian, "Timelock::cancelTransaction: Call must come from admin or guardian.");
|
||||||
|
|
||||||
bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));
|
bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));
|
||||||
queuedTransactions[txHash] = false;
|
queuedTransactions[txHash] = false;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user