diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-12-21 06:32:11 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-12-21 06:32:11 +0800 |
commit | 080c6d3146bee3691b6f3b9452be639354236e44 (patch) | |
tree | 048ebf24cf6d6f521801675ede166e70be1e62b7 /packages/instant/src | |
parent | 2effc3e267f01e620c50622138d98381883d4c32 (diff) | |
download | dexon-sol-tools-080c6d3146bee3691b6f3b9452be639354236e44.tar dexon-sol-tools-080c6d3146bee3691b6f3b9452be639354236e44.tar.gz dexon-sol-tools-080c6d3146bee3691b6f3b9452be639354236e44.tar.bz2 dexon-sol-tools-080c6d3146bee3691b6f3b9452be639354236e44.tar.lz dexon-sol-tools-080c6d3146bee3691b6f3b9452be639354236e44.tar.xz dexon-sol-tools-080c6d3146bee3691b6f3b9452be639354236e44.tar.zst dexon-sol-tools-080c6d3146bee3691b6f3b9452be639354236e44.zip |
fix(instant): catch unknown errors from executeBuyAsync, report them and show could not submit transaction
Diffstat (limited to 'packages/instant/src')
-rw-r--r-- | packages/instant/src/components/buy_button.tsx | 9 | ||||
-rw-r--r-- | packages/instant/src/containers/selected_asset_buy_order_state_buttons.ts | 3 | ||||
-rw-r--r-- | packages/instant/src/types.ts | 1 |
3 files changed, 9 insertions, 4 deletions
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<BuyButtonProps> { 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; |