2021-07-12 18:16:03 +02:00
|
|
|
import React, { useContext } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2021-06-28 16:45:08 +02:00
|
|
|
|
2021-06-24 01:39:44 +02:00
|
|
|
import { I18nContext } from '../../../contexts/i18n';
|
2021-07-07 00:19:11 +02:00
|
|
|
import FormField from '../../ui/form-field';
|
2021-07-20 21:34:32 +02:00
|
|
|
import { getGasFormErrorText } from '../../../helpers/constants/gas';
|
2021-07-12 18:16:03 +02:00
|
|
|
|
|
|
|
export default function AdvancedGasControls({
|
|
|
|
onManualChange,
|
|
|
|
gasLimit,
|
|
|
|
setGasLimit,
|
|
|
|
gasPrice,
|
|
|
|
setGasPrice,
|
2021-07-20 21:34:32 +02:00
|
|
|
gasErrors,
|
2021-07-31 15:02:14 +02:00
|
|
|
minimumGasLimit,
|
2021-07-12 18:16:03 +02:00
|
|
|
}) {
|
2021-06-24 01:39:44 +02:00
|
|
|
const t = useContext(I18nContext);
|
2021-06-28 16:45:08 +02:00
|
|
|
|
2021-06-24 01:39:44 +02:00
|
|
|
return (
|
|
|
|
<div className="advanced-gas-controls">
|
2021-07-07 00:19:11 +02:00
|
|
|
<FormField
|
2021-06-24 01:39:44 +02:00
|
|
|
titleText={t('gasLimit')}
|
2021-07-20 21:34:32 +02:00
|
|
|
error={
|
|
|
|
gasErrors?.gasLimit
|
2021-07-30 13:35:30 +02:00
|
|
|
? getGasFormErrorText(gasErrors.gasLimit, t, { minimumGasLimit })
|
2021-07-20 21:34:32 +02:00
|
|
|
: null
|
|
|
|
}
|
2021-08-02 22:28:30 +02:00
|
|
|
onChange={(value) => {
|
|
|
|
onManualChange?.();
|
|
|
|
setGasLimit(value);
|
|
|
|
}}
|
2021-07-15 19:23:37 +02:00
|
|
|
tooltipText={t('editGasLimitTooltip')}
|
2021-06-24 01:39:44 +02:00
|
|
|
value={gasLimit}
|
2021-07-29 17:59:14 +02:00
|
|
|
allowDecimals={false}
|
2021-07-07 00:19:11 +02:00
|
|
|
numeric
|
2021-06-24 01:39:44 +02:00
|
|
|
/>
|
2022-12-08 19:37:06 +01:00
|
|
|
<>
|
|
|
|
<FormField
|
|
|
|
titleText={t('advancedGasPriceTitle')}
|
|
|
|
titleUnit="(GWEI)"
|
|
|
|
onChange={(value) => {
|
|
|
|
onManualChange?.();
|
|
|
|
setGasPrice(value);
|
|
|
|
}}
|
|
|
|
tooltipText={t('editGasPriceTooltip')}
|
|
|
|
value={gasPrice}
|
|
|
|
numeric
|
|
|
|
allowDecimals
|
|
|
|
error={
|
|
|
|
gasErrors?.gasPrice
|
|
|
|
? getGasFormErrorText(gasErrors.gasPrice, t)
|
|
|
|
: null
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</>
|
2021-06-24 01:39:44 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2021-07-12 18:16:03 +02:00
|
|
|
|
|
|
|
AdvancedGasControls.propTypes = {
|
|
|
|
onManualChange: PropTypes.func,
|
|
|
|
gasLimit: PropTypes.number,
|
|
|
|
setGasLimit: PropTypes.func,
|
2022-06-02 20:05:41 +02:00
|
|
|
gasPrice: PropTypes.string,
|
2021-07-12 18:16:03 +02:00
|
|
|
setGasPrice: PropTypes.func,
|
2021-08-10 22:45:09 +02:00
|
|
|
minimumGasLimit: PropTypes.string,
|
2022-12-08 19:37:06 +01:00
|
|
|
gasErrors: PropTypes.object,
|
2021-07-12 18:16:03 +02:00
|
|
|
};
|