aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/instant/src')
-rw-r--r--packages/instant/src/components/buy_button.tsx14
-rw-r--r--packages/instant/src/constants.ts1
-rw-r--r--packages/instant/src/containers/selected_asset_buy_order_state_buttons.ts3
-rw-r--r--packages/instant/src/types.ts2
-rw-r--r--packages/instant/src/util/analytics.ts6
-rw-r--r--packages/instant/src/util/env.ts2
6 files changed, 24 insertions, 4 deletions
diff --git a/packages/instant/src/components/buy_button.tsx b/packages/instant/src/components/buy_button.tsx
index 1489b94d4..5c9c28ae4 100644
--- a/packages/instant/src/components/buy_button.tsx
+++ b/packages/instant/src/components/buy_button.tsx
@@ -10,6 +10,7 @@ import { WEB_3_WRAPPER_TRANSACTION_FAILED_ERROR_MSG_PREFIX } from '../constants'
import { ColorOption } from '../style/theme';
import { AffiliateInfo, Asset, ZeroExInstantError } from '../types';
import { analytics } from '../util/analytics';
+import { errorReporter } from '../util/error_reporter';
import { gasPriceEstimator } from '../util/gas_price_estimator';
import { util } from '../util/util';
@@ -82,13 +83,18 @@ export class BuyButton extends React.Component<BuyButtonProps> {
});
} catch (e) {
if (e instanceof Error) {
- if (e.message === AssetBuyerError.SignatureRequestDenied) {
+ if (e.message === AssetBuyerError.TransactionValueTooLow) {
+ analytics.trackBuySimulationFailed(buyQuote);
+ this.props.onValidationFail(buyQuote, AssetBuyerError.TransactionValueTooLow);
+ return;
+ } else if (e.message === AssetBuyerError.SignatureRequestDenied) {
analytics.trackBuySignatureDenied(buyQuote);
this.props.onSignatureDenied(buyQuote);
return;
- } else if (e.message === AssetBuyerError.TransactionValueTooLow) {
- analytics.trackBuySimulationFailed(buyQuote);
- this.props.onValidationFail(buyQuote, AssetBuyerError.TransactionValueTooLow);
+ } else {
+ errorReporter.report(e);
+ analytics.trackBuyUnknownError(buyQuote, e.message);
+ this.props.onValidationFail(buyQuote, ZeroExInstantError.CouldNotSubmitTransaction);
return;
}
}
diff --git a/packages/instant/src/constants.ts b/packages/instant/src/constants.ts
index 975dfcbea..22f0cb6a4 100644
--- a/packages/instant/src/constants.ts
+++ b/packages/instant/src/constants.ts
@@ -72,5 +72,6 @@ export const PROVIDER_TYPE_TO_NAME: { [key in ProviderType]: string } = {
[ProviderType.Mist]: 'Mist',
[ProviderType.CoinbaseWallet]: 'Coinbase Wallet',
[ProviderType.Parity]: 'Parity',
+ [ProviderType.TrustWallet]: 'Trust Wallet',
[ProviderType.Fallback]: 'Fallback',
};
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 e7c920f36..ae672c919 100644
--- a/packages/instant/src/types.ts
+++ b/packages/instant/src/types.ts
@@ -96,6 +96,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;
@@ -181,6 +182,7 @@ export enum ProviderType {
Mist = 'MIST',
CoinbaseWallet = 'COINBASE_WALLET',
Cipher = 'CIPHER',
+ TrustWallet = 'TRUST_WALLET',
Fallback = 'FALLBACK',
}
diff --git a/packages/instant/src/util/analytics.ts b/packages/instant/src/util/analytics.ts
index 6c63907dc..4faeaaf5a 100644
--- a/packages/instant/src/util/analytics.ts
+++ b/packages/instant/src/util/analytics.ts
@@ -46,6 +46,7 @@ enum EventNames {
BUY_STARTED = 'Buy - Started',
BUY_SIGNATURE_DENIED = 'Buy - Signature Denied',
BUY_SIMULATION_FAILED = 'Buy - Simulation Failed',
+ BUY_UNKNOWN_ERROR = 'Buy - Unknown Error',
BUY_TX_SUBMITTED = 'Buy - Tx Submitted',
BUY_TX_SUCCEEDED = 'Buy - Tx Succeeded',
BUY_TX_FAILED = 'Buy - Tx Failed',
@@ -189,6 +190,11 @@ export const analytics = {
trackingEventFnWithPayload(EventNames.BUY_SIGNATURE_DENIED)(buyQuoteEventProperties(buyQuote)),
trackBuySimulationFailed: (buyQuote: BuyQuote) =>
trackingEventFnWithPayload(EventNames.BUY_SIMULATION_FAILED)(buyQuoteEventProperties(buyQuote)),
+ trackBuyUnknownError: (buyQuote: BuyQuote, errorMessage: string) =>
+ trackingEventFnWithPayload(EventNames.BUY_UNKNOWN_ERROR)({
+ ...buyQuoteEventProperties(buyQuote),
+ errorMessage,
+ }),
trackBuyTxSubmitted: (buyQuote: BuyQuote, txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) =>
trackingEventFnWithPayload(EventNames.BUY_TX_SUBMITTED)({
...buyQuoteEventProperties(buyQuote),
diff --git a/packages/instant/src/util/env.ts b/packages/instant/src/util/env.ts
index 0fda0cc0e..aedf4f5d6 100644
--- a/packages/instant/src/util/env.ts
+++ b/packages/instant/src/util/env.ts
@@ -44,6 +44,8 @@ export const envUtil = {
getProviderType(provider: Provider): ProviderType | undefined {
if (provider.constructor.name === 'EthereumProvider') {
return ProviderType.Mist;
+ } else if ((provider as any).isTrust) {
+ return ProviderType.TrustWallet;
} else if ((provider as any).isParity) {
return ProviderType.Parity;
} else if ((provider as any).isMetaMask) {