|
@@ -174,30 +174,36 @@ abstract contract AccessControl is Context, IAccessControl, ERC165 {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @dev Grants `role` to `account`.
|
|
|
|
|
|
+ * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
|
|
*
|
|
*
|
|
* Internal function without access restriction.
|
|
* Internal function without access restriction.
|
|
*
|
|
*
|
|
* May emit a {RoleGranted} event.
|
|
* May emit a {RoleGranted} event.
|
|
*/
|
|
*/
|
|
- function _grantRole(bytes32 role, address account) internal virtual {
|
|
|
|
|
|
+ function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
|
|
if (!hasRole(role, account)) {
|
|
if (!hasRole(role, account)) {
|
|
_roles[role].members[account] = true;
|
|
_roles[role].members[account] = true;
|
|
emit RoleGranted(role, account, _msgSender());
|
|
emit RoleGranted(role, account, _msgSender());
|
|
|
|
+ return true;
|
|
|
|
+ } else {
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @dev Revokes `role` from `account`.
|
|
|
|
|
|
+ * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
|
|
*
|
|
*
|
|
* Internal function without access restriction.
|
|
* Internal function without access restriction.
|
|
*
|
|
*
|
|
* May emit a {RoleRevoked} event.
|
|
* May emit a {RoleRevoked} event.
|
|
*/
|
|
*/
|
|
- function _revokeRole(bytes32 role, address account) internal virtual {
|
|
|
|
|
|
+ function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
|
|
if (hasRole(role, account)) {
|
|
if (hasRole(role, account)) {
|
|
_roles[role].members[account] = false;
|
|
_roles[role].members[account] = false;
|
|
emit RoleRevoked(role, account, _msgSender());
|
|
emit RoleRevoked(role, account, _msgSender());
|
|
|
|
+ return true;
|
|
|
|
+ } else {
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|