PausableCancellable is an abstract utility contract that provides pause and cancel functionality for emergency controls and state management in campaigns and treasuries.
Overview
Purpose
- Emergency Controls: Allow pausing campaigns in emergencies
- Cancellation Support: Permanent cancellation capability
- State Management: Track paused and cancelled states
- Reusable: Can be inherited by any contract needing these states
- Safe Defaults: Prevents operations when paused/cancelled
State Variables
| Variable | Type | Description |
|---|---|---|
_paused | bool | Whether contract is paused |
_cancelled | bool | Whether contract is cancelled |
Functions
State Queries
Paused
- True if contract is paused
Cancelled
- True if contract is cancelled
State Management
Pause
reason: Reason for pausing
- Sets
_pausedto true - Emits
Pausedevent - Stops most operations
- Contract must not be paused
- Contract must not be cancelled
Unpause
reason: Reason for unpausing
- Sets
_pausedto false - Emits
Unpausedevent - Resumes operations
- Contract must be paused
Cancel
reason: Reason for cancellation
- Sets
_cancelledto true - Unpauses if paused
- Emits
Cancelledevent - Prevents future operations
- Contract must not be cancelled
- Cancellation is permanent and irreversible
Modifiers
When Not Paused
- Reverts if contract is paused
- Used on functions that should be disabled when paused
When Paused
- Reverts if contract is not paused
- Used on functions that should only work when paused
When Not Cancelled
- Reverts if contract is cancelled
- Used on most functions to prevent operations
When Cancelled
- Reverts if contract is not cancelled
- Used on functions that should only work when cancelled
Events
Paused
Unpaused
Cancelled
Errors
PausedError
NotPausedError
CancelledError
CannotCancel
Usage Examples
Using State Modifiers
Checking State
Emergency Pause
Cancellation
Integration
With CampaignInfo
With BaseTreasury
State Transitions
Paused
Cancelled
Security Considerations
Permanent Cancellation
- Cancellation is irreversible
- No way to recover from cancelled state
- All operations permanently disabled
- Use only when absolutely necessary
Pause vs Cancel
- Pause: Temporary, can be unpaused
- Cancel: Permanent, cannot be undone
- Choose carefully which to use
Access Control
- Only authorized accounts can pause/unpause/cancel
- Typically protocol admins can pause
- Campaign owners or protocol admins can cancel
Best Practices
Use Clear Reasons
Monitor State Changes
Frontend State Checks
Next Steps
- CampaignAccessChecker - Access control using this state
- BaseTreasury - Uses these modifiers
- CampaignInfo - Implements pause/cancel functionality