-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPausableLayer.sol
36 lines (27 loc) · 1.04 KB
/
PausableLayer.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
//SPDX-License-Identifier: opensource
// @authors: mohamed khalil rouissi mohamed amine ghodhbene
// @description: pausable security layer
/*
* used by only root admin to stop and start contracts , stop contract if any bug identified
*/
pragma solidity ^0.8.0;
/* the contract is always running by default */
abstract contract PausableLayer {
event PauseContractCRBAC(uint256 timestamp,string reason);
event StartContratCRBAC(uint256 timestamp);
bool public state = true;
modifier RunningOnly() {
require(state == true,"the contract must be running");
_;
}
function _pause(string memory _reason) internal virtual {
require(state == true,"can only be pressed when the contract is running");
state = false;
emit PauseContractCRBAC(block.timestamp,_reason);
}
function _restart() internal virtual {
require(state == false,"can only be pressed when the contract is paused");
state = true;
emit StartContratCRBAC(block.timestamp);
}
}