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:
parent
1771ed4925
commit
ebf967562b
@ -1,7 +1,5 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// 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 EIP-1559 enabled 1`] = `null`;
|
||||||
|
|
||||||
exports[`FeeCard renders the component with initial props 1`] = `null`;
|
exports[`FeeCard renders the component with initial props 1`] = `null`;
|
||||||
|
@ -18,7 +18,6 @@ import {
|
|||||||
TYPOGRAPHY,
|
TYPOGRAPHY,
|
||||||
FONT_WEIGHT,
|
FONT_WEIGHT,
|
||||||
} from '../../../helpers/constants/design-system';
|
} from '../../../helpers/constants/design-system';
|
||||||
import GasDetailsItemTitle from '../../../components/app/gas-details-item/gas-details-item-title';
|
|
||||||
import { MetaMetricsContext } from '../../../contexts/metametrics';
|
import { MetaMetricsContext } from '../../../contexts/metametrics';
|
||||||
import { EVENT } from '../../../../shared/constants/metametrics';
|
import { EVENT } from '../../../../shared/constants/metametrics';
|
||||||
|
|
||||||
@ -35,10 +34,7 @@ export default function FeeCard({
|
|||||||
numberOfQuotes,
|
numberOfQuotes,
|
||||||
onQuotesClick,
|
onQuotesClick,
|
||||||
chainId,
|
chainId,
|
||||||
smartTransactionsOptInStatus,
|
|
||||||
smartTransactionsEnabled,
|
|
||||||
isBestQuote,
|
isBestQuote,
|
||||||
supportsEIP1559V2 = false,
|
|
||||||
}) {
|
}) {
|
||||||
const t = useContext(I18nContext);
|
const t = useContext(I18nContext);
|
||||||
|
|
||||||
@ -72,17 +68,11 @@ export default function FeeCard({
|
|||||||
<div className="fee-card">
|
<div className="fee-card">
|
||||||
<div className="fee-card__main">
|
<div className="fee-card__main">
|
||||||
<TransactionDetail
|
<TransactionDetail
|
||||||
disableEditGasFeeButton={
|
disableEditGasFeeButton
|
||||||
smartTransactionsEnabled && smartTransactionsOptInStatus
|
|
||||||
}
|
|
||||||
rows={[
|
rows={[
|
||||||
<TransactionDetailItem
|
<TransactionDetailItem
|
||||||
key="gas-item"
|
key="gas-item"
|
||||||
detailTitle={
|
detailTitle={
|
||||||
supportsEIP1559V2 &&
|
|
||||||
(!smartTransactionsEnabled || !smartTransactionsOptInStatus) ? (
|
|
||||||
<GasDetailsItemTitle />
|
|
||||||
) : (
|
|
||||||
<>
|
<>
|
||||||
{t('transactionDetailGasHeading')}
|
{t('transactionDetailGasHeading')}
|
||||||
<InfoTooltip
|
<InfoTooltip
|
||||||
@ -122,7 +112,6 @@ export default function FeeCard({
|
|||||||
wide
|
wide
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)
|
|
||||||
}
|
}
|
||||||
detailText={primaryFee.fee}
|
detailText={primaryFee.fee}
|
||||||
detailTotal={secondaryFee.fee}
|
detailTotal={secondaryFee.fee}
|
||||||
@ -209,8 +198,5 @@ FeeCard.propTypes = {
|
|||||||
onQuotesClick: PropTypes.func.isRequired,
|
onQuotesClick: PropTypes.func.isRequired,
|
||||||
numberOfQuotes: PropTypes.number.isRequired,
|
numberOfQuotes: PropTypes.number.isRequired,
|
||||||
chainId: PropTypes.string.isRequired,
|
chainId: PropTypes.string.isRequired,
|
||||||
smartTransactionsOptInStatus: PropTypes.bool,
|
|
||||||
smartTransactionsEnabled: PropTypes.bool,
|
|
||||||
isBestQuote: PropTypes.bool.isRequired,
|
isBestQuote: PropTypes.bool.isRequired,
|
||||||
supportsEIP1559V2: PropTypes.bool,
|
|
||||||
};
|
};
|
||||||
|
@ -9,23 +9,15 @@ import {
|
|||||||
setBackgroundConnection,
|
setBackgroundConnection,
|
||||||
MOCKS,
|
MOCKS,
|
||||||
} from '../../../../test/jest';
|
} from '../../../../test/jest';
|
||||||
import { EDIT_GAS_MODES } from '../../../../shared/constants/gas';
|
|
||||||
import { MAINNET_CHAIN_ID } from '../../../../shared/constants/network';
|
import { MAINNET_CHAIN_ID } from '../../../../shared/constants/network';
|
||||||
|
|
||||||
import {
|
import { checkNetworkAndAccountSupports1559 } from '../../../selectors';
|
||||||
checkNetworkAndAccountSupports1559,
|
|
||||||
getEIP1559V2Enabled,
|
|
||||||
getPreferences,
|
|
||||||
getSelectedAccount,
|
|
||||||
} from '../../../selectors';
|
|
||||||
import {
|
import {
|
||||||
getGasEstimateType,
|
getGasEstimateType,
|
||||||
getGasFeeEstimates,
|
getGasFeeEstimates,
|
||||||
getIsGasEstimatesLoading,
|
getIsGasEstimatesLoading,
|
||||||
} from '../../../ducks/metamask/metamask';
|
} from '../../../ducks/metamask/metamask';
|
||||||
import { GasFeeContextProvider } from '../../../contexts/gasFee';
|
|
||||||
import { TRANSACTION_ENVELOPE_TYPE_NAMES } from '../../../helpers/constants/transactions';
|
import { TRANSACTION_ENVELOPE_TYPE_NAMES } from '../../../helpers/constants/transactions';
|
||||||
import { useGasFeeEstimates } from '../../../hooks/useGasFeeEstimates';
|
|
||||||
|
|
||||||
import FeeCard from '.';
|
import FeeCard from '.';
|
||||||
|
|
||||||
@ -153,56 +145,4 @@ describe('FeeCard', () => {
|
|||||||
expect(getByText(`: ${props.secondaryFee.maxFee}`)).toBeInTheDocument();
|
expect(getByText(`: ${props.secondaryFee.maxFee}`)).toBeInTheDocument();
|
||||||
expect(queryByTestId('fee-card__edit-link')).not.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();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -60,7 +60,6 @@ import {
|
|||||||
isHardwareWallet,
|
isHardwareWallet,
|
||||||
getHardwareWalletType,
|
getHardwareWalletType,
|
||||||
checkNetworkAndAccountSupports1559,
|
checkNetworkAndAccountSupports1559,
|
||||||
getEIP1559V2Enabled,
|
|
||||||
getUSDConversionRate,
|
getUSDConversionRate,
|
||||||
} from '../../../selectors';
|
} from '../../../selectors';
|
||||||
import { getNativeCurrency, getTokens } from '../../../ducks/metamask/metamask';
|
import { getNativeCurrency, getTokens } from '../../../ducks/metamask/metamask';
|
||||||
@ -92,8 +91,6 @@ import {
|
|||||||
hexWEIToDecGWEI,
|
hexWEIToDecGWEI,
|
||||||
addHexes,
|
addHexes,
|
||||||
} from '../../../helpers/utils/conversions.util';
|
} from '../../../helpers/utils/conversions.util';
|
||||||
import { GasFeeContextProvider } from '../../../contexts/gasFee';
|
|
||||||
import { TransactionModalContextProvider } from '../../../contexts/transaction-modal';
|
|
||||||
import MainQuoteSummary from '../main-quote-summary';
|
import MainQuoteSummary from '../main-quote-summary';
|
||||||
import { calcGasTotal } from '../../send/send.utils';
|
import { calcGasTotal } from '../../send/send.utils';
|
||||||
import { getCustomTxParamsData } from '../../confirm-approve/confirm-approve.util';
|
import { getCustomTxParamsData } from '../../confirm-approve/confirm-approve.util';
|
||||||
@ -105,10 +102,7 @@ import {
|
|||||||
} from '../swaps.util';
|
} from '../swaps.util';
|
||||||
import { useTokenTracker } from '../../../hooks/useTokenTracker';
|
import { useTokenTracker } from '../../../hooks/useTokenTracker';
|
||||||
import { QUOTES_EXPIRED_ERROR } from '../../../../shared/constants/swaps';
|
import { QUOTES_EXPIRED_ERROR } from '../../../../shared/constants/swaps';
|
||||||
import {
|
import { GAS_RECOMMENDATIONS } from '../../../../shared/constants/gas';
|
||||||
EDIT_GAS_MODES,
|
|
||||||
GAS_RECOMMENDATIONS,
|
|
||||||
} from '../../../../shared/constants/gas';
|
|
||||||
import CountdownTimer from '../countdown-timer';
|
import CountdownTimer from '../countdown-timer';
|
||||||
import SwapsFooter from '../swaps-footer';
|
import SwapsFooter from '../swaps-footer';
|
||||||
import PulseLoader from '../../../components/ui/pulse-loader'; // TODO: Replace this with a different loading component.
|
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 dispatch = useDispatch();
|
||||||
const t = useContext(I18nContext);
|
const t = useContext(I18nContext);
|
||||||
const trackEvent = useContext(MetaMetricsContext);
|
const trackEvent = useContext(MetaMetricsContext);
|
||||||
const eip1559V2Enabled = useSelector(getEIP1559V2Enabled);
|
|
||||||
|
|
||||||
const [dispatchedSafeRefetch, setDispatchedSafeRefetch] = useState(false);
|
const [dispatchedSafeRefetch, setDispatchedSafeRefetch] = useState(false);
|
||||||
const [submitClicked, setSubmitClicked] = useState(false);
|
const [submitClicked, setSubmitClicked] = useState(false);
|
||||||
@ -830,24 +823,7 @@ export default function ViewQuote() {
|
|||||||
submitClicked,
|
submitClicked,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const transaction = {
|
|
||||||
userFeeLevel: swapsUserFeeLevel || GAS_RECOMMENDATIONS.HIGH,
|
|
||||||
txParams: {
|
|
||||||
maxFeePerGas,
|
|
||||||
maxPriorityFeePerGas,
|
|
||||||
gas: maxGasLimit,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const supportsEIP1559V2 = eip1559V2Enabled && networkAndAccountSupports1559;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GasFeeContextProvider
|
|
||||||
editGasMode={EDIT_GAS_MODES.SWAPS}
|
|
||||||
minimumGasLimit={usedGasLimit}
|
|
||||||
transaction={transaction}
|
|
||||||
>
|
|
||||||
<TransactionModalContextProvider>
|
|
||||||
<div className="view-quote">
|
<div className="view-quote">
|
||||||
<div
|
<div
|
||||||
className={classnames('view-quote__content', {
|
className={classnames('view-quote__content', {
|
||||||
@ -889,10 +865,7 @@ export default function ViewQuote() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<MainQuoteSummary
|
<MainQuoteSummary
|
||||||
sourceValue={calcTokenValue(
|
sourceValue={calcTokenValue(sourceTokenValue, sourceTokenDecimals)}
|
||||||
sourceTokenValue,
|
|
||||||
sourceTokenDecimals,
|
|
||||||
)}
|
|
||||||
sourceDecimals={sourceTokenDecimals}
|
sourceDecimals={sourceTokenDecimals}
|
||||||
sourceSymbol={sourceTokenSymbol}
|
sourceSymbol={sourceTokenSymbol}
|
||||||
destinationValue={calcTokenValue(
|
destinationValue={calcTokenValue(
|
||||||
@ -942,14 +915,10 @@ export default function ViewQuote() {
|
|||||||
}}
|
}}
|
||||||
chainId={chainId}
|
chainId={chainId}
|
||||||
isBestQuote={isBestQuote}
|
isBestQuote={isBestQuote}
|
||||||
supportsEIP1559V2={supportsEIP1559V2}
|
|
||||||
networkAndAccountSupports1559={networkAndAccountSupports1559}
|
|
||||||
maxPriorityFeePerGasDecGWEI={hexWEIToDecGWEI(
|
maxPriorityFeePerGasDecGWEI={hexWEIToDecGWEI(
|
||||||
maxPriorityFeePerGas,
|
maxPriorityFeePerGas,
|
||||||
)}
|
)}
|
||||||
maxFeePerGasDecGWEI={hexWEIToDecGWEI(maxFeePerGas)}
|
maxFeePerGasDecGWEI={hexWEIToDecGWEI(maxFeePerGas)}
|
||||||
smartTransactionsEnabled={currentSmartTransactionsEnabled}
|
|
||||||
smartTransactionsOptInStatus={smartTransactionsOptInStatus}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@ -999,7 +968,5 @@ export default function ViewQuote() {
|
|||||||
showTopBorder
|
showTopBorder
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</TransactionModalContextProvider>
|
|
||||||
</GasFeeContextProvider>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user