Skip to content
Lattice

IAccessManager

Git Source

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

NameTypeDescription
<none>uint64

PUBLIC_ROLE

function PUBLIC_ROLE() external pure returns (uint64);

Returns

NameTypeDescription
<none>uint64

hasRole

function hasRole(uint64 roleId, address account) external view returns (bool isMember, uint32 executionDelay);

Parameters

NameTypeDescription
roleIduint64
accountaddress

Returns

NameTypeDescription
isMemberbool
executionDelayuint32

getAccess

function getAccess(uint64 roleId, address account)
        external
        view
        returns (uint48 since, uint32 currentDelay, uint32 pendingDelay, uint48 effect);

Parameters

NameTypeDescription
roleIduint64
accountaddress

Returns

NameTypeDescription
sinceuint48
currentDelayuint32
pendingDelayuint32
effectuint48

getRoleAdmin

function getRoleAdmin(uint64 roleId) external view returns (uint64);

Parameters

NameTypeDescription
roleIduint64

Returns

NameTypeDescription
<none>uint64

getRoleGuardian

function getRoleGuardian(uint64 roleId) external view returns (uint64);

Parameters

NameTypeDescription
roleIduint64

Returns

NameTypeDescription
<none>uint64

getRoleGrantDelay

function getRoleGrantDelay(uint64 roleId) external view returns (uint32);

Parameters

NameTypeDescription
roleIduint64

Returns

NameTypeDescription
<none>uint32

getRoleMembers

function getRoleMembers(uint64 roleId) external view returns (address[] memory);

Parameters

NameTypeDescription
roleIduint64

Returns

NameTypeDescription
<none>address[]

getRoleMemberCount

function getRoleMemberCount(uint64 roleId) external view returns (uint256);

Parameters

NameTypeDescription
roleIduint64

Returns

NameTypeDescription
<none>uint256

getTargetFunctionRole

function getTargetFunctionRole(address target, bytes4 selector) external view returns (uint64);

Parameters

NameTypeDescription
targetaddress
selectorbytes4

Returns

NameTypeDescription
<none>uint64

getTargetAdminDelay

function getTargetAdminDelay(address target) external view returns (uint32);

Parameters

NameTypeDescription
targetaddress

Returns

NameTypeDescription
<none>uint32

isTargetClosed

function isTargetClosed(address target) external view returns (bool);

Parameters

NameTypeDescription
targetaddress

Returns

NameTypeDescription
<none>bool

canCall

function canCall(address caller, address target, bytes4 selector)
        external
        view
        returns (bool immediate, uint32 delay);

Parameters

NameTypeDescription
calleraddress
targetaddress
selectorbytes4

Returns

NameTypeDescription
immediatebool
delayuint32

hashOperation

function hashOperation(address caller, address target, bytes calldata data) external pure returns (bytes32);

Parameters

NameTypeDescription
calleraddress
targetaddress
databytes

Returns

NameTypeDescription
<none>bytes32

getSchedule

function getSchedule(bytes32 operationId) external view returns (uint48);

Parameters

NameTypeDescription
operationIdbytes32

Returns

NameTypeDescription
<none>uint48

getNonce

function getNonce(bytes32 operationId) external view returns (uint32);

Parameters

NameTypeDescription
operationIdbytes32

Returns

NameTypeDescription
<none>uint32

grantRole

function grantRole(uint64 roleId, address account, uint32 executionDelay) external;

Parameters

NameTypeDescription
roleIduint64
accountaddress
executionDelayuint32

revokeRole

function revokeRole(uint64 roleId, address account) external;

Parameters

NameTypeDescription
roleIduint64
accountaddress

renounceRole

function renounceRole(uint64 roleId, address callerConfirmation) external;

Parameters

NameTypeDescription
roleIduint64
callerConfirmationaddress

setRoleAdmin

function setRoleAdmin(uint64 roleId, uint64 admin) external;

Parameters

NameTypeDescription
roleIduint64
adminuint64

setRoleGuardian

function setRoleGuardian(uint64 roleId, uint64 guardian) external;

Parameters

NameTypeDescription
roleIduint64
guardianuint64

setGrantDelay

function setGrantDelay(uint64 roleId, uint32 newDelay) external;

Parameters

NameTypeDescription
roleIduint64
newDelayuint32

labelRole

function labelRole(uint64 roleId, string calldata label) external;

Parameters

NameTypeDescription
roleIduint64
labelstring

setTargetFunctionRole

function setTargetFunctionRole(address target, bytes4[] calldata selectors, uint64 roleId) external;

Parameters

NameTypeDescription
targetaddress
selectorsbytes4[]
roleIduint64

setTargetAdminDelay

function setTargetAdminDelay(address target, uint32 newDelay) external;

Parameters

NameTypeDescription
targetaddress
newDelayuint32

setTargetClosed

