|
1 | 1 | pragma solidity ^0.6.4;
|
2 | 2 | pragma experimental ABIEncoderV2;
|
3 | 3 |
|
4 |
| -/* |
5 |
| - * @title GraphToken contract |
6 |
| - * |
7 |
| - */ |
8 |
| - |
9 | 4 | import "./Governed.sol";
|
| 5 | +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; |
10 | 6 | import "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol";
|
11 |
| -import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol"; |
12 | 7 |
|
13 | 8 |
|
14 |
| -// NOTE: This is based off of ERC777TokensRecipient interface, but does not fully implement it |
15 |
| -interface TokenReceiver { |
16 |
| - function tokensReceived(address _from, uint256 _amount, bytes calldata _data) |
17 |
| - external |
18 |
| - returns (bool); |
19 |
| -} |
20 |
| - |
| 9 | +/** |
| 10 | + * @title GraphToken contract |
| 11 | + * @dev This is the implementation of the ERC20 Graph Token. |
| 12 | + */ |
| 13 | +contract GraphToken is Governed, ERC20, ERC20Burnable { |
| 14 | + // -- State -- |
21 | 15 |
|
22 |
| -contract GraphToken is Governed, ERC20Detailed, ERC20Burnable { |
23 | 16 | mapping(address => bool) private _minters;
|
24 | 17 |
|
25 | 18 | // -- Events --
|
| 19 | + |
26 | 20 | event MinterAdded(address indexed account);
|
27 | 21 | event MinterRemoved(address indexed account);
|
28 | 22 |
|
29 | 23 | modifier onlyMinter() {
|
30 |
| - require(isMinter(msg.sender) || msg.sender == governor, "Only minter can call"); |
| 24 | + require(isMinter(msg.sender), "Only minter can call"); |
31 | 25 | _;
|
32 | 26 | }
|
33 | 27 |
|
34 |
| - /* |
35 |
| - * @dev Init Graph Token contract |
36 |
| - * @param _governor <address> Address of the multisig contract as Governor of this contract |
37 |
| - * @param _initialSupply <uint256> Initial supply of Graph Tokens |
| 28 | + /** |
| 29 | + * @dev Graph Token Contract Constructor |
| 30 | + * @param _governor Owner address of this contract |
| 31 | + * @param _initialSupply Initial supply of GRT |
38 | 32 | */
|
39 | 33 | constructor(address _governor, uint256 _initialSupply)
|
40 | 34 | public
|
41 |
| - ERC20Detailed("Graph Token", "GRT", 18) |
| 35 | + ERC20("Graph Token", "GRT") |
42 | 36 | Governed(_governor)
|
43 | 37 | {
|
44 |
| - // Governor is initially the sole treasurer |
45 |
| - _addMinter(_governor); |
46 |
| - |
47 | 38 | // The Governor has the initial supply of tokens
|
48 | 39 | _mint(_governor, _initialSupply);
|
| 40 | + // The Governor is the default minter |
| 41 | + _addMinter(_governor); |
49 | 42 | }
|
50 | 43 |
|
| 44 | + /** |
| 45 | + * @dev Add a new minter |
| 46 | + * @param _account Address of the minter |
| 47 | + */ |
51 | 48 | function addMinter(address _account) external onlyGovernor {
|
52 | 49 | _addMinter(_account);
|
53 | 50 | }
|
54 | 51 |
|
| 52 | + /** |
| 53 | + * @dev Remove a minter |
| 54 | + * @param _account Address of the minter |
| 55 | + */ |
55 | 56 | function removeMinter(address _account) external onlyGovernor {
|
56 | 57 | _removeMinter(_account);
|
57 | 58 | }
|
58 | 59 |
|
59 |
| - function isMinter(address _account) public view returns (bool) { |
60 |
| - return _minters[_account]; |
61 |
| - } |
62 |
| - |
| 60 | + /** |
| 61 | + * @dev Renounce to be a minter |
| 62 | + */ |
63 | 63 | function renounceMinter() external {
|
64 | 64 | _removeMinter(msg.sender);
|
65 | 65 | }
|
66 | 66 |
|
67 |
| - function mint(address _account, uint256 _amount) external onlyMinter returns (bool) { |
68 |
| - _mint(_account, _amount); |
69 |
| - return true; |
| 67 | + /** |
| 68 | + * @dev Mint new tokens |
| 69 | + * @param _to Address to send the newly minted tokens |
| 70 | + * @param _amount Amount of tokens to mint |
| 71 | + */ |
| 72 | + function mint(address _to, uint256 _amount) external onlyMinter { |
| 73 | + _mint(_to, _amount); |
70 | 74 | }
|
71 | 75 |
|
72 |
| - /* |
73 |
| - * @dev Transfer Graph tokens to the Staking interface |
74 |
| - * @notice Interacts with Staking contract |
75 |
| - * @notice Overriding `transfer` was not working with web3.js so we renamed to `transferToTokenReceiver` |
| 76 | + /** |
| 77 | + * @dev Return if the `_account` is a minter or not |
| 78 | + * @param _account Address to check |
| 79 | + * @return True if the `_account` is minter |
76 | 80 | */
|
77 |
| - function transferToTokenReceiver(address _to, uint256 _amount, bytes memory _data) |
78 |
| - public |
79 |
| - returns (bool success) |
80 |
| - { |
81 |
| - assert(super.transfer(_to, _amount)); // Handle basic transfer functionality |
82 |
| - // @imp 08 Have staking contract receive the token and handle the data |
83 |
| - assert(TokenReceiver(_to).tokensReceived(msg.sender, _amount, _data)); |
84 |
| - success = true; |
| 81 | + function isMinter(address _account) public view returns (bool) { |
| 82 | + return _minters[_account]; |
85 | 83 | }
|
86 | 84 |
|
| 85 | + /** |
| 86 | + * @dev Add a new minter |
| 87 | + * @param _account Address of the minter |
| 88 | + */ |
87 | 89 | function _addMinter(address _account) internal {
|
88 | 90 | _minters[_account] = true;
|
89 | 91 | emit MinterAdded(_account);
|
90 | 92 | }
|
91 | 93 |
|
| 94 | + /** |
| 95 | + * @dev Remove a minter |
| 96 | + * @param _account Address of the minter |
| 97 | + */ |
92 | 98 | function _removeMinter(address _account) internal {
|
93 | 99 | _minters[_account] = false;
|
94 | 100 | emit MinterRemoved(_account);
|
|
0 commit comments