Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make some private functions internal to allow the developpement of "withSignature" functions (like permit) #2568

Merged
merged 12 commits into from
Sep 14, 2021
Prev Previous commit
Next Next commit
improve changelog and documentation
Amxx committed Sep 3, 2021
commit c611861f355a6746a777a24a6cb639dd51af65f6
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@
## Unreleased

* `ERC2771Context`: use private variable from storage to store the forwarder address. Fixes issues where `_msgSender()` was not callable from constructors. ([#2754](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2754))
* `Ownable`: add `_transferOwnership` to Ownable. ([#2568](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/#2568))
* `AccessControl`: make some private functions internal. ([#2568](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/#2568))
* `Ownable`: add an internal `_transferOwnership` to Ownable. ([#2568](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/#2568))
* `AccessControl`: change `_grantRole` and `_revokeRole` visibility from private to internal. ([#2568](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/#2568))

## 4.2.0 (2021-06-30)

12 changes: 12 additions & 0 deletions contracts/access/AccessControl.sol
Original file line number Diff line number Diff line change
@@ -219,6 +219,8 @@ abstract contract AccessControl is Context, IAccessControl, ERC165 {
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* CAUTION: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
@@ -235,13 +237,23 @@ abstract contract AccessControl is Context, IAccessControl, ERC165 {
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}

/**
* @dev Grants `role` to `account`.
*
* Internal function without specific requirements
*/
function _grantRole(bytes32 role, address account) internal virtual {
Amxx marked this conversation as resolved.
Show resolved Hide resolved
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}

/**
* @dev Revokes `role` from `account`.
*
* Internal function without specific requirements
*/
function _revokeRole(bytes32 role, address account) internal virtual {
Amxx marked this conversation as resolved.
Show resolved Hide resolved
if (hasRole(role, account)) {
_roles[role].members[account] = false;
4 changes: 2 additions & 2 deletions contracts/access/Ownable.sol
Original file line number Diff line number Diff line change
@@ -64,8 +64,8 @@ abstract contract Ownable is Context {
}

/**
* @dev Internal function that forces an ownership change. Can be used to
* implement custom ownership management logic in childs contracts.
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;