DotnsRoleManager
Inherits: AccessControlUpgradeable, OwnableUpgradeable, IDotnsRoleManager
Title: Dotns Role Manager
Shared owner-administered role layer for DotNS contracts with operational roles.
Consuming contracts define their supported role set in @custom:function _isSupportedRole. The owner remains the only account that can grant or revoke roles; role holders receive only the operational permissions each consuming contract explicitly gates with
Notes:
-
function: _checkRoleOrOwner.
-
security-contact: admin@parity.io
Functions
_dotnsRoleManagerInit
Initialises the OpenZeppelin access-control state for consuming contracts.
Must be called during the consuming contract initialiser.
function _dotnsRoleManagerInit() internal onlyInitializing;
setRole
Grants or revokes an operational role.
Only the owner can manage roles (otherwise @custom:reverts OwnableUnauthorizedAccount);
role must be one of the roles recognised by the consuming contract (otherwise
Note:
reverts: UnsupportedRole); account must not be the zero address (otherwise
function setRole(bytes32 role, address account, bool enabled) external override onlyOwner;
Parameters
| Name | Type | Description |
|---|---|---|
role | bytes32 | Role identifier declared in DotnsConstants. |
account | address | Account whose role membership is updated. |
enabled | bool | Whether the role should be granted or revoked. |
grantRole
Grants role to account.
If account had not been already granted role, emits a {RoleGranted}
event.
Requirements:
- the caller must have
role's admin role.
function grantRole(
bytes32 role,
address account
)
public
override(AccessControlUpgradeable, IAccessControl)
onlyOwner;
revokeRole
Revokes role from account.
If account had been granted role, emits a {RoleRevoked} event.
Requirements:
- the caller must have
role's admin role.
function revokeRole(
bytes32 role,
address account
)
public
override(AccessControlUpgradeable, IAccessControl)
onlyOwner;
supportsInterface
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(AccessControlUpgradeable)
returns (bool supported);
_checkRoleOrOwner
Reverts unless the caller is the owner or holds role.
Consuming contracts use this for operational paths where the owner keeps super-user access and role holders receive a narrower permission; any other caller is rejected with @custom:reverts NotRoleOrOwner.
function _checkRoleOrOwner(bytes32 role) internal view;
_setRole
Grants or revokes a supported role for account.
role must be recognised by the consuming contract (otherwise
Notes:
-
reverts: UnsupportedRole) and
accountmust be non-zero (otherwise -
reverts: InvalidRoleAccount). Delegates to OpenZeppelin's
_grantRoleor_revokeRole, which emit @custom:emits IAccessControl.RoleGranted on grant and -
emits: IAccessControl.RoleRevoked on revoke.
function _setRole(bytes32 role, address account, bool enabled) internal;
_isSupportedRole
Returns whether role is recognised by the consuming contract.
Implemented by each consuming contract so unsupported role identifiers fail closed.
function _isSupportedRole(bytes32 role) internal view virtual returns (bool supported);