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
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,10 @@
# Changelog

## Unreleased

* `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))
Amxx marked this conversation as resolved.
Show resolved Hide resolved

## 4.3.1

* `TimelockController`: Add additional isOperationReady check.
Expand Down
4 changes: 2 additions & 2 deletions contracts/access/AccessControl.sol
Expand Up @@ -194,14 +194,14 @@ abstract contract AccessControl is Context, IAccessControl, ERC165 {
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}

function _grantRole(bytes32 role, address account) private {
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());
}
}

function _revokeRole(bytes32 role, address account) private {
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;
emit RoleRevoked(role, account, _msgSender());
Expand Down
12 changes: 8 additions & 4 deletions contracts/access/Ownable.sol
Expand Up @@ -25,7 +25,7 @@ abstract contract Ownable is Context {
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
_transferOwnership(_msgSender());
}

/**
Expand All @@ -51,7 +51,7 @@ abstract contract Ownable is Context {
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
_transferOwnership(address(0));
}

/**
Expand All @@ -60,10 +60,14 @@ abstract contract Ownable is Context {
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
_transferOwnership(newOwner);
}

function _setOwner(address newOwner) private {
/**
* @dev Internal function that forces an ownership change. Can be used to
* implement custom ownership management logic in childs contracts.
Amxx marked this conversation as resolved.
Show resolved Hide resolved
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
Expand Down