// Source: contracts/interfaces/IRoles.sol pragma solidity ^0.8.0; // SPDX-License-Identifier: MIT // File contracts/interfaces/IRolesBase.sol /** * @title IRolesBase Interface * @notice IRolesBase is an interface that abstracts the implementation of a * contract with role control internal functions. */ interface IRolesBase { error MissingRole(address account, uint8 role); error MissingAllRoles(address account, uint256 accountRoles); error MissingAnyOfRoles(address account, uint256 accountRoles); error InvalidProposedRoles(address fromAccount, address toAccount, uint256 accountRoles); event RolesProposed(address indexed fromAccount, address indexed toAccount, uint256 accountRoles); event RolesAdded(address indexed account, uint256 accountRoles); event RolesRemoved(address indexed account, uint256 accountRoles); /** * @notice Checks if an account has a role. * @param account The address to check * @param role The role to check * @return True if the account has the role, false otherwise */ function hasRole(address account, uint8 role) external view returns (bool); } // File contracts/interfaces/IRoles.sol /** * @title IRoles Interface * @notice IRoles is an interface that abstracts the implementation of a * contract with role control features. It's commonly included for the functionality to * get current role, transfer role, and propose and accept role. */ interface IRoles is IRolesBase { error InvalidProposedAccount(address account); /** * @notice Checks if an account has all the roles. * @param account The address to check * @param roles The roles to check * @return True if the account has all the roles, false otherwise */ function hasAllTheRoles(address account, uint8[] memory roles) external view returns (bool); /** * @notice Checks if an account has any of the roles. * @param account The address to check * @param roles The roles to check * @return True if the account has any of the roles, false otherwise */ function hasAnyOfRoles(address account, uint8[] memory roles) external view returns (bool); /** * @notice Returns the roles of an account. * @param account The address to get the roles for * @return accountRoles The roles of the account in uint256 format */ function getAccountRoles(address account) external view returns (uint256 accountRoles); /** * @notice Returns the pending role of the contract. * @param fromAccount The address with the current roles * @param toAccount The address with the pending roles * @return proposedRoles_ The pending role of the contract in uint256 format */ function getProposedRoles(address fromAccount, address toAccount) external view returns (uint256 proposedRoles_); /** * @notice Transfers roles of the contract to a new account. * @dev Can only be called by the account with all the roles. * @dev Emits RolesRemoved and RolesAdded events. * @param toAccount The address to transfer role to * @param roles The roles to transfer */ function transferRoles(address toAccount, uint8[] memory roles) external; /** * @notice Propose to transfer roles of message sender to a new account. * @dev Can only be called by the account with all the proposed roles. * @dev emits a RolesProposed event. * @dev Roles are not transferred until the new role accepts the role transfer. * @param toAccount The address to transfer role to * @param roles The roles to transfer */ function proposeRoles(address toAccount, uint8[] memory roles) external; /** * @notice Accepts roles transferred from another account. * @dev Can only be called by the pending account with all the proposed roles. * @dev Emits RolesRemoved and RolesAdded events. * @param fromAccount The address of the current role * @param roles The roles to accept */ function acceptRoles(address fromAccount, uint8[] memory roles) external; }