aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/containers
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-10-30 01:26:27 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-10-30 01:37:56 +0800
commitaab9bedd7fe1ab328e416024b6397f242d39d84f (patch)
tree5ffa6dc9d737d5dddd1b16c4ecb6fb65e6e85ee4 /packages/instant/src/containers
parent8d1689073b702d973075d30b2bb36369487fad1c (diff)
parent4e4291eccdd6c837bbec70603aa6eb64d3aa8d85 (diff)
downloaddexon-sol-tools-aab9bedd7fe1ab328e416024b6397f242d39d84f.tar
dexon-sol-tools-aab9bedd7fe1ab328e416024b6397f242d39d84f.tar.gz
dexon-sol-tools-aab9bedd7fe1ab328e416024b6397f242d39d84f.tar.bz2
dexon-sol-tools-aab9bedd7fe1ab328e416024b6397f242d39d84f.tar.lz
dexon-sol-tools-aab9bedd7fe1ab328e416024b6397f242d39d84f.tar.xz
dexon-sol-tools-aab9bedd7fe1ab328e416024b6397f242d39d84f.tar.zst
dexon-sol-tools-aab9bedd7fe1ab328e416024b6397f242d39d84f.zip
Merge branch 'development' into feature/instant/fixed-orders-in-render-method
* development: Has Sufficient Funds/Balance -> Has Sufficient ETH When transaction too low, treat as validation error. also modify callback: errorMessage could be AssetBuyError as well onPendingValidation -> onValidationPending linting Simpler way of validaitng has enough eth questionmark syntax instead of '| undefined' Validate enough ETH when user clicks buy acccount for no address move funct into util move imports yarn.lock changes feat(instant): Show message if user doesn't have enough ETH ethDecimals -> ETH_DECIMALS
Diffstat (limited to 'packages/instant/src/containers')
-rw-r--r--packages/instant/src/containers/selected_asset_buy_order_state_buttons.ts23
-rw-r--r--packages/instant/src/containers/selected_erc20_asset_amount_input.ts3
2 files changed, 17 insertions, 9 deletions
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 10734df96..500d6b88a 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
@@ -1,17 +1,16 @@
-import { AssetBuyer, BuyQuote } from '@0x/asset-buyer';
+import { AssetBuyer, AssetBuyerError, BuyQuote } from '@0x/asset-buyer';
import * as _ from 'lodash';
import * as React from 'react';
import { connect } from 'react-redux';
import { Dispatch } from 'redux';
+import { BuyOrderStateButtons } from '../components/buy_order_state_buttons';
import { Action, actions } from '../redux/actions';
import { State } from '../redux/reducer';
-import { OrderProcessState, OrderState } from '../types';
+import { OrderProcessState, OrderState, ZeroExInstantError } from '../types';
import { errorFlasher } from '../util/error_flasher';
import { etherscanUtil } from '../util/etherscan';
-import { BuyOrderStateButtons } from '../components/buy_order_state_buttons';
-
interface ConnectedState {
buyQuote?: BuyQuote;
buyOrderProcessingState: OrderProcessState;
@@ -20,12 +19,13 @@ interface ConnectedState {
}
interface ConnectedDispatch {
- onAwaitingSignature: (buyQuote: BuyQuote) => void;
+ onValidationPending: (buyQuote: BuyQuote) => void;
onSignatureDenied: (buyQuote: BuyQuote) => void;
onBuyProcessing: (buyQuote: BuyQuote, txHash: string) => void;
onBuySuccess: (buyQuote: BuyQuote, txHash: string) => void;
onBuyFailure: (buyQuote: BuyQuote, txHash: string) => void;
onRetry: () => void;
+ onValidationFail: (buyQuote: BuyQuote, errorMessage: AssetBuyerError | ZeroExInstantError) => void;
}
export interface SelectedAssetBuyOrderStateButtons {}
const mapStateToProps = (state: State, _ownProps: SelectedAssetBuyOrderStateButtons): ConnectedState => ({
@@ -55,8 +55,8 @@ const mapDispatchToProps = (
dispatch: Dispatch<Action>,
ownProps: SelectedAssetBuyOrderStateButtons,
): ConnectedDispatch => ({
- onAwaitingSignature: (buyQuote: BuyQuote) => {
- const newOrderState: OrderState = { processState: OrderProcessState.AWAITING_SIGNATURE };
+ onValidationPending: (buyQuote: BuyQuote) => {
+ const newOrderState: OrderState = { processState: OrderProcessState.VALIDATING };
dispatch(actions.updateBuyOrderState(newOrderState));
},
onBuyProcessing: (buyQuote: BuyQuote, txHash: string) => {
@@ -72,6 +72,15 @@ const mapDispatchToProps = (
const errorMessage = 'You denied this transaction';
errorFlasher.flashNewErrorMessage(dispatch, errorMessage);
},
+ onValidationFail: (buyQuote, error) => {
+ dispatch(actions.updateBuyOrderState({ processState: OrderProcessState.NONE }));
+ if (error === ZeroExInstantError.InsufficientETH) {
+ const errorMessage = "You don't have enough ETH";
+ errorFlasher.flashNewErrorMessage(dispatch, errorMessage);
+ } else {
+ errorFlasher.flashNewErrorMessage(dispatch);
+ }
+ },
onRetry: () => {
dispatch(actions.resetAmount());
},
diff --git a/packages/instant/src/containers/selected_erc20_asset_amount_input.ts b/packages/instant/src/containers/selected_erc20_asset_amount_input.ts
index 1e93a6deb..4767b15d4 100644
--- a/packages/instant/src/containers/selected_erc20_asset_amount_input.ts
+++ b/packages/instant/src/containers/selected_erc20_asset_amount_input.ts
@@ -7,6 +7,7 @@ import * as React from 'react';
import { connect } from 'react-redux';
import { Dispatch } from 'redux';
+import { ERC20AssetAmountInput } from '../components/erc20_asset_amount_input';
import { Action, actions } from '../redux/actions';
import { State } from '../redux/reducer';
import { ColorOption } from '../style/theme';
@@ -15,8 +16,6 @@ import { assetUtils } from '../util/asset';
import { BigNumberInput } from '../util/big_number_input';
import { errorFlasher } from '../util/error_flasher';
-import { ERC20AssetAmountInput } from '../components/erc20_asset_amount_input';
-
export interface SelectedERC20AssetAmountInputProps {
fontColor?: ColorOption;
startingFontSizePx: number;