aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/blockchain.ts
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-04-19 03:22:02 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-04-19 08:12:38 +0800
commit51b2fce8c13c8e9393558d34dd664b7dd7749941 (patch)
tree94d623b55fac4d7b2f1a24e9ad413b065b4676e5 /packages/website/ts/blockchain.ts
parent39c0064ffb73b8cb0b0b350e13bd7afec69e7e7e (diff)
downloaddexon-sol-tools-51b2fce8c13c8e9393558d34dd664b7dd7749941.tar
dexon-sol-tools-51b2fce8c13c8e9393558d34dd664b7dd7749941.tar.gz
dexon-sol-tools-51b2fce8c13c8e9393558d34dd664b7dd7749941.tar.bz2
dexon-sol-tools-51b2fce8c13c8e9393558d34dd664b7dd7749941.tar.lz
dexon-sol-tools-51b2fce8c13c8e9393558d34dd664b7dd7749941.tar.xz
dexon-sol-tools-51b2fce8c13c8e9393558d34dd664b7dd7749941.tar.zst
dexon-sol-tools-51b2fce8c13c8e9393558d34dd664b7dd7749941.zip
Implement backendClient object to unify calls to the portal api
Diffstat (limited to 'packages/website/ts/blockchain.ts')
-rw-r--r--packages/website/ts/blockchain.ts16
1 files changed, 8 insertions, 8 deletions
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts
index 3edc00644..e90dfa747 100644
--- a/packages/website/ts/blockchain.ts
+++ b/packages/website/ts/blockchain.ts
@@ -47,6 +47,7 @@ import {
Token,
TokenByAddress,
} from 'ts/types';
+import { backendClient } from 'ts/utils/backend_client';
import { configs } from 'ts/utils/configs';
import { constants } from 'ts/utils/constants';
import { errorReporter } from 'ts/utils/error_reporter';
@@ -854,14 +855,13 @@ export class Blockchain {
}
}
private async _updateDefaultGasPriceAsync() {
- const endpoint = `${configs.BACKEND_BASE_URL}/eth_gas_station`;
- const response = await fetch(endpoint);
- if (response.status !== 200) {
- return; // noop and we keep hard-coded default
+ try {
+ const gasInfo = await backendClient.getGasInfoAsync();
+ const gasPriceInGwei = new BigNumber(gasInfo.average / 10);
+ const gasPriceInWei = gasPriceInGwei.mul(1000000000);
+ this._defaultGasPrice = gasPriceInWei;
+ } catch (err) {
+ return;
}
- const gasInfo = await response.json();
- const gasPriceInGwei = new BigNumber(gasInfo.average / 10);
- const gasPriceInWei = gasPriceInGwei.mul(1000000000);
- this._defaultGasPrice = gasPriceInWei;
}
} // tslint:disable:max-file-line-count