@kub-chain/contracts 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -0
- package/contracts/access/AccessController.sol +96 -0
- package/contracts/access/AccessControllerKAP.sol +116 -0
- package/contracts/access/Authorization.sol +36 -0
- package/contracts/access/AuthorizationKAP.sol +60 -0
- package/contracts/access/Committee.sol +26 -0
- package/contracts/access/Ownable.sol +39 -0
- package/contracts/interfaces/IAdminProjectRouter.sol +9 -0
- package/contracts/interfaces/IKYCBitkubChain.sol +8 -0
- package/contracts/kyc/KYCHandler.sol +24 -0
- package/contracts/libs/Address.sol +16 -0
- package/contracts/libs/EnumerableSetAddress.sol +70 -0
- package/contracts/libs/EnumerableSetUint.sol +74 -0
- package/contracts/libs/EnumerateMap.sol +136 -0
- package/contracts/libs/String.sol +26 -0
- package/contracts/token/KAP-1155/KAP1155.sol +493 -0
- package/contracts/token/KAP-1155/interfaces/IKAP1155.sol +69 -0
- package/contracts/token/KAP-1155/interfaces/IKAP1155Enumerable.sol +7 -0
- package/contracts/token/KAP-1155/interfaces/IKAP1155Metadata.sol +12 -0
- package/contracts/token/KAP-1155/interfaces/IKAP1155Receiver.sol +20 -0
- package/contracts/token/KAP-20/KAP20.sol +276 -0
- package/contracts/token/KAP-20/interfaces/IKAP20.sol +43 -0
- package/contracts/token/KAP-20/interfaces/IKToken.sol +17 -0
- package/contracts/token/KAP-22/KAP22.sol +358 -0
- package/contracts/token/KAP-22/interfaces/IKAP22.sol +23 -0
- package/contracts/token/KAP-22/utils/TransferRouter.sol +29 -0
- package/contracts/token/KAP-22/utils/WhitelistAddress.sol +35 -0
- package/contracts/token/KAP-721/KAP721.sol +416 -0
- package/contracts/token/KAP-721/interfaces/IKAP721.sol +60 -0
- package/contracts/token/KAP-721/interfaces/IKAP721Enumerable.sol +10 -0
- package/contracts/token/KAP-721/interfaces/IKAP721Metadata.sol +10 -0
- package/contracts/token/KAP-721/interfaces/IKAP721Receiver.sol +11 -0
- package/contracts/token/KAP-721/interfaces/IKAP721V2.sol +20 -0
- package/contracts/utils/Context.sol +13 -0
- package/contracts/utils/Pausable.sol +34 -0
- package/contracts/utils/introspections/IKAP165.sol +6 -0
- package/contracts/utils/introspections/KAP165.sol +12 -0
- package/package.json +26 -0
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity >=0.8.0;
|
|
4
|
+
|
|
5
|
+
import {IKAP20} from "../KAP-20/interfaces/IKAP20.sol";
|
|
6
|
+
import {IKAP22} from "./interfaces/IKAP22.sol";
|
|
7
|
+
import {IKToken} from "../KAP-20/interfaces/IKToken.sol";
|
|
8
|
+
import {TransferRouter} from "./utils/TransferRouter.sol";
|
|
9
|
+
import {IKYCBitkubChain} from "../../interfaces/IKYCBitkubChain.sol";
|
|
10
|
+
import {KYCHandler} from "../../kyc/KYCHandler.sol";
|
|
11
|
+
import {AccessControllerKAP} from "../../access/AccessControllerKAP.sol";
|
|
12
|
+
import {WhitelistAddress} from "./utils/WhitelistAddress.sol";
|
|
13
|
+
import {EnumerableSetAddress} from "../../libs/EnumerableSetAddress.sol";
|
|
14
|
+
|
|
15
|
+
abstract contract KAP22 is IKAP20, IKAP22, IKToken, AccessControllerKAP {
|
|
16
|
+
mapping(address => mapping(uint256 => uint256)) private _balances; // owner => period => balance
|
|
17
|
+
mapping(address => uint256) private _unStampBalance; // owner => balance
|
|
18
|
+
mapping(address => mapping(address => uint256)) private _allowances; // owner => spender => amount
|
|
19
|
+
|
|
20
|
+
string public override name;
|
|
21
|
+
string public override symbol;
|
|
22
|
+
uint8 public immutable override decimals;
|
|
23
|
+
uint256 public override cap;
|
|
24
|
+
uint256 public override totalSupply;
|
|
25
|
+
uint256 public override currentIndex;
|
|
26
|
+
uint256 public override startTime;
|
|
27
|
+
uint256 public override periodLength;
|
|
28
|
+
|
|
29
|
+
modifier updatePeriod() {
|
|
30
|
+
_updatePeriod();
|
|
31
|
+
_;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// constructor(
|
|
35
|
+
// // string memory name_,
|
|
36
|
+
// // string memory symbol_,
|
|
37
|
+
// // uint8 decimals_,
|
|
38
|
+
// address owner_,
|
|
39
|
+
// address vault_,
|
|
40
|
+
// address minter_,
|
|
41
|
+
// address burner_,
|
|
42
|
+
// address transferRouter_,
|
|
43
|
+
// address kyc_,
|
|
44
|
+
// uint256 acceptedKycLevel_,
|
|
45
|
+
// uint256 startTime_,
|
|
46
|
+
// uint256 periodLength_
|
|
47
|
+
// ) AccessControllerKAP(owner_, vault_, minter_, burner_, transferRouter_, kyc_, acceptedKycLevel_) {
|
|
48
|
+
// name = "name_";
|
|
49
|
+
// symbol = "symbol_";
|
|
50
|
+
// decimals = 18;
|
|
51
|
+
// startTime = startTime_;
|
|
52
|
+
// periodLength = periodLength_;
|
|
53
|
+
// }
|
|
54
|
+
|
|
55
|
+
constructor(
|
|
56
|
+
string memory name_,
|
|
57
|
+
string memory symbol_,
|
|
58
|
+
address owner_,
|
|
59
|
+
uint256 startTime_,
|
|
60
|
+
uint256 periodLength_,
|
|
61
|
+
uint256 cap_
|
|
62
|
+
) AccessControllerKAP(owner_, address(0), address(0), 4) {
|
|
63
|
+
name = name_;
|
|
64
|
+
symbol = symbol_;
|
|
65
|
+
decimals = 18;
|
|
66
|
+
startTime = startTime_;
|
|
67
|
+
periodLength = periodLength_;
|
|
68
|
+
cap = cap_;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function setCap(uint256 amount) external onlyOwner updatePeriod returns (bool) {
|
|
72
|
+
require(cap <= amount, "KAP22: can't set less than older cap");
|
|
73
|
+
|
|
74
|
+
cap = amount;
|
|
75
|
+
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function adminApprove(
|
|
80
|
+
address _owner,
|
|
81
|
+
address _spender,
|
|
82
|
+
uint256 _amount
|
|
83
|
+
) external override onlyOwner returns (bool) {
|
|
84
|
+
_approve(_owner, _spender, _amount);
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function mint(uint256 amount, address receiver) external override onlyOwner updatePeriod returns (bool) {
|
|
89
|
+
require(totalSupply + amount <= cap, "KAP22: cap exceeded");
|
|
90
|
+
|
|
91
|
+
totalSupply += amount;
|
|
92
|
+
|
|
93
|
+
_balances[receiver][currentIndex + 1] += amount;
|
|
94
|
+
|
|
95
|
+
emit Mint(currentIndex, receiver, amount);
|
|
96
|
+
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function burn(
|
|
101
|
+
uint256 period,
|
|
102
|
+
uint256 amount,
|
|
103
|
+
address _owner
|
|
104
|
+
) external override onlyOwner updatePeriod returns (bool) {
|
|
105
|
+
// _totalSupply -= amount;
|
|
106
|
+
|
|
107
|
+
// _balances[_owner][period] -= amount;
|
|
108
|
+
|
|
109
|
+
// emit Burn(period, _owner, amount);
|
|
110
|
+
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function currentPeriod() external view override returns (uint256) {
|
|
115
|
+
return _currentPeriod(currentIndex);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function balanceOf(address _owner) external view override returns (uint256 balance) {
|
|
119
|
+
uint256 tmpBalances;
|
|
120
|
+
uint256 tmpPeriod = _currentPeriod(currentIndex);
|
|
121
|
+
|
|
122
|
+
if (isWhitelistAddr(_owner)) {
|
|
123
|
+
for (uint256 i = 0; i <= tmpPeriod + 1; i++) {
|
|
124
|
+
tmpBalances += _balances[_owner][i];
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
tmpBalances += _balances[_owner][tmpPeriod];
|
|
128
|
+
tmpBalances += _balances[_owner][tmpPeriod + 1];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return tmpBalances;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function balanceOfCurrentPeriod(address _owner) external view returns (uint256 balance) {
|
|
135
|
+
uint256 tmpPeriod = _currentPeriod(currentIndex);
|
|
136
|
+
|
|
137
|
+
return _balances[_owner][tmpPeriod];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function balanceOfNextPeriod(address _owner) external view returns (uint256 balance) {
|
|
141
|
+
uint256 tmpPeriod = _currentPeriod(currentIndex);
|
|
142
|
+
|
|
143
|
+
return _balances[_owner][tmpPeriod + 1];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function balanceOfByPeriod(address _owner, uint256 _period) external view returns (uint256 balance) {
|
|
147
|
+
return _balances[_owner][_period];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function transfer(address _recipient, uint256 _amount) external override returns (bool) {
|
|
151
|
+
if ((isWhitelistAddr(msg.sender) || msg.sender == owner) && isWhitelistAddr(_recipient)) {
|
|
152
|
+
_transferPreviousPeriod(msg.sender, _recipient, _amount, 0);
|
|
153
|
+
} else if (msg.sender == owner) {
|
|
154
|
+
_transferSpecificPeriod(msg.sender, _recipient, _amount, currentIndex + 1);
|
|
155
|
+
} else {
|
|
156
|
+
_transfer(msg.sender, _recipient, _amount);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function allowance(address _owner, address _spender) external view override returns (uint256 remaining) {
|
|
163
|
+
return _allowances[_owner][_spender];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function approve(address _spender, uint256 _amount) external override returns (bool) {
|
|
167
|
+
_approve(msg.sender, _spender, _amount);
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function transferFrom(
|
|
172
|
+
address _sender,
|
|
173
|
+
address _recipient,
|
|
174
|
+
uint256 _amount
|
|
175
|
+
) external override returns (bool) {
|
|
176
|
+
uint256 currentAllowance = _allowances[_sender][msg.sender];
|
|
177
|
+
require(currentAllowance >= _amount, "KAP22: transfer amount exceeds allowance");
|
|
178
|
+
_approve(_sender, msg.sender, currentAllowance - _amount);
|
|
179
|
+
|
|
180
|
+
if ((isWhitelistAddr(msg.sender) || msg.sender == owner) && isWhitelistAddr(_recipient)) {
|
|
181
|
+
_transferPreviousPeriod(msg.sender, _recipient, _amount, 0);
|
|
182
|
+
} else if (msg.sender == owner) {
|
|
183
|
+
_transferSpecificPeriod(msg.sender, _recipient, _amount, currentIndex + 1);
|
|
184
|
+
} else {
|
|
185
|
+
_transfer(msg.sender, _recipient, _amount);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function increaseAllowance(address _spender, uint256 _addedValue) external returns (bool) {
|
|
192
|
+
_approve(msg.sender, _spender, _allowances[msg.sender][_spender] + _addedValue);
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function decreaseAllowance(address _spender, uint256 _subtractedValue) external returns (bool) {
|
|
197
|
+
uint256 currentAllowance = _allowances[msg.sender][_spender];
|
|
198
|
+
require(currentAllowance >= _subtractedValue, "KAP22: decreased allowance below zero");
|
|
199
|
+
_approve(msg.sender, _spender, currentAllowance - _subtractedValue);
|
|
200
|
+
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function adminTransfer(
|
|
205
|
+
address _sender,
|
|
206
|
+
address _recipient,
|
|
207
|
+
uint256 _amount
|
|
208
|
+
) external override onlyOwner returns (bool) {
|
|
209
|
+
_transfer(_sender, _recipient, _amount);
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function adminTransferPreviousPeriod(
|
|
214
|
+
address _sender,
|
|
215
|
+
address _recipient,
|
|
216
|
+
uint256 _amount,
|
|
217
|
+
uint256 _period
|
|
218
|
+
) external onlyOwner returns (bool) {
|
|
219
|
+
_transferPreviousPeriod(_sender, _recipient, _amount, _period);
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function internalTransfer(
|
|
224
|
+
address _sender,
|
|
225
|
+
address _recipient,
|
|
226
|
+
uint256 _amount
|
|
227
|
+
) external override onlyTransferRouter returns (bool) {
|
|
228
|
+
require(_isBitkubNext(_sender) && _isBitkubNext(_recipient), "KAP22: only internal purpose");
|
|
229
|
+
|
|
230
|
+
_transfer(_sender, _recipient, _amount);
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function externalTransfer(
|
|
235
|
+
address _sender,
|
|
236
|
+
address _recipient,
|
|
237
|
+
uint256 _amount
|
|
238
|
+
) external override onlyTransferRouter returns (bool) {
|
|
239
|
+
require(_isBitkubNext(_sender), "KAP22: only internal purpose");
|
|
240
|
+
|
|
241
|
+
_transfer(_sender, _recipient, _amount);
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function updatePeriodNow() external {
|
|
246
|
+
_updatePeriod();
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function _updatePeriod() internal {
|
|
250
|
+
while (block.timestamp > (currentIndex * periodLength) + startTime) {
|
|
251
|
+
currentIndex++;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function _currentPeriod(uint256 _period) internal view returns (uint256) {
|
|
256
|
+
uint256 newCurrentPeriod = _period;
|
|
257
|
+
|
|
258
|
+
while (block.timestamp > (newCurrentPeriod * periodLength) + startTime) {
|
|
259
|
+
newCurrentPeriod++;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return newCurrentPeriod;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function _transfer(
|
|
266
|
+
address _from,
|
|
267
|
+
address _to,
|
|
268
|
+
uint256 _amount
|
|
269
|
+
) internal updatePeriod {
|
|
270
|
+
require(_balances[_from][currentIndex] >= _amount, "KAP22: transfer amount exceeds balance");
|
|
271
|
+
|
|
272
|
+
_balances[_from][currentIndex] -= _amount;
|
|
273
|
+
_balances[_to][currentIndex] += _amount;
|
|
274
|
+
|
|
275
|
+
emit Transfer(_from, _to, _amount);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function _transferSpecificPeriod(
|
|
279
|
+
address _from,
|
|
280
|
+
address _to,
|
|
281
|
+
uint256 _amount,
|
|
282
|
+
uint256 _period
|
|
283
|
+
) internal updatePeriod {
|
|
284
|
+
require(_balances[_from][_period] >= _amount, "KAP22: transfer amount exceeds balance");
|
|
285
|
+
|
|
286
|
+
_balances[_from][_period] -= _amount;
|
|
287
|
+
_balances[_to][_period] += _amount;
|
|
288
|
+
|
|
289
|
+
emit Transfer(_from, _to, _amount);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function _transferNextPeriod(
|
|
293
|
+
address _from,
|
|
294
|
+
address _to,
|
|
295
|
+
uint256 _amount
|
|
296
|
+
) internal updatePeriod {
|
|
297
|
+
require(
|
|
298
|
+
_balances[_from][currentIndex] + _balances[_from][currentIndex + 1] >= _amount,
|
|
299
|
+
"KAP22: transfer amount exceeds balance"
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
if (_balances[_from][currentIndex] >= _amount) {
|
|
303
|
+
_balances[_from][currentIndex] -= _amount;
|
|
304
|
+
_balances[_to][currentIndex] += _amount;
|
|
305
|
+
} else {
|
|
306
|
+
uint256 balanceCurrentPeriod = _balances[_from][currentIndex];
|
|
307
|
+
|
|
308
|
+
_balances[_from][currentIndex] = 0;
|
|
309
|
+
_balances[_to][currentIndex] += balanceCurrentPeriod;
|
|
310
|
+
|
|
311
|
+
_balances[_from][currentIndex + 1] -= _amount - balanceCurrentPeriod;
|
|
312
|
+
_balances[_to][currentIndex + 1] += _amount - balanceCurrentPeriod;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
emit Transfer(_from, _to, _amount);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function _transferPreviousPeriod(
|
|
319
|
+
address _from,
|
|
320
|
+
address _to,
|
|
321
|
+
uint256 _amount,
|
|
322
|
+
uint256 _period
|
|
323
|
+
) internal updatePeriod {
|
|
324
|
+
uint256 remainingToTransfer = _amount;
|
|
325
|
+
for (uint256 i = _period; i <= currentIndex; i++) {
|
|
326
|
+
uint256 amountToTransfer = _balances[_from][i];
|
|
327
|
+
if (amountToTransfer > remainingToTransfer) {
|
|
328
|
+
amountToTransfer = remainingToTransfer;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
_balances[_from][i] -= amountToTransfer;
|
|
332
|
+
_balances[_to][i] += amountToTransfer;
|
|
333
|
+
|
|
334
|
+
remainingToTransfer -= amountToTransfer;
|
|
335
|
+
|
|
336
|
+
if (remainingToTransfer == 0) {
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
require(remainingToTransfer == 0, "KAP22: transfer amount exceeds balance");
|
|
342
|
+
|
|
343
|
+
emit Transfer(_from, _to, _amount);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function _approve(
|
|
347
|
+
address _owner,
|
|
348
|
+
address _spender,
|
|
349
|
+
uint256 _amount
|
|
350
|
+
) internal updatePeriod {
|
|
351
|
+
require(_owner != address(0), "KAP22: approve from the zero address");
|
|
352
|
+
require(_spender != address(0), "KAP22: approve to the zero address");
|
|
353
|
+
|
|
354
|
+
_allowances[_owner][_spender] = _amount;
|
|
355
|
+
|
|
356
|
+
emit Approval(_owner, _spender, _amount);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity >=0.8.0;
|
|
4
|
+
|
|
5
|
+
interface IKAP22 {
|
|
6
|
+
function cap() external view returns (uint256);
|
|
7
|
+
|
|
8
|
+
function currentIndex() external view returns (uint256);
|
|
9
|
+
|
|
10
|
+
function currentPeriod() external view returns (uint256);
|
|
11
|
+
|
|
12
|
+
function startTime() external view returns (uint256);
|
|
13
|
+
|
|
14
|
+
function periodLength() external view returns (uint256);
|
|
15
|
+
|
|
16
|
+
function mint(uint256 amount, address receiver) external returns (bool);
|
|
17
|
+
|
|
18
|
+
function burn(uint256 period, uint256 amount, address owner) external returns (bool);
|
|
19
|
+
|
|
20
|
+
event Mint(uint256 indexed period, address indexed receiver, uint256 amount);
|
|
21
|
+
|
|
22
|
+
event Burn(address indexed owner, uint256 amount);
|
|
23
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
abstract contract TransferRouter {
|
|
5
|
+
address public transferRouter;
|
|
6
|
+
|
|
7
|
+
event TransferRouterSet(
|
|
8
|
+
address indexed oldTransferRouter,
|
|
9
|
+
address indexed newTransferRouter,
|
|
10
|
+
address indexed caller
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
modifier onlyTransferRouter() {
|
|
14
|
+
require(
|
|
15
|
+
msg.sender == transferRouter,
|
|
16
|
+
"TransferRouter: restricted only transferRouter"
|
|
17
|
+
);
|
|
18
|
+
_;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
constructor(address transferRouter_) {
|
|
22
|
+
transferRouter = transferRouter_;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function _setTransferRouter(address _transferRouter) internal virtual {
|
|
26
|
+
emit TransferRouterSet(transferRouter, _transferRouter, msg.sender);
|
|
27
|
+
transferRouter = _transferRouter;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity >=0.8.0;
|
|
3
|
+
|
|
4
|
+
import {EnumerableSetAddress} from "../../../libs/EnumerableSetAddress.sol";
|
|
5
|
+
|
|
6
|
+
abstract contract WhitelistAddress {
|
|
7
|
+
using EnumerableSetAddress for EnumerableSetAddress.AddressSet;
|
|
8
|
+
|
|
9
|
+
EnumerableSetAddress.AddressSet private _whitelistAddr;
|
|
10
|
+
|
|
11
|
+
function isWhitelistAddr(address _addr) public view returns (bool) {
|
|
12
|
+
return _whitelistAddr.contains(_addr);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function whitelistAddrLength() external view returns (uint256) {
|
|
16
|
+
return _whitelistAddr.length();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function whitelistAddrByIndex(uint256 _index) external view returns (address) {
|
|
20
|
+
return _whitelistAddr.at(_index);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function whitelistAddrByPage(uint256 _page, uint256 _limit) external view returns (address[] memory) {
|
|
24
|
+
return _whitelistAddr.get(_page, _limit);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function addWhitelistAddress(address _addr) public virtual {
|
|
28
|
+
require(_addr != address(0) && _addr != address(this), "WhitelistAddress: invalid address");
|
|
29
|
+
require(_whitelistAddr.add(_addr), "WhitelistAddress: address already exists");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function revokeWhitelistAddress(address _addr) public virtual {
|
|
33
|
+
require(_whitelistAddr.remove(_addr), "WhitelistAddress: address does not exist");
|
|
34
|
+
}
|
|
35
|
+
}
|