contract ERC1155Metadata is ERC1155MintBurn {
    // URI's default URI prefix
    string internal baseMetadataURI;
    event URI(string _uri, uint256 indexed _id);
    
    /***********************************|
    |     Metadata Public Function s    |
    |__________________________________*/
    
    /**
    * @notice A distinct Uniform Resource Identifier (URI) for a given token.
    * @dev URIs are defined in RFC 3986.
    *      URIs are assumed to be deterministically generated based on token ID
    * @return URI string
    */
    function uri(uint256 _id) public view returns (string memory) {
        return string(abi.encodePacked(baseMetadataURI, _uint2str(_id), ".json"));
    }
    
    
    /***********************************|
    |    Metadata Internal Functions    |
    |__________________________________*/
    
    /**
    * @notice Will emit default URI log event for corresponding token _id
    * @param _tokenIDs Array of IDs of tokens to log default URI
    */
    function _logURIs(uint256[] memory _tokenIDs) internal {
        string memory baseURL = baseMetadataURI;
        string memory tokenURI;
    
        for (uint256 i = 0; i < _tokenIDs.length; i++) {
          tokenURI = string(abi.encodePacked(baseURL, _uint2str(_tokenIDs[i]), ".json"));
          emit URI(tokenURI, _tokenIDs[i]);
        }
    }
    
    /**
    * @notice Will update the base URL of token's URI
    * @param _newBaseMetadataURI New base URL of token's URI
    */
    function _setBaseMetadataURI(string memory _newBaseMetadataURI) internal {
        baseMetadataURI = _newBaseMetadataURI;
    }
    
    /**
    * @notice Query if a contract implements an interface
    * @param _interfaceID  The interface identifier, as specified in ERC-165
    * @return `true` if the contract implements `_interfaceID` and
    */
    function supportsInterface(bytes4 _interfaceID) public override virtual pure returns (bool) {
        if (_interfaceID == type(IERC1155Metadata).interfaceId) {
          return true;
        }
        return super.supportsInterface(_interfaceID);
    }
    
    
    /***********************************|
    |    Utility Internal Functions     |
    |__________________________________*/
    
    /**
    * @notice Convert uint256 to string
    * @param _i Unsigned integer to convert to string
    */
    function _uint2str(uint256 _i) internal pure returns (string memory _uintAsString) {
        if (_i == 0) {
          return "0";
        }
        
        uint256 j = _i;
        uint256 ii = _i;
        uint256 len;
        
        // Get number of bytes
        while (j != 0) {
          len++;
          j /= 10;
        }
        
        bytes memory bstr = new bytes(len);
        uint256 k = len - 1;
        
        // Get each individual ASCII
        while (ii != 0) {
          bstr[k--] = byte(uint8(48 + ii % 10));
          ii /= 10;
        }
        
        // Convert to string
        return string(bstr);
    }
}
/**
 * @notice Contract that handles metadata related methods.
 * @dev Methods assume a deterministic generation of URI based on token IDs.
 *      Methods also assume that URI uses hex representation of token IDs.
 */
function _setBaseMetadataURI(string memory _newBaseMetadataURI) internal {
    baseMetadataURI = _newBaseMetadataURI;
}

/**
 * @notice Will update the base URL of token's URI
 * @param _newBaseMetadataURI New base URL of token's URI
 */