From dfbb829fe4d850ab0755c15e96af32bd9efb5450 Mon Sep 17 00:00:00 2001 From: Cal Leung Date: Sat, 4 Sep 2021 02:41:56 -0700 Subject: [PATCH] Catch undefined navigate on buy eth --- app/components/UI/ApproveTransactionReview/index.js | 6 +++++- app/components/UI/Swaps/QuotesView.js | 7 ++++++- .../TransactionReviewInformation/index.js | 7 ++++++- app/components/Views/SendFlow/Confirm/index.js | 6 +++++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/components/UI/ApproveTransactionReview/index.js b/app/components/UI/ApproveTransactionReview/index.js index 5643a125efe..5e3fc6f5ce1 100644 --- a/app/components/UI/ApproveTransactionReview/index.js +++ b/app/components/UI/ApproveTransactionReview/index.js @@ -689,7 +689,11 @@ class ApproveTransactionReview extends PureComponent { const { navigation } = this.props; /* this is kinda weird, we have to reject the transaction to collapse the modal */ this.onCancelPress(); - navigation.navigate('FiatOnRamp'); + try { + navigation.navigate('FiatOnRamp'); + } catch (error) { + Logger.error(error, 'Navigation: Error when navigating to buy ETH.'); + } InteractionManager.runAfterInteractions(() => { Analytics.trackEvent(ANALYTICS_EVENT_OPTS.RECEIVE_OPTIONS_PAYMENT_REQUEST); }); diff --git a/app/components/UI/Swaps/QuotesView.js b/app/components/UI/Swaps/QuotesView.js index a86d192a1b2..2fa25eec064 100644 --- a/app/components/UI/Swaps/QuotesView.js +++ b/app/components/UI/Swaps/QuotesView.js @@ -55,6 +55,7 @@ import { toLowerCaseEquals } from '../../../util/general'; import { swapsTokensSelector } from '../../../reducers/swaps'; import { decGWEIToHexWEI } from '../../../util/conversions'; import FadeAnimationView from '../FadeAnimationView'; +import Logger from '../../../util/Logger'; const POLLING_INTERVAL = 30000; const SLIPPAGE_BUCKETS = { @@ -883,7 +884,11 @@ function SwapsQuotesView({ }, [selectedQuote]); const buyEth = useCallback(() => { - navigation.navigate('FiatOnRamp'); + try { + navigation.navigate('FiatOnRamp'); + } catch (error) { + Logger.error(error, 'Navigation: Error when navigating to buy ETH.'); + } InteractionManager.runAfterInteractions(() => { Analytics.trackEvent(ANALYTICS_EVENT_OPTS.RECEIVE_OPTIONS_PAYMENT_REQUEST); }); diff --git a/app/components/UI/TransactionReview/TransactionReviewInformation/index.js b/app/components/UI/TransactionReview/TransactionReviewInformation/index.js index f956ac6a330..1e572747b26 100644 --- a/app/components/UI/TransactionReview/TransactionReviewInformation/index.js +++ b/app/components/UI/TransactionReview/TransactionReviewInformation/index.js @@ -31,6 +31,7 @@ import { setNonce, setProposedNonce } from '../../../../actions/transaction'; import TransactionReviewEIP1559 from '../TransactionReviewEIP1559'; import { GAS_ESTIMATE_TYPES } from '@metamask/controllers'; import CustomNonce from '../../../UI/CustomNonce'; +import Logger from '../../../../util/Logger'; const styles = StyleSheet.create({ overviewAlert: { @@ -241,7 +242,11 @@ class TransactionReviewInformation extends PureComponent { const { navigation } = this.props; /* this is kinda weird, we have to reject the transaction to collapse the modal */ this.onCancelPress(); - navigation.navigate('FiatOnRamp'); + try { + navigation.navigate('FiatOnRamp'); + } catch (error) { + Logger.error(error, 'Navigation: Error when navigating to buy ETH.'); + } InteractionManager.runAfterInteractions(() => { Analytics.trackEvent(ANALYTICS_EVENT_OPTS.RECEIVE_OPTIONS_PAYMENT_REQUEST); }); diff --git a/app/components/Views/SendFlow/Confirm/index.js b/app/components/Views/SendFlow/Confirm/index.js index 61fa8403b39..2b2de4cd9aa 100644 --- a/app/components/Views/SendFlow/Confirm/index.js +++ b/app/components/Views/SendFlow/Confirm/index.js @@ -1142,7 +1142,11 @@ class Confirm extends PureComponent { buyEth = () => { const { navigation } = this.props; - navigation.navigate('FiatOnRamp'); + try { + navigation.navigate('FiatOnRamp'); + } catch (error) { + Logger.error(error, 'Navigation: Error when navigating to buy ETH.'); + } InteractionManager.runAfterInteractions(() => { Analytics.trackEvent(ANALYTICS_EVENT_OPTS.RECEIVE_OPTIONS_PAYMENT_REQUEST); });