mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Swaps: Add specific error content if Contract data are not enabled on Ledger (#11088)
This commit is contained in:
parent
79e79e9212
commit
3f70afb3ff
@ -1836,6 +1836,12 @@
|
||||
"swapConfirmWithHwWallet": {
|
||||
"message": "Confirm with your hardware wallet"
|
||||
},
|
||||
"swapContractDataDisabledErrorDescription": {
|
||||
"message": "In the Ethereum app on your Ledger, go to \"Settings\" and allow contract data. Then, try your swap again."
|
||||
},
|
||||
"swapContractDataDisabledErrorTitle": {
|
||||
"message": "Contract data is not enabled on your Ledger"
|
||||
},
|
||||
"swapCustom": {
|
||||
"message": "custom"
|
||||
},
|
||||
|
@ -12,6 +12,7 @@ export const QUOTES_EXPIRED_ERROR = 'quotes-expired';
|
||||
export const SWAP_FAILED_ERROR = 'swap-failed-error';
|
||||
export const ERROR_FETCHING_QUOTES = 'error-fetching-quotes';
|
||||
export const QUOTES_NOT_AVAILABLE_ERROR = 'quotes-not-avilable';
|
||||
export const CONTRACT_DATA_DISABLED_ERROR = 'contract-data-disabled';
|
||||
export const OFFLINE_FOR_MAINTENANCE = 'offline-for-maintenance';
|
||||
export const SWAPS_FETCH_ORDER_CONFLICT = 'swaps-fetch-order-conflict';
|
||||
|
||||
|
@ -59,6 +59,7 @@ import {
|
||||
import {
|
||||
ERROR_FETCHING_QUOTES,
|
||||
QUOTES_NOT_AVAILABLE_ERROR,
|
||||
CONTRACT_DATA_DISABLED_ERROR,
|
||||
SWAP_FAILED_ERROR,
|
||||
SWAPS_FETCH_ORDER_CONFLICT,
|
||||
} from '../../../shared/constants/swaps';
|
||||
@ -785,7 +786,10 @@ export const signAndSendTransactions = (history, metaMetricsEvent) => {
|
||||
try {
|
||||
await dispatch(updateAndApproveTx(finalTradeTxMeta, true));
|
||||
} catch (e) {
|
||||
await dispatch(setSwapsErrorKey(SWAP_FAILED_ERROR));
|
||||
const errorKey = e.message.includes('EthAppPleaseEnableContractData')
|
||||
? CONTRACT_DATA_DISABLED_ERROR
|
||||
: SWAP_FAILED_ERROR;
|
||||
await dispatch(setSwapsErrorKey(errorKey));
|
||||
history.push(SWAPS_ERROR_ROUTE);
|
||||
return;
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ import {
|
||||
SWAP_FAILED_ERROR,
|
||||
ERROR_FETCHING_QUOTES,
|
||||
QUOTES_NOT_AVAILABLE_ERROR,
|
||||
CONTRACT_DATA_DISABLED_ERROR,
|
||||
OFFLINE_FOR_MAINTENANCE,
|
||||
SWAPS_CHAINID_DEFAULT_BLOCK_EXPLORER_URL_MAP,
|
||||
} from '../../../../shared/constants/swaps';
|
||||
@ -184,6 +185,11 @@ export default function AwaitingSwap({
|
||||
descriptionText = t('swapQuotesNotAvailableErrorDescription');
|
||||
submitText = t('tryAgain');
|
||||
statusImage = <SwapFailureIcon />;
|
||||
} else if (errorKey === CONTRACT_DATA_DISABLED_ERROR) {
|
||||
headerText = t('swapContractDataDisabledErrorTitle');
|
||||
descriptionText = t('swapContractDataDisabledErrorDescription');
|
||||
submitText = t('tryAgain');
|
||||
statusImage = <SwapFailureIcon />;
|
||||
} else if (!errorKey && !swapComplete) {
|
||||
headerText = t('swapProcessing');
|
||||
statusImage = <PulseLoader />;
|
||||
@ -283,6 +289,7 @@ AwaitingSwap.propTypes = {
|
||||
ERROR_FETCHING_QUOTES,
|
||||
QUOTES_NOT_AVAILABLE_ERROR,
|
||||
OFFLINE_FOR_MAINTENANCE,
|
||||
CONTRACT_DATA_DISABLED_ERROR,
|
||||
]),
|
||||
submittingSwap: PropTypes.bool,
|
||||
inputValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
|
@ -48,6 +48,7 @@ import {
|
||||
ERROR_FETCHING_QUOTES,
|
||||
QUOTES_NOT_AVAILABLE_ERROR,
|
||||
SWAP_FAILED_ERROR,
|
||||
CONTRACT_DATA_DISABLED_ERROR,
|
||||
OFFLINE_FOR_MAINTENANCE,
|
||||
} from '../../../shared/constants/swaps';
|
||||
|
||||
@ -136,7 +137,7 @@ export default function Swap() {
|
||||
tradeTxData?.txReceipt?.status === '0x0';
|
||||
const conversionError = approveError || tradeError;
|
||||
|
||||
if (conversionError) {
|
||||
if (conversionError && swapsErrorKey !== CONTRACT_DATA_DISABLED_ERROR) {
|
||||
swapsErrorKey = SWAP_FAILED_ERROR;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user