forked from cryppadotta/dotta-license
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLicenseAccessControl.sol
173 lines (151 loc) · 3.68 KB
/
LicenseAccessControl.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
pragma solidity ^0.4.19;
/**
* @title LicenseAccessControl
* @notice This contract defines organizational roles and permissions.
*/
contract LicenseAccessControl {
/**
* @notice ContractUpgrade is the event that will be emitted if we set a new contract address
*/
event ContractUpgrade(address newContract);
event Paused();
event Unpaused();
/**
* @notice CEO's address FOOBAR
*/
address public ceoAddress;
/**
* @notice CFO's address
*/
address public cfoAddress;
/**
* @notice COO's address
*/
address public cooAddress;
/**
* @notice withdrawal address
*/
address public withdrawalAddress;
bool public paused = false;
/**
* @dev Modifier to make a function only callable by the CEO
*/
modifier onlyCEO() {
require(msg.sender == ceoAddress);
_;
}
/**
* @dev Modifier to make a function only callable by the CFO
*/
modifier onlyCFO() {
require(msg.sender == cfoAddress);
_;
}
/**
* @dev Modifier to make a function only callable by the COO
*/
modifier onlyCOO() {
require(msg.sender == cooAddress);
_;
}
/**
* @dev Modifier to make a function only callable by C-level execs
*/
modifier onlyCLevel() {
require(
msg.sender == cooAddress ||
msg.sender == ceoAddress ||
msg.sender == cfoAddress
);
_;
}
/**
* @dev Modifier to make a function only callable by CEO or CFO
*/
modifier onlyCEOOrCFO() {
require(
msg.sender == cfoAddress ||
msg.sender == ceoAddress
);
_;
}
/**
* @dev Modifier to make a function only callable by CEO or COO
*/
modifier onlyCEOOrCOO() {
require(
msg.sender == cooAddress ||
msg.sender == ceoAddress
);
_;
}
/**
* @notice Sets a new CEO
* @param _newCEO - the address of the new CEO
*/
function setCEO(address _newCEO) external onlyCEO {
require(_newCEO != address(0));
ceoAddress = _newCEO;
}
/**
* @notice Sets a new CFO
* @param _newCFO - the address of the new CFO
*/
function setCFO(address _newCFO) external onlyCEO {
require(_newCFO != address(0));
cfoAddress = _newCFO;
}
/**
* @notice Sets a new COO
* @param _newCOO - the address of the new COO
*/
function setCOO(address _newCOO) external onlyCEO {
require(_newCOO != address(0));
cooAddress = _newCOO;
}
/**
* @notice Sets a new withdrawalAddress
* @param _newWithdrawalAddress - the address where we'll send the funds
*/
function setWithdrawalAddress(address _newWithdrawalAddress) external onlyCEO {
require(_newWithdrawalAddress != address(0));
withdrawalAddress = _newWithdrawalAddress;
}
/**
* @notice Withdraw the balance to the withdrawalAddress
* @dev We set a withdrawal address seperate from the CFO because this allows us to withdraw to a cold wallet.
*/
function withdrawBalance() external onlyCEOOrCFO {
require(withdrawalAddress != address(0));
withdrawalAddress.transfer(this.balance);
}
/** Pausable functionality adapted from OpenZeppelin **/
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @notice called by any C-level to pause, triggers stopped state
*/
function pause() public onlyCLevel whenNotPaused {
paused = true;
Paused();
}
/**
* @notice called by the CEO to unpause, returns to normal state
*/
function unpause() public onlyCEO whenPaused {
paused = false;
Unpaused();
}
}