// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @title The ConfirmedOwner contract * @notice A contract with helpers for basic contract ownership. */ contract ConfirmedOwner { address private s_owner; address private s_pendingOwner; event OwnershipTransferRequested( address indexed from, address indexed to ); event OwnershipTransferred( address indexed from, address indexed to ); constructor(address newOwner) { s_owner = newOwner; } /** * @notice Allows an owner to begin transferring ownership to a new address, * pending. */ function transferOwnership(address to) external onlyOwner() { require(to != msg.sender, "Cannot transfer to self"); s_pendingOwner = to; emit OwnershipTransferRequested(s_owner, to); } /** * @notice Allows an ownership transfer to be completed by the recipient. */ function acceptOwnership() external { require(msg.sender == s_pendingOwner, "Must be proposed owner"); address oldOwner = s_owner; s_owner = msg.sender; s_pendingOwner = address(0); emit OwnershipTransferred(oldOwner, msg.sender); } /** * @notice Get the current owner */ function owner() public view returns (address) { return s_owner; } /** * @notice Reverts if called by anyone other than the contract owner. */ modifier onlyOwner() { require(msg.sender == s_owner, "Only callable by owner"); _; } }