-
Notifications
You must be signed in to change notification settings - Fork 24
Closed
Milestone
Description
Overview
The Pausable module as spec'ed in #1 currently exposes when_paused
and when_not_paused
functions, which are used to control contract behavior based on its paused state. While functional, this approach requires explicit function calls within the contract code, potentially leading to verbose and less intuitive implementations.
Proposal
To improve developer experience and code readability, we propose introducing procedural macros for the Pausable functionality. These macros would allow developers to decorate functions directly, streamlining the implementation of pause-aware contract logic.
Implementation Details
- Convert the existing
when_paused
andwhen_not_paused
functions into procedural macros. - The new macros will be used as function decorators:
#[when_paused]
pub fn emergency_execution(e: Env) {
}
#[when_not_paused]
pub fn normal_execution(e: Env) {
}
- The macros will internally generate the necessary checks and logic, equivalent to calling the current functions at the very beginning of the function body.
Benefits
- Improved Readability: The pause-aware nature of functions becomes immediately apparent from their declarations.
- Reduced Boilerplate: Eliminates the need for explicit function calls within each pause-aware function.
- Consistency: Encourages a standardized approach to implementing pause-aware functionality across contracts.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done