You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.6 KiB
51 lines
1.6 KiB
4 years ago
|
import { connect } from 'react-redux';
|
||
2 years ago
|
import { decGWEIToHexWEI } from '../../../helpers/utils/conversions.util';
|
||
|
import { getNetworkSupportsSettingGasFees } from '../../../selectors/selectors';
|
||
|
import { MIN_GAS_LIMIT_DEC } from '../../../pages/send/send.constants';
|
||
6 years ago
|
import {
|
||
|
decimalToHex,
|
||
|
hexWEIToDecGWEI,
|
||
2 years ago
|
} from '../../../../shared/lib/transactions-controller-utils';
|
||
4 years ago
|
import AdvancedGasInputs from './advanced-gas-inputs.component';
|
||
6 years ago
|
|
||
4 years ago
|
function convertGasPriceForInputs(gasPriceInHexWEI) {
|
||
4 years ago
|
return Number(hexWEIToDecGWEI(gasPriceInHexWEI));
|
||
6 years ago
|
}
|
||
|
|
||
4 years ago
|
function convertGasLimitForInputs(gasLimitInHexWEI) {
|
||
4 years ago
|
return parseInt(gasLimitInHexWEI, 16) || 0;
|
||
6 years ago
|
}
|
||
|
|
||
3 years ago
|
function convertMinimumGasLimitForInputs(minimumGasLimit = MIN_GAS_LIMIT_DEC) {
|
||
|
return parseInt(minimumGasLimit, 10);
|
||
|
}
|
||
|
|
||
3 years ago
|
function mapStateToProps(state) {
|
||
|
return {
|
||
3 years ago
|
networkSupportsSettingGasFees: getNetworkSupportsSettingGasFees(state),
|
||
3 years ago
|
};
|
||
|
}
|
||
|
|
||
|
function mergeProps(stateProps, dispatchProps, ownProps) {
|
||
4 years ago
|
const {
|
||
|
customGasPrice,
|
||
|
customGasLimit,
|
||
|
updateCustomGasPrice,
|
||
|
updateCustomGasLimit,
|
||
3 years ago
|
minimumGasLimit,
|
||
4 years ago
|
} = ownProps;
|
||
6 years ago
|
return {
|
||
5 years ago
|
...ownProps,
|
||
6 years ago
|
...stateProps,
|
||
|
...dispatchProps,
|
||
|
customGasPrice: convertGasPriceForInputs(customGasPrice),
|
||
|
customGasLimit: convertGasLimitForInputs(customGasLimit),
|
||
3 years ago
|
minimumGasLimit: convertMinimumGasLimitForInputs(minimumGasLimit),
|
||
4 years ago
|
updateCustomGasPrice: (price) =>
|
||
|
updateCustomGasPrice(decGWEIToHexWEI(price)),
|
||
6 years ago
|
updateCustomGasLimit: (limit) => updateCustomGasLimit(decimalToHex(limit)),
|
||
4 years ago
|
};
|
||
3 years ago
|
}
|
||
6 years ago
|
|
||
3 years ago
|
export default connect(mapStateToProps, null, mergeProps)(AdvancedGasInputs);
|