From 080c6d3146bee3691b6f3b9452be639354236e44 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Thu, 20 Dec 2018 14:32:11 -0800 Subject: fix(instant): catch unknown errors from executeBuyAsync, report them and show could not submit transaction --- packages/instant/src/components/buy_button.tsx | 9 +++++---- .../src/containers/selected_asset_buy_order_state_buttons.ts | 3 +++ packages/instant/src/types.ts | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'packages/instant/src') diff --git a/packages/instant/src/components/buy_button.tsx b/packages/instant/src/components/buy_button.tsx index 880303cc7..ff1cda1e1 100644 --- a/packages/instant/src/components/buy_button.tsx +++ b/packages/instant/src/components/buy_button.tsx @@ -87,13 +87,14 @@ export class BuyButton extends React.Component { analytics.trackBuySimulationFailed(buyQuote); this.props.onValidationFail(buyQuote, AssetBuyerError.TransactionValueTooLow); return; - } else { - if (e.message !== AssetBuyerError.SignatureRequestDenied) { - errorReporter.report(e); - } + } else if (e.message === AssetBuyerError.SignatureRequestDenied) { analytics.trackBuySignatureDenied(buyQuote); this.props.onSignatureDenied(buyQuote); return; + } else { + errorReporter.report(e); + this.props.onValidationFail(buyQuote, ZeroExInstantError.CouldNotSubmitTransaction); + return; } } throw e; diff --git a/packages/instant/src/containers/selected_asset_buy_order_state_buttons.ts b/packages/instant/src/containers/selected_asset_buy_order_state_buttons.ts index 80943a96f..4da99cf04 100644 --- a/packages/instant/src/containers/selected_asset_buy_order_state_buttons.ts +++ b/packages/instant/src/containers/selected_asset_buy_order_state_buttons.ts @@ -95,6 +95,9 @@ const mapDispatchToProps = ( if (error === ZeroExInstantError.InsufficientETH) { const errorMessage = "You don't have enough ETH"; errorFlasher.flashNewErrorMessage(dispatch, errorMessage); + } else if (error === ZeroExInstantError.CouldNotSubmitTransaction) { + const errorMessage = 'Could not submit transaction'; + errorFlasher.flashNewErrorMessage(dispatch, errorMessage); } else { errorFlasher.flashNewErrorMessage(dispatch); } diff --git a/packages/instant/src/types.ts b/packages/instant/src/types.ts index 6374dda09..d217c1a4f 100644 --- a/packages/instant/src/types.ts +++ b/packages/instant/src/types.ts @@ -91,6 +91,7 @@ export enum Network { export enum ZeroExInstantError { AssetMetaDataNotAvailable = 'ASSET_META_DATA_NOT_AVAILABLE', InsufficientETH = 'INSUFFICIENT_ETH', + CouldNotSubmitTransaction = 'COULD_NOT_SUBMIT_TRANSACTION', } export type SimpleHandler = () => void; -- cgit v1.2.3