4
4
5
5
pragma solidity ^ 0.8.0 ;
6
6
7
- import '@openzeppelin/contracts/access/AccessControl .sol ' ;
7
+ import '@openzeppelin/contracts/access/AccessControlEnumerable .sol ' ;
8
8
import '../precompiles/ArbOwner.sol ' ;
9
9
10
10
/**
@@ -13,48 +13,48 @@ import '../precompiles/ArbOwner.sol';
13
13
* Minting and burning will be done by using the ArbOwner functions mintNativeToken and burnNativeToken.
14
14
* This contract must be set as a chain owner of the chain to be able to call ArbOwner functions
15
15
*/
16
- contract MinterBurnerForwarder is AccessControl {
16
+ contract MinterBurnerForwarder is AccessControlEnumerable {
17
17
// Roles
18
18
bytes32 public constant MINTER_ROLE = keccak256 ('MINTER ' );
19
19
bytes32 public constant BURNER_ROLE = keccak256 ('BURNER ' );
20
20
21
21
// ArbOwner precompile
22
22
ArbOwner constant ARB_OWNER = ArbOwner (address (112 ));
23
23
24
- // Events
25
- event NativeTokenMinted (address indexed caller , uint256 amount );
26
- event NativeTokenBurned (address indexed caller , uint256 amount );
27
-
28
- // Errors
29
- error NotChainOwner ();
30
-
31
- constructor () {
32
- // Check if the deployer is a chain owner
33
- if (! ARB_OWNER.isChainOwner (msg .sender )) {
34
- revert NotChainOwner ();
24
+ constructor (address [] memory admins , address [] memory minters , address [] memory burners ) {
25
+ // Grant ADMIN role to admins
26
+ for (uint256 i = 0 ; i < admins.length ; i++ ) {
27
+ _grantRole (DEFAULT_ADMIN_ROLE, admins[i]);
28
+ }
29
+
30
+ // Grant MINTER role to minters
31
+ for (uint256 i = 0 ; i < minters.length ; i++ ) {
32
+ _grantRole (MINTER_ROLE, minters[i]);
35
33
}
36
34
37
- // Grant admin role to the chain owner
38
- _setupRole (DEFAULT_ADMIN_ROLE, msg .sender );
35
+ // Grant BURNER role to burners
36
+ for (uint256 i = 0 ; i < burners.length ; i++ ) {
37
+ _grantRole (BURNER_ROLE, burners[i]);
38
+ }
39
39
}
40
40
41
41
/**
42
42
* @notice Mints some amount of the native gas token for this chain to the calling address.
43
43
* @dev This function calls mintNativeToken in the ArbOwner precompile, so this contract must also be a chain owner.
44
+ * No events are emitted in this function, since the ArbOwner precompile already emits OwnerActs()
44
45
* @param amount The amount of native gas token to mint
45
46
*/
46
47
function mintNativeToken (uint256 amount ) external onlyRole (MINTER_ROLE) {
47
48
ARB_OWNER.mintNativeToken (msg .sender , amount);
48
- emit NativeTokenMinted (msg .sender , amount);
49
49
}
50
50
51
51
/**
52
52
* @notice Burns some amount of the native gas token for this chain from the given address.
53
53
* @dev This function calls burnNativeToken in the ArbOwner precompile, so this contract must also be a chain owner.
54
+ * No events are emitted in this function, since the ArbOwner precompile already emits OwnerActs()
54
55
* @param amount The amount of native gas token to burn
55
56
*/
56
57
function burnNativeToken (uint256 amount ) external onlyRole (BURNER_ROLE) {
57
58
ARB_OWNER.burnNativeToken (msg .sender , amount);
58
- emit NativeTokenBurned (msg .sender , amount);
59
59
}
60
60
}
0 commit comments