aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/utils
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-05-16 21:15:23 +0800
committerFabio Berger <me@fabioberger.com>2018-05-16 21:15:23 +0800
commit22f3f57f44cfc4bdd27a79df36a8d80b96b02a07 (patch)
treed0d7a510b4322d1253a6f3d02c6267c4c7eabed2 /packages/website/ts/utils
parentb2f362225c5c03526852fc6b997241faba6d1231 (diff)
parentcc486cb86d46cefbd31a43a87be3ee9b3fd461a6 (diff)
downloaddexon-sol-tools-22f3f57f44cfc4bdd27a79df36a8d80b96b02a07.tar
dexon-sol-tools-22f3f57f44cfc4bdd27a79df36a8d80b96b02a07.tar.gz
dexon-sol-tools-22f3f57f44cfc4bdd27a79df36a8d80b96b02a07.tar.bz2
dexon-sol-tools-22f3f57f44cfc4bdd27a79df36a8d80b96b02a07.tar.lz
dexon-sol-tools-22f3f57f44cfc4bdd27a79df36a8d80b96b02a07.tar.xz
dexon-sol-tools-22f3f57f44cfc4bdd27a79df36a8d80b96b02a07.tar.zst
dexon-sol-tools-22f3f57f44cfc4bdd27a79df36a8d80b96b02a07.zip
Merge branch 'development' into improvement/addCustomTslintRules
* development: fix style errors Fix circular dependency Add my profile image to images Add myself to about page Add dogfood configs to website Change minimum Node version to 6.12 Document Node.js version requirement and add it to package.json
Diffstat (limited to 'packages/website/ts/utils')
-rw-r--r--packages/website/ts/utils/backend_client.ts10
-rw-r--r--packages/website/ts/utils/configs.ts5
-rw-r--r--packages/website/ts/utils/utils.ts6
3 files changed, 15 insertions, 6 deletions
diff --git a/packages/website/ts/utils/backend_client.ts b/packages/website/ts/utils/backend_client.ts
index 63e06fda7..c440b1604 100644
--- a/packages/website/ts/utils/backend_client.ts
+++ b/packages/website/ts/utils/backend_client.ts
@@ -1,8 +1,8 @@
import * as _ from 'lodash';
import { ArticlesBySection, WebsiteBackendGasInfo, WebsiteBackendPriceInfo, WebsiteBackendRelayerInfo } from 'ts/types';
-import { configs } from 'ts/utils/configs';
import { fetchUtils } from 'ts/utils/fetch_utils';
+import { utils } from 'ts/utils/utils';
const ETH_GAS_STATION_ENDPOINT = '/eth_gas_station';
const PRICES_ENDPOINT = '/prices';
@@ -11,7 +11,7 @@ const WIKI_ENDPOINT = '/wiki';
export const backendClient = {
async getGasInfoAsync(): Promise<WebsiteBackendGasInfo> {
- const result = await fetchUtils.requestAsync(configs.BACKEND_BASE_URL, ETH_GAS_STATION_ENDPOINT);
+ const result = await fetchUtils.requestAsync(utils.getBackendBaseUrl(), ETH_GAS_STATION_ENDPOINT);
return result;
},
async getPriceInfoAsync(tokenSymbols: string[]): Promise<WebsiteBackendPriceInfo> {
@@ -22,15 +22,15 @@ export const backendClient = {
const queryParams = {
tokens: joinedTokenSymbols,
};
- const result = await fetchUtils.requestAsync(configs.BACKEND_BASE_URL, PRICES_ENDPOINT, queryParams);
+ const result = await fetchUtils.requestAsync(utils.getBackendBaseUrl(), PRICES_ENDPOINT, queryParams);
return result;
},
async getRelayerInfosAsync(): Promise<WebsiteBackendRelayerInfo[]> {
- const result = await fetchUtils.requestAsync(configs.BACKEND_BASE_URL, RELAYERS_ENDPOINT);
+ const result = await fetchUtils.requestAsync(utils.getBackendBaseUrl(), RELAYERS_ENDPOINT);
return result;
},
async getWikiArticlesBySectionAsync(): Promise<ArticlesBySection> {
- const result = await fetchUtils.requestAsync(configs.BACKEND_BASE_URL, WIKI_ENDPOINT);
+ const result = await fetchUtils.requestAsync(utils.getBackendBaseUrl(), WIKI_ENDPOINT);
return result;
},
};
diff --git a/packages/website/ts/utils/configs.ts b/packages/website/ts/utils/configs.ts
index a54fc56a8..9fec814b7 100644
--- a/packages/website/ts/utils/configs.ts
+++ b/packages/website/ts/utils/configs.ts
@@ -1,5 +1,6 @@
import * as _ from 'lodash';
import { Environments, OutdatedWrappedEtherByNetworkId, PublicNodeUrlsByNetworkId } from 'ts/types';
+import { utils } from 'ts/utils/utils';
const BASE_URL = window.location.origin;
const isDevelopment = _.includes(
@@ -10,13 +11,15 @@ const INFURA_API_KEY = 'T5WSC8cautR4KXyYgsRs';
export const configs = {
AMOUNT_DISPLAY_PRECSION: 5,
- BACKEND_BASE_URL: 'https://website-api.0xproject.com',
+ BACKEND_BASE_PROD_URL: 'https://website-api.0xproject.com',
+ BACKEND_BASE_STAGING_URL: 'http://ec2-52-91-181-85.compute-1.amazonaws.com',
BASE_URL,
BITLY_ACCESS_TOKEN: 'ffc4c1a31e5143848fb7c523b39f91b9b213d208',
DEFAULT_DERIVATION_PATH: `44'/60'/0'`,
// WARNING: ZRX & WETH MUST always be default trackedTokens
DEFAULT_TRACKED_TOKEN_SYMBOLS: ['WETH', 'ZRX'],
DOMAIN_STAGING: 'staging-0xproject.s3-website-us-east-1.amazonaws.com',
+ DOMAIN_DOGFOOD: 'dogfood-0xproject.s3-website-us-east-1.amazonaws.com',
DOMAIN_DEVELOPMENT: '0xproject.localhost:3572',
DOMAIN_PRODUCTION: '0xproject.com',
ENVIRONMENT: isDevelopment ? Environments.DEVELOPMENT : Environments.PRODUCTION,
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index bf30f4e04..3c99bd2fe 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -24,6 +24,8 @@ import * as u2f from 'ts/vendor/u2f_api';
const LG_MIN_EM = 64;
const MD_MIN_EM = 52;
+const isDogfood = (): boolean => _.includes(window.location.href, configs.DOMAIN_DOGFOOD);
+
export const utils = {
assert(condition: boolean, message: string): void {
if (!condition) {
@@ -302,10 +304,14 @@ export const utils = {
}
return parsedProviderName;
},
+ getBackendBaseUrl(): string {
+ return isDogfood() ? configs.BACKEND_BASE_STAGING_URL : configs.BACKEND_BASE_PROD_URL;
+ },
isDevelopment(): boolean {
return configs.ENVIRONMENT === Environments.DEVELOPMENT;
},
isStaging(): boolean {
return _.includes(window.location.href, configs.DOMAIN_STAGING);
},
+ isDogfood,
};