-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNumaMinter.sol
70 lines (60 loc) · 1.99 KB
/
NumaMinter.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
//SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import "@openzeppelin/contracts_5.0.2/access/Ownable2Step.sol";
import "../interfaces/INuma.sol";
/// @title Numa minter
/// @notice maintains a list of addresses allowed to mint numa
contract NumaMinter is Ownable2Step {
//
INuma public numa;
mapping(address => bool) allowedMinters;
// Events
event AddedToMinters(address indexed a);
event RemovedFromMinters(address indexed a);
event SetToken(address token);
modifier onlyMinters() {
require(isMinter(msg.sender), "not allowed");
_;
}
constructor() Ownable(msg.sender) {}
/**
* @notice Sets the address of the token to be minted by this contract.
* @param _token the token to mint
*/
function setTokenAddress(address _token) external onlyOwner {
numa = INuma(_token);
emit SetToken(_token);
}
/**
* @notice mints amount of tokens to the caller.
* @param to the receiver of the minted tokens
* @param amount amount to be minted
*/
function mint(address to, uint256 amount) external onlyMinters {
require(address(numa) != address(0), "token address invalid");
numa.mint(to, amount);
}
/**
* @notice adds an address as allowed to mint token
* @param _address address to be whitelisted to mint
*/
function addToMinters(address _address) public onlyOwner {
allowedMinters[_address] = true;
emit AddedToMinters(_address);
}
/**
* @notice removes an address from whitelist
* @param _address address to be removed
*/
function removeFromMinters(address _address) public onlyOwner {
allowedMinters[_address] = false;
emit RemovedFromMinters(_address);
}
/**
* @notice returns true if address is allowed to mint
* @param _address address we want to check
*/
function isMinter(address _address) public view returns (bool) {
return allowedMinters[_address];
}
}