forked from calvinheath/wheat-v1-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWhitelistGuard.sol
36 lines (29 loc) · 890 Bytes
/
WhitelistGuard.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
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.6.0;
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { EnumerableSet } from "@openzeppelin/contracts/utils/EnumerableSet.sol";
abstract contract WhitelistGuard is Ownable
{
using EnumerableSet for EnumerableSet.AddressSet;
EnumerableSet.AddressSet private whitelist;
modifier onlyEOAorWhitelist()
{
address _from = _msgSender();
require(tx.origin == _from || whitelist.contains(_from), "access denied");
_;
}
modifier onlyWhitelist()
{
address _from = _msgSender();
require(whitelist.contains(_from), "access denied");
_;
}
function addToWhitelist(address _address) external onlyOwner
{
require(whitelist.add(_address), "already listed");
}
function removeFromWhitelist(address _address) external onlyOwner
{
require(whitelist.remove(_address), "not listed");
}
}