Disableable

Git Source

Inherits: IDisableable, Authorizable

This abstract contract provides the ability to disable the inheriting contract, triggering (if implemented) an on-disable routine hook.

This contract also implements whenEnabled and whenDisabled modifiers to restrict the methods that can be called on each state.

State Variables

contractEnabled

Check if the contract is enabled

bool public contractEnabled = true;

Functions

disableContract

External method to trigger the contract disablement

Triggers an internal call to _onContractDisable virtual method

function disableContract() external isAuthorized whenEnabled;

_onContractDisable

Internal virtual method to be called when the contract is disabled

This method is virtual and should be overriden to implement

function _onContractDisable() internal virtual;

_isEnabled

Internal virtual view to check if the contract is enabled

This method is virtual and could be overriden for non-standard implementations

function _isEnabled() internal view virtual returns (bool _enabled);

whenEnabled

Allows method calls only when the contract is enabled

modifier whenEnabled();

whenDisabled

Allows method calls only when the contract is disabled

modifier whenDisabled();