Expand description

Pause pattern implements methods to pause, unpause and get the status of the contract.

Pause implements methods to pause and unpause the contract. When the methods are called the contracts status changes and the respective event is emitted. A contract starts off as “unpaused” by default. PauseExternal exposes an external function to check the status of the contract.

This derive macro derives a default implementation for both these traits.

Safety

The default implementation assumes or enforces the following invariants. Violating assumed invariants may corrupt contract state and show unexpected behavior (UB). Enforced invariants throw an error (ERR) but contract state remains intact.

  • Initial state is unpaused.
  • (UB) The pause root storage slot is not used or modified. The default key is ~p.
  • (ERR) Only an “unpaused” contract can call pause.
  • (ERR) Only a “paused” contract can call unpause.
  • (ERR) Pause::require_paused may only be called when the contract is paused.
  • (ERR) Pause::require_unpaused may only be called when the contract is unpaused.

Modules

Enums

Events emitted when contract pause state is changed

Traits

Internal-only interactions for a pausable contract
External methods for Pause