1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-18 15:33:21 +01:00
metamask-extension/ui/app/pages/send/send-content/send-amount-row/amount-max-button/amount-max-button.container.js

40 lines
1.2 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,
getSendToken,
2018-04-11 16:21:54 +02:00
getSendFromBalance,
getTokenBalance,
getSendMaxModeState,
getBasicGasEstimateLoadingStatus,
} from '../../../../../selectors'
2020-11-03 00:41:28 +01:00
import { updateSendAmount, setMaxModeTo } from '../../../../../store/actions'
import { updateSendErrors } from '../../../../../ducks/send/send.duck'
import { calcMaxAmount } from './amount-max-button.utils'
import AmountMaxButton from './amount-max-button.component'
2018-04-11 16:21:54 +02:00
export default connect(mapStateToProps, mapDispatchToProps)(AmountMaxButton)
2018-04-11 16:21:54 +02:00
2020-11-03 00:41:28 +01:00
function mapStateToProps(state) {
2018-04-11 16:21:54 +02:00
return {
balance: getSendFromBalance(state),
buttonDataLoading: getBasicGasEstimateLoadingStatus(state),
2018-04-11 16:21:54 +02:00
gasTotal: getGasTotal(state),
maxModeOn: getSendMaxModeState(state),
sendToken: getSendToken(state),
2018-04-11 16:21:54 +02:00
tokenBalance: getTokenBalance(state),
}
}
2020-11-03 00:41:28 +01:00
function mapDispatchToProps(dispatch) {
2018-04-11 16:21:54 +02:00
return {
2020-02-15 21:34:12 +01:00
setAmountToMax: (maxAmountDataObject) => {
2018-04-30 18:03:49 +02:00
dispatch(updateSendErrors({ amount: null }))
dispatch(updateSendAmount(calcMaxAmount(maxAmountDataObject)))
},
clearMaxAmount: () => {
dispatch(updateSendAmount('0'))
},
2020-02-15 21:34:12 +01:00
setMaxModeTo: (bool) => dispatch(setMaxModeTo(bool)),
2018-04-11 16:21:54 +02:00
}
}