<commit_before>import * as Web3 from 'web3'
import { memoize } from 'decko'
import ChannelEthContract from './ChannelEthContract'
import ChannelTokenContract from './ChannelTokenContract'
import ChannelInflator from './ChannelInflator'
import Storage from './Storage'
import MachinomyOptions from './MachinomyOptions'
import ChannelContract from './ChannelContract'
import IChannelManager from './IChannelManager'
import ChannelManager from './ChannelManager'
import PaymentManager from './PaymentManager'
import ChainManager from './ChainManager'
import Client, { ClientImpl } from './client'
import IChannelsDatabase from './storage/IChannelsDatabase'
import { Transport } from './transport'

export default class Registry {
  account: string
  web3: Web3
  options: MachinomyOptions

  constructor (account: string, web3: Web3, options: MachinomyOptions) {
    this.account = account
    this.web3 = web3
    this.options = options
  }

  @memoize
  async inflator (): Promise<ChannelInflator> {
    const channelEthContract = await this.channelEthContract()
    const channelTokenContract = await this.channelTokenContract()
    return new ChannelInflator(channelEthContract, channelTokenContract)
  }

  @memoize
  async channelEthContract (): Promise<ChannelEthContract> {
    return new ChannelEthContract(this.web3)
  }

  @memoize
  async channelTokenContract (): Promise<ChannelTokenContract> {
    return new ChannelTokenContract(this.web3)
  }

  @memoize
  async channelContract (): Promise<ChannelContract> {
    const channelEthContract = await this.channelEthContract()
    const channelTokenContract = await this.channelTokenContract()
    return new ChannelContract(this.web3, {} as IChannelsDatabase, channelEthContract, channelTokenContract)
  }

  @memoize
  async storage (): Promise<Storage> {
    const channelContract = await this.channelContract()
    const inflator = await this.inflator()
    return Storage.build(this.options.databaseUrl, channelContract, inflator)
  }

  @memoize
  async chainManager (): Promise<ChainManager> {
    return new ChainManager(this.web3)
  }<commit_msg>Fix #237 "this.channelsDao.firstById is not a function" error.<commit_after>import * as Web3 from 'web3'
import { memoize } from 'decko'
import ChannelEthContract from './ChannelEthContract'
import ChannelTokenContract from './ChannelTokenContract'
import ChannelInflator from './ChannelInflator'
import Storage from './Storage'
import MachinomyOptions from './MachinomyOptions'
import ChannelContract from './ChannelContract'
import IChannelManager from './IChannelManager'
import ChannelManager from './ChannelManager'
import PaymentManager from './PaymentManager'
import ChainManager from './ChainManager'
import Client, { ClientImpl } from './client'
import IChannelsDatabase from './storage/IChannelsDatabase'
import { Transport } from './transport'

export default class Registry {
  account: string
  web3: Web3
  options: MachinomyOptions

  constructor (account: string, web3: Web3, options: MachinomyOptions) {
    this.account = account
    this.web3 = web3
    this.options = options
  }

  @memoize
  async inflator (): Promise<ChannelInflator> {
    const channelEthContract = await this.channelEthContract()
    const channelTokenContract = await this.channelTokenContract()
    return new ChannelInflator(channelEthContract, channelTokenContract)
  }

  @memoize
  async channelEthContract (): Promise<ChannelEthContract> {
    return new ChannelEthContract(this.web3)
  }

  @memoize
  async channelTokenContract (): Promise<ChannelTokenContract> {
    return new ChannelTokenContract(this.web3)
  }

  @memoize
  async channelContract (): Promise<ChannelContract> {
    const channelEthContract = await this.channelEthContract()
    const channelTokenContract = await this.channelTokenContract()
    return new ChannelContract(this.web3, {} as IChannelsDatabase, channelEthContract, channelTokenContract)
  }

  @memoize
  async storage (): Promise<Storage> {
    const channelContract = await this.channelContract()
    const inflator = await this.inflator()
    const result = await Storage.build(this.options.databaseUrl, channelContract, inflator)
    channelContract.channelsDao = result.channelsDatabase
    return result
  }

  @memoize
  async chainManager (): Promise<ChainManager> {
    return new ChainManager(this.web3)
  }
{'fraction_non_alphanumeric': 0.08747423860773987, 'fraction_numerical': 0.006182734142431876, 'mean_word_length': 4.975376196990424, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, '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': '7467488', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1150, 'n_words': 327}