From 74705225b59f12e3e2a67da742ed2a0228bdbb09 Mon Sep 17 00:00:00 2001 From: plondon Date: Fri, 1 Jun 2018 14:48:24 -0400 Subject: [PATCH] feat(Watch Only): fetch spendable balance on websocket --- .../blockchain-wallet-v4/src/redux/refresh/sagas.js | 13 ++++++++++++- .../src/redux/webSocket/bch/sagas.js | 3 +++ .../src/redux/webSocket/bitcoin/sagas.js | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/blockchain-wallet-v4/src/redux/refresh/sagas.js b/packages/blockchain-wallet-v4/src/redux/refresh/sagas.js index e3605632656..aa690a58b78 100644 --- a/packages/blockchain-wallet-v4/src/redux/refresh/sagas.js +++ b/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)) diff --git a/packages/blockchain-wallet-v4/src/redux/webSocket/bch/sagas.js b/packages/blockchain-wallet-v4/src/redux/webSocket/bch/sagas.js index 885feb91188..9dd97d18425 100644 --- a/packages/blockchain-wallet-v4/src/redux/webSocket/bch/sagas.js +++ b/packages/blockchain-wallet-v4/src/redux/webSocket/bch/sagas.js @@ -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' @@ -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] diff --git a/packages/blockchain-wallet-v4/src/redux/webSocket/bitcoin/sagas.js b/packages/blockchain-wallet-v4/src/redux/webSocket/bitcoin/sagas.js index 12c1ed2b51c..5565d83d588 100644 --- a/packages/blockchain-wallet-v4/src/redux/webSocket/bitcoin/sagas.js +++ b/packages/blockchain-wallet-v4/src/redux/webSocket/bitcoin/sagas.js @@ -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]