contract Ownable {
    /**
     * @dev Returns the address of the current owner.
     */
    address public owner;

    /**
     * @dev Returns the address of the current pending owner.
     */
    address public pendingOwner;

    event NewOwner(address indexed previousOwner, address indexed newOwner);
    event NewPendingOwner(
        address indexed oldPendingOwner,
        address indexed newPendingOwner
    );

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner == msg.sender, "onlyOwner: caller is not the owner");
        _;
    }

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     * @param _owner owner address.
     */
    function __Ownable_init(address _owner) internal {
        owner = _owner;
        emit NewOwner(address(0), _owner);
    }

    /**
     * @notice Base on the inputing parameter `_newPendingOwner` to check the exact error reason.
     * @dev Transfer contract control to a new owner. The _newPendingOwner must call `_acceptOwner` to finish the transfer.
     * @param _newPendingOwner New pending owner.
     */
    function _setPendingOwner(address _newPendingOwner)
        external
        onlyOwner
    {
        require(
            _newPendingOwner != address(0) && _newPendingOwner != pendingOwner,
            "_setPendingOwner: New owenr can not be zero address and owner has been set!"
        );

        // Gets current owner.
        address _oldPendingOwner = pendingOwner;

        // Sets new pending owner.
        pendingOwner = _newPendingOwner;

        emit NewPendingOwner(_oldPendingOwner, _newPendingOwner);
    }

    /**
     * @dev Accepts the admin rights, but only for pendingOwenr.
     */
    function _acceptOwner() external {
        require(
            msg.sender == pendingOwner,
            "_acceptOwner: Only for pending owner!"
        );

        // Gets current values for events.
        address _oldOwner = owner;
        address _oldPendingOwner = pendingOwner;

        // Set the new contract owner.
        owner = pendingOwner;

        // Clear the pendingOwner.
        pendingOwner = address(0);

        emit NewOwner(_oldOwner, owner);
        emit NewPendingOwner(_oldPendingOwner, pendingOwner);
    }
}
/**
 * @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.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {_setPendingOwner} and {_acceptOwner}.
 */
function _setPendingOwner(address _newPendingOwner)
    external
    onlyOwner
{
    require(
        _newPendingOwner != address(0) && _newPendingOwner != pendingOwner,
        "_setPendingOwner: New owenr can not be zero address and owner has been set!"
    );

    // Gets current owner.
    address _oldPendingOwner = pendingOwner;

    // Sets new pending owner.
    pendingOwner = _newPendingOwner;

    emit NewPendingOwner(_oldPendingOwner, _newPendingOwner);
}

/**
 * @notice Base on the inputing parameter `_newPendingOwner` to check the exact error reason.
 * @dev Transfer contract control to a new owner. The _newPendingOwner must call `_acceptOwner` to finish the transfer.
 * @param _newPendingOwner New pending owner.
 */