aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/controllers/balance.js
blob: 5dfe266e3b86760144129c8ebf9fe01a734ad718 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const ObservableStore = require('obs-store')
const normalizeAddress = require('eth-sig-util').normalize
const extend = require('xtend')
const PendingBalanceCalculator = require('../lib/pending-balance-calculator')

class BalanceController {

  constructor (opts = {}) {
    const { address, ethQuery, txController } = opts
    this.ethQuery = ethQuery
    this.txController = txController

    const initState = extend({
      ethBalance: undefined,
    }, opts.initState)
    this.store = new ObservableStore(initState)

    const { getBalance, getPendingTransactions } = opts
    this.balanceCalc = new PendingBalanceCalculator({
      getBalance,
      getPendingTransactions,
    })
    this.updateBalance()
  }

}

module.exports = BalanceController