-
Notifications
You must be signed in to change notification settings - Fork 1
/
Chaperone.sol
71 lines (51 loc) · 2.05 KB
/
Chaperone.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
pragma solidity 0.4.18;
import {SafeMath} from "./SafeMath.sol";
contract Chaperone {
using SafeMath for uint;
uint public waitingPeriodInSeconds;
address public chaperone;
mapping (address => uint) pending;
mapping (address => bool) owners;
event SubmitOwnerEvent(address indexed newOwner, uint indexed pendingComplete);
event RejectOwnerEvent(address indexed rejectedOwner, uint indexed rejectedTimestamp);
event ApproveOwnerEvent(address indexed approvedOwner, uint indexed approvedTimestamp);
event ExecuteEvent(address indexed owner, address indexed destination, uint indexed value, bytes data);
modifier isOwner {
assert(owners[msg.sender] == true);
_;
}
modifier isChaperone {
assert(chaperone == msg.sender);
_;
}
function Chaperone(address _owner, address _chaperone, uint _waitingPeriodInSeconds) public {
require(_owner != address(0));
require(_chaperone != address(0));
require(_waitingPeriodInSeconds != 0);
owners[_owner] = true;
chaperone = _chaperone;
waitingPeriodInSeconds = _waitingPeriodInSeconds;
}
function submitOwner(address _pending) isChaperone public {
require(owners[_pending] == false);
require(pending[_pending] == 0);
uint pendingComplete = waitingPeriodInSeconds.add(block.timestamp);
pending[_pending] = pendingComplete;
SubmitOwnerEvent(_pending, pendingComplete);
}
function rejectOwner(address _pending) isOwner public {
pending[_pending] = 0;
RejectOwnerEvent(_pending, block.timestamp);
}
function approveOwner(address _pending) isChaperone public {
require(pending[_pending] != 0);
require(pending[_pending] < waitingPeriodInSeconds.add(block.timestamp));
owners[_pending] = true;
ApproveOwnerEvent(_pending, block.timestamp);
}
function execute(address destination, uint value, bytes data) isOwner public {
require(destination.call.value(value)(data));
ExecuteEvent(msg.sender, destination, value, data);
}
function () public payable {}
}