AccessControlPausableFacet
Manage role pausing and unpausing within a diamond
- Enables temporary disabling of specific roles.
- Integrates role pausing with the diamond proxy pattern.
- Emits
RolePausedandRoleUnpausedevents for state tracking. - Reverts with
AccessControlUnauthorizedAccountandAccessControlRolePausedcustom errors.
Overview
This facet provides functionality to pause and unpause specific roles within a Compose diamond. It allows authorized administrators to temporarily disable role execution, enhancing control during critical operations. Calls are routed through the diamond proxy, integrating seamlessly with the diamond's access control and upgradeability.
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. |
Events
Errors
Best Practices
- Initialize roles and their pause status during diamond deployment.
- Ensure only authorized administrators can call
pauseRoleandunpauseRole. - Utilize
requireRoleNotPausedto enforce pause state before executing role-dependent logic.
Security Considerations
The pauseRole and unpauseRole functions are restricted to role administrators, preventing unauthorized pausing or unpausing. The requireRoleNotPaused function ensures that calls are only permitted when the specified role is not paused, mitigating risks associated with executing functions during critical periods. Input validation is handled by custom errors.