From ee68353020aa3ff8eec996282d55e0abf9c954d6 Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Thu, 4 Nov 2021 11:36:06 +0100 Subject: [PATCH 1/2] AccessControlEnumerable: Hook into the internal function --- contracts/access/AccessControlEnumerable.sol | 28 +++++--------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/contracts/access/AccessControlEnumerable.sol b/contracts/access/AccessControlEnumerable.sol index 1c628b0ca03..655195d9a38 100644 --- a/contracts/access/AccessControlEnumerable.sol +++ b/contracts/access/AccessControlEnumerable.sol @@ -47,34 +47,18 @@ abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessCon } /** - * @dev Overload {grantRole} to track enumerable memberships + * @dev Overload {_grantRole} to track enumerable memberships */ - function grantRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { - super.grantRole(role, account); + function _grantRole(bytes32 role, address account) internal virtual override { + super._grantRole(role, account); _roleMembers[role].add(account); } /** - * @dev Overload {revokeRole} to track enumerable memberships + * @dev Overload {_revokeRole} to track enumerable memberships */ - function revokeRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { - super.revokeRole(role, account); + function _revokeRole(bytes32 role, address account) internal virtual override { + super._revokeRole(role, account); _roleMembers[role].remove(account); } - - /** - * @dev Overload {renounceRole} to track enumerable memberships - */ - function renounceRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { - super.renounceRole(role, account); - _roleMembers[role].remove(account); - } - - /** - * @dev Overload {_setupRole} to track enumerable memberships - */ - function _setupRole(bytes32 role, address account) internal virtual override { - super._setupRole(role, account); - _roleMembers[role].add(account); - } } From 0704ff433bc0f8e7e8ee20e312748ff3f6c7af7c Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Thu, 4 Nov 2021 11:39:11 +0100 Subject: [PATCH 2/2] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a73672793a..f816911c60b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * `Ownable`: add an internal `_transferOwnership(address)`. ([#2568](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2568)) * `AccessControl`: add internal `_grantRole(bytes32,address)` and `_revokeRole(bytes32,address)`. ([#2568](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2568)) * `AccessControl`: mark `_setupRole(bytes32,address)` as deprecated in favor of `_grantRole(bytes32,address)`. ([#2568](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2568)) + * `AccessControlEnumerable`: hook into `_grantRole(bytes32,address)` and `_revokeRole(bytes32,address)`. ([#2946](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2946)) * `EIP712`: cache `address(this)` to immutable storage to avoid potential issues if a vanilla contract is used in a delegatecall context. ([#2852](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2852)) * Add internal `_setApprovalForAll` to `ERC721` and `ERC1155`. ([#2834](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2834)) * `Governor`: shift vote start and end by one block to better match Compound's GovernorBravo and prevent voting at the Governor level if the voting snapshot is not ready. ([#2892](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2892))