-
Notifications
You must be signed in to change notification settings - Fork 40
/
ANTController.sol
88 lines (73 loc) · 3.23 KB
/
ANTController.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
pragma solidity 0.5.17;
import "./interfaces/IMiniMeLike.sol";
import "./interfaces/ITokenController.sol";
contract ANTController is ITokenController {
string private constant ERROR_NOT_MINTER = "ANTC_SENDER_NOT_MINTER";
string private constant ERROR_NOT_ANT = "ANTC_SENDER_NOT_ANT";
IMiniMeLike public ant;
address public minter;
event ChangedMinter(address indexed minter);
/**
* @dev Ensure the msg.sender is the minter
*/
modifier onlyMinter {
require(msg.sender == minter, ERROR_NOT_MINTER);
_;
}
constructor(IMiniMeLike _ant, address _minter) public {
ant = _ant;
_changeMinter(_minter);
}
/**
* @notice Generate ANT for a specified address
* @dev Note that failure to generate the requested tokens will result in a revert
* @param _owner Address to receive ANT
* @param _amount Amount to generate
* @return True if the tokens are generated correctly
*/
function generateTokens(address _owner, uint256 _amount) external onlyMinter returns (bool) {
return ant.generateTokens(_owner, _amount);
}
/**
* @notice Change the permitted minter to another address
* @param _newMinter Address that will be permitted to mint ANT
*/
function changeMinter(address _newMinter) external onlyMinter {
_changeMinter(_newMinter);
}
// Default ITokenController settings for allowing token transfers.
// ANT was compiled with solc 0.4.8, so there is no point in marking any of these functions as `view`:
// - The original interface does not specify these as `constant`
// - ANT does not use a `staticcall` when calling into these functions
/**
* @dev Callback function called from MiniMe-like instances when ETH is sent into the token contract
* It allows specifying a custom logic to control if the ETH should be accepted or not
* @return Always false, this controller does not permit the ANT contract to receive ETH transfers
*/
function proxyPayment(address /* _owner */) external payable returns (bool) {
// We only apply this extra check here to ensure `proxyPayment()` cannot be sent ETH from arbitrary addresses
require(msg.sender == address(ant), ERROR_NOT_ANT);
return false;
}
/**
* @dev Callback function called from MiniMe-like instances when an ERC20 transfer is requested
* It allows specifying a custom logic to control if a transfer should be allowed or not
* @return Always true, this controller allows all transfers
*/
function onTransfer(address /* _from */, address /* _to */, uint /* _amount */) external returns (bool) {
return true;
}
/**
* @dev Callback function called from MiniMe-like instances when an ERC20 approval is requested
* It allows specifying a custom logic to control if an approval should be allowed or not
* @return Always true, this controller allows all approvals
*/
function onApprove(address /* _owner */, address /* _spender */, uint /* _amount */) external returns (bool) {
return true;
}
// Internal fns
function _changeMinter(address _newMinter) internal {
minter = _newMinter;
emit ChangedMinter(_newMinter);
}
}