-
Notifications
You must be signed in to change notification settings - Fork 24
Closed
Milestone
Description
Overview
A contract module enabling an emergency stop mechanism that can be triggered by authorized accounts. This module provides functionality through trait implementation, making available the functions when_not_paused
and when_paused
which can be applied to contract functions.
State
const PAUSED: Symbol = symbol_short!("PAUSED");
The contract maintains a boolean state initialized to false
(unpaused) in instance storage.
Events
paused
- Emitted when pause is triggered by an account
- Contains the caller's address
unpaused
- Emitted when pause is lifted by an account
- Contains the caller's address
Erros
#[contracterror]
#[repr(u32)]
pub enum PausableError {
EnforcedPaused = 1, // Operation failed because contract is paused
ExpectedPause = 2, // Operation failed because contract is not paused
}
Core Functions
State Query
fn paused(e: Env) -> bool
Returns true if contract is paused, false otherwise.
Guard Functions
fn when_not_paused(e: Env)
fn when_paused(e: Env)
Function modifiers to restrict operations based on pause state.
State Control
fn pause(e: Env, caller: Address)
fn unpause(e: Env, caller: Address)
Internal functions to trigger and lift the stopped state. Requirements:
- Pause: Contract must not be paused
- Unpause: Contract must be paused
- Both require caller authentication
Security Considerations
- All state-changing operations require explicit caller authentication
- State transitions are protected against invalid sequences
- Events are emitted for all state changes
- Clear error conditions for invalid state transitions
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done