52 lines
1.5 KiB
Solidity
52 lines
1.5 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity >=0.8.4;
|
|
|
|
/// @notice Simple single owner authorization mixin.
|
|
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/auth/Owned.sol)
|
|
abstract contract Owned {
|
|
error Unauthorized();
|
|
|
|
/*//////////////////////////////////////////////////////////////
|
|
EVENTS
|
|
//////////////////////////////////////////////////////////////*/
|
|
|
|
event OwnerUpdated(
|
|
address indexed user,
|
|
address indexed newOwner
|
|
);
|
|
|
|
/*//////////////////////////////////////////////////////////////
|
|
OWNERSHIP STORAGE
|
|
//////////////////////////////////////////////////////////////*/
|
|
|
|
address public owner;
|
|
|
|
modifier onlyOwner() virtual {
|
|
if (msg.sender != owner) revert Unauthorized();
|
|
|
|
_;
|
|
}
|
|
|
|
/*//////////////////////////////////////////////////////////////
|
|
CONSTRUCTOR
|
|
//////////////////////////////////////////////////////////////*/
|
|
|
|
constructor(address _owner) {
|
|
owner = _owner;
|
|
|
|
emit OwnerUpdated(address(0), _owner);
|
|
}
|
|
|
|
/*//////////////////////////////////////////////////////////////
|
|
OWNERSHIP LOGIC
|
|
//////////////////////////////////////////////////////////////*/
|
|
|
|
function setOwner(
|
|
address newOwner
|
|
) public virtual onlyOwner {
|
|
owner = newOwner;
|
|
|
|
emit OwnerUpdated(msg.sender, newOwner);
|
|
}
|
|
}
|