Skip to content

Commit

Permalink
fix(Coinify): save coinify trades in metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Welber committed Jun 29, 2018
1 parent 3d6c442 commit b3e2cb6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/blockchain-wallet-v4/src/redux/data/coinify/sagas.js
Expand Up @@ -7,7 +7,7 @@ import * as walletActions from '../../wallet/actions'
import * as buySellSelectors from '../../kvStore/buySell/selectors'
import { coinifyService } from '../../../exchange/service'
import * as buySellA from '../../kvStore/buySell/actions'
import { equals, head, prop, sort, path } from 'ramda'
import { equals, head, prop, sort, path, prepend } from 'ramda'

export default ({ api, options }) => {
const getCoinify = function * () {
Expand Down Expand Up @@ -243,6 +243,16 @@ export default ({ api, options }) => {
yield put(A.handleTradeSuccess(buyResult))
const coinifyObj = yield call(getCoinify)
yield put(A.fetchTrades(coinifyObj))

// get current kvstore trades
const kvTrades = yield select(buySellSelectors.getCoinifyTrades)

// prepend new trade
const newTrades = prepend(buyResult, kvTrades)

// set new trades to metadata
yield put(buySellA.setCoinifyTradesBuySell(newTrades))

yield call(labelAddressForBuy, buyResult, addressData)
return buyResult
} catch (e) {
Expand Down
Expand Up @@ -4,6 +4,7 @@ export const setSfoxTradesBuySell = (payload) => ({ type: AT.SET_SFOX_TRADES_BUY
export const updateMetadataBuySell = (payload = {}) => ({ type: AT.UPDATE_METADATA_BUYSELL, payload })

export const setCoinifyTradesBuySell = (payload) => ({ type: AT.SET_COINIFY_TRADES_BUYSELL, payload })

// FETCH_METADATA_BUYSELL
export const fetchMetadataBuySell = () => ({ type: AT.FETCH_METADATA_BUYSELL })
export const fetchMetadataBuySellLoading = () => ({ type: AT.FETCH_METADATA_BUYSELL_LOADING })
Expand Down
Expand Up @@ -7,3 +7,5 @@ export const getMetadata = path([kvStorePath, BUYSELL])
export const getSfoxTrades = path([kvStorePath, BUYSELL, 'data', 'value', 'sfox', 'trades'])

export const getSfoxUser = path([kvStorePath, BUYSELL, 'data', 'value', 'sfox', 'user'])

export const getCoinifyTrades = state => getMetadata(state).map(path(['value', 'coinify', 'trades']))

0 comments on commit b3e2cb6

Please sign in to comment.