Access Control Temporal Data Facet
Manages time-bound role assignments and checks for expired roles
- Manages temporal role assignments and checks for expiry.
- Exposes
getRoleExpiry,isRoleExpired, andrequireValidRolefor role validation. - Operates on shared diamond storage via internal
getStorageandgetAccessControlStoragefunctions. - Exports its selectors for diamond registration.
Overview
This facet provides functionality for managing time-bound access control roles within a Compose diamond. It exposes external view functions to check role expiry and internal functions to access its specific storage layout. This facet integrates with other access control facets by operating on shared diamond storage.
Storage
AccessControlStorage
AccessControlTemporalStorage
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
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. |
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. - 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. |
exportSelectors
Exports the selectors that are exposed by the facet.
Returns:
| Property | Type | Description |
|---|---|---|
- | bytes | Selectors that are exported by the facet. |
Events
Errors
Best Practices
- Ensure the
AccessControlTemporalDataFacetis correctly initialized with its storage slot. - When granting roles with expiry, ensure the
_expiresAttimestamp is set appropriately. - Verify that
requireValidRoleis called before sensitive operations that depend on time-bound roles.
Security Considerations
This facet exposes requireValidRole, which reverts with AccessControlUnauthorizedAccount if the account lacks the role, or AccessControlRoleExpired if the role has expired. Input validation for role names and account addresses is handled by the underlying logic. No reentrancy concerns are present as all exposed functions are view or pure.