2021-02-04 19:15:23 +01:00
|
|
|
import { connect } from 'react-redux';
|
2018-04-11 16:21:54 +02:00
|
|
|
import {
|
2021-06-23 23:35:25 +02:00
|
|
|
getGasPrice,
|
|
|
|
getGasLimit,
|
|
|
|
gasFeeIsInError,
|
|
|
|
getGasInputMode,
|
|
|
|
updateGasPrice,
|
|
|
|
updateGasLimit,
|
|
|
|
isSendStateInitialized,
|
|
|
|
getIsBalanceInsufficient,
|
|
|
|
getMinimumGasLimitForSend,
|
|
|
|
} from '../../../../ducks/send';
|
2018-11-05 18:01:46 +01:00
|
|
|
import {
|
2019-02-06 18:13:45 +01:00
|
|
|
setCustomGasPrice,
|
|
|
|
setCustomGasLimit,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../../../ducks/gas/gas.duck';
|
2022-09-16 21:05:21 +02:00
|
|
|
import { hexToDecimal } from '../../../../../shared/lib/metamask-controller-utils';
|
2021-02-04 19:15:23 +01:00
|
|
|
import SendGasRow from './send-gas-row.component';
|
2018-04-11 16:21:54 +02:00
|
|
|
|
2022-09-28 22:00:57 +02:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(SendGasRow);
|
2018-04-11 16:21:54 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function mapStateToProps(state) {
|
2021-02-04 19:15:23 +01:00
|
|
|
const gasPrice = getGasPrice(state);
|
|
|
|
const gasLimit = getGasLimit(state);
|
2019-02-06 01:24:28 +01:00
|
|
|
|
2021-06-23 23:35:25 +02:00
|
|
|
const minimumGasLimit = getMinimumGasLimitForSend(state);
|
2018-09-13 14:35:17 +02:00
|
|
|
|
2018-04-11 16:21:54 +02:00
|
|
|
return {
|
2021-06-23 23:35:25 +02:00
|
|
|
minimumGasLimit: hexToDecimal(minimumGasLimit),
|
2018-06-29 19:19:40 +02:00
|
|
|
gasFeeError: gasFeeIsInError(state),
|
2021-06-23 23:35:25 +02:00
|
|
|
gasLoadingError: isSendStateInitialized(state),
|
|
|
|
gasInputMode: getGasInputMode(state),
|
2019-02-08 14:50:25 +01:00
|
|
|
gasPrice,
|
|
|
|
gasLimit,
|
2021-06-23 23:35:25 +02:00
|
|
|
insufficientBalance: getIsBalanceInsufficient(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 {
|
2021-06-23 23:35:25 +02:00
|
|
|
updateGasPrice: (gasPrice) => {
|
|
|
|
dispatch(updateGasPrice(gasPrice));
|
2021-02-04 19:15:23 +01:00
|
|
|
dispatch(setCustomGasPrice(gasPrice));
|
2019-02-06 01:24:28 +01:00
|
|
|
},
|
2021-06-23 23:35:25 +02:00
|
|
|
updateGasLimit: (newLimit) => {
|
|
|
|
dispatch(updateGasLimit(newLimit));
|
2021-02-04 19:15:23 +01:00
|
|
|
dispatch(setCustomGasLimit(newLimit));
|
2019-05-20 18:38:08 +02:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-09-20 06:16:43 +02:00
|
|
|
}
|