1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 11:22:43 +02:00

Swaps: Add specific error content if Contract data are not enabled on Ledger (#11088)

This commit is contained in:
Daniel 2021-05-13 21:49:00 +02:00 committed by GitHub
parent a174e3b99a
commit 85eb62e8cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 2 deletions

View File

@ -1820,6 +1820,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"
},

View File

@ -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';

View File

@ -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;
}

View File

@ -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]),

View File

@ -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;
}