forked from CMTA/CMTAT
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathERC20BurnModule.sol
More file actions
104 lines (92 loc) · 3.07 KB
/
ERC20BurnModule.sol
File metadata and controls
104 lines (92 loc) · 3.07 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
102
103
104
// SPDX-License-Identifier: MPL-2.0
pragma solidity ^0.8.20;
/* ==== Module === */
import {ERC20BurnModuleInternal} from "../../internal/ERC20BurnModuleInternal.sol";
/* ==== Technical === */
import {IBurnBatchERC20} from "../../../interfaces/technical/IMintBurnToken.sol";
/* ==== Tokenization === */
import {IERC3643Burn} from "../../../interfaces/tokenization/IERC3643Partial.sol";
import {IERC7551Burn, IERC5679Burn} from "../../../interfaces/tokenization/draft-IERC7551.sol";
/**
* @title ERC20Burn module.
* @dev
*
* Contains all burn functions, inherits from ERC-20
*/
abstract contract ERC20BurnModule is ERC20BurnModuleInternal, IBurnBatchERC20, IERC3643Burn, IERC7551Burn {
/* ============ State Variables ============ */
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
/* ============ Modifier ============ */
/// @dev Modifier to restrict access to the burner functions
modifier onlyBurner() {
_authorizeBurn();
_;
}
/*//////////////////////////////////////////////////////////////
PUBLIC/EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
/**
* @dev
* @inheritdoc IERC7551Burn
* @custom:access-control
* - the caller must have the `BURNER_ROLE`.
*/
function burn(
address account,
uint256 value,
bytes calldata data
) public virtual override(IERC5679Burn) onlyBurner{
_burn(account, value, data);
}
/**
* @inheritdoc IERC3643Burn
* @custom:access-control
* - the caller must have the `BURNER_ROLE`.
*/
function burn(
address account,
uint256 value
) public virtual override(IERC3643Burn) onlyBurner {
_burn(account, value,"");
}
/**
*
* @inheritdoc IBurnBatchERC20
* @custom:access-control
* - the caller must have the `BURNER_ROLE`.
*/
function batchBurn(
address[] calldata accounts,
uint256[] calldata values,
bytes memory data
) public virtual override(IBurnBatchERC20) onlyBurner {
_batchBurn(accounts, values);
emit BatchBurn(_msgSender(),accounts, values, data );
}
/**
*
* @inheritdoc IERC3643Burn
* @custom:access-control
* - the caller must have the `BURNER_ROLE`.
*/
function batchBurn(
address[] calldata accounts,
uint256[] calldata values
) public virtual override (IERC3643Burn) onlyBurner {
_batchBurn(accounts, values);
emit BatchBurn(_msgSender(),accounts, values, "" );
}
/*//////////////////////////////////////////////////////////////
INTERNAL/PRIVATE FUNCTIONS
//////////////////////////////////////////////////////////////*/
function _burn(
address account,
uint256 value,
bytes memory data
) internal virtual {
_burnOverride(account, value);
emit Burn(_msgSender(), account, value, data);
}
/* ============ Access Control ============ */
function _authorizeBurn() internal virtual;
}