IAccessManager
Title: IAccessManager
Author: Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/manager/IAccessManager.sol)
Centralized authority: roles, hierarchies, grant/execution delays,
per-target function-selector permissions, operation scheduling.
Follows OpenZeppelin v5 AccessManager, including its admin restrictions: setTargetFunctionRole,
setTargetClosed and updateAuthority carry the target's admin delay, grantRole/revokeRole are
restricted to the role's admin, and a non-zero required delay (the larger of that delay and the caller's
execution delay) means the call must be scheduled against this manager, then made directly or through
execute once ready. A schedule expires 1 week after it is ready, that second included.
As in OZ, the admin delay on updateAuthority does not bind execute(target, setAuthority(x)), which is
gated by the target's own role for setAuthority (ADMIN_ROLE unless mapped). To make the admin delay an
exit window for authority migration, map the target's setAuthority selector to a role nobody holds;
undoing that mapping is itself subject to the admin delay.
Differences from OpenZeppelin v5.1.0: ADMIN_ROLE is held only by the initial admin and cannot be granted,
revoked or renounced; errors keep the Lattice shapes (AccessManagerUnauthorizedAccount where OZ has
AccessManagerUnauthorizedCall, AccessManagerTargetCallFailed for a target that reverts without data,
and a schedule by a caller with immediate access reverts AccessManagerNotScheduled); execute does not
reject a target without code (OZ reverts AddressEmptyCode); schedule raises
a too-early when to the earliest allowed time instead of reverting; nonces come from one global counter;
hasRole reports an execution delay of 0 for an account whose grant is still waiting out the grant delay
(OZ returns (false, delay); membership and canCall are the same); and expiration()/minSetback() are
not exposed (1 week and 5 days). In a diamond, address(this) also hosts the other facets, so a call
execute makes to the diamond with a selector that is not one of this manager's admin functions is gated by the diamond's own target roles (see issue #240). Those default to
ADMIN_ROLE, and the call arrives with msg.sender == address(this), so a co-cut ADMIN_ROLE holder acts as
the diamond itself on every other facet: it passes any gate that trusts the diamond as caller, such as
GovernedDiamondCut's UPGRADE_EXECUTOR_ROLE, the timelock's self-only setters and the ERC-7786 handlers.
Keep the manager in its own authority diamond; to govern it, make the governed diamond that authority's
initial admin (ADMIN_ROLE cannot be granted later). Do not make a co-cut manager's own diamond its admin:
the manager refuses that caller outside an execute already in flight, so it could never be configured.
See "Composition hazards" in docs/guides/compose-your-own-diamond.md.
Functions
ADMIN_ROLE
function ADMIN_ROLE() external pure returns (uint64);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint64 |
PUBLIC_ROLE
function PUBLIC_ROLE() external pure returns (uint64);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint64 |
hasRole
function hasRole(uint64 roleId, address account) external view returns (bool isMember, uint32 executionDelay);Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 | |
| account | address |
Returns
| Name | Type | Description |
|---|---|---|
| isMember | bool | |
| executionDelay | uint32 |
getAccess
function getAccess(uint64 roleId, address account)
external
view
returns (uint48 since, uint32 currentDelay, uint32 pendingDelay, uint48 effect);Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 | |
| account | address |
Returns
| Name | Type | Description |
|---|---|---|
| since | uint48 | |
| currentDelay | uint32 | |
| pendingDelay | uint32 | |
| effect | uint48 |
getRoleAdmin
function getRoleAdmin(uint64 roleId) external view returns (uint64);Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint64 |
getRoleGuardian
function getRoleGuardian(uint64 roleId) external view returns (uint64);Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint64 |
getRoleGrantDelay
function getRoleGrantDelay(uint64 roleId) external view returns (uint32);Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint32 |
getRoleMembers
function getRoleMembers(uint64 roleId) external view returns (address[] memory);Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | address[] |
getRoleMemberCount
function getRoleMemberCount(uint64 roleId) external view returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
getTargetFunctionRole
function getTargetFunctionRole(address target, bytes4 selector) external view returns (uint64);Parameters
| Name | Type | Description |
|---|---|---|
| target | address | |
| selector | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint64 |
getTargetAdminDelay
function getTargetAdminDelay(address target) external view returns (uint32);Parameters
| Name | Type | Description |
|---|---|---|
| target | address |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint32 |
isTargetClosed
function isTargetClosed(address target) external view returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| target | address |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
canCall
function canCall(address caller, address target, bytes4 selector)
external
view
returns (bool immediate, uint32 delay);Parameters
| Name | Type | Description |
|---|---|---|
| caller | address | |
| target | address | |
| selector | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
| immediate | bool | |
| delay | uint32 |
hashOperation
function hashOperation(address caller, address target, bytes calldata data) external pure returns (bytes32);Parameters
| Name | Type | Description |
|---|---|---|
| caller | address | |
| target | address | |
| data | bytes |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bytes32 |
getSchedule
function getSchedule(bytes32 operationId) external view returns (uint48);Parameters
| Name | Type | Description |
|---|---|---|
| operationId | bytes32 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint48 |
getNonce
function getNonce(bytes32 operationId) external view returns (uint32);Parameters
| Name | Type | Description |
|---|---|---|
| operationId | bytes32 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint32 |
grantRole
function grantRole(uint64 roleId, address account, uint32 executionDelay) external;Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 | |
| account | address | |
| executionDelay | uint32 |
revokeRole
function revokeRole(uint64 roleId, address account) external;Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 | |
| account | address |
renounceRole
function renounceRole(uint64 roleId, address callerConfirmation) external;Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 | |
| callerConfirmation | address |
setRoleAdmin
function setRoleAdmin(uint64 roleId, uint64 admin) external;Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 | |
| admin | uint64 |
setRoleGuardian
function setRoleGuardian(uint64 roleId, uint64 guardian) external;Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 | |
| guardian | uint64 |
setGrantDelay
function setGrantDelay(uint64 roleId, uint32 newDelay) external;Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 | |
| newDelay | uint32 |
labelRole
function labelRole(uint64 roleId, string calldata label) external;Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 | |
| label | string |
setTargetFunctionRole
function setTargetFunctionRole(address target, bytes4[] calldata selectors, uint64 roleId) external;Parameters
| Name | Type | Description |
|---|---|---|
| target | address | |
| selectors | bytes4[] | |
| roleId | uint64 |
setTargetAdminDelay
function setTargetAdminDelay(address target, uint32 newDelay) external;Parameters
| Name | Type | Description |
|---|---|---|
| target | address | |
| newDelay | uint32 |
setTargetClosed
function setTargetClosed(address target, bool closed) external;Parameters
| Name | Type | Description |
|---|---|---|
| target | address | |
| closed | bool |
updateAuthority
Points managed target at newAuthority. Only callable by ADMIN_ROLE; this manager must be
target's current authority.
function updateAuthority(address target, address newAuthority) external;Parameters
| Name | Type | Description |
|---|---|---|
| target | address | |
| newAuthority | address |
schedule
function schedule(address target, bytes calldata data, uint48 when)
external
returns (bytes32 operationId, uint32 nonce);Parameters
| Name | Type | Description |
|---|---|---|
| target | address | |
| data | bytes | |
| when | uint48 |
Returns
| Name | Type | Description |
|---|---|---|
| operationId | bytes32 | |
| nonce | uint32 |
execute
function execute(address target, bytes calldata data) external payable returns (uint32 nonce);Parameters
| Name | Type | Description |
|---|---|---|
| target | address | |
| data | bytes |
Returns
| Name | Type | Description |
|---|---|---|
| nonce | uint32 |
cancel
function cancel(address caller, address target, bytes calldata data) external returns (uint32 nonce);Parameters
| Name | Type | Description |
|---|---|---|
| caller | address | |
| target | address | |
| data | bytes |
Returns
| Name | Type | Description |
|---|---|---|
| nonce | uint32 |
consumeScheduledOp
Consumes the scheduled operation (caller, msg.sender, data) for a managed target making a
delayed direct call. Reverts AccessManagerUnauthorizedConsume unless msg.sender reports
isConsumingScheduledOp.selector from IAccessManaged.isConsumingScheduledOp, and reverts unless
the operation is scheduled, ready and not expired.
function consumeScheduledOp(address caller, bytes calldata data) external;Parameters
| Name | Type | Description |
|---|---|---|
| caller | address | |
| data | bytes |
Events
OperationScheduled
event OperationScheduled(
bytes32 indexed operationId, uint32 indexed nonce, uint48 schedule, address caller, address target, bytes data
);Parameters
| Name | Type | Description |
|---|---|---|
| operationId | bytes32 | |
| nonce | uint32 | |
| schedule | uint48 | |
| caller | address | |
| target | address | |
| data | bytes |
OperationExecuted
event OperationExecuted(bytes32 indexed operationId, uint32 indexed nonce);Parameters
| Name | Type | Description |
|---|---|---|
| operationId | bytes32 | |
| nonce | uint32 |
OperationCanceled
event OperationCanceled(bytes32 indexed operationId, uint32 indexed nonce);Parameters
| Name | Type | Description |
|---|---|---|
| operationId | bytes32 | |
| nonce | uint32 |
RoleLabel
event RoleLabel(uint64 indexed roleId, string label);Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 | |
| label | string |
RoleGranted
event RoleGranted(uint64 indexed roleId, address indexed account, uint32 delay, uint48 since, bool newMember);Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 | |
| account | address | |
| delay | uint32 | |
| since | uint48 | |
| newMember | bool |
RoleRevoked
event RoleRevoked(uint64 indexed roleId, address indexed account);Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 | |
| account | address |
RoleAdminChanged
event RoleAdminChanged(uint64 indexed roleId, uint64 indexed admin);Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 | |
| admin | uint64 |
RoleGuardianChanged
event RoleGuardianChanged(uint64 indexed roleId, uint64 indexed guardian);Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 | |
| guardian | uint64 |
RoleGrantDelayChanged
event RoleGrantDelayChanged(uint64 indexed roleId, uint32 delay, uint48 since);Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 | |
| delay | uint32 | |
| since | uint48 |
TargetClosed
event TargetClosed(address indexed target, bool closed);Parameters
| Name | Type | Description |
|---|---|---|
| target | address | |
| closed | bool |
TargetFunctionRoleUpdated
event TargetFunctionRoleUpdated(address indexed target, bytes4 selector, uint64 indexed roleId);Parameters
| Name | Type | Description |
|---|---|---|
| target | address | |
| selector | bytes4 | |
| roleId | uint64 |
TargetAdminDelayUpdated
event TargetAdminDelayUpdated(address indexed target, uint32 delay, uint48 since);Parameters
| Name | Type | Description |
|---|---|---|
| target | address | |
| delay | uint32 | |
| since | uint48 |
Errors
AccessManagerAlreadyScheduled
error AccessManagerAlreadyScheduled(bytes32 operationId);Parameters
| Name | Type | Description |
|---|---|---|
| operationId | bytes32 |
AccessManagerNotScheduled
error AccessManagerNotScheduled(bytes32 operationId);Parameters
| Name | Type | Description |
|---|---|---|
| operationId | bytes32 |
AccessManagerNotReady
error AccessManagerNotReady(bytes32 operationId);Parameters
| Name | Type | Description |
|---|---|---|
| operationId | bytes32 |
AccessManagerExpired
error AccessManagerExpired(bytes32 operationId);Parameters
| Name | Type | Description |
|---|---|---|
| operationId | bytes32 |
AccessManagerLockedRole
error AccessManagerLockedRole(uint64 roleId);Parameters
| Name | Type | Description |
|---|---|---|
| roleId | uint64 |
AccessManagerBadConfirmation
error AccessManagerBadConfirmation();AccessManagerUnauthorizedAccount
error AccessManagerUnauthorizedAccount(address caller, uint64 roleId);Parameters
| Name | Type | Description |
|---|---|---|
| caller | address | |
| roleId | uint64 |
AccessManagerUnauthorizedConsume
error AccessManagerUnauthorizedConsume(address target);Parameters
| Name | Type | Description |
|---|---|---|
| target | address |
AccessManagerUnauthorizedCancel
error AccessManagerUnauthorizedCancel(address caller, address target);Parameters
| Name | Type | Description |
|---|---|---|
| caller | address | |
| target | address |
AccessManagerInvalidInitialAdmin
error AccessManagerInvalidInitialAdmin();AccessManagerTargetCallFailed
error AccessManagerTargetCallFailed(address target);Parameters
| Name | Type | Description |
|---|---|---|
| target | address |