Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
26 additions
and
49 deletions.
There are no files selected for viewing
12 changes: 5 additions & 7 deletions
12
...in-wallet-v4-frontend/src/layouts/Wallet/MenuTop/Balance/BchWatchOnlyBalance/selectors.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
import { selectors } from 'data' | ||
import { createDeepEqualSelector } from 'services/ReselectHelper' | ||
import { add, contains, filter, reduce, prop, values } from 'ramda' | ||
import { add, reduce, lift, path } from 'ramda' | ||
import { Remote } from 'blockchain-wallet-v4/src' | ||
|
||
export const getData = createDeepEqualSelector( | ||
[ | ||
selectors.core.kvStore.bch.getUnspendableContext, | ||
selectors.core.data.bch.getAddresses | ||
], | ||
(context, addressesR) => { | ||
const transform = addresses => { | ||
const filteredAddresses = filter(x => contains(prop('address', x), context), values(addresses)) | ||
const filteredBalances = filteredAddresses.map(prop('final_balance')) | ||
return reduce(add, 0, filteredBalances) | ||
} | ||
return addressesR.map(transform) | ||
const contextToBalances = (context, balances) => context.map(a => path([a, 'final_balance'], balances) || 0) | ||
const balancesR = lift(contextToBalances)(Remote.of(context), addressesR) | ||
return balancesR.map(reduce(add, 0)) | ||
} | ||
) |
12 changes: 5 additions & 7 deletions
12
...in-wallet-v4-frontend/src/layouts/Wallet/MenuTop/Balance/BtcWatchOnlyBalance/selectors.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
import { add, lift, path, reduce } from 'ramda' | ||
import { selectors } from 'data' | ||
import { createDeepEqualSelector } from 'services/ReselectHelper' | ||
import { add, contains, filter, reduce, prop, values } from 'ramda' | ||
import { Remote } from 'blockchain-wallet-v4/src' | ||
|
||
export const getData = createDeepEqualSelector( | ||
[ | ||
selectors.core.wallet.getUnspendableContext, | ||
selectors.core.data.bitcoin.getAddresses | ||
], | ||
(context, addressesR) => { | ||
const transform = addresses => { | ||
const filteredAddresses = filter(x => contains(prop('address', x), context), values(addresses)) | ||
const filteredBalances = filteredAddresses.map(prop('final_balance')) | ||
return reduce(add, 0, filteredBalances) | ||
} | ||
return addressesR.map(transform) | ||
const contextToBalances = (context, balances) => context.map(a => path([a, 'final_balance'], balances) || 0) | ||
const balancesR = lift(contextToBalances)(Remote.of(context), addressesR) | ||
return balancesR.map(reduce(add, 0)) | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters