contract ERC1155Metadata {
  // URI's default URI prefix
  string private baseMetadataURI;

  /***********************************|
  |     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
   *      Token IDs are assumed to be represented in their hex format in URIs
   * @return URI string
   */
  function uri(uint256 _id) public view returns (string memory) {
    bytes memory bytesURI = bytes(baseMetadataURI);
    if (bytesURI.length == 0 || bytesURI[bytesURI.length - 1] == '/')
      return string(abi.encodePacked(baseMetadataURI, _uint2str(_id), ".json"));
    else return baseMetadataURI;
  }

  /**
   * @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;
  }

  /***********************************|
  |    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);

    // Get each individual ASCII
    while (ii != 0) {
      bstr[--len] = bytes1(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 _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);

  // Get each individual ASCII
  while (ii != 0) {
    bstr[--len] = bytes1(uint8(48 + ii % 10));
    ii /= 10;
  }

  // Convert to string
  return string(bstr);
}

/**
 * @notice Convert uint256 to string
 * @param _i Unsigned integer to convert to string
 */