-
Notifications
You must be signed in to change notification settings - Fork 47
/
PausableOz.sol
58 lines (48 loc) · 1.34 KB
/
PausableOz.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
pragma solidity 0.5.17;
import "./Ownable.sol";
contract PausableOz is Ownable {
/**
* @dev Emitted when the pause is triggered by the owner (`account`).
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by the owner (`account`).
*/
event Unpaused(address account);
bool internal _paused;
constructor() internal {}
/**
* @dev Returns true if the contract is paused, and 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, "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(_paused, "Pausable: not paused");
_;
}
/**
* @dev Called by the owner to pause, triggers stopped state.
*/
function pause() public onlyOwner whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Called by the owner to unpause, returns to normal state.
*/
function unpause() public onlyOwner whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}