<commit_before>import ChluIPFS from 'chlu-ipfs-support'
import ChluAPIClient from 'chlu-api-client'

function getChluNetwork() {
  const isProduction = process.env.NODE_ENV === 'production'
  const defaultNetwork = isProduction ? ChluIPFS.networks.staging : ChluIPFS.networks.experimental
  return process.env.REACT_APP_CHLU_NETWORK || defaultNetwork
}

export async function getChluIPFS() {
  const chluApiClient = await getChluAPIClient()
  const did = await chluApiClient.exportDID() // use same did that is in chlu api client
  const options = {
    network: getChluNetwork(),
    bitcoinNetwork: process.env.REACT_APP_BLOCKCYPHER_RESOURCE || 'test3',
    blockCypherApiKey: process.env.REACT_APP_BLOCKCYPHER_TOKEN,
    did,
    OrbitDBIndexName: 'NOOP'
  }
  if (!window.chluIpfs) {
    window.chluIpfs = new ChluIPFS(options)
    // Resolve DIDs through the API Client
    window.chluIpfs.didIpfsHelper.getDID = (...args) => chluApiClient.didIpfsHelper.getDID(...args)
    await window.chluIpfs.start()
  } else {
    await window.chluIpfs.waitUntilReady()
    if (window.chluIpfs.didIpfsHelper.didId !== did.publicDidDocument.id) {
      await window.chluIpfs.importDID(did)
    }
  }
  return window.chluIpfs;
}

export async function getChluAPIClient() {
  const options = {
    network: getChluNetwork(),
    publishApiUrl: process.env.REACT_APP_CHLU_PUBLISH_API_URL || 'https://publish.chlu.io',
    queryApiUrl: process.env.REACT_APP_CHLU_QUERY_API_URL || 'https://query.chlu.io'
  }
  if (!window.chluApiClient) {
    window.chluApiClient = new ChluAPIClient(options)
    await window.chluApiClient.start()
  }
  window.getChluIPFS = getChluIPFS
  return window.chluApiClient;
}

export async function readReviews(didId) {
  // TODO: replace this with API Client call
  const chluIpfs = await getChluIPFS()
  const multihashes = await chluIpfs.getReviewsByDID(didId)
  const reviews = []
  for (const multihash of multihashes) {
    // TODO: show them as loading and dispatch redux actions to resolve them
    reviews.push(await chluIpfs.readReviewRecord(multihash))
  }
  return reviews
}

export async function importUnverifiedReviews(reviews) {
  const chluIpfs = await getChluIPFS()
  return await chluIpfs.importUnverifiedReviews(reviews.map(r => {
    r.chlu_version = 0
    // set this to myself so that it gets indexed right in Chlu
    r.subject.did = chluIpfs.didIpfsHelper.didId
    return r
  }))
}
<commit_msg>remove dead code<commit_after>import ChluIPFS from 'chlu-ipfs-support'
import ChluAPIClient from 'chlu-api-client'

function getChluNetwork() {
  const isProduction = process.env.NODE_ENV === 'production'
  const defaultNetwork = isProduction ? ChluIPFS.networks.staging : ChluIPFS.networks.experimental
  return process.env.REACT_APP_CHLU_NETWORK || defaultNetwork
}

export async function getChluIPFS() {
  const chluApiClient = await getChluAPIClient()
  const did = await chluApiClient.exportDID() // use same did that is in chlu api client
  const options = {
    network: getChluNetwork(),
    bitcoinNetwork: process.env.REACT_APP_BLOCKCYPHER_RESOURCE || 'test3',
    blockCypherApiKey: process.env.REACT_APP_BLOCKCYPHER_TOKEN,
    did,
    OrbitDBIndexName: 'NOOP'
  }
  if (!window.chluIpfs) {
    window.chluIpfs = new ChluIPFS(options)
    // Resolve DIDs through the API Client. Needed for review publishing
    window.chluIpfs.didIpfsHelper.getDID = (...args) => chluApiClient.didIpfsHelper.getDID(...args)
    await window.chluIpfs.start()
  } else {
    await window.chluIpfs.waitUntilReady()
    if (window.chluIpfs.didIpfsHelper.didId !== did.publicDidDocument.id) {
      await window.chluIpfs.importDID(did)
    }
  }
  return window.chluIpfs;
}

export async function getChluAPIClient() {
  const options = {
    network: getChluNetwork(),
    publishApiUrl: process.env.REACT_APP_CHLU_PUBLISH_API_URL || 'https://publish.chlu.io',
    queryApiUrl: process.env.REACT_APP_CHLU_QUERY_API_URL || 'https://query.chlu.io'
  }
  if (!window.chluApiClient) {
    window.chluApiClient = new ChluAPIClient(options)
    await window.chluApiClient.start()
  }
  window.getChluIPFS = getChluIPFS
  return window.chluApiClient;
}
{'fraction_non_alphanumeric': 0.10091083413231064, 'fraction_numerical': 0.0007190795781399808, 'mean_word_length': 4.222778473091364, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4359734', 'n_tokens_mistral': 1463, 'n_tokens_neox': 1470, 'n_words': 289}