Skip to content

Commit a82d64d

Browse files
committed
added minter role
1 parent adde557 commit a82d64d

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

foundry.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@ seed = "0x544D"
2020
[invariant]
2121
runs = 256
2222

23-
2423
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

src/M3ter.sol

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,34 @@ import "./ERC721ABC.sol";
77
/// @custom:security-contact [email protected]
88
contract M3ter is ERC721ABC, IM3ter {
99
bytes32 public constant REGISTRAR_ROLE = keccak256("REGISTRAR_ROLE");
10-
uint256 private _nextTokenId;
10+
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
11+
uint256 public nextTokenId;
1112

12-
mapping(uint256 => bytes32) public token_to_key;
13-
mapping(bytes32 => uint256) public key_to_token;
13+
mapping(uint256 => bytes32) public keyByToken;
14+
mapping(bytes32 => uint256) public tokenByKey;
1415

1516
constructor() ERC721("M3ter", "M3R") {
1617
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
1718
_grantRole(REGISTRAR_ROLE, msg.sender);
19+
_grantRole(MINTER_ROLE, msg.sender);
1820
_grantRole(PAUSER_ROLE, msg.sender);
1921
}
2022

21-
function safeMint(address to, string memory uri) public whenNotPaused {
22-
uint256 tokenId = _nextTokenId++;
23+
function safeMint(
24+
address to,
25+
string memory uri
26+
) external onlyRole(MINTER_ROLE) whenNotPaused {
27+
uint256 tokenId = nextTokenId++;
2328
_setTokenURI(tokenId, uri);
2429
_safeMint(to, tokenId);
2530
}
2631

27-
function _register(
32+
function register(
2833
uint256 tokenId,
2934
bytes32 publicKey
30-
) external onlyRole(REGISTRAR_ROLE) {
31-
token_to_key[tokenId] = publicKey;
32-
key_to_token[publicKey] = tokenId;
35+
) external onlyRole(REGISTRAR_ROLE) whenNotPaused {
36+
keyByToken[tokenId] = publicKey;
37+
tokenByKey[publicKey] = tokenId;
3338
emit Register(tokenId, publicKey, msg.sender, block.timestamp);
3439
}
3540
}

src/interfaces/IM3ter.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ interface IM3ter is IERC721 {
1212

1313
function safeMint(address to, string memory uri) external;
1414

15-
function _register(uint256 tokenId, bytes32 publicKey) external;
15+
function register(uint256 tokenId, bytes32 publicKey) external;
1616
}

0 commit comments

Comments
 (0)