contract WooshiNFT is ERC721{
    address minter;
    string public baseTokenURI;
    mapping(address => bool) public whitelist;

    constructor ()
        ERC721("WOOSHI WORLD", "WOOSH")
        public
    {
        _transferOwnership(_msgSender());
        minter=msg.sender;
        whitelist[msg.sender]=true;
    }
    //calls
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        return string(abi.encodePacked(baseTokenURI, uint2str(tokenId)));
        
        //return urilist[tokenId];
    }
    //admin
    function editWhitelist(address payable user, bool whitelisted) external{
        require(msg.sender==minter, "User is not minter");
        whitelist[user]=whitelisted;
    }
    function editMinter(address payable user) external{
        require(msg.sender==minter, "User is not minter");
        minter=user;
    }
    function setTokenURI(string memory _tokenURI) public virtual {
        require(whitelist[msg.sender]==true, "User is not whitelisted");
        baseTokenURI=_tokenURI;
    }
    function mint(uint tokenID, address user) external{
        require(whitelist[msg.sender]==true, "User is not whitelisted");
        _mint(user, tokenID);
    }
    
    //utils
     function uint2str(
      uint256 _i
    )
      internal
      pure
      returns (string memory str)
    {
        if (_i == 0)
        {
        return "0";
        }
        uint256 j = _i;
        uint256 length;
        while (j != 0)
        {
        length++;
        j /= 10;
        }
        bytes memory bstr = new bytes(length);
        uint256 k = length;
        j = _i;
        while (j != 0)
        {
        bstr[--k] = bytes1(uint8(48 + j % 10));
        j /= 10;
        }
        str = string(bstr);
    }
    
    address private _owner;
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

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

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public 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) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
function renounceOwnership() public virtual onlyOwner {
    _transferOwnership(address(0));
}

/**
 * @dev Leaves the contract without owner. It will not be possible to call
 * `onlyOwner` functions anymore. Can only be called by the current owner.
 *
 * NOTE: Renouncing ownership will leave the contract without an owner,
 * thereby removing any functionality that is only available to the owner.
 */