aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/ui/token-input/token-input.container.js
blob: 981cb3598b906fb1d1c8413ab4562a930f31d505 (plain) (blame)
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
import { connect } from 'react-redux'
import TokenInput from './token-input.component'
import {getIsMainnet, getSelectedToken, getSelectedTokenExchangeRate, preferencesSelector} from '../../../selectors/selectors'

const mapStateToProps = state => {
  const { metamask: { currentCurrency } } = state
  const { showFiatInTestnets } = preferencesSelector(state)
  const isMainnet = getIsMainnet(state)

  return {
    currentCurrency,
    selectedToken: getSelectedToken(state),
    selectedTokenExchangeRate: getSelectedTokenExchangeRate(state),
    hideConversion: (!isMainnet && !showFiatInTestnets),
  }
}

const mergeProps = (stateProps, dispatchProps, ownProps) => {
  const { selectedToken } = stateProps
  const suffix = selectedToken && selectedToken.symbol

  return {
    ...stateProps,
    ...dispatchProps,
    ...ownProps,
    suffix,
  }
}

export default connect(mapStateToProps, null, mergeProps)(TokenInput)