1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Remove experimental gas editing for Swaps (#14942)

This commit is contained in:
Daniel 2022-06-15 21:08:13 +02:00 committed by ryanml
parent f561aeeef6
commit 80e7d82eed
4 changed files with 183 additions and 292 deletions

View File

@ -1,7 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`FeeCard renders the component with EIP-1559 V2 enabled 1`] = `null`;
exports[`FeeCard renders the component with EIP-1559 enabled 1`] = `null`;
exports[`FeeCard renders the component with initial props 1`] = `null`;

View File

@ -18,7 +18,6 @@ import {
TYPOGRAPHY,
FONT_WEIGHT,
} from '../../../helpers/constants/design-system';
import GasDetailsItemTitle from '../../../components/app/gas-details-item/gas-details-item-title';
import { MetaMetricsContext } from '../../../contexts/metametrics';
import { EVENT } from '../../../../shared/constants/metametrics';
@ -35,10 +34,7 @@ export default function FeeCard({
numberOfQuotes,
onQuotesClick,
chainId,
smartTransactionsOptInStatus,
smartTransactionsEnabled,
isBestQuote,
supportsEIP1559V2 = false,
}) {
const t = useContext(I18nContext);
@ -72,17 +68,11 @@ export default function FeeCard({
<div className="fee-card">
<div className="fee-card__main">
<TransactionDetail
disableEditGasFeeButton={
smartTransactionsEnabled && smartTransactionsOptInStatus
}
disableEditGasFeeButton
rows={[
<TransactionDetailItem
key="gas-item"
detailTitle={
supportsEIP1559V2 &&
(!smartTransactionsEnabled || !smartTransactionsOptInStatus) ? (
<GasDetailsItemTitle />
) : (
<>
{t('transactionDetailGasHeading')}
<InfoTooltip
@ -122,7 +112,6 @@ export default function FeeCard({
wide
/>
</>
)
}
detailText={primaryFee.fee}
detailTotal={secondaryFee.fee}
@ -209,8 +198,5 @@ FeeCard.propTypes = {
onQuotesClick: PropTypes.func.isRequired,
numberOfQuotes: PropTypes.number.isRequired,
chainId: PropTypes.string.isRequired,
smartTransactionsOptInStatus: PropTypes.bool,
smartTransactionsEnabled: PropTypes.bool,
isBestQuote: PropTypes.bool.isRequired,
supportsEIP1559V2: PropTypes.bool,
};

View File

@ -9,23 +9,15 @@ import {
setBackgroundConnection,
MOCKS,
} from '../../../../test/jest';
import { EDIT_GAS_MODES } from '../../../../shared/constants/gas';
import { MAINNET_CHAIN_ID } from '../../../../shared/constants/network';
import {
checkNetworkAndAccountSupports1559,
getEIP1559V2Enabled,
getPreferences,
getSelectedAccount,
} from '../../../selectors';
import { checkNetworkAndAccountSupports1559 } from '../../../selectors';
import {
getGasEstimateType,
getGasFeeEstimates,
getIsGasEstimatesLoading,
} from '../../../ducks/metamask/metamask';
import { GasFeeContextProvider } from '../../../contexts/gasFee';
import { TRANSACTION_ENVELOPE_TYPE_NAMES } from '../../../helpers/constants/transactions';
import { useGasFeeEstimates } from '../../../hooks/useGasFeeEstimates';
import FeeCard from '.';
@ -153,56 +145,4 @@ describe('FeeCard', () => {
expect(getByText(`: ${props.secondaryFee.maxFee}`)).toBeInTheDocument();
expect(queryByTestId('fee-card__edit-link')).not.toBeInTheDocument();
});
it('renders the component with EIP-1559 V2 enabled', () => {
useGasFeeEstimates.mockImplementation(() => ({ gasFeeEstimates: {} }));
useSelector.mockImplementation((selector) => {
if (selector === getPreferences) {
return {
useNativeCurrencyAsPrimaryCurrency: true,
};
}
if (selector === getEIP1559V2Enabled) {
return true;
}
if (selector === getSelectedAccount) {
return {
balance: '0x440aa47cc2556',
};
}
if (selector === checkNetworkAndAccountSupports1559) {
return true;
}
return undefined;
});
const store = configureMockStore(middleware)(createSwapsMockStore());
const props = createProps({
networkAndAccountSupports1559: true,
maxPriorityFeePerGasDecGWEI: '3',
maxFeePerGasDecGWEI: '4',
supportsEIP1559V2: true,
});
const { getByText } = renderWithProvider(
<GasFeeContextProvider
transaction={{ txParams: {}, userFeeLevel: 'high' }}
editGasMode={EDIT_GAS_MODES.SWAPS}
>
<FeeCard {...props} />
</GasFeeContextProvider>,
store,
);
expect(getByText('Best of 6 quotes.')).toBeInTheDocument();
expect(getByText('Gas')).toBeInTheDocument();
expect(getByText('(estimated)')).toBeInTheDocument();
expect(getByText('Swap suggested')).toBeInTheDocument();
expect(getByText('Max fee')).toBeInTheDocument();
expect(getByText(props.primaryFee.fee)).toBeInTheDocument();
expect(getByText(props.secondaryFee.fee)).toBeInTheDocument();
expect(getByText(`: ${props.secondaryFee.maxFee}`)).toBeInTheDocument();
expect(getByText('Includes a 0.875% MetaMask fee.')).toBeInTheDocument();
expect(
document.querySelector('.fee-card__top-bordered-row'),
).toMatchSnapshot();
});
});

View File

@ -60,7 +60,6 @@ import {
isHardwareWallet,
getHardwareWalletType,
checkNetworkAndAccountSupports1559,
getEIP1559V2Enabled,
getUSDConversionRate,
} from '../../../selectors';
import { getNativeCurrency, getTokens } from '../../../ducks/metamask/metamask';
@ -92,8 +91,6 @@ import {
hexWEIToDecGWEI,
addHexes,
} from '../../../helpers/utils/conversions.util';
import { GasFeeContextProvider } from '../../../contexts/gasFee';
import { TransactionModalContextProvider } from '../../../contexts/transaction-modal';
import MainQuoteSummary from '../main-quote-summary';
import { calcGasTotal } from '../../send/send.utils';
import { getCustomTxParamsData } from '../../confirm-approve/confirm-approve.util';
@ -105,10 +102,7 @@ import {
} from '../swaps.util';
import { useTokenTracker } from '../../../hooks/useTokenTracker';
import { QUOTES_EXPIRED_ERROR } from '../../../../shared/constants/swaps';
import {
EDIT_GAS_MODES,
GAS_RECOMMENDATIONS,
} from '../../../../shared/constants/gas';
import { GAS_RECOMMENDATIONS } from '../../../../shared/constants/gas';
import CountdownTimer from '../countdown-timer';
import SwapsFooter from '../swaps-footer';
import PulseLoader from '../../../components/ui/pulse-loader'; // TODO: Replace this with a different loading component.
@ -125,7 +119,6 @@ export default function ViewQuote() {
const dispatch = useDispatch();
const t = useContext(I18nContext);
const trackEvent = useContext(MetaMetricsContext);
const eip1559V2Enabled = useSelector(getEIP1559V2Enabled);
const [dispatchedSafeRefetch, setDispatchedSafeRefetch] = useState(false);
const [submitClicked, setSubmitClicked] = useState(false);
@ -830,24 +823,7 @@ export default function ViewQuote() {
submitClicked,
]);
const transaction = {
userFeeLevel: swapsUserFeeLevel || GAS_RECOMMENDATIONS.HIGH,
txParams: {
maxFeePerGas,
maxPriorityFeePerGas,
gas: maxGasLimit,
},
};
const supportsEIP1559V2 = eip1559V2Enabled && networkAndAccountSupports1559;
return (
<GasFeeContextProvider
editGasMode={EDIT_GAS_MODES.SWAPS}
minimumGasLimit={usedGasLimit}
transaction={transaction}
>
<TransactionModalContextProvider>
<div className="view-quote">
<div
className={classnames('view-quote__content', {
@ -889,10 +865,7 @@ export default function ViewQuote() {
/>
</div>
<MainQuoteSummary
sourceValue={calcTokenValue(
sourceTokenValue,
sourceTokenDecimals,
)}
sourceValue={calcTokenValue(sourceTokenValue, sourceTokenDecimals)}
sourceDecimals={sourceTokenDecimals}
sourceSymbol={sourceTokenSymbol}
destinationValue={calcTokenValue(
@ -942,14 +915,10 @@ export default function ViewQuote() {
}}
chainId={chainId}
isBestQuote={isBestQuote}
supportsEIP1559V2={supportsEIP1559V2}
networkAndAccountSupports1559={networkAndAccountSupports1559}
maxPriorityFeePerGasDecGWEI={hexWEIToDecGWEI(
maxPriorityFeePerGas,
)}
maxFeePerGasDecGWEI={hexWEIToDecGWEI(maxFeePerGas)}
smartTransactionsEnabled={currentSmartTransactionsEnabled}
smartTransactionsOptInStatus={smartTransactionsOptInStatus}
/>
</div>
)}
@ -999,7 +968,5 @@ export default function ViewQuote() {
showTopBorder
/>
</div>
</TransactionModalContextProvider>
</GasFeeContextProvider>
);
}