function setTargetClosed(address target, bool closed) external;

Parameters

NameTypeDescription
targetaddress
closedbool

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

NameTypeDescription
targetaddress
newAuthorityaddress

schedule

function schedule(address target, bytes calldata data, uint48 when)
        external
        returns (bytes32 operationId, uint32 nonce);

Parameters

NameTypeDescription
targetaddress
databytes
whenuint48

Returns

NameTypeDescription
operationIdbytes32
nonceuint32

execute

function execute(address target, bytes calldata data) external payable returns (uint32 nonce);

Parameters

NameTypeDescription
targetaddress
databytes

Returns

NameTypeDescription
nonceuint32

cancel

function cancel(address caller, address target, bytes calldata data) external returns (uint32 nonce);

Parameters

NameTypeDescription
calleraddress
targetaddress
databytes

Returns

NameTypeDescription
nonceuint32

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

NameTypeDescription
calleraddress
databytes

Events

OperationScheduled

event OperationScheduled(
        bytes32 indexed operationId, uint32 indexed nonce, uint48 schedule, address caller, address target, bytes data
    );

Parameters

NameTypeDescription
operationIdbytes32
nonceuint32
scheduleuint48
calleraddress
targetaddress
databytes

OperationExecuted

event OperationExecuted(bytes32 indexed operationId, uint32 indexed nonce);

Parameters

NameTypeDescription
operationIdbytes32
nonceuint32

OperationCanceled

event OperationCanceled(bytes32 indexed operationId, uint32 indexed nonce);

Parameters

NameTypeDescription
operationIdbytes32
nonceuint32

RoleLabel

event RoleLabel(uint64 indexed roleId, string label);

Parameters

NameTypeDescription
roleIduint64
labelstring

RoleGranted

event RoleGranted(uint64 indexed roleId, address indexed account, uint32 delay, uint48 since, bool newMember);

Parameters

NameTypeDescription
roleIduint64
accountaddress
delayuint32
sinceuint48
newMemberbool

RoleRevoked

event RoleRevoked(uint64 indexed roleId, address indexed account);

Parameters

NameTypeDescription
roleIduint64
accountaddress

RoleAdminChanged

event RoleAdminChanged(uint64 indexed roleId, uint64 indexed admin);

Parameters

NameTypeDescription
roleIduint64
adminuint64

RoleGuardianChanged

event RoleGuardianChanged(uint64 indexed roleId, uint64 indexed guardian);

Parameters

NameTypeDescription
roleIduint64
guardianuint64

RoleGrantDelayChanged

event RoleGrantDelayChanged(uint64 indexed roleId, uint32 delay, uint48 since);

Parameters

NameTypeDescription
roleIduint64
delayuint32
sinceuint48

TargetClosed

event TargetClosed(address indexed target, bool closed);

Parameters

NameTypeDescription
targetaddress
closedbool

TargetFunctionRoleUpdated

event TargetFunctionRoleUpdated(address indexed target, bytes4 selector, uint64 indexed roleId);

Parameters

NameTypeDescription
targetaddress
selectorbytes4
roleIduint64

TargetAdminDelayUpdated

event TargetAdminDelayUpdated(address indexed target, uint32 delay, uint48 since);

Parameters

NameTypeDescription
targetaddress
delayuint32
sinceuint48

Errors

AccessManagerAlreadyScheduled

error AccessManagerAlreadyScheduled(bytes32 operationId);

Parameters

NameTypeDescription
operationIdbytes32

AccessManagerNotScheduled

error AccessManagerNotScheduled(bytes32 operationId);

Parameters

NameTypeDescription
operationIdbytes32

AccessManagerNotReady

error AccessManagerNotReady(bytes32 operationId);

Parameters

NameTypeDescription
operationIdbytes32

AccessManagerExpired

error AccessManagerExpired(bytes32 operationId);

Parameters

NameTypeDescription
operationIdbytes32

AccessManagerLockedRole

error AccessManagerLockedRole(uint64 roleId);

Parameters

NameTypeDescription
roleIduint64

AccessManagerBadConfirmation

error AccessManagerBadConfirmation();

AccessManagerUnauthorizedAccount

error AccessManagerUnauthorizedAccount(address caller, uint64 roleId);

Parameters

NameTypeDescription
calleraddress
roleIduint64

AccessManagerUnauthorizedConsume

error AccessManagerUnauthorizedConsume(address target);

Parameters

NameTypeDescription
targetaddress

AccessManagerUnauthorizedCancel

error AccessManagerUnauthorizedCancel(address caller, address target);

Parameters

NameTypeDescription
calleraddress
targetaddress

AccessManagerInvalidInitialAdmin

error AccessManagerInvalidInitialAdmin();

AccessManagerTargetCallFailed

error AccessManagerTargetCallFailed(address target);

Parameters

NameTypeDescription
targetaddress