1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 19:10:22 +01:00
metamask-extension/ui/pages/send/send-content/send-gas-row/send-gas-row.container.js

51 lines
1.3 KiB
JavaScript

import { connect } from 'react-redux';
import {
getGasPrice,
getGasLimit,
gasFeeIsInError,
getGasInputMode,
updateGasPrice,
updateGasLimit,
isSendStateInitialized,
getIsBalanceInsufficient,
getMinimumGasLimitForSend,
} from '../../../../ducks/send';
import {
setCustomGasPrice,
setCustomGasLimit,
} from '../../../../ducks/gas/gas.duck';
import { hexToDecimal } from '../../../../../shared/lib/metamask-controller-utils';
import SendGasRow from './send-gas-row.component';
export default connect(mapStateToProps, mapDispatchToProps)(SendGasRow);
function mapStateToProps(state) {
const gasPrice = getGasPrice(state);
const gasLimit = getGasLimit(state);
const minimumGasLimit = getMinimumGasLimitForSend(state);
return {
minimumGasLimit: hexToDecimal(minimumGasLimit),
gasFeeError: gasFeeIsInError(state),
gasLoadingError: isSendStateInitialized(state),
gasInputMode: getGasInputMode(state),
gasPrice,
gasLimit,
insufficientBalance: getIsBalanceInsufficient(state),
};
}
function mapDispatchToProps(dispatch) {
return {
updateGasPrice: (gasPrice) => {
dispatch(updateGasPrice(gasPrice));
dispatch(setCustomGasPrice(gasPrice));
},
updateGasLimit: (newLimit) => {
dispatch(updateGasLimit(newLimit));
dispatch(setCustomGasLimit(newLimit));
},
};
}