mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Allow editing custom gas while estimate is loading (#11853)
This commit is contained in:
parent
4da940fdd4
commit
b6086ebc17
@ -25,6 +25,7 @@ export default function AdvancedGasControls({
|
|||||||
maxFeeFiat,
|
maxFeeFiat,
|
||||||
gasErrors,
|
gasErrors,
|
||||||
minimumGasLimit,
|
minimumGasLimit,
|
||||||
|
estimateToUse,
|
||||||
}) {
|
}) {
|
||||||
const t = useContext(I18nContext);
|
const t = useContext(I18nContext);
|
||||||
const networkAndAccountSupport1559 = useSelector(
|
const networkAndAccountSupport1559 = useSelector(
|
||||||
@ -35,7 +36,8 @@ export default function AdvancedGasControls({
|
|||||||
getGasLoadingAnimationIsShowing,
|
getGasLoadingAnimationIsShowing,
|
||||||
);
|
);
|
||||||
const disableFormFields =
|
const disableFormFields =
|
||||||
isGasEstimatesLoading || isGasLoadingAnimationIsShowing;
|
estimateToUse !== 'custom' &&
|
||||||
|
(isGasEstimatesLoading || isGasLoadingAnimationIsShowing);
|
||||||
|
|
||||||
const showFeeMarketFields =
|
const showFeeMarketFields =
|
||||||
networkAndAccountSupport1559 &&
|
networkAndAccountSupport1559 &&
|
||||||
@ -141,4 +143,5 @@ AdvancedGasControls.propTypes = {
|
|||||||
maxFeeFiat: PropTypes.string,
|
maxFeeFiat: PropTypes.string,
|
||||||
gasErrors: PropTypes.object,
|
gasErrors: PropTypes.object,
|
||||||
minimumGasLimit: PropTypes.number,
|
minimumGasLimit: PropTypes.number,
|
||||||
|
estimateToUse: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
@ -265,6 +265,7 @@ export default function EditGasDisplay({
|
|||||||
gasErrors={gasErrors}
|
gasErrors={gasErrors}
|
||||||
onManualChange={onManualChange}
|
onManualChange={onManualChange}
|
||||||
minimumGasLimit={minimumGasLimit}
|
minimumGasLimit={minimumGasLimit}
|
||||||
|
estimateToUse={estimateToUse}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@ -210,9 +210,9 @@ export default function EditGasPopover({
|
|||||||
onClick={onSubmit}
|
onClick={onSubmit}
|
||||||
disabled={
|
disabled={
|
||||||
hasGasErrors ||
|
hasGasErrors ||
|
||||||
isGasEstimatesLoading ||
|
|
||||||
balanceError ||
|
balanceError ||
|
||||||
gasLoadingAnimationIsShowing
|
((isGasEstimatesLoading || gasLoadingAnimationIsShowing) &&
|
||||||
|
!estimateToUse === 'custom')
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{footerButtonText}
|
{footerButtonText}
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
import React, { useContext } from 'react';
|
import React, { useContext } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { useSelector } from 'react-redux';
|
|
||||||
|
|
||||||
import { getIsGasEstimatesLoading } from '../../../ducks/metamask/metamask';
|
|
||||||
import { getGasLoadingAnimationIsShowing } from '../../../ducks/app/app';
|
|
||||||
|
|
||||||
import { I18nContext } from '../../../contexts/i18n';
|
import { I18nContext } from '../../../contexts/i18n';
|
||||||
|
|
||||||
@ -12,22 +8,13 @@ import LoadingHeartBeat from '../../ui/loading-heartbeat';
|
|||||||
|
|
||||||
export default function TransactionDetail({ rows = [], onEdit }) {
|
export default function TransactionDetail({ rows = [], onEdit }) {
|
||||||
const t = useContext(I18nContext);
|
const t = useContext(I18nContext);
|
||||||
const isGasEstimatesLoading = useSelector(getIsGasEstimatesLoading);
|
|
||||||
const gasLoadingAnimationIsShowing = useSelector(
|
|
||||||
getGasLoadingAnimationIsShowing,
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="transaction-detail">
|
<div className="transaction-detail">
|
||||||
{process.env.IN_TEST === 'true' ? null : <LoadingHeartBeat />}
|
{process.env.IN_TEST === 'true' ? null : <LoadingHeartBeat />}
|
||||||
{onEdit && (
|
{onEdit && (
|
||||||
<div className="transaction-detail-edit">
|
<div className="transaction-detail-edit">
|
||||||
<button
|
<button onClick={onEdit}>{t('edit')}</button>
|
||||||
onClick={onEdit}
|
|
||||||
disabled={isGasEstimatesLoading || gasLoadingAnimationIsShowing}
|
|
||||||
>
|
|
||||||
{t('edit')}
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="transaction-detail-rows">{rows}</div>
|
<div className="transaction-detail-rows">{rows}</div>
|
||||||
|
@ -112,6 +112,7 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
maxFeePerGas: PropTypes.string,
|
maxFeePerGas: PropTypes.string,
|
||||||
maxPriorityFeePerGas: PropTypes.string,
|
maxPriorityFeePerGas: PropTypes.string,
|
||||||
baseFeePerGas: PropTypes.string,
|
baseFeePerGas: PropTypes.string,
|
||||||
|
gasFeeIsCustom: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
@ -196,6 +197,7 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
txData: { simulationFails, txParams: { value: amount } = {} } = {},
|
txData: { simulationFails, txParams: { value: amount } = {} } = {},
|
||||||
customGas,
|
customGas,
|
||||||
noGasPrice,
|
noGasPrice,
|
||||||
|
gasFeeIsCustom,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const insufficientBalance =
|
const insufficientBalance =
|
||||||
@ -230,7 +232,7 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noGasPrice) {
|
if (noGasPrice && !gasFeeIsCustom) {
|
||||||
return {
|
return {
|
||||||
valid: false,
|
valid: false,
|
||||||
errorKey: GAS_PRICE_FETCH_FAILURE_ERROR_KEY,
|
errorKey: GAS_PRICE_FETCH_FAILURE_ERROR_KEY,
|
||||||
@ -829,6 +831,7 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
showAccountInHeader,
|
showAccountInHeader,
|
||||||
txData,
|
txData,
|
||||||
gasIsLoading,
|
gasIsLoading,
|
||||||
|
gasFeeIsCustom,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const {
|
const {
|
||||||
submitting,
|
submitting,
|
||||||
@ -895,7 +898,7 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
lastTx={lastTx}
|
lastTx={lastTx}
|
||||||
ofText={ofText}
|
ofText={ofText}
|
||||||
requestsWaitingText={requestsWaitingText}
|
requestsWaitingText={requestsWaitingText}
|
||||||
disabled={!valid || submitting || gasIsLoading}
|
disabled={!valid || submitting || (gasIsLoading && !gasFeeIsCustom)}
|
||||||
onEdit={() => this.handleEdit()}
|
onEdit={() => this.handleEdit()}
|
||||||
onCancelAll={() => this.handleCancelAll()}
|
onCancelAll={() => this.handleCancelAll()}
|
||||||
onCancel={() => this.handleCancel()}
|
onCancel={() => this.handleCancel()}
|
||||||
|
@ -155,6 +155,7 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
const isEthGasPrice = getIsEthGasPriceFetched(state);
|
const isEthGasPrice = getIsEthGasPriceFetched(state);
|
||||||
const noGasPrice = !supportsEIP1599 && getNoGasPriceFetched(state);
|
const noGasPrice = !supportsEIP1599 && getNoGasPriceFetched(state);
|
||||||
const { useNativeCurrencyAsPrimaryCurrency } = getPreferences(state);
|
const { useNativeCurrencyAsPrimaryCurrency } = getPreferences(state);
|
||||||
|
const gasFeeIsCustom = fullTxData.userFeeLevel === 'custom';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
balance,
|
balance,
|
||||||
@ -201,6 +202,7 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
maxFeePerGas: gasEstimationObject.maxFeePerGas,
|
maxFeePerGas: gasEstimationObject.maxFeePerGas,
|
||||||
maxPriorityFeePerGas: gasEstimationObject.maxPriorityFeePerGas,
|
maxPriorityFeePerGas: gasEstimationObject.maxPriorityFeePerGas,
|
||||||
baseFeePerGas: gasEstimationObject.baseFeePerGas,
|
baseFeePerGas: gasEstimationObject.baseFeePerGas,
|
||||||
|
gasFeeIsCustom,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user