-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathController.sol
84 lines (73 loc) · 2.56 KB
/
Controller.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* Copyright 2020 (C) FreightTrust and Clearing Corporation - All Rights Reserved
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
pragma solidity >=0.4.24 <0.7.0;
/**
* @title BOLApp
* @dev An interface for BOL admin functions implemented in the proxy contracts
*/
contract BOLApp {
function pause() external;
function changeController(address) external;
function setMaster(address) external;
function setTarget(bytes4, address) external;
function getTarget(bytes4) external view returns (address);
}
/**
* @title Controller
* @dev Admin interface for the BOLApp
*/
contract Controller {
BOLApp public app;
address public admin;
/**
* @dev Only the admin address can access functions with this modifier
*/
modifier onlyAdmin {
require(msg.sender == admin);
_;
}
/**
* @dev Constructor
* @param bolApp The address implementing the BOLApp interface
* @param bolAdmin The address allowed to use this contract
*/
constructor (address bolApp, address bolAdmin) public {
app = BOLApp(bolApp);
admin = bolAdmin;
}
/**
* @dev Allows the admin to pause/unpause all non-admin execution in the application
* All functions not implemented in the MasterProxy contract will be locked
* until this function is called again.
*/
function pause() external onlyAdmin {
app.pause();
}
/**
* @dev Change the address allowed to execute admin functions in the app.
* Note that by default, this contract is the controller. Changing
* the controller will migrate the permissions for this contract to
* another address.
* @param newController The new controller address
*/
function changeController(address newController) external onlyAdmin {
app.changeController(newController);
}
/**
* @dev Allows the admin to set a delegate target for a function selector in the app
* @param functionSel The function selector for which routing is adjusted
* @param newTarget The new destination to which calls with the selector will be routed
*/
function setTarget(bytes4 functionSel, address newTarget) external onlyAdmin {
app.setTarget(functionSel, newTarget);
}
/**
* @dev Allows the admin to set a new master address for the application
* @param newMaster The new default delegate target for the universal proxy
*/
function setMaster(address newMaster) external onlyAdmin {
app.setMaster(newMaster);
}
}