// SPDX-License-Identifier: UNLICENSED pragma solidity =0.8.18; import "../../SomaGuard/utils/GuardableUpgradeable.sol"; import "./IMintableSecurity.sol"; /** * @notice Implementation of the {IMintableSecurity} interface. */ abstract contract MintableSecurity is IMintableSecurity, AccessibleUpgradeable { /** * @notice Initializer for extended contracts. */ function __MintableSecurity_init() internal { __Accessible_init_unchained(); __SomaContract_init_unchained(); __ERC165_init_unchained(); __Context_init_unchained(); __Multicall_init_unchained(); __Pausable_init_unchained(); __MintableSecurity_init_unchained(); } /** * @notice Unchained initializer. */ function __MintableSecurity_init_unchained() internal onlyInitializing { LOCAL_MINT_ROLE = keccak256(abi.encodePacked(address(this), GLOBAL_MINT_ROLE)); } /** * @notice Returns the GLOBAL_MINT_ROLE. */ bytes32 public constant GLOBAL_MINT_ROLE = keccak256("MintableSecurity.MINT_ROLE"); /** * @notice Returns the LOCAL_MINT_ROLE. */ bytes32 public LOCAL_MINT_ROLE; /** * @notice Modifier to restrict a function caller to accounts that have the GLOBAL_MINT_ROLE or LOCAL_MINT_ROLE. */ modifier onlyMintRole() { address sender = _msgSender(); require(hasRole(LOCAL_MINT_ROLE, sender) || hasRole(GLOBAL_MINT_ROLE, sender), "MintableSecurity: UNAUTHORIZED"); _; } /** * @notice Checks if MintableSecurity inherits a given contract interface. * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IMintableSecurity).interfaceId || super.supportsInterface(interfaceId); } /** * @inheritdoc IMintableSecurity */ function mint(bytes32 id, uint256 amount, bytes memory data) public override onlyMintRole { address mintTo = SOMA.mintTo(); _mint(mintTo, id, amount, data); emit Minted(_msgSender(), mintTo, id, amount, data); } /** * @inheritdoc IMintableSecurity */ function burn(bytes32 id, uint256 amount, bytes memory data) public override onlyMintRole { address mintTo = SOMA.mintTo(); _burn(mintTo, id, amount, data); emit Burned(_msgSender(), mintTo, id, amount, data); } function _mint(address to, bytes32 id, uint256 amount, bytes memory data) internal virtual; function _burn(address from, bytes32 id, uint256 amount, bytes memory data) internal virtual; uint256[50] private __gap; }