From 02e21141c67b888a13ca774c820110ebe6b8b970 Mon Sep 17 00:00:00 2001 From: David Sun Date: Sun, 5 Jan 2020 19:00:59 -0800 Subject: [PATCH] added minor polish + bug fixes --- .../instant/src/components/buy_button.tsx | 8 +++ .../instant/src/components/order_details.tsx | 3 +- .../instant/src/components/payment_method.tsx | 52 +++++++------------ packages/instant/src/redux/reducer.ts | 7 --- .../src/util/provider_state_factory.ts | 1 - .../instant/src/util/swap_quote_updater.ts | 1 - 6 files changed, 29 insertions(+), 43 deletions(-) diff --git a/packages/instant/src/components/buy_button.tsx b/packages/instant/src/components/buy_button.tsx index cfd7a76cb8..677bd53d11 100644 --- a/packages/instant/src/components/buy_button.tsx +++ b/packages/instant/src/components/buy_button.tsx @@ -132,6 +132,14 @@ export class BuyButton extends React.PureComponent { this.props.onSignatureDenied(swapQuote); return; } + // Fortmatic specific error handling + if (e.message && e.message.includes('Fortmatic:')) { + if (e.message.includes('User denied transaction.')) { + analytics.trackBuySignatureDenied(swapQuote); + this.props.onSignatureDenied(swapQuote); + return; + } + } throw e; } const startTimeUnix = new Date().getTime(); diff --git a/packages/instant/src/components/order_details.tsx b/packages/instant/src/components/order_details.tsx index 4c693385bd..b0df6297c9 100644 --- a/packages/instant/src/components/order_details.tsx +++ b/packages/instant/src/components/order_details.tsx @@ -6,7 +6,7 @@ import { oc } from 'ts-optchain'; import { BIG_NUMBER_ZERO, DEFAULT_UNKOWN_ASSET_NAME } from '../constants'; import { ColorOption } from '../style/theme'; -import {Account, AccountState, BaseCurrency} from '../types'; +import { Account, AccountState, BaseCurrency } from '../types'; import { format } from '../util/format'; import { AmountPlaceholder } from './amount_placeholder'; @@ -45,7 +45,6 @@ export class OrderDetails extends React.PureComponent { private _renderRows(): React.ReactNode { const { swapQuoteInfo } = this.props; - console.log(swapQuoteInfo); return ( { return 'payment method'; } }; - private readonly _renderTitleLabel = (): React.ReactNode => { - const { account } = this.props; - if (account.state === AccountState.Ready || account.state === AccountState.Locked) { - const circleColor: ColorOption = account.state === AccountState.Ready ? ColorOption.green : ColorOption.red; - return ( - - - - - {this.props.walletDisplayName} - - - - ); - } - return null; - }; private readonly _renderMainContent = (): React.ReactNode => { const { account, network } = this.props; const isMobile = envUtil.isMobileOperatingSystem(); @@ -93,12 +74,12 @@ export class PaymentMethod extends React.PureComponent { padding="15px 18px" image={ - {metamaskLogo} + {logo} } {...colors} > - Metamask + {isMobile ? 'Coinbase Wallet' : 'MetaMask'} { case AccountState.None: return ( - + {isMobile ? 'Install Coinbase Wallet' : 'Install MetaMask'} { const newSwapQuoteIfExists = action.data; const shouldUpdate = newSwapQuoteIfExists === undefined || doesSwapQuoteMatchState(newSwapQuoteIfExists, state); - console.log('shouldUpdate', newSwapQuoteIfExists, shouldUpdate); if (shouldUpdate) { return { ...state, @@ -281,13 +280,9 @@ const doesSwapQuoteMatchState = (swapQuote: MarketBuySwapQuote, state: State): b const selectedAssetIfExists = state.selectedAsset; const selectedAssetUnitAmountIfExists = state.selectedAssetUnitAmount; // if no selectedAsset or selectedAssetAmount exists on the current state, return false - console.log('hmmmm?'); if (selectedAssetIfExists === undefined || selectedAssetUnitAmountIfExists === undefined) { return false; } - console.log('lol wut', selectedAssetIfExists.assetData); - console.log(selectedAssetIfExists.assetData); - console.log(swapQuote.makerAssetData); // if swapQuote's assetData does not match that of the current selected asset, return false if (selectedAssetIfExists.assetData !== swapQuote.makerAssetData) { return false; @@ -295,14 +290,12 @@ const doesSwapQuoteMatchState = (swapQuote: MarketBuySwapQuote, state: State): b // if ERC20 and swapQuote's makerAssetFillAmount does not match selectedAssetAmount, return false // if ERC721, return true const selectedAssetMetaData = selectedAssetIfExists.metaData; - console.log('here then'); if (selectedAssetMetaData.assetProxyId === AssetProxyId.ERC20) { const selectedAssetAmountBaseUnits = Web3Wrapper.toBaseUnitAmount( selectedAssetUnitAmountIfExists, selectedAssetMetaData.decimals, ); const doesAssetAmountMatch = selectedAssetAmountBaseUnits.eq(swapQuote.makerAssetFillAmount); - console.log('doesAssetAmountMatch', doesAssetAmountMatch); return doesAssetAmountMatch; } else { return true; diff --git a/packages/instant/src/util/provider_state_factory.ts b/packages/instant/src/util/provider_state_factory.ts index 65cf36e67b..4f63d49486 100644 --- a/packages/instant/src/util/provider_state_factory.ts +++ b/packages/instant/src/util/provider_state_factory.ts @@ -100,7 +100,6 @@ export const providerStateFactory = { providerType: ProviderType, ): ProviderState => { let providerState = currentProviderState; - console.log('lets see', providerState, providerType); const chainId = currentProviderState.swapQuoter.chainId; const orderSource = currentProviderState.orderSource; // Returns current provider if the provider type selected is not found diff --git a/packages/instant/src/util/swap_quote_updater.ts b/packages/instant/src/util/swap_quote_updater.ts index f26bc499d6..88f9b04188 100644 --- a/packages/instant/src/util/swap_quote_updater.ts +++ b/packages/instant/src/util/swap_quote_updater.ts @@ -69,7 +69,6 @@ export const swapQuoteUpdater = { // We have a successful new swap quote errorFlasher.clearError(dispatch); // invalidate the last swap quote. - console.log('newSwapQuote', newSwapQuote); dispatch(actions.updateLatestSwapQuote(newSwapQuote)); analytics.trackQuoteFetched(newSwapQuote, fetchOrigin); },