mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-24 11:01:41 +01:00
37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import {
|
|
decGWEIToHexWEI,
|
|
decimalToHex,
|
|
hexWEIToDecGWEI,
|
|
} from '../../../../helpers/utils/conversions.util';
|
|
import AdvancedGasInputs from './advanced-gas-inputs.component';
|
|
|
|
function convertGasPriceForInputs(gasPriceInHexWEI) {
|
|
return Number(hexWEIToDecGWEI(gasPriceInHexWEI));
|
|
}
|
|
|
|
function convertGasLimitForInputs(gasLimitInHexWEI) {
|
|
return parseInt(gasLimitInHexWEI, 16) || 0;
|
|
}
|
|
|
|
const mergeProps = (stateProps, dispatchProps, ownProps) => {
|
|
const {
|
|
customGasPrice,
|
|
customGasLimit,
|
|
updateCustomGasPrice,
|
|
updateCustomGasLimit,
|
|
} = ownProps;
|
|
return {
|
|
...ownProps,
|
|
...stateProps,
|
|
...dispatchProps,
|
|
customGasPrice: convertGasPriceForInputs(customGasPrice),
|
|
customGasLimit: convertGasLimitForInputs(customGasLimit),
|
|
updateCustomGasPrice: (price) =>
|
|
updateCustomGasPrice(decGWEIToHexWEI(price)),
|
|
updateCustomGasLimit: (limit) => updateCustomGasLimit(decimalToHex(limit)),
|
|
};
|
|
};
|
|
|
|
export default connect(null, null, mergeProps)(AdvancedGasInputs);
|