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
|
import { connect } from 'react-redux'
import Balance from './balance.component'
import {
getNativeCurrency,
getAssetImages,
conversionRateSelector,
getCurrentCurrency,
getMetaMaskAccounts,
getIsMainnet,
preferencesSelector,
} from '../../selectors'
const mapStateToProps = state => {
const { showFiatInTestnets } = preferencesSelector(state)
const isMainnet = getIsMainnet(state)
const accounts = getMetaMaskAccounts(state)
const network = state.metamask.network
const selectedAddress = state.metamask.selectedAddress || Object.keys(accounts)[0]
const account = accounts[selectedAddress]
return {
account,
network,
nativeCurrency: getNativeCurrency(state),
conversionRate: conversionRateSelector(state),
currentCurrency: getCurrentCurrency(state),
assetImages: getAssetImages(state),
showFiat: (isMainnet || !!showFiatInTestnets),
}
}
export default connect(mapStateToProps)(Balance)
|