Has Sufficient Funds/Balance -> Has Sufficient ETH
This commit is contained in:
@@ -49,9 +49,9 @@ export class BuyButton extends React.Component<BuyButtonProps> {
|
||||
this.props.onValidationPending(buyQuote);
|
||||
const takerAddress = await getBestAddress();
|
||||
|
||||
const hasSufficientFunds = await balanceUtil.hasSufficientFunds(takerAddress, buyQuote, web3Wrapper);
|
||||
if (!hasSufficientFunds) {
|
||||
this.props.onValidationFail(buyQuote, ZeroExInstantError.InsufficientBalance);
|
||||
const hasSufficentEth = await balanceUtil.hasSufficentEth(takerAddress, buyQuote, web3Wrapper);
|
||||
if (!hasSufficentEth) {
|
||||
this.props.onValidationFail(buyQuote, ZeroExInstantError.InsufficientETH);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,5 +72,5 @@ export enum Network {
|
||||
|
||||
export enum ZeroExInstantError {
|
||||
AssetMetaDataNotAvailable = 'ASSET_META_DATA_NOT_AVAILABLE',
|
||||
InsufficientBalance = 'INSUFFICIENT_BALANCE',
|
||||
InsufficientETH = 'INSUFFICIENT_ETH',
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
export const balanceUtil = {
|
||||
hasSufficientFunds: async (takerAddress: string | undefined, buyQuote: BuyQuote, web3Wrapper: Web3Wrapper) => {
|
||||
hasSufficentEth: async (takerAddress: string | undefined, buyQuote: BuyQuote, web3Wrapper: Web3Wrapper) => {
|
||||
if (_.isUndefined(takerAddress)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ const humanReadableMessageForError = (error: Error, asset?: Asset): string | und
|
||||
if (error.message === AssetBuyerError.SignatureRequestDenied) {
|
||||
return 'You denied this transaction';
|
||||
}
|
||||
if (error.message === ZeroExInstantError.InsufficientBalance) {
|
||||
if (error.message === ZeroExInstantError.InsufficientETH) {
|
||||
return "You don't have enough ETH";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user