Skip to content

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() public

Initializes 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

NameTypeDescription
rolebytes32The 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

NameTypeDescription
rolebytes32The 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

NameTypeDescription
rolebytes32The 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

NameTypeDescription
rolebytes32The 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

NameTypeDescription
accountaddressThe account to check

Return Values

NameTypeDescription
[0]boolbool 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

NameTypeDescription
accountaddressThe account to check

Return Values

NameTypeDescription
[0]boolbool 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) public

This function can only be called by the role admin or diamond owner

Grants a role to an account

Parameters

NameTypeDescription
rolebytes32The role to grant
accountaddressThe 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

NameTypeDescription
rolebytes32The role to check
accountaddressThe account to check

Return Values

NameTypeDescription
[0]boolbool 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

NameTypeDescription
rolebytes32The minimum role to check

Return Values

NameTypeDescription
[0]boolbool 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

NameTypeDescription
rolebytes32The minimum role to check
accountaddressThe account to check

Return Values

NameTypeDescription
[0]boolbool 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

NameTypeDescription
rolebytes32The role to check

Return Values

NameTypeDescription
[0]bytes32bytes32 The admin role

revokeRole

solidity
function revokeRole(bytes32 role, address account) external

This function can only be called by the role admin or diamond owner

Revokes a role from an account

Parameters

NameTypeDescription
rolebytes32The role to revoke
accountaddressThe account to revoke the role from

renounceRole

solidity
function renounceRole(bytes32 role) external

This function allows an account to give up their role

Allows an account to renounce a role

Parameters

NameTypeDescription
rolebytes32The 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

NameTypeDescription
rolebytes32The role to check
indexuint256The index of the member

Return Values

NameTypeDescription
[0]addressaddress 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

NameTypeDescription
rolebytes32The role to check

Return Values

NameTypeDescription
[0]uint256uint256 The number of accounts with the role

setRoleAdmin

solidity
function setRoleAdmin(bytes32 role, bytes32 adminRole) public

This 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

NameTypeDescription
rolebytes32The role to set the admin for
adminRolebytes32The new admin role

checkRole

solidity
function checkRole(bytes32 role) public view

This function reverts if the caller doesn't have the specified role

Checks if the caller has a specific role

Parameters

NameTypeDescription
rolebytes32The role to check

checkRole

solidity
function checkRole(bytes32 role, address account) public view

This function reverts if the account doesn't have the specified role

Checks if an account has a specific role

Parameters

NameTypeDescription
rolebytes32The role to check
accountaddressThe account to check