forked from lamina1/spaces-registry
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseItem.sol
More file actions
44 lines (36 loc) · 1.27 KB
/
BaseItem.sol
File metadata and controls
44 lines (36 loc) · 1.27 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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "../interfaces/ISpaceItem.sol";
contract BaseItem is ERC1155, AccessControl, ISpaceItem {
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
constructor(string memory uri) ERC1155(uri) {
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(MINTER_ROLE, msg.sender);
}
function setURI(string memory newuri) public onlyRole(DEFAULT_ADMIN_ROLE) {
_setURI(newuri);
}
// Implement ISpaceItem
function authorized(address account) public view override returns (bool) {
return hasRole(DEFAULT_ADMIN_ROLE, account);
}
function mint(address account, uint256 id, uint256 amount)
public
virtual
onlyRole(MINTER_ROLE)
{
_mint(account, id, amount, bytes(''));
}
// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC1155, AccessControl)
returns (bool)
{
return interfaceId == type(ISpaceItem).interfaceId || super.supportsInterface(interfaceId);
}
}