forked from sherlock-audit/2023-04-splits
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OwnableImpl.sol
57 lines (43 loc) · 1.86 KB
/
OwnableImpl.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
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.17;
/// @title Ownable Implementation
/// @author 0xSplits
/// @notice Ownable clone-implementation
abstract contract OwnableImpl {
error Unauthorized();
event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);
/// -----------------------------------------------------------------------
/// storage - mutables
/// -----------------------------------------------------------------------
/// slot 0 - 12 bytes free
address internal $owner;
/// 20 bytes
/// -----------------------------------------------------------------------
/// constructor & initializer
/// -----------------------------------------------------------------------
constructor() {}
function __initOwnable(address owner_) internal virtual {
emit OwnershipTransferred(address(0), owner_);
$owner = owner_;
}
/// -----------------------------------------------------------------------
/// modifiers
/// -----------------------------------------------------------------------
modifier onlyOwner() virtual {
if (msg.sender != owner()) revert Unauthorized();
_;
}
/// -----------------------------------------------------------------------
/// functions - public & external - onlyOwner
/// -----------------------------------------------------------------------
function transferOwnership(address owner_) public virtual onlyOwner {
$owner = owner_;
emit OwnershipTransferred(msg.sender, owner_);
}
/// -----------------------------------------------------------------------
/// functions - public & external - view
/// -----------------------------------------------------------------------
function owner() public view virtual returns (address) {
return $owner;
}
}