-
Notifications
You must be signed in to change notification settings - Fork 4
/
SenderBlacklistValidator.sol
107 lines (95 loc) · 2.75 KB
/
SenderBlacklistValidator.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
pragma solidity 0.4.24;
import "openzeppelin-solidity/contracts/lifecycle/Pausable.sol";
import "../interfaces/IModuleContract.sol";
import "../inheritables/TransferValidator.sol";
/**
* @title Transfer Validator that checks if sender/maker is NOT on blacklist
*/
contract SenderBlacklistValidator is TransferValidator, IModuleContract, Pausable {
/*----------- Constants -----------*/
bytes32 public constant moduleName = "SenderBlacklistValidator";
/*----------- Globals -----------*/
mapping(address => bool) public blacklist;
/*----------- Events -----------*/
event LogAddAddress(address sender, address nowOkay);
event LogRemoveAddress(address sender, address deleted);
/*----------- Validator Methods -----------*/
/**
* @dev Validate whether an address is not on the blacklist
* @param _token address Unused for this validation
* @param _to address unused for this validation
* @param _from address The address which you want to transfer from - must not be blacklisted
* @param _amount uint256 unused for this validation
* @return bool
*/
function canSend(address _token, address _from, address _to, uint256 _amount)
external
returns(bool)
{
return !isBlacklisted(_from);
}
/**
* @dev Returns the name of the validator
* @return bytes32
*/
function getName()
external
view
returns(bytes32)
{
return moduleName;
}
/**
* @dev Returns the type of the validator
* @return uint8
*/
function getType()
external
view
returns(uint8)
{
return moduleType;
}
/*----------- Owner Methods -----------*/
/**
* @dev Add address to blacklist
* @param _okay address Unused for this validation
* @return success bool
*/
function addAddress(address _okay)
external
onlyOwner
whenNotPaused
returns (bool success)
{
require(_okay != address(0));
require(!isBlacklisted(_okay));
blacklist[_okay] = true;
emit LogAddAddress(msg.sender, _okay);
return true;
}
/**
* @dev Remove address from blacklist
* @param _delete address Unused for this validation
* @return success bool
*/
function removeAddress(address _delete)
external
onlyOwner
whenNotPaused
returns(bool success)
{
require(isBlacklisted(_delete));
blacklist[_delete] = false;
emit LogRemoveAddress(msg.sender, _delete);
return true;
}
/*----------- View Methods -----------*/
function isBlacklisted(address _check)
public
view
returns(bool isIndeed)
{
return blacklist[_check];
}
}