Access Control Temporal Data Module
Manages temporal role assignments and their expiry
- Provides internal functions for temporal role management.
- Leverages diamond storage for temporal role data.
- Reverts with specific errors for expired roles or unauthorized accounts.
- No external dependencies; designed for direct integration into facets.
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 to manage temporal role assignments, including their expiry. Facets can import this module to check and enforce role validity using shared diamond storage. Changes to role expiry are immediately visible to all facets accessing the same storage.
Storage
AccessControlStorage
Storage struct for AccessControl (reused struct definition). Must match the struct definition in AccessControlDataFacet. storage-location: erc8042:compose.accesscontrol
AccessControlTemporalStorage
Storage struct for AccessControlTemporal. storage-location: erc8042:compose.accesscontrol.temporal
State Variables
| Property | Type | Description |
|---|---|---|
ACCESS_CONTROL_STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("compose.accesscontrol")) |
TEMPORAL_STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("compose.accesscontrol.temporal")) |
Functions
getAccessControlStorage
Returns the storage for AccessControl.
Returns:
| Property | Type | Description |
|---|---|---|
s | AccessControlStorage | The AccessControl storage struct. |
getRoleExpiry
Returns the expiry timestamp for a role assignment.
Parameters:
| Property | Type | Description |
|---|---|---|
_role | bytes32 | The role to check. |
_account | address | The account to check. |
Returns:
| Property | Type | Description |
|---|---|---|
- | uint256 | The expiry timestamp, or 0 if no expiry is set. |
getStorage
Returns the storage for AccessControlTemporal.
Returns:
| Property | Type | Description |
|---|---|---|
s | AccessControlTemporalStorage | The AccessControlTemporal storage struct. |
isRoleExpired
Checks if a role assignment has expired.
Parameters:
| Property | Type | Description |
|---|---|---|
_role | bytes32 | The role to check. |
_account | address | The account to check. |
Returns:
| Property | Type | Description |
|---|---|---|
- | bool | True if the role has expired or doesn't exist, false if still valid. |
requireValidRole
Checks if an account has a valid (non-expired) role. Notes: - Reverts with AccessControlUnauthorizedAccount If the account does not have the role. - Reverts with AccessControlRoleExpired If the role has expired.
Parameters:
| Property | Type | Description |
|---|---|---|
_role | bytes32 | The role to check. |
_account | address | The account to check the role for. |
Events
Errors
Best Practices
- Ensure temporal role expiry checks are performed before critical operations.
- Handle
AccessControlRoleExpiredandAccessControlUnauthorizedAccounterrors explicitly when callingrequireValidRole. - Verify that the
AccessControlTemporalDataModis initialized with correct storage slot and that related modules are compatible.
Integration Notes
This module interacts with diamond storage at the ACCESS_CONTROL_STORAGE_POSITION, identified by keccak256("compose.accesscontrol"), to store and retrieve temporal role assignment data. The AccessControlTemporalStorage struct is managed implicitly through this slot. Changes made via functions like getRoleExpiry or checks performed by isRoleExpired and requireValidRole directly access and reflect the state within the diamond's shared storage, making them immediately visible to any other facet that reads from the same storage position.