diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-10-27 10:53:15 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-10-27 10:53:15 +0800 |
commit | ff295daa5c56b5c056a5faa5ca8875c317524070 (patch) | |
tree | 96e6ee707cf75e3272d90d44a8c8cf1b0567a5ce /packages/instant/src/containers | |
parent | bb307a55d347c34ab51144c75721860e13659ecb (diff) | |
download | dexon-sol-tools-ff295daa5c56b5c056a5faa5ca8875c317524070.tar dexon-sol-tools-ff295daa5c56b5c056a5faa5ca8875c317524070.tar.gz dexon-sol-tools-ff295daa5c56b5c056a5faa5ca8875c317524070.tar.bz2 dexon-sol-tools-ff295daa5c56b5c056a5faa5ca8875c317524070.tar.lz dexon-sol-tools-ff295daa5c56b5c056a5faa5ca8875c317524070.tar.xz dexon-sol-tools-ff295daa5c56b5c056a5faa5ca8875c317524070.tar.zst dexon-sol-tools-ff295daa5c56b5c056a5faa5ca8875c317524070.zip |
Simpler way of validaitng has enough eth
Diffstat (limited to 'packages/instant/src/containers')
-rw-r--r-- | packages/instant/src/containers/selected_asset_buy_order_state_buttons.ts | 20 | ||||
-rw-r--r-- | packages/instant/src/containers/selected_erc20_asset_amount_input.ts | 4 |
2 files changed, 11 insertions, 13 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 49b9cf209..dee724e15 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 @@ -6,12 +6,13 @@ import { Dispatch } from 'redux'; import { Action, actions } from '../redux/actions'; import { State } from '../redux/reducer'; -import { OrderProcessState, OrderState } from '../types'; +import { OrderProcessState, OrderState, ZeroExInstantError } from '../types'; import { balanceUtil } from '../util/balance'; import { etherscanUtil } from '../util/etherscan'; import { web3Wrapper } from '../util/web3_wrapper'; import { BuyOrderStateButtons } from '../components/buy_order_state_buttons'; +import { errorUtil } from '../util/error'; interface ConnectedState { buyQuote?: BuyQuote; @@ -21,13 +22,13 @@ interface ConnectedState { } interface ConnectedDispatch { - onAwaitingSignature: (buyQuote: BuyQuote) => void; + onPendingValidation: (buyQuote: BuyQuote) => void; onSignatureDenied: (buyQuote: BuyQuote, error: Error) => void; onBuyProcessing: (buyQuote: BuyQuote, txHash: string) => void; onBuySuccess: (buyQuote: BuyQuote, txHash: string) => void; onBuyFailure: (buyQuote: BuyQuote, txHash: string) => void; onRetry: () => void; - validateWalletBeforeBuy: (buyQuote: BuyQuote, takerAddress: string | undefined) => Promise<boolean>; + onValidationFail: (buyQuote: BuyQuote, error: ZeroExInstantError) => void; } export interface SelectedAssetBuyOrderStateButtons {} const mapStateToProps = (state: State, _ownProps: SelectedAssetBuyOrderStateButtons): ConnectedState => ({ @@ -57,8 +58,8 @@ const mapDispatchToProps = ( dispatch: Dispatch<Action>, ownProps: SelectedAssetBuyOrderStateButtons, ): ConnectedDispatch => ({ - onAwaitingSignature: (buyQuote: BuyQuote) => { - const newOrderState: OrderState = { processState: OrderProcessState.AWAITING_SIGNATURE }; + onPendingValidation: (buyQuote: BuyQuote) => { + const newOrderState: OrderState = { processState: OrderProcessState.VALIDATING }; dispatch(actions.updateBuyOrderState(newOrderState)); }, onBuyProcessing: (buyQuote: BuyQuote, txHash: string) => { @@ -71,14 +72,15 @@ const mapDispatchToProps = ( dispatch(actions.updateBuyOrderState({ processState: OrderProcessState.FAILURE, txHash })), onSignatureDenied: (buyQuote, error) => { dispatch(actions.resetAmount()); - dispatch(actions.setError(error)); + errorUtil.errorFlasher.flashNewError(dispatch, error); + }, + onValidationFail: (buyQuote, error) => { + dispatch(actions.updateBuyOrderState({ processState: OrderProcessState.NONE })); + errorUtil.errorFlasher.flashNewError(dispatch, new Error(error)); }, onRetry: () => { dispatch(actions.resetAmount()); }, - validateWalletBeforeBuy: async (buyQuote: BuyQuote, takerAddress: string | undefined) => { - return balanceUtil.checkInsufficientEthBalanceAndFlashError(takerAddress, buyQuote, web3Wrapper, dispatch); - }, }); export const SelectedAssetBuyOrderStateButtons: React.ComponentClass<SelectedAssetBuyOrderStateButtons> = connect( 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 325dc0ef2..a090ad8fb 100644 --- a/packages/instant/src/containers/selected_erc20_asset_amount_input.ts +++ b/packages/instant/src/containers/selected_erc20_asset_amount_input.ts @@ -79,10 +79,6 @@ const updateBuyQuoteAsync = async ( errorUtil.errorFlasher.clearError(dispatch); // invalidate the last buy quote. dispatch(actions.updateLatestBuyQuote(newBuyQuote)); - - // set error if user doesn't have appropriate balance - const takerAddress = await getBestAddress(); - await balanceUtil.checkInsufficientEthBalanceAndFlashError(takerAddress, newBuyQuote, web3Wrapper, dispatch); }; const debouncedUpdateBuyQuoteAsync = _.debounce(updateBuyQuoteAsync, 200, { trailing: true }); |