1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 11:01:41 +01:00
metamask-extension/ui/app/components/transaction-view-balance/transaction-view-balance.container.js
Dan J Miller 4c24555545 Save recent network balances in local storage (#5843)
* Use selector for state.metamask.accounts in all cases.

* Default to cached balance when selecting metamask accounts

* Adds the cached-balances controller

* Documentation and small codes fixes for #5843

Co-Authored-By: danjm <danjm.com@gmail.com>
2018-11-30 14:51:24 -08:00

40 lines
1.0 KiB
JavaScript

import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom'
import { compose } from 'recompose'
import TransactionViewBalance from './transaction-view-balance.component'
import {
getSelectedToken,
getSelectedAddress,
getNativeCurrency,
getSelectedTokenAssetImage,
getMetaMaskAccounts,
} from '../../selectors'
import { showModal } from '../../actions'
const mapStateToProps = state => {
const selectedAddress = getSelectedAddress(state)
const { metamask: { network } } = state
const accounts = getMetaMaskAccounts(state)
const account = accounts[selectedAddress]
const { balance } = account
return {
selectedToken: getSelectedToken(state),
network,
balance,
nativeCurrency: getNativeCurrency(state),
assetImage: getSelectedTokenAssetImage(state),
}
}
const mapDispatchToProps = dispatch => {
return {
showDepositModal: () => dispatch(showModal({ name: 'DEPOSIT_ETHER' })),
}
}
export default compose(
withRouter,
connect(mapStateToProps, mapDispatchToProps)
)(TransactionViewBalance)