1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- // SPDX-License-Identifier: MIT
- pragma solidity ^0.6.0;
- import "../GSN/Context.sol";
- /**
- * @dev Contract module which allows children to implement an emergency stop
- * mechanism that can be triggered by an authorized account.
- *
- * This module is used through inheritance. It will make available the
- * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
- * the functions of your contract. Note that they will not be pausable by
- * simply including this module, only once the modifiers are put in place.
- */
- contract Pausable is Context {
- /**
- * @dev Emitted when the pause is triggered by `account`.
- */
- event Paused(address account);
- /**
- * @dev Emitted when the pause is lifted by `account`.
- */
- event Unpaused(address account);
- bool private _paused;
- /**
- * @dev Initializes the contract in unpaused state.
- */
- constructor () internal {
- _paused = false;
- }
- /**
- * @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 Triggers stopped state.
- */
- function _pause() internal virtual whenNotPaused {
- _paused = true;
- emit Paused(_msgSender());
- }
- /**
- * @dev Returns to normal state.
- */
- function _unpause() internal virtual whenPaused {
- _paused = false;
- emit Unpaused(_msgSender());
- }
- }
|