Skip to content

Commit 6dab43c

Browse files
Amxxfrangio
authored andcommitted
AccessControlEnumerable: Hook into the internal function (#2946)
* AccessControlEnumerable: Hook into the internal function * add changelog entry (cherry picked from commit 7579828)
1 parent db58ace commit 6dab43c

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* `Ownable`: add an internal `_transferOwnership(address)`. ([#2568](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2568))
66
* `AccessControl`: add internal `_grantRole(bytes32,address)` and `_revokeRole(bytes32,address)`. ([#2568](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2568))
77
* `AccessControl`: mark `_setupRole(bytes32,address)` as deprecated in favor of `_grantRole(bytes32,address)`. ([#2568](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2568))
8+
* `AccessControlEnumerable`: hook into `_grantRole(bytes32,address)` and `_revokeRole(bytes32,address)`. ([#2946](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2946))
89
* `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))
910
* Add internal `_setApprovalForAll` to `ERC721` and `ERC1155`. ([#2834](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2834))
1011
* `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))

contracts/access/AccessControlEnumerable.sol

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,34 +47,18 @@ abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessCon
4747
}
4848

4949
/**
50-
* @dev Overload {grantRole} to track enumerable memberships
50+
* @dev Overload {_grantRole} to track enumerable memberships
5151
*/
52-
function grantRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
53-
super.grantRole(role, account);
52+
function _grantRole(bytes32 role, address account) internal virtual override {
53+
super._grantRole(role, account);
5454
_roleMembers[role].add(account);
5555
}
5656

5757
/**
58-
* @dev Overload {revokeRole} to track enumerable memberships
58+
* @dev Overload {_revokeRole} to track enumerable memberships
5959
*/
60-
function revokeRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
61-
super.revokeRole(role, account);
60+
function _revokeRole(bytes32 role, address account) internal virtual override {
61+
super._revokeRole(role, account);
6262
_roleMembers[role].remove(account);
6363
}
64-
65-
/**
66-
* @dev Overload {renounceRole} to track enumerable memberships
67-
*/
68-
function renounceRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
69-
super.renounceRole(role, account);
70-
_roleMembers[role].remove(account);
71-
}
72-
73-
/**
74-
* @dev Overload {_setupRole} to track enumerable memberships
75-
*/
76-
function _setupRole(bytes32 role, address account) internal virtual override {
77-
super._setupRole(role, account);
78-
_roleMembers[role].add(account);
79-
}
8064
}

0 commit comments

Comments
 (0)