-
Notifications
You must be signed in to change notification settings - Fork 0
/
GazeCoinCrowdsaleWhitelist.sol
182 lines (146 loc) · 6.91 KB
/
GazeCoinCrowdsaleWhitelist.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
174
175
176
177
178
179
180
181
182
pragma solidity ^0.4.16;
// ----------------------------------------------------------------------------
// GazeCoin Crowdsale Whitelist
//
// Deployed to : 0x73855EE8C390C5c6741e14c18F6017A5b877F428
//
// Enjoy.
//
// (c) GazeCoin 2017. The MIT Licence.
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Owned contract
// ----------------------------------------------------------------------------
contract Owned {
// ------------------------------------------------------------------------
// Current owner, and proposed new owner
// ------------------------------------------------------------------------
address public owner;
address public newOwner;
// ------------------------------------------------------------------------
// Constructor - assign creator as the owner
// ------------------------------------------------------------------------
function Owned() public {
owner = msg.sender;
}
// ------------------------------------------------------------------------
// Modifier to mark that a function can only be executed by the owner
// ------------------------------------------------------------------------
modifier onlyOwner {
require(msg.sender == owner);
_;
}
// ------------------------------------------------------------------------
// Owner can initiate transfer of contract to a new owner
// ------------------------------------------------------------------------
function transferOwnership(address _newOwner) public onlyOwner {
newOwner = _newOwner;
}
// ------------------------------------------------------------------------
// New owner has to accept transfer of contract
// ------------------------------------------------------------------------
function acceptOwnership() public {
require(msg.sender == newOwner);
OwnershipTransferred(owner, newOwner);
owner = newOwner;
newOwner = 0x0;
}
event OwnershipTransferred(address indexed _from, address indexed _to);
}
// ----------------------------------------------------------------------------
// Administrators, borrowed from Gimli
// ----------------------------------------------------------------------------
contract Administered is Owned {
// ------------------------------------------------------------------------
// Mapping of administrators
// ------------------------------------------------------------------------
mapping (address => bool) public administrators;
// ------------------------------------------------------------------------
// Add and delete adminstrator events
// ------------------------------------------------------------------------
event AdminstratorAdded(address adminAddress);
event AdminstratorRemoved(address adminAddress);
// ------------------------------------------------------------------------
// Modifier for functions that can only be executed by adminstrator
// ------------------------------------------------------------------------
modifier onlyAdministrator() {
require(administrators[msg.sender] || owner == msg.sender);
_;
}
// ------------------------------------------------------------------------
// Owner can add a new administrator
// ------------------------------------------------------------------------
function addAdministrators(address _adminAddress) public onlyOwner {
administrators[_adminAddress] = true;
AdminstratorAdded(_adminAddress);
}
// ------------------------------------------------------------------------
// Owner can remove an administrator
// ------------------------------------------------------------------------
function removeAdministrators(address _adminAddress) public onlyOwner {
delete administrators[_adminAddress];
AdminstratorRemoved(_adminAddress);
}
}
// ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals
// ----------------------------------------------------------------------------
contract GazeCoinCrowdsaleWhitelist is Administered {
// ------------------------------------------------------------------------
// Administrators can add until sealed
// ------------------------------------------------------------------------
bool public sealed;
// ------------------------------------------------------------------------
// The whitelist, true for enabled, false for disabled
// ------------------------------------------------------------------------
mapping(address => bool) public whitelist;
// ------------------------------------------------------------------------
// Events
// ------------------------------------------------------------------------
event Whitelisted(address indexed whitelistedAddress, bool enabled);
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function GazeCoinCrowdsaleWhitelist() public {
}
// ------------------------------------------------------------------------
// Whitelist
// ------------------------------------------------------------------------
function enable(address[] _addresses) public onlyAdministrator {
require(!sealed);
require(_addresses.length != 0);
for (uint i = 0; i < _addresses.length; i++) {
require(_addresses[i] != 0x0);
if (!whitelist[_addresses[i]]) {
whitelist[_addresses[i]] = true;
Whitelisted(_addresses[i], true);
}
}
}
// ------------------------------------------------------------------------
// Disable whitelisting
// ------------------------------------------------------------------------
function disable(address[] _addresses) public onlyAdministrator {
require(!sealed);
require(_addresses.length != 0);
for (uint i = 0; i < _addresses.length; i++) {
require(_addresses[i] != 0x0);
if (whitelist[_addresses[i]]) {
whitelist[_addresses[i]] = false;
Whitelisted(_addresses[i], false);
}
}
}
// ------------------------------------------------------------------------
// After sealing, no more whitelisting is possible
// ------------------------------------------------------------------------
function seal() public onlyOwner {
require(!sealed);
sealed = true;
}
// ------------------------------------------------------------------------
// Don't accept ethers - no payable modifier
// ------------------------------------------------------------------------
function () public {
}
}