Skip to content

Commit

Permalink
feat(Watch Only): fetch spendable balance on websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
plondon committed Jun 1, 2018
1 parent b251318 commit 7470522
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/blockchain-wallet-v4/src/redux/refresh/sagas.js
@@ -1,10 +1,21 @@
import { put } from 'redux-saga/effects'
import { put, select } from 'redux-saga/effects'
import * as btcActions from '../data/bitcoin/actions'
import * as bchActions from '../data/bch/actions'
import * as ethActions from '../data/ethereum/actions'
import * as btcSelectors from '../wallet/selectors'
import * as bchSelectors from '../kvStore/bch/selectors'

export default () => {
const refresh = function * () {
const btcSpendableContext = yield select(btcSelectors.getSpendableContext)
const bchSpendableContext = yield select(bchSelectors.getSpendableContext)
const btcUnspendableContext = yield select(btcSelectors.getUnspendableContext)
const bchUnspendableContext = yield select(bchSelectors.getUnspendableContext)

yield put(btcActions.fetchUnspendableBalance(btcUnspendableContext))
yield put(bchActions.fetchUnspendableBalance(bchUnspendableContext))
yield put(btcActions.fetchSpendableBalance(btcSpendableContext))
yield put(bchActions.fetchSpendableBalance(bchSpendableContext))
yield put(btcActions.fetchTransactions('', true))
yield put(bchActions.fetchTransactions('', true))
yield put(ethActions.fetchTransactions(true))
Expand Down
@@ -1,6 +1,7 @@
import { call, put, select, take } from 'redux-saga/effects'
import { compose } from 'ramda'
import * as A from '../../actions'
import * as bchSelectors from '../../kvStore/bch/selectors'
import * as walletSelectors from '../../wallet/selectors'
import { Socket } from '../../../network/index'
import * as bchActions from '../../data/bch/actions'
Expand All @@ -20,7 +21,9 @@ export default ({ api, bchSocket }) => {

switch (message.op) {
case 'utx':
const spendableContext = yield select(walletSelectors.getSpendableContext)
yield put(bchActions.fetchTransactions('', true))
yield put(bchActions.fetchSpendableBalance(spendableContext))
const transactions = yield take(bchAT.FETCH_BCH_TRANSACTIONS_SUCCESS)
for (let i in transactions.payload.transactions) {
const tx = transactions.payload.transactions[i]
Expand Down
Expand Up @@ -35,7 +35,9 @@ export default ({ api, btcSocket }) => {
}
break
case 'utx':
const spendableContext = yield select(walletSelectors.getSpendableContext)
yield put(btcActions.fetchTransactions('', true))
yield put(btcActions.fetchSpendableBalance(spendableContext))
const transactions = yield take(btcAT.FETCH_BITCOIN_TRANSACTIONS_SUCCESS)
for (let i in transactions.payload.transactions) {
const tx = transactions.payload.transactions[i]
Expand Down

0 comments on commit 7470522

Please sign in to comment.