You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.1 KiB
57 lines
1.1 KiB
pragma solidity ^0.4.24;
|
|
|
|
import "../access/roles/PauserRole.sol";
|
|
|
|
/**
|
|
* @title Pausable
|
|
* @dev Base contract which allows children to implement an emergency stop mechanism.
|
|
*/
|
|
contract Pausable is PauserRole {
|
|
event Paused();
|
|
event Unpaused();
|
|
|
|
bool private _paused;
|
|
|
|
constructor() public {
|
|
_paused = false;
|
|
}
|
|
|
|
/**
|
|
* @return true if the contract is paused, false otherwise.
|
|
*/
|
|
function paused() public view returns(bool) {
|
|
return _paused;
|
|
}
|
|
|
|
/**
|
|
* @dev Modifier to make a function callable only when the contract is not paused.
|
|
*/
|
|
modifier whenNotPaused() {
|
|
require(!_paused);
|
|
_;
|
|
}
|
|
|
|
/**
|
|
* @dev Modifier to make a function callable only when the contract is paused.
|
|
*/
|
|
modifier whenPaused() {
|
|
require(_paused);
|
|
_;
|
|
}
|
|
|
|
/**
|
|
* @dev called by the owner to pause, triggers stopped state
|
|
*/
|
|
function pause() public onlyPauser whenNotPaused {
|
|
_paused = true;
|
|
emit Paused();
|
|
}
|
|
|
|
/**
|
|
* @dev called by the owner to unpause, returns to normal state
|
|
*/
|
|
function unpause() public onlyPauser whenPaused {
|
|
_paused = false;
|
|
emit Unpaused();
|
|
}
|
|
}
|
|
|