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

feature/default_network_editable
Daniel 4 years ago committed by Dan Miller
parent 79e79e9212
commit 3f70afb3ff
  1. 6
      app/_locales/en/messages.json
  2. 1
      shared/constants/swaps.js
  3. 6
      ui/ducks/swaps/swaps.js
  4. 7
      ui/pages/swaps/awaiting-swap/awaiting-swap.js
  5. 3
      ui/pages/swaps/index.js

@ -1836,6 +1836,12 @@
"swapConfirmWithHwWallet": { "swapConfirmWithHwWallet": {
"message": "Confirm with your hardware wallet" "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": { "swapCustom": {
"message": "custom" "message": "custom"
}, },

@ -12,6 +12,7 @@ export const QUOTES_EXPIRED_ERROR = 'quotes-expired';
export const SWAP_FAILED_ERROR = 'swap-failed-error'; export const SWAP_FAILED_ERROR = 'swap-failed-error';
export const ERROR_FETCHING_QUOTES = 'error-fetching-quotes'; export const ERROR_FETCHING_QUOTES = 'error-fetching-quotes';
export const QUOTES_NOT_AVAILABLE_ERROR = 'quotes-not-avilable'; 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 OFFLINE_FOR_MAINTENANCE = 'offline-for-maintenance';
export const SWAPS_FETCH_ORDER_CONFLICT = 'swaps-fetch-order-conflict'; export const SWAPS_FETCH_ORDER_CONFLICT = 'swaps-fetch-order-conflict';

@ -59,6 +59,7 @@ import {
import { import {
ERROR_FETCHING_QUOTES, ERROR_FETCHING_QUOTES,
QUOTES_NOT_AVAILABLE_ERROR, QUOTES_NOT_AVAILABLE_ERROR,
CONTRACT_DATA_DISABLED_ERROR,
SWAP_FAILED_ERROR, SWAP_FAILED_ERROR,
SWAPS_FETCH_ORDER_CONFLICT, SWAPS_FETCH_ORDER_CONFLICT,
} from '../../../shared/constants/swaps'; } from '../../../shared/constants/swaps';
@ -785,7 +786,10 @@ export const signAndSendTransactions = (history, metaMetricsEvent) => {
try { try {
await dispatch(updateAndApproveTx(finalTradeTxMeta, true)); await dispatch(updateAndApproveTx(finalTradeTxMeta, true));
} catch (e) { } 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); history.push(SWAPS_ERROR_ROUTE);
return; return;
} }

@ -33,6 +33,7 @@ import {
SWAP_FAILED_ERROR, SWAP_FAILED_ERROR,
ERROR_FETCHING_QUOTES, ERROR_FETCHING_QUOTES,
QUOTES_NOT_AVAILABLE_ERROR, QUOTES_NOT_AVAILABLE_ERROR,
CONTRACT_DATA_DISABLED_ERROR,
OFFLINE_FOR_MAINTENANCE, OFFLINE_FOR_MAINTENANCE,
SWAPS_CHAINID_DEFAULT_BLOCK_EXPLORER_URL_MAP, SWAPS_CHAINID_DEFAULT_BLOCK_EXPLORER_URL_MAP,
} from '../../../../shared/constants/swaps'; } from '../../../../shared/constants/swaps';
@ -184,6 +185,11 @@ export default function AwaitingSwap({
descriptionText = t('swapQuotesNotAvailableErrorDescription'); descriptionText = t('swapQuotesNotAvailableErrorDescription');
submitText = t('tryAgain'); submitText = t('tryAgain');
statusImage = <SwapFailureIcon />; statusImage = <SwapFailureIcon />;
} else if (errorKey === CONTRACT_DATA_DISABLED_ERROR) {
headerText = t('swapContractDataDisabledErrorTitle');
descriptionText = t('swapContractDataDisabledErrorDescription');
submitText = t('tryAgain');
statusImage = <SwapFailureIcon />;
} else if (!errorKey && !swapComplete) { } else if (!errorKey && !swapComplete) {
headerText = t('swapProcessing'); headerText = t('swapProcessing');
statusImage = <PulseLoader />; statusImage = <PulseLoader />;
@ -283,6 +289,7 @@ AwaitingSwap.propTypes = {
ERROR_FETCHING_QUOTES, ERROR_FETCHING_QUOTES,
QUOTES_NOT_AVAILABLE_ERROR, QUOTES_NOT_AVAILABLE_ERROR,
OFFLINE_FOR_MAINTENANCE, OFFLINE_FOR_MAINTENANCE,
CONTRACT_DATA_DISABLED_ERROR,
]), ]),
submittingSwap: PropTypes.bool, submittingSwap: PropTypes.bool,
inputValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), inputValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),

@ -48,6 +48,7 @@ import {
ERROR_FETCHING_QUOTES, ERROR_FETCHING_QUOTES,
QUOTES_NOT_AVAILABLE_ERROR, QUOTES_NOT_AVAILABLE_ERROR,
SWAP_FAILED_ERROR, SWAP_FAILED_ERROR,
CONTRACT_DATA_DISABLED_ERROR,
OFFLINE_FOR_MAINTENANCE, OFFLINE_FOR_MAINTENANCE,
} from '../../../shared/constants/swaps'; } from '../../../shared/constants/swaps';
@ -136,7 +137,7 @@ export default function Swap() {
tradeTxData?.txReceipt?.status === '0x0'; tradeTxData?.txReceipt?.status === '0x0';
const conversionError = approveError || tradeError; const conversionError = approveError || tradeError;
if (conversionError) { if (conversionError && swapsErrorKey !== CONTRACT_DATA_DISABLED_ERROR) {
swapsErrorKey = SWAP_FAILED_ERROR; swapsErrorKey = SWAP_FAILED_ERROR;
} }

Loading…
Cancel
Save