Add a virtual _checkRole(bytes32) internal function to AccessControl (#3137)

* add a virtual _onlyRole(bytes32) modifier

* _onlyRole(role) → _checkRole(role)

* update doc
This commit is contained in:
Hadrien Croubois
2022-01-26 21:36:10 +01:00
committed by GitHub
parent 6fb1e843cf
commit fb950c6166
2 changed files with 17 additions and 1 deletions

View File

@ -67,7 +67,7 @@ abstract contract AccessControl is Context, IAccessControl, ERC165 {
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role, _msgSender());
_checkRole(role);
_;
}
@ -85,6 +85,18 @@ abstract contract AccessControl is Context, IAccessControl, ERC165 {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*