63 lines
2.1 KiB
Solidity
63 lines
2.1 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
|
|
|
|
pragma solidity ^0.8.20;
|
|
|
|
import "../lib/openzeppelin-contracts/contracts/utils/Context.sol";
|
|
import {OwnableInternal} from "./OwnableInternal.sol";
|
|
import {IOwnable} from "./IOwnable.sol";
|
|
|
|
/**
|
|
* @dev Contract module which provides a basic access control mechanism, where
|
|
* there is an account (an owner) that can be granted exclusive access to
|
|
* specific functions.
|
|
*
|
|
* The initial owner is set to the address provided by the deployer. This can
|
|
* later be changed with {transferOwnership}.
|
|
*
|
|
* This module is used through inheritance. It will make available the modifier
|
|
* `onlyOwner`, which can be applied to your functions to restrict their use to
|
|
* the owner.
|
|
*/
|
|
abstract contract OwnableExternal is OwnableInternal, IOwnable {
|
|
/**
|
|
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
|
|
*/
|
|
constructor(address initialOwner) {
|
|
if (initialOwner == address(0)) {
|
|
revert OwnableInvalidOwner(address(0));
|
|
}
|
|
_transferOwnership(initialOwner);
|
|
}
|
|
|
|
/**
|
|
* @dev Returns the address of the current owner.
|
|
*/
|
|
function owner() external view virtual returns (address) {
|
|
return _owner;
|
|
}
|
|
|
|
/**
|
|
* @dev Leaves the contract without owner. It will not be possible to call
|
|
* `onlyOwner` functions. Can only be called by the current owner.
|
|
*
|
|
* NOTE: Renouncing ownership will leave the contract without an owner,
|
|
* thereby disabling any functionality that is only available to the owner.
|
|
*/
|
|
function renounceOwnership() external virtual onlyOwner {
|
|
_transferOwnership(address(0));
|
|
}
|
|
|
|
/**
|
|
* @dev Transfers ownership of the contract to a new account (`newOwner`).
|
|
* Can only be called by the current owner.
|
|
*/
|
|
function transferOwnership(address newOwner) external virtual onlyOwner {
|
|
if (newOwner == address(0)) {
|
|
revert OwnableInvalidOwner(address(0));
|
|
}
|
|
_transferOwnership(newOwner);
|
|
}
|
|
|
|
}
|