/ contracts / common / Controlled.sol
Controlled.sol
 1  pragma solidity >=0.5.0 <0.7.0;
 2  
 3  contract Controlled {
 4      string internal constant ERR_BAD_PARAMETER = "Bad parameter";
 5      string internal constant ERR_UNAUTHORIZED = "Unauthorized";
 6      event NewController(address controller);
 7      /// @notice The address of the controller is the only address that can call
 8      ///  a function with this modifier
 9      modifier onlyController {
10          require(msg.sender == controller, "Unauthorized");
11          _;
12      }
13  
14      address payable public controller;
15  
16      constructor(address payable _initController) internal {
17          require(_initController != address(0), ERR_BAD_PARAMETER);
18          controller = _initController;
19      }
20  
21      /// @notice Changes the controller of the contract
22      /// @param _newController The new controller of the contract
23      function changeController(address payable _newController) public onlyController {
24          controller = _newController;
25          emit NewController(_newController);
26      }
27  }