-
Notifications
You must be signed in to change notification settings - Fork 504
/
selectors.ts
executable file
·52 lines (43 loc) · 1.58 KB
/
selectors.ts
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
41
42
43
44
45
46
47
48
49
50
51
52
import * as selectors from '../../selectors'
import { CoinType, RatesType, RemoteDataType } from 'core/types'
import { dataPath } from '../../paths'
import { INVALID_COIN_TYPE } from 'blockchain-wallet-v4/src/model'
import { path } from 'ramda'
import { Remote } from 'blockchain-wallet-v4/src'
import { RootState } from 'data/rootReducer'
export const getCaptcha = path([dataPath, 'misc', 'captcha'])
export const getPriceIndexSeries = path([
dataPath,
'misc',
'price_index_series'
])
export const getLogs = path([dataPath, 'misc', 'logs'])
export const getPairingCode = path([dataPath, 'misc', 'pairing_code'])
export const authorizeLogin = path([dataPath, 'misc', 'authorize_login'])
export const handle2FAReset = path([dataPath, 'misc', 'handle_2fa_reset'])
export const verifyEmailToken = path([dataPath, 'misc', 'verify_email_token'])
export const getPrice24H = (state: RootState, coin: CoinType) =>
state.dataPath.misc.price_24h[coin]
export const getRatesSelector = (
coin: CoinType,
state
): RemoteDataType<string, RatesType> => {
switch (coin) {
case 'BTC':
return selectors.data.btc.getRates(state)
case 'BCH':
return selectors.data.bch.getRates(state)
case 'ETH':
return selectors.data.eth.getRates(state)
case 'XLM':
return selectors.data.xlm.getRates(state)
case 'ALGO':
return selectors.data.algo.getRates(state)
case 'USDT':
return selectors.data.eth.getErc20Rates(state, 'usdt')
case 'PAX':
return selectors.data.eth.getErc20Rates(state, 'pax')
default:
return Remote.Failure(INVALID_COIN_TYPE)
}
}