Skip to content

Commit

Permalink
feat: update selector role conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
seinmyung25 committed Mar 15, 2024
1 parent 9193038 commit a9fbba3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
40 changes: 35 additions & 5 deletions contracts/access/SelectorRoleControlUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,26 @@ interface IMulticall {
function multicall(bytes[] calldata data) external returns (bytes[] memory results);
}

interface ISelectorRoleControl is IAccessControlEnumerable, IPausable {
function grantSelectorRole(bytes4 selector, address account) external;
interface ISelectorControl is IAccessControl {
function hasSelectorRole(bytes4 role, address account) external view returns (bool);

function revokeSelectorRole(bytes4 selector, address account) external;
function getSelectorRoleAdmin(bytes4 role) external view returns (bytes32);

function pause() external;
function grantSelectorRole(bytes4 role, address account) external;

function unpause() external;
function revokeSelectorRole(bytes4 role, address account) external;

function renounceSelectorRole(bytes4 role, address callerConfirmation) external;
}

interface ISelectorControlEnumerable is IAccessControlEnumerable, ISelectorControl {
function getSelectorRoleMember(bytes4 role, uint256 index) external view returns (address);

function getSelectorRoleMemberCount(bytes4 role) external view returns (uint256);
}

interface ISelectorRoleControl is ISelectorControlEnumerable, IPausable {}

contract SelectorRoleControlUpgradeable is
Initializable,
ISelectorRoleControl,
Expand Down Expand Up @@ -72,4 +82,24 @@ contract SelectorRoleControlUpgradeable is
function unpause() public virtual override onlyAdmin {
_unpause();
}

function hasSelectorRole(bytes4 role, address account) external view override returns (bool) {
return hasRole(role, account);
}

function getSelectorRoleAdmin(bytes4 role) external view override returns (bytes32) {
return getRoleAdmin(role);
}

function renounceSelectorRole(bytes4 role, address callerConfirmation) external override {
return renounceRole(role, callerConfirmation);
}

function getSelectorRoleMember(bytes4 role, uint256 index) external view override returns (address) {
return getRoleMember(role, index);
}

function getSelectorRoleMemberCount(bytes4 role) external view override returns (uint256) {
return getRoleMemberCount(role);
}
}
1 change: 1 addition & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "./tasks/utils";

import "hardhat-tracer";
import "solidity-coverage";
import "hardhat-contract-sizer";

import "./tasks/namespace-slot";

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "eco-lib",
"version": "1.0.0",
"license": "MIT",

"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
"@nomicfoundation/hardhat-ethers": "^3.0.0",
Expand Down

0 comments on commit a9fbba3

Please sign in to comment.