Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

AccessControlEnumerableUpgradeable

Inherits: Initializable, IAccessControlEnumerable, AccessControlUpgradeable

Extension of {AccessControl} that allows enumerating the members of each role.

State Variables

AccessControlEnumerableStorageLocation

bytes32 private constant AccessControlEnumerableStorageLocation =
    0xc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000;

Functions

_getAccessControlEnumerableStorage

function _getAccessControlEnumerableStorage() private pure returns (AccessControlEnumerableStorage storage $);

__AccessControlEnumerable_init

function __AccessControlEnumerable_init() internal onlyInitializing;

__AccessControlEnumerable_init_unchained

function __AccessControlEnumerable_init_unchained() internal onlyInitializing;

supportsInterface

Query if a contract implements an interface

Interface identification is specified in ERC-165. This function uses less than 30,000 gas.

function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool);

Parameters

NameTypeDescription
interfaceIdbytes4

Returns

NameTypeDescription
<none>booltrue if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise

getRoleMember

Returns one of the accounts that have role. index must be a value between 0 and getRoleMemberCount, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information.

function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address);

getRoleMemberCount

Returns the number of accounts that have role. Can be used together with getRoleMember to enumerate all bearers of a role.

function getRoleMemberCount(bytes32 role) public view virtual returns (uint256);

getRoleMembers

Return all accounts that have role WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.

function getRoleMembers(bytes32 role) public view virtual returns (address[] memory);

_grantRole

Overload AccessControl-_grantRole to track enumerable memberships

function _grantRole(bytes32 role, address account) internal virtual override returns (bool);

_revokeRole

Overload AccessControl-_revokeRole to track enumerable memberships

function _revokeRole(bytes32 role, address account) internal virtual override returns (bool);

Structs

AccessControlEnumerableStorage

Note: storage-location: erc7201:openzeppelin.storage.AccessControlEnumerable

struct AccessControlEnumerableStorage {
    mapping(bytes32 role => EnumerableSet.AddressSet) _roleMembers;
}