AccessControlPausableMod
Manage paused roles using diamond storage
- Internal functions for pausing and unpausing roles.
- Uses diamond storage pattern (EIP-8042) for shared state management.
- Reverts with specific errors (
AccessControlRolePaused,AccessControlUnauthorizedAccount) on failed checks. - Compatible with ERC-2535 diamonds.
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 pause and unpause specific roles within a diamond. Facets can import this module to enforce role-based access control, ensuring that certain actions are temporarily blocked for a given role. Changes to role pause status are immediately visible across all facets interacting with the shared diamond storage.
Storage
AccessControlPausableStorage
AccessControlStorage
State Variables
| Property | Type | Description |
|---|---|---|
ACCESS_CONTROL_STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("compose.accesscontrol")) |
PAUSABLE_STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("compose.accesscontrol.pausable")) |
Functions
getAccessControlStorage
Returns the storage for AccessControl.
Returns:
| Property | Type | Description |
|---|---|---|
s | AccessControlStorage | The AccessControl storage struct. |
getStorage
Returns the storage for AccessControlPausable.
Returns:
| Property | Type | Description |
|---|---|---|
s | AccessControlPausableStorage | The AccessControlPausable storage struct. |
isRolePaused
function to check if a role is paused.
Parameters:
| Property | Type | Description |
|---|---|---|
_role | bytes32 | The role to check. |
Returns:
| Property | Type | Description |
|---|---|---|
- | bool | True if the role is paused, false otherwise. |
pauseRole
function to pause a role.
Parameters:
| Property | Type | Description |
|---|---|---|
_role | bytes32 | The role to pause. |
requireRoleNotPaused
function to check if an account has a role and if the role is not paused. Notes: - Reverts with AccessControlUnauthorizedAccount If the account does not have the role. - Reverts with AccessControlRolePaused If the role is paused.
Parameters:
| Property | Type | Description |
|---|---|---|
_role | bytes32 | The role to check. |
_account | address | The account to check the role for. |
unpauseRole
function to unpause a role.
Parameters:
| Property | Type | Description |
|---|---|---|
_role | bytes32 | The role to unpause. |
Events
Errors
Best Practices
- Call
pauseRoleandunpauseRoleonly when necessary to temporarily restrict role functionality. - Use
requireRoleNotPausedto enforce active role checks, reverting withAccessControlRolePausedif the role is paused. - Ensure the
AccessControlPausableModinstance is correctly initialized and accessible by facets that require role pause management.
Integration Notes
This module utilizes diamond storage at the ACCESS_CONTROL_STORAGE_POSITION, identified by keccak25356("compose.accesscontrol"). The AccessControlPausableStorage struct manages the pause state for roles. All functions are internal, directly interacting with this shared storage. Any facet that imports and calls functions on this module will see the updated pause status immediately due to the shared nature of diamond storage.