aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-10-31 07:39:52 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-10-31 07:39:52 +0800
commit9cc82308e504a62a2bd3b16e79173a98279fdb66 (patch)
tree5a7f6b97808366a36923e85dbb5542183674e373 /packages/instant/src
parent96fcbeaba6cb63cb25af34a7c8264bd30ddf91be (diff)
downloaddexon-sol-tools-9cc82308e504a62a2bd3b16e79173a98279fdb66.tar
dexon-sol-tools-9cc82308e504a62a2bd3b16e79173a98279fdb66.tar.gz
dexon-sol-tools-9cc82308e504a62a2bd3b16e79173a98279fdb66.tar.bz2
dexon-sol-tools-9cc82308e504a62a2bd3b16e79173a98279fdb66.tar.lz
dexon-sol-tools-9cc82308e504a62a2bd3b16e79173a98279fdb66.tar.xz
dexon-sol-tools-9cc82308e504a62a2bd3b16e79173a98279fdb66.tar.zst
dexon-sol-tools-9cc82308e504a62a2bd3b16e79173a98279fdb66.zip
Always return estimated time, just use default if not known
Diffstat (limited to 'packages/instant/src')
-rw-r--r--packages/instant/src/util/gas_price_estimator.ts17
1 files changed, 14 insertions, 3 deletions
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<GasInfo> => {
@@ -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();