contract WaifuWrapper is Ownable, ERC721 {

    event Wrapped(address indexed owner, uint indexed _tokenId);
    event Unwrapped(address indexed owner, uint indexed _tokenId);

    address public _waifuAddress = 0x36697e362Ee7E9CA977b7550B3e4f955fc5BF27d;
    string public _baseTokenURI;

    constructor() payable ERC721("Wrapped Waifus", "WWFU") {
    }

    /**
     * @dev Transfers a waifu from the contract and assigns a wrapped token to msg.sender
     */
    function wrap(uint _tokenId) public payable {

        WaifuContract(_waifuAddress).transferFrom(msg.sender, address(this), _tokenId);
        _mint(msg.sender, _tokenId);
        Wrapped(msg.sender, _tokenId);
    }

    /**
     * @dev Burns the wrapped token and transfers the underlying waifu to the owner
     **/
    function unwrap(uint256 _tokenId) public {
        require(_isApprovedOrOwner(msg.sender, _tokenId));
        _burn(_tokenId);
        WaifuContract(_waifuAddress).transfer(msg.sender, _tokenId);
        Unwrapped(msg.sender, _tokenId);
    }

    /**
     * @dev Returns a URI for a given token ID's metadata
     */
    function tokenURI(uint256 _tokenId) public view override returns (string memory) {
        return string(abi.encodePacked(_baseTokenURI, Strings.toString(_tokenId)));
    }

    function setBaseTokenURI(string memory __baseTokenURI) public onlyOwner {
        _baseTokenURI = __baseTokenURI;
    }
}
function unwrap(uint256 _tokenId) public {
    require(_isApprovedOrOwner(msg.sender, _tokenId));
    _burn(_tokenId);
    WaifuContract(_waifuAddress).transfer(msg.sender, _tokenId);
    Unwrapped(msg.sender, _tokenId);
}

/**
 * @dev Burns the wrapped token and transfers the underlying waifu to the owner
 **/