-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy path_SafeOwnable.sol
53 lines (46 loc) · 1.46 KB
/
_SafeOwnable.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import { ERC173Storage } from '../../storage/ERC173Storage.sol';
import { _ISafeOwnable } from './_ISafeOwnable.sol';
import { _Ownable } from './_Ownable.sol';
abstract contract _SafeOwnable is _ISafeOwnable, _Ownable {
modifier onlyNomineeOwner() {
if (_msgSender() != _nomineeOwner())
revert SafeOwnable__NotNomineeOwner();
_;
}
/**
* @notice get the nominated owner who has permission to call acceptOwnership
*/
function _nomineeOwner() internal view virtual returns (address) {
return
ERC173Storage
.layout(ERC173Storage.DEFAULT_STORAGE_SLOT)
.nomineeOwner;
}
/**
* @notice accept transfer of contract ownership
*/
function _acceptOwnership() internal virtual onlyNomineeOwner {
_setOwner(_msgSender());
delete ERC173Storage
.layout(ERC173Storage.DEFAULT_STORAGE_SLOT)
.nomineeOwner;
}
/**
* @notice grant permission to given address to claim contract ownership
*/
function _transferOwnership(
address account
) internal virtual override onlyOwner {
_setNomineeOwner(account);
}
/**
* @notice set nominee owner
*/
function _setNomineeOwner(address account) internal virtual {
ERC173Storage
.layout(ERC173Storage.DEFAULT_STORAGE_SLOT)
.nomineeOwner = account;
}
}