You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1002 B

// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.14;
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol";
abstract contract RoleControl is AccessControlUpgradeable {
bytes32 OPERATOR_ROLE = bytes32("OPERATOR_ROLE");
function isAdmin(address account) public view returns(bool) {
return hasRole(DEFAULT_ADMIN_ROLE, account);
}
modifier onlyAdmin() {
require(isAdmin(msg.sender));
_;
}
function grantOperator(address account) public onlyAdmin {
grantRole(OPERATOR_ROLE, account);
}
function isOperator(address account) public view returns(bool) {
return hasRole(OPERATOR_ROLE, account);
}
modifier onlyOperator() {
require(isAdmin(msg.sender));
_;
}
function grantAdminRole(address account) public onlyAdmin {
grantRole(DEFAULT_ADMIN_ROLE, account);
}
}