forked from CMTA/CMTAT
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathERC20MintModule.sol
More file actions
101 lines (89 loc) · 3.43 KB
/
ERC20MintModule.sol
File metadata and controls
101 lines (89 loc) · 3.43 KB
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
// SPDX-License-Identifier: MPL-2.0
pragma solidity ^0.8.20;
/* ==== Module === */
import {ERC20MintModuleInternal} from "../../internal/ERC20MintModuleInternal.sol";
/* ==== Technical === */
import {IMintBatchERC20Event} from "../../../interfaces/technical/IMintBurnToken.sol";
/* ==== Tokenization === */
import {IERC3643Mint, IERC3643BatchTransfer} from "../../../interfaces/tokenization/IERC3643Partial.sol";
import {IERC7551Mint, IERC5679Mint} from "../../../interfaces/tokenization/draft-IERC7551.sol";
/**
* @title ERC20Mint module.
* @dev
*
* Contains all mint functions, inherits from ERC-20
*/
abstract contract ERC20MintModule is ERC20MintModuleInternal, IERC3643Mint, IERC3643BatchTransfer, IERC7551Mint, IMintBatchERC20Event {
/* ============ State Variables ============ */
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
/* ============ Modifier ============ */
/// @dev Modifier to restrict access to the burner functions
modifier onlyMinter() {
_authorizeMint();
_;
}
/*//////////////////////////////////////////////////////////////
PUBLIC/EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
/**
* @inheritdoc IERC5679Mint
* @custom:devimpl
* Requirements:
* - `account` cannot be the zero address (check made by _mint).
* @custom:access-control
* - the caller must have the `MINTER_ROLE`.
*/
function mint(address account, uint256 value, bytes calldata data) public virtual override(IERC5679Mint) onlyMinter {
_mint(account, value, data);
}
/**
* @inheritdoc IERC3643Mint
* @dev
* Emits a {Mint} event.
* Emits a {Transfer} event with `from` set to the zero address (emits inside _mint).
*
* Requirements:
* - `account` cannot be the zero address (check made by _mint).
* @custom:access-control
* - the caller must have the `MINTER_ROLE`.
*/
function mint(address account, uint256 value) public virtual override(IERC3643Mint) onlyMinter {
_mint(account, value, "");
}
/**
*
* @inheritdoc IERC3643Mint
* @custom:devimpl
* Requirement
* - `accounts` cannot contain a zero address (check made by _mint).
* @custom:access-control
* - the caller must have the `MINTER_ROLE`.
*/
function batchMint(
address[] calldata accounts,
uint256[] calldata values
) public virtual override(IERC3643Mint) onlyMinter{
_batchMint(accounts, values);
emit BatchMint(_msgSender(), accounts, values);
}
/**
* @inheritdoc IERC3643BatchTransfer
* @custom:access-control
* - the caller must have the `MINTER_ROLE`.
*/
function batchTransfer(
address[] calldata tos,
uint256[] calldata values
) public virtual override(IERC3643BatchTransfer) onlyMinter returns (bool success_) {
return _batchTransfer(tos, values);
}
/*//////////////////////////////////////////////////////////////
INTERNAL/PRIVATE FUNCTIONS
//////////////////////////////////////////////////////////////*/
function _mint(address account, uint256 value, bytes memory data) internal virtual {
_mintOverride(account, value);
emit Mint(_msgSender(), account, value, data);
}
/* ============ Access Control ============ */
function _authorizeMint() internal virtual;
}