// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.18; import "@openzeppelin/contracts/access/Ownable.sol"; /** * @title EnhancedOwnable * @notice This contract is an extension of OpenZeppelin Ownable contract that allows to temporarily transfer ownership. */ contract EnhancedOwnable is Ownable { address private _tempOwner; constructor() { _transferOwnership(_msgSender()); } /** * @dev Temporarily transfers ownership of the contract to a new account (`tempOwner`). * @param tempOwner The address to temporarily transfer ownership to. */ function addTemporaryOwnership(address tempOwner) public virtual onlyOwner { _tempOwner = tempOwner; } /** * @dev Revokes temporary ownership of the contract. */ function revokeTemporaryOwnership() public virtual onlyOwner { _tempOwner = address(0); } /** * @dev Returns the address of the current owner or the temporary owner if set. */ function owner() public view virtual override returns (address) { if (_tempOwner != address(0)) { return _tempOwner; } else { return super.owner(); } } /** * @dev Throws if the sender is not the owner or the temporary owner if set. */ function _checkOwner() internal view virtual override { if (_tempOwner != address(0)) { require(_tempOwner == _msgSender(), "Ownable: caller is not the temporary owner"); } else { super._checkOwner(); } } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. * * NOTE: Revoke temporary ownership if set. */ function _transferOwnership(address newOwner) internal virtual override { revokeTemporaryOwnership(); super._transferOwnership(newOwner); } }