-
Notifications
You must be signed in to change notification settings - Fork 503
/
selectors.js
40 lines (36 loc) · 1.47 KB
/
selectors.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { lift, map, path, prop } from 'ramda'
import { getAddresses, getTransactions, getHeight } from '../../data/ethereum/selectors.js'
import { getAccounts } from '../../kvStore/ethereum/selectors.js'
import * as transactions from '../../../transactions'
import { getShapeshiftTxHashMatch } from '../../kvStore/shapeShift/selectors'
export const getAccountBalances = (state) => {
const digest = (addresses, account) => ({
coin: 'ETH',
label: account.label,
balance: path([account.addr, 'balance'], addresses),
address: account.addr
})
return map(lift(digest)(getAddresses(state)), getAccounts(state))
}
export const getAccountsInfo = (state) => {
const digest = (account) => ({
coin: 'ETH',
label: prop('label', account),
address: prop('addr', account)
})
return getAccounts(state).map(map(digest))
}
const mTransformTx = transactions.ethereum.transformTx
// getWalletTransactions :: state -> Remote([ProcessedTx])
export const getWalletTransactions = (state) => {
const accountsR = getAccounts(state)
const blockHeightR = getHeight(state)
const addressesR = accountsR.map(map(prop('addr')))
const pages = getTransactions(state)
const getPartnerLabel = hash => getShapeshiftTxHashMatch(state, hash)
const ProcessTxs = (addresses, blockHeight, txList) => {
return map(mTransformTx(addresses, blockHeight, state, getPartnerLabel), txList)
}
const ProcessPage = lift(ProcessTxs)(addressesR, blockHeightR)
return map(ProcessPage, pages)
}