diff options
Diffstat (limited to 'packages/instant/src/containers')
-rw-r--r-- | packages/instant/src/containers/selected_erc20_asset_amount_input.ts | 7 |
1 files changed, 2 insertions, 5 deletions
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 3d0895aac..1fc5b6d8c 100644 --- a/packages/instant/src/containers/selected_erc20_asset_amount_input.ts +++ b/packages/instant/src/containers/selected_erc20_asset_amount_input.ts @@ -13,6 +13,7 @@ import { State } from '../redux/reducer'; import { ColorOption } from '../style/theme'; import { ERC20Asset, OrderProcessState, ZeroExInstantError } from '../types'; import { getBestAddress } from '../util/address'; +import { balanceUtil } from '../util/balance'; import { BigNumberInput } from '../util/big_number_input'; import { errorUtil } from '../util/error'; import { web3Wrapper } from '../util/web3_wrapper'; @@ -81,11 +82,7 @@ const updateBuyQuoteAsync = async ( // set error if user doesn't have appropriate balance const takerAddress = await getBestAddress(); - const balanceWei = await web3Wrapper.getBalanceInWeiAsync(takerAddress); - if (balanceWei < newBuyQuote.worstCaseQuoteInfo.totalEthAmount) { - const balanceError = new Error(ZeroExInstantError.InsufficientBalance); - errorUtil.errorFlasher.flashNewError(dispatch, balanceError); - } + await balanceUtil.checkSufficientBalanceAndFlashError(takerAddress, newBuyQuote, web3Wrapper, dispatch); }; const debouncedUpdateBuyQuoteAsync = _.debounce(updateBuyQuoteAsync, 200, { trailing: true }); |