Skip to content

Commit

Permalink
rename modifiers in AccessControl an TimelockController
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx committed Mar 23, 2021
1 parent 8d34329 commit 68af355
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion contracts/access/AccessControl.sol
Expand Up @@ -96,7 +96,7 @@ abstract contract AccessControl is Context, IAccessControl, ERC165 {
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*/
modifier onlySenderWithRole(bytes32 role) {
modifier onlyRole(bytes32 role) {
_checkRole(role, _msgSender());
_;
}
Expand Down
12 changes: 6 additions & 6 deletions contracts/governance/TimelockController.sol
Expand Up @@ -80,7 +80,7 @@ contract TimelockController is AccessControl {
* considered. Granting a role to `address(0)` is equivalent to enabling
* this role for everyone.
*/
modifier onlyRole(bytes32 role) {
modifier onlyRoleOrOpenRole(bytes32 role) {
require(hasRole(role, _msgSender()) || hasRole(role, address(0)), "TimelockController: sender requires permission");
_;
}
Expand Down Expand Up @@ -163,7 +163,7 @@ contract TimelockController is AccessControl {
*
* - the caller must have the 'proposer' role.
*/
function schedule(address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt, uint256 delay) public virtual onlyRole(PROPOSER_ROLE) {
function schedule(address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt, uint256 delay) public virtual onlyRoleOrOpenRole(PROPOSER_ROLE) {
bytes32 id = hashOperation(target, value, data, predecessor, salt);
_schedule(id, delay);
emit CallScheduled(id, 0, target, value, data, predecessor, delay);
Expand All @@ -178,7 +178,7 @@ contract TimelockController is AccessControl {
*
* - the caller must have the 'proposer' role.
*/
function scheduleBatch(address[] calldata targets, uint256[] calldata values, bytes[] calldata datas, bytes32 predecessor, bytes32 salt, uint256 delay) public virtual onlyRole(PROPOSER_ROLE) {
function scheduleBatch(address[] calldata targets, uint256[] calldata values, bytes[] calldata datas, bytes32 predecessor, bytes32 salt, uint256 delay) public virtual onlyRoleOrOpenRole(PROPOSER_ROLE) {
require(targets.length == values.length, "TimelockController: length mismatch");
require(targets.length == datas.length, "TimelockController: length mismatch");

Expand Down Expand Up @@ -206,7 +206,7 @@ contract TimelockController is AccessControl {
*
* - the caller must have the 'proposer' role.
*/
function cancel(bytes32 id) public virtual onlyRole(PROPOSER_ROLE) {
function cancel(bytes32 id) public virtual onlyRoleOrOpenRole(PROPOSER_ROLE) {
require(isOperationPending(id), "TimelockController: operation cannot be cancelled");
delete _timestamps[id];

Expand All @@ -222,7 +222,7 @@ contract TimelockController is AccessControl {
*
* - the caller must have the 'executor' role.
*/
function execute(address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt) public payable virtual onlyRole(EXECUTOR_ROLE) {
function execute(address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) {
bytes32 id = hashOperation(target, value, data, predecessor, salt);
_beforeCall(predecessor);
_call(id, 0, target, value, data);
Expand All @@ -238,7 +238,7 @@ contract TimelockController is AccessControl {
*
* - the caller must have the 'executor' role.
*/
function executeBatch(address[] calldata targets, uint256[] calldata values, bytes[] calldata datas, bytes32 predecessor, bytes32 salt) public payable virtual onlyRole(EXECUTOR_ROLE) {
function executeBatch(address[] calldata targets, uint256[] calldata values, bytes[] calldata datas, bytes32 predecessor, bytes32 salt) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) {
require(targets.length == values.length, "TimelockController: length mismatch");
require(targets.length == datas.length, "TimelockController: length mismatch");

Expand Down
2 changes: 2 additions & 0 deletions contracts/mocks/AccessControlEnumerableMock.sol
Expand Up @@ -12,4 +12,6 @@ contract AccessControlEnumerableMock is AccessControlEnumerable {
function setRoleAdmin(bytes32 roleId, bytes32 adminRoleId) public {
_setRoleAdmin(roleId, adminRoleId);
}

function senderProtected(bytes32 roleId) public onlyRole(roleId) {}
}
2 changes: 1 addition & 1 deletion contracts/mocks/AccessControlMock.sol
Expand Up @@ -13,5 +13,5 @@ contract AccessControlMock is AccessControl {
_setRoleAdmin(roleId, adminRoleId);
}

function senderProtected(bytes32 roleId) public onlySenderWithRole(roleId) {}
function senderProtected(bytes32 roleId) public onlyRole(roleId) {}
}

0 comments on commit 68af355

Please sign in to comment.