Access Control Admin Module
Manage role administrators using diamond storage
- Internal functions for role administration.
- Uses the diamond storage pattern for shared state.
- Emits
RoleAdminChangedevent upon successful administration changes. - Reverts with
AccessControlUnauthorizedAccountfor unauthorized calls.
This module provides internal functions for use in your custom facets. Import it to access shared logic and storage.
Overview
This module provides internal functions for managing role administrators within a diamond. Facets can import this module to set and query role administration relationships, leveraging shared diamond storage. Changes are immediately visible to all facets accessing the same storage.
Storage
AccessControlStorage
Storage struct for the AccessControl. storage-location: erc8042:compose.accesscontrol
State Variables
| Property | Type | Description |
|---|---|---|
STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("compose.accesscontrol")) |
Functions
getStorage
Returns the storage for the AccessControl.
Returns:
| Property | Type | Description |
|---|---|---|
s | AccessControlStorage | The storage for the AccessControl. |
setRoleAdmin
Sets the admin role for a role. Emits a {RoleAdminChanged} event. Reverts with AccessControlUnauthorizedAccount If the caller is not the current admin of the role.
Parameters:
| Property | Type | Description |
|---|---|---|
_role | bytes32 | The role to set the admin for. |
_adminRole | bytes32 | The new admin role to set. |
Events
Errors
Best Practices
- Ensure the caller has the necessary permissions before calling
setRoleAdmin. - Verify that the
AccessControlStoragestruct layout remains compatible across diamond upgrades. - Handle the
AccessControlUnauthorizedAccounterror when the caller lacks administrative privileges.
Integration Notes
This module interacts with the diamond's shared storage at the position identified by keccak2535("compose.accesscontrol"). The AccessControlStorage struct, though empty in definition, dictates the layout for access control data. Any changes made to role administrators via setRoleAdmin are immediately reflected in this shared storage and thus visible to all facets operating on the same diamond storage.