/ contracts / common / Owned.sol
Owned.sol
 1  pragma solidity >=0.5.0 <0.7.0;
 2  
 3  /// @dev `Owned` is a base level contract that assigns an `owner` that can be
 4  ///  later changed
 5  contract Owned {
 6      event OwnerChanged(address newOwner);
 7  
 8      /// @dev `owner` is the only address that can call a function with this
 9      /// modifier
10      modifier onlyOwner() {
11          require(msg.sender == owner, "Unauthorized");
12          _;
13      }
14  
15      address payable public owner;
16  
17      /// @notice The Constructor assigns the message sender to be `owner`
18      constructor() internal {
19          owner = msg.sender;
20      }
21  
22      address payable public newOwner;
23  
24      /// @notice `owner` can step down and assign some other address to this role
25      /// @param _newOwner The address of the new owner. 0x0 can be used to create
26      ///  an unowned neutral vault, however that cannot be undone
27      function changeOwner(address payable _newOwner) public onlyOwner {
28          emit OwnerChanged(_newOwner);
29          newOwner = _newOwner;
30      }
31  
32  
33      function acceptOwnership() public {
34          if (msg.sender == newOwner) {
35              owner = newOwner;
36          }
37      }
38  }