Access Control Pausable Facet
Manage role pausing and unpausing within a diamond
- Allows temporary disabling of roles using
pauseRole. - Enables re-enabling of roles via
unpauseRole. - Provides
isRolePausedto check role status. - Integrates seamlessly with diamond storage and access control patterns.
Overview
This facet provides functionality to pause and unpause specific roles within a diamond, controlled by role administrators. It integrates with diamond storage to manage role states and allows for temporary suspension of role execution. Developers add this facet to enable granular control over role availability.
Storage
AccessControlStorage
AccessControlPausableStorage
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
isRolePaused
Returns 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
Temporarily disables a role, preventing all accounts from using it. Only the admin of the role can pause it. Emits a RolePaused event. Reverts with AccessControlUnauthorizedAccount If the caller is not the admin of the role.
Parameters:
| Property | Type | Description |
|---|---|---|
_role | bytes32 | The role to pause. |
unpauseRole
Re-enables a role that was previously paused. Only the admin of the role can unpause it. Emits a RoleUnpaused event. Reverts with AccessControlUnauthorizedAccount If the caller is not the admin of the role.
Parameters:
| Property | Type | Description |
|---|---|---|
_role | bytes32 | The role to unpause. |
requireRoleNotPaused
Checks if an account has a role and if the role is not paused. - 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. |
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
- Grant the role administrator appropriate permissions to call
pauseRoleandunpauseRole. - Use
requireRoleNotPausedbefore executing critical operations tied to a specific role. - Ensure
AccessControlPausableFacetselectors are correctly registered with the diamond.
Security Considerations
All state-changing functions (pauseRole, unpauseRole) are protected by access control, reverting with AccessControlUnauthorizedAccount if the caller is not the admin of the role. The requireRoleNotPaused function reverts with AccessControlRolePaused if the specified role is paused, preventing execution. Follow standard Solidity security practices for input validation.