Appearance
Solidity API
PropsAccessControl
This contract extends AccessControlInternal and ERC2771Context to provide role-based access control functionality with additional features for diamond ownership
Implements role-based access control with diamond owner privileges
constructor
solidity
constructor() publicInitializes the contract with no trusted forwarder for meta-transactions
Constructor that initializes the ERC2771Context with a null address.
onlyMinimumRoleOrDiamondOwner
solidity
modifier onlyMinimumRoleOrDiamondOwner(bytes32 role)Reverts if the caller doesn't have the minimum required role or is not the diamond owner
Modifier to restrict access to accounts with at least the specified role or the diamond owner
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The minimum role required |
onlyPreciseRole
solidity
modifier onlyPreciseRole(bytes32 role)Reverts if the caller doesn't have the exact required role
Modifier to restrict access to accounts with the exact specified role
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The precise role required |
onlyPreciseRoleOrDiamondOwner
solidity
modifier onlyPreciseRoleOrDiamondOwner(bytes32 role)Reverts if the caller is not the diamond owner and doesn't have the exact required role
Modifier to restrict access to accounts with the exact specified role or the diamond owner
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The precise role required (or diamond owner) |
onlyRoleAdmin
solidity
modifier onlyRoleAdmin(bytes32 role)Reverts if the caller is not the diamond owner and doesn't have the admin role for the specified role
Modifier to restrict access to role admins or the diamond owner
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The role whose admin is required |
onlyDiamondOwner
solidity
modifier onlyDiamondOwner()Reverts if the caller is not the diamond owner
Modifier to restrict access to the diamond owner only
onlyDiamondOwnerOrFactory
solidity
modifier onlyDiamondOwnerOrFactory()Reverts if the caller is neither the diamond owner nor the diamond factory
Modifier to restrict access to the diamond owner or diamond factory only
onlyDiamondOwnerOrFactoryOrSelf
solidity
modifier onlyDiamondOwnerOrFactoryOrSelf()Reverts if the caller is neither the diamond owner nor the diamond factory
Modifier to restrict access to the diamond owner or diamond factory only
onlyDiamondSelf
solidity
modifier onlyDiamondSelf()onlyMinimumRoleOrDiamondSelf
solidity
modifier onlyMinimumRoleOrDiamondSelf(bytes32 role)isDiamondOwner
solidity
function isDiamondOwner(address account) public view returns (bool)This function uses LibDiamond to determine the contract owner
Checks if an account is the diamond owner
Parameters
| Name | Type | Description |
|---|---|---|
| account | address | The account to check |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bool | bool True if the account is the diamond owner, false otherwise |
isDiamondFactory
solidity
function isDiamondFactory(address account) public view returns (bool)This function uses PropsAccessControlStorage to determine the factory address
Checks if an account is the diamond factory
Parameters
| Name | Type | Description |
|---|---|---|
| account | address | The account to check |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bool | bool True if the account is the diamond factory, false otherwise |
isDiamondSelf
solidity
function isDiamondSelf(address account) public view returns (bool)grantRole
solidity
function grantRole(bytes32 role, address account) publicThis function can only be called by the role admin or diamond owner
Grants a role to an account
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The role to grant |
| account | address | The account to receive the role |
hasRole
solidity
function hasRole(bytes32 role, address account) public view returns (bool)The diamond owner always has the DEFAULT_ADMIN_ROLE
Checks if an account has a specific role
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The role to check |
| account | address | The account to check |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bool | bool True if the account has the role, false otherwise |
hasMinimumRole
solidity
function hasMinimumRole(bytes32 role) public view returns (bool)This function checks for the minimum role in the role hierarchy
Checks if the caller has at least the specified role
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The minimum role to check |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bool | bool True if the caller has at least the specified role, false otherwise |
_hasMinimumRole
solidity
function _hasMinimumRole(bytes32 role, address account) internal view returns (bool)This function recursively checks the role hierarchy
Internal function to check if an account has at least the specified role
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The minimum role to check |
| account | address | The account to check |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bool | bool True if the account has at least the specified role, false otherwise |
getRoleAdmin
solidity
function getRoleAdmin(bytes32 role) public view returns (bytes32)This function returns the admin role as defined in the access control system
Returns the admin role for a specified role
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The role to check |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bytes32 | bytes32 The admin role |
revokeRole
solidity
function revokeRole(bytes32 role, address account) externalThis function can only be called by the role admin or diamond owner
Revokes a role from an account
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The role to revoke |
| account | address | The account to revoke the role from |
renounceRole
solidity
function renounceRole(bytes32 role) externalThis function allows an account to give up their role
Allows an account to renounce a role
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The role to renounce |
getRoleMember
solidity
function getRoleMember(bytes32 role, uint256 index) external view returns (address)This function allows iterating over all members of a role
Returns a role member by index
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The role to check |
| index | uint256 | The index of the member |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | address | address The address of the role member |
getRoleMemberCount
solidity
function getRoleMemberCount(bytes32 role) external view returns (uint256)This function returns the total count of members for a given role
Returns the number of accounts that have a specific role
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The role to check |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | uint256 | uint256 The number of accounts with the role |
setRoleAdmin
solidity
function setRoleAdmin(bytes32 role, bytes32 adminRole) publicThis function can only be called by accounts with the DEFAULT_ADMIN_ROLE or the diamond owner
Sets the admin role for a specified role
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The role to set the admin for |
| adminRole | bytes32 | The new admin role |
checkRole
solidity
function checkRole(bytes32 role) public viewThis function reverts if the caller doesn't have the specified role
Checks if the caller has a specific role
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The role to check |
checkRole
solidity
function checkRole(bytes32 role, address account) public viewThis function reverts if the account doesn't have the specified role
Checks if an account has a specific role
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The role to check |
| account | address | The account to check |