From 9cc82308e504a62a2bd3b16e79173a98279fdb66 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Tue, 30 Oct 2018 16:39:52 -0700 Subject: Always return estimated time, just use default if not known --- packages/instant/src/util/gas_price_estimator.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'packages/instant') diff --git a/packages/instant/src/util/gas_price_estimator.ts b/packages/instant/src/util/gas_price_estimator.ts index 0552ccde1..6b15809a3 100644 --- a/packages/instant/src/util/gas_price_estimator.ts +++ b/packages/instant/src/util/gas_price_estimator.ts @@ -1,6 +1,11 @@ import { BigNumber, fetchAsync } from '@0x/utils'; -import { DEFAULT_GAS_PRICE, ETH_GAS_STATION_API_BASE_URL, GWEI_IN_WEI } from '../constants'; +import { + DEFAULT_ESTIMATED_TRANSACTION_TIME_MS, + DEFAULT_GAS_PRICE, + ETH_GAS_STATION_API_BASE_URL, + GWEI_IN_WEI, +} from '../constants'; interface EthGasStationResult { average: number; @@ -18,7 +23,7 @@ interface EthGasStationResult { interface GasInfo { gasPriceInWei: BigNumber; - estimatedTimeMs?: number; + estimatedTimeMs: number; } const fetchFastAmountInWeiAsync = async (): Promise => { @@ -45,7 +50,13 @@ export class GasPriceEstimator { this._lastFetched = fetchedAmount; } - return fetchedAmount || this._lastFetched || { gasPriceInWei: DEFAULT_GAS_PRICE, estimatedTimeMs: undefined }; + return ( + fetchedAmount || + this._lastFetched || { + gasPriceInWei: DEFAULT_GAS_PRICE, + estimatedTimeMs: DEFAULT_ESTIMATED_TRANSACTION_TIME_MS, + } + ); } } export const gasPriceEstimator = new GasPriceEstimator(); -- cgit