PolygonAccessControlUpgradeable.sol
A contract that inherits 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¶
function __AccessControl_init(
) internal
hasRole¶
Returns true if account has been granted role.
function hasRole(
) public returns (bool)
_checkRole¶
function _checkRole(
) internal
- 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¶
function _checkRole(
) internal
- Reverts with a standard message if
accountis missingrole. - The format of the revert reason is given by the following regular expression:
/^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
getRoleAdmin¶
Returns the admin role that controls role. See grantRole and revokeRole.
function getRoleAdmin(
) public returns (bytes32)
To change a role’s admin, use _setRoleAdmin.
grantRole¶
Grants role to account. If account has not been granted role, it emits a RoleGranted event.
function grantRole(
) public
- 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.
function revokeRole(
) public
renounceRole¶
Revokes role from the calling account.
function renounceRole(
) public
- The caller must have the admin role
account. - May emit a
RoleRevokedevent.
Roles are often managed via 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¶
function _setupRole(
) internal
Grants 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.
Warn
- 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.
Note
- This function is deprecated in favor of
_grantRole.
_setRoleAdmin¶
Sets adminRole as the admin role.
function _setRoleAdmin(
) internal
Emits a RoleAdminChanged event.
_grantRole¶
Grants role to account. Internal function without access restriction.
function _grantRole(
) internal
May emit a RoleGranted event.
_revokeRole¶
Revokes role from account. Internal function without access restriction.
function _revokeRole(
) internal
May emit a RoleRevoked event.