1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-28 23:06:37 +01:00
metamask-extension/ui/app/components/send_/send-content/send-amount-row/amount-max-button/amount-max-button.container.js

41 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-04-26 18:38:38 +02:00
import { connect } from 'react-redux'
2018-04-11 16:21:54 +02:00
import {
getGasTotal,
getSelectedToken,
2018-04-11 16:21:54 +02:00
getSendFromBalance,
getTokenBalance,
2018-04-11 16:21:54 +02:00
} from '../../../send.selectors.js'
import { getMaxModeOn } from './amount-max-button.selectors.js'
2018-04-11 16:21:54 +02:00
import { calcMaxAmount } from './amount-max-button.utils.js'
import {
updateSendAmount,
setMaxModeTo,
} from '../../../../../actions'
2018-04-11 16:21:54 +02:00
import AmountMaxButton from './amount-max-button.component'
import {
updateSendErrors,
} from '../../../../../ducks/send.duck'
2018-04-11 16:21:54 +02:00
export default connect(mapStateToProps, mapDispatchToProps)(AmountMaxButton)
2018-04-11 16:21:54 +02:00
function mapStateToProps (state) {
return {
balance: getSendFromBalance(state),
2018-04-11 16:21:54 +02:00
gasTotal: getGasTotal(state),
maxModeOn: getMaxModeOn(state),
selectedToken: getSelectedToken(state),
2018-04-11 16:21:54 +02:00
tokenBalance: getTokenBalance(state),
}
}
function mapDispatchToProps (dispatch) {
return {
setAmountToMax: maxAmountDataObject => {
2018-04-30 18:03:49 +02:00
dispatch(updateSendErrors({ amount: null }))
dispatch(updateSendAmount(calcMaxAmount(maxAmountDataObject)))
},
2018-04-11 16:21:54 +02:00
setMaxModeTo: bool => dispatch(setMaxModeTo(bool)),
}
}