-
Notifications
You must be signed in to change notification settings - Fork 45
/
Manager.sol
64 lines (51 loc) · 1.59 KB
/
Manager.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
59
60
61
62
63
64
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "./IManager.sol";
import "./IController.sol";
contract Manager is IManager {
// Controller that contract is registered with
IController public controller;
// Check if sender is controller
modifier onlyController() {
_onlyController();
_;
}
// Check if sender is controller owner
modifier onlyControllerOwner() {
_onlyControllerOwner();
_;
}
// Check if controller is not paused
modifier whenSystemNotPaused() {
_whenSystemNotPaused();
_;
}
// Check if controller is paused
modifier whenSystemPaused() {
_whenSystemPaused();
_;
}
constructor(address _controller) {
controller = IController(_controller);
}
/**
* @notice Set controller. Only callable by current controller
* @param _controller Controller contract address
*/
function setController(address _controller) external onlyController {
controller = IController(_controller);
emit SetController(_controller);
}
function _onlyController() private view {
require(msg.sender == address(controller), "caller must be Controller");
}
function _onlyControllerOwner() private view {
require(msg.sender == controller.owner(), "caller must be Controller owner");
}
function _whenSystemNotPaused() private view {
require(!controller.paused(), "system is paused");
}
function _whenSystemPaused() private view {
require(controller.paused(), "system is not paused");
}
}