2021-02-04 19:15:23 +01:00
|
|
|
import { connect } from 'react-redux';
|
2018-04-11 16:21:54 +02:00
|
|
|
import {
|
|
|
|
getGasTotal,
|
2020-05-29 19:46:10 +02:00
|
|
|
getSendToken,
|
2018-04-11 16:21:54 +02:00
|
|
|
getSendFromBalance,
|
2018-04-27 02:38:14 +02:00
|
|
|
getTokenBalance,
|
2020-05-04 17:22:34 +02:00
|
|
|
getSendMaxModeState,
|
2020-05-04 21:06:28 +02:00
|
|
|
getBasicGasEstimateLoadingStatus,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../../../../selectors';
|
2021-06-10 19:53:15 +02:00
|
|
|
import {
|
|
|
|
updateSendErrors,
|
|
|
|
updateSendAmount,
|
|
|
|
setMaxModeTo,
|
|
|
|
} from '../../../../../ducks/send/send.duck';
|
2021-02-04 19:15:23 +01:00
|
|
|
import { calcMaxAmount } from './amount-max-button.utils';
|
|
|
|
import AmountMaxButton from './amount-max-button.component';
|
2018-04-11 16:21:54 +02:00
|
|
|
|
2021-02-04 19:15:23 +01: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 {
|
2018-04-27 02:38:14 +02:00
|
|
|
balance: getSendFromBalance(state),
|
2019-05-20 18:38:08 +02:00
|
|
|
buttonDataLoading: getBasicGasEstimateLoadingStatus(state),
|
2018-04-11 16:21:54 +02:00
|
|
|
gasTotal: getGasTotal(state),
|
2020-05-04 17:22:34 +02:00
|
|
|
maxModeOn: getSendMaxModeState(state),
|
2020-05-29 19:46:10 +02:00
|
|
|
sendToken: getSendToken(state),
|
2018-04-11 16:21:54 +02:00
|
|
|
tokenBalance: getTokenBalance(state),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-04-11 16:21:54 +02:00
|
|
|
}
|
|
|
|
|
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) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
dispatch(updateSendErrors({ amount: null }));
|
|
|
|
dispatch(updateSendAmount(calcMaxAmount(maxAmountDataObject)));
|
2018-04-27 02:38:14 +02:00
|
|
|
},
|
2019-05-20 18:38:08 +02:00
|
|
|
clearMaxAmount: () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
dispatch(updateSendAmount('0'));
|
2019-05-20 18:38:08 +02:00
|
|
|
},
|
2020-02-15 21:34:12 +01:00
|
|
|
setMaxModeTo: (bool) => dispatch(setMaxModeTo(bool)),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-04-27 02:38:14 +02:00
|
|
|
}
|