// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title Contract to be inherited by contracts that will derive /// AccessControlRegistry roles /// @notice If a contract interfaces with AccessControlRegistry and needs to /// derive roles, it should inherit this contract instead of re-implementing /// the logic contract RoleDeriver { /// @notice Derives the root role of the manager /// @param manager Manager address /// @return rootRole Root role function _deriveRootRole( address manager ) internal pure returns (bytes32 rootRole) { rootRole = keccak256(abi.encodePacked(manager)); } /// @notice Derives the role using its admin role and description /// @dev This implies that roles adminned by the same role cannot have the /// same description /// @param adminRole Admin role /// @param description Human-readable description of the role /// @return role Role function _deriveRole( bytes32 adminRole, string memory description ) internal pure returns (bytes32 role) { role = _deriveRole(adminRole, keccak256(abi.encodePacked(description))); } /// @notice Derives the role using its admin role and description hash /// @dev This implies that roles adminned by the same role cannot have the /// same description /// @param adminRole Admin role /// @param descriptionHash Hash of the human-readable description of the /// role /// @return role Role function _deriveRole( bytes32 adminRole, bytes32 descriptionHash ) internal pure returns (bytes32 role) { role = keccak256(abi.encodePacked(adminRole, descriptionHash)); } }