36 lines
1011 B
Solidity
Raw Normal View History

pragma solidity >=0.5.0 <0.6.0;
2018-04-23 01:58:58 -03:00
/// @dev `Owned` is a base level contract that assigns an `owner` that can be
/// later changed
contract Owned {
/// @dev `owner` is the only address that can call a function with this
/// modifier
modifier onlyOwner() {
2018-12-11 00:13:51 -02:00
require(msg.sender == owner, "Unauthorized");
2018-04-23 01:58:58 -03:00
_;
}
2018-12-11 00:13:51 -02:00
address payable public owner;
2018-04-23 01:58:58 -03:00
/// @notice The Constructor assigns the message sender to be `owner`
2018-12-11 00:13:51 -02:00
constructor() internal {
2018-04-23 01:58:58 -03:00
owner = msg.sender;
}
2018-12-11 00:13:51 -02:00
address payable public newOwner;
2018-04-23 01:58:58 -03:00
/// @notice `owner` can step down and assign some other address to this role
/// @param _newOwner The address of the new owner. 0x0 can be used to create
/// an unowned neutral vault, however that cannot be undone
2018-12-11 00:13:51 -02:00
function changeOwner(address payable _newOwner) public onlyOwner {
2018-04-23 01:58:58 -03:00
newOwner = _newOwner;
}
function acceptOwnership() public {
if (msg.sender == newOwner) {
owner = newOwner;
}
}
}