AccessControlUpgradeable from Openzeppelin, but with the following modifications:
- Deletes
ERC165Upgradeabledependencies to save us the “gap” variables and let us have consistent storage. - Adds the legacy
Ownervariable, to be consistent with the previous. - Adds custom errors.
- Replaces
_msgSender()withmsg.sender.
Functions
__AccessControl_init
hasRole
Returns true if account has been granted role.
_checkRole
- Reverts with a standard message if
msg.senderis missingrole. Overriding this function changes the behavior of the{onlyRole}modifier. - Describes the format of the revert message in
{_checkRole}. - Available since v4.6.
_checkRole
- Reverts with a standard message if
accountis missingrole. - The format of the revert reason is given by the following regular expression:
getRoleAdmin
Returns the admin role that controls role. See grantRole and revokeRole.
_setRoleAdmin.
grantRole
Grants role to account. If account has not been granted role, it emits a RoleGranted event.
- The caller must have the
roleas the admin role. - May emit a
RoleGrantedevent.
revokeRole
Revokes role from account. If account had been granted role, this function emits a RoleRevoked event.
renounceRole
Revokes role from the calling account.
- The caller must have the admin role
account. - May emit a
RoleRevokedevent.
grantRole and revokeRole. The purpose of this function is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced).
Emits a RoleRevokedevent if the calling account had its role revoked.
_setupRole
role to an account.
Emits a RoleGranted event if account has not been granted role before.
Note that unlike grantRole, this function doesn’t perform any checks on the calling account.
May emit a RoleGranted event.
- This function should only be called from the constructor, when setting up the initial roles for the system.
- Using this function in any other way is effectively circumventing the admin system imposed by
AccessControl.
- This function is deprecated in favor of
_grantRole.
_setRoleAdmin
Sets adminRole as the admin role.
RoleAdminChanged event.
_grantRole
Grants role to account. Internal function without access restriction.
RoleGranted event.
_revokeRole
Revokes role from account. Internal function without access restriction.
RoleRevoked event.