// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; import "./AccessControlledUpgradeable.sol"; import "../../contract-registry/ContractEntity.sol"; import "../../contract-registry/Contracts.sol"; /** * @title Access Control List contract */ contract ACL is IACL, AccessControlEnumerableUpgradeable, AccessControlledUpgradeable, ContractEntity, UUPSUpgradeable { /** * @dev Constructor that gets called for the implementation contract. * @custom:oz-upgrades-unsafe-allow constructor */ constructor() initializer { // solhint-disable-previous-line no-empty-blocks } /** * @dev ACL initializer. */ function initialize() external initializer { __AccessControlEnumerable_init(); __UUPSUpgradeable_init(); if (Roles.ADMIN != DEFAULT_ADMIN_ROLE) revert RolesContractIncorrectlyConfigured(); _grantRole(Roles.ADMIN, msg.sender); _grantRole(Roles.SUPERVISOR, msg.sender); } /** * @inheritdoc IACL */ function checkRole(bytes32 role, address account) external view { _checkRole(role, account); } /** * @inheritdoc IACL */ function adminRole() external pure override returns (bytes32) { return Roles.ADMIN; } /** * @inheritdoc IACL */ function supervisorRole() external pure override returns (bytes32) { return Roles.SUPERVISOR; } /** * @inheritdoc IACL */ function listingWizardRole() external pure override returns (bytes32) { return Roles.LISTING_WIZARD; } /** * @inheritdoc IACL */ function universeWizardRole() external pure override returns (bytes32) { return Roles.UNIVERSE_WIZARD; } /** * @inheritdoc IACL */ function tokenQuoteSignerRole() external pure override returns (bytes32) { return Roles.TOKEN_QUOTE_SIGNER; } /** * @inheritdoc IContractEntity */ function contractKey() external pure override returns (bytes4) { return Contracts.ACL; } /** * @inheritdoc IERC165 */ function supportsInterface(bytes4 interfaceId) public view override(ContractEntity, AccessControlEnumerableUpgradeable, IERC165) returns (bool) { return interfaceId == type(IACL).interfaceId || ContractEntity.supportsInterface(interfaceId) || super.supportsInterface(interfaceId); } /** * @inheritdoc UUPSUpgradeable */ function _authorizeUpgrade(address newImplementation) internal virtual override onlyAdmin { // solhint-disable-previous-line no-empty-blocks } /** * @inheritdoc AccessControlEnumerableUpgradeable */ function _revokeRole(bytes32 role, address account) internal virtual override { if (Roles.ADMIN == role && getRoleMemberCount(role) == 1) revert CannotRemoveLastAdmin(); super._revokeRole(role, account); } /** * @inheritdoc AccessControlledUpgradeable */ function _acl() internal view virtual override returns (IACL) { return IACL(address(this)); } }