Skip to content

Commit

Permalink
fix(Context): getOrElse(0) in 'Total Balance'
Browse files Browse the repository at this point in the history
  • Loading branch information
plondon committed Jun 23, 2018
1 parent cd28fe2 commit bff515b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
import { lift } from 'ramda'
import { add, lift, reduce } from 'ramda'
import { selectors } from 'data'
import { Exchange } from 'blockchain-wallet-v4/src'
import { Remote, Exchange } from 'blockchain-wallet-v4/src'
import * as Currency from 'blockchain-wallet-v4/src/exchange/currency'
import { createDeepEqualSelector } from 'services/ReselectHelper'
import { getBchBalance, getBtcBalance, getEthBalance } from '../selectors'

export const getBtcBalance = state => createDeepEqualSelector(
[
selectors.core.wallet.getSpendableContext
],
(context) => {
const getBalance = address => selectors.core.data.bitcoin.getFinalBalance(address, state)
const balancesR = context.map(x => getBalance(x).getOrElse(0))
return Remote.of(reduce(add, 0, balancesR))
}
)(state)

export const getBchBalance = state => createDeepEqualSelector(
[
selectors.core.kvStore.bch.getSpendableContext
],
(context) => {
const getBalance = address => selectors.core.data.bch.getFinalBalance(address, state)
const balancesR = context.map(x => getBalance(x).getOrElse(0))
return Remote.of(reduce(add, 0, balancesR))
}
)(state)

export const getEthBalance = state => createDeepEqualSelector(
[
selectors.core.data.ethereum.getBalance
],
(balance) => {
return Remote.of(balance.getOrElse(0))
}
)(state)

export const getBtcBalanceInfo = createDeepEqualSelector(
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default ({ rootUrl, apiUrl, get, post }) => {

const getEthereumData = (context) => get({
url: apiUrl,
endPoint: `/eth/accounts/${Array.isArray(context) ? context.join() : context}`
endPoint: `/eth/account/${Array.isArray(context) ? context.join() : context}`
})

const getEthereumFee = () => get({
Expand Down

0 comments on commit bff515b

Please sign in to comment.