Merge pull request #593 from 0xProject/bug/website/fix-cirular-dependency

Fix circular dependency
This commit is contained in:
Francesco Agosti
2018-05-15 16:35:05 -07:00
committed by GitHub
3 changed files with 13 additions and 11 deletions

View File

@@ -1,8 +1,8 @@
import * as _ from 'lodash'; import * as _ from 'lodash';
import { ArticlesBySection, WebsiteBackendGasInfo, WebsiteBackendPriceInfo, WebsiteBackendRelayerInfo } from 'ts/types'; import { ArticlesBySection, WebsiteBackendGasInfo, WebsiteBackendPriceInfo, WebsiteBackendRelayerInfo } from 'ts/types';
import { configs } from 'ts/utils/configs';
import { fetchUtils } from 'ts/utils/fetch_utils'; import { fetchUtils } from 'ts/utils/fetch_utils';
import { utils } from 'ts/utils/utils';
const ETH_GAS_STATION_ENDPOINT = '/eth_gas_station'; const ETH_GAS_STATION_ENDPOINT = '/eth_gas_station';
const PRICES_ENDPOINT = '/prices'; const PRICES_ENDPOINT = '/prices';
@@ -11,7 +11,7 @@ const WIKI_ENDPOINT = '/wiki';
export const backendClient = { export const backendClient = {
async getGasInfoAsync(): Promise<WebsiteBackendGasInfo> { 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; return result;
}, },
async getPriceInfoAsync(tokenSymbols: string[]): Promise<WebsiteBackendPriceInfo> { async getPriceInfoAsync(tokenSymbols: string[]): Promise<WebsiteBackendPriceInfo> {
@@ -22,15 +22,15 @@ export const backendClient = {
const queryParams = { const queryParams = {
tokens: joinedTokenSymbols, 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; return result;
}, },
async getRelayerInfosAsync(): Promise<WebsiteBackendRelayerInfo[]> { 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; return result;
}, },
async getWikiArticlesBySectionAsync(): Promise<ArticlesBySection> { 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; return result;
}, },
}; };

View File

@@ -11,9 +11,8 @@ const INFURA_API_KEY = 'T5WSC8cautR4KXyYgsRs';
export const configs = { export const configs = {
AMOUNT_DISPLAY_PRECSION: 5, AMOUNT_DISPLAY_PRECSION: 5,
BACKEND_BASE_URL: utils.isDogfood() BACKEND_BASE_PROD_URL: 'https://website-api.0xproject.com',
? 'http://ec2-52-91-181-85.compute-1.amazonaws.com' BACKEND_BASE_STAGING_URL: 'http://ec2-52-91-181-85.compute-1.amazonaws.com',
: 'https://website-api.0xproject.com',
BASE_URL, BASE_URL,
BITLY_ACCESS_TOKEN: 'ffc4c1a31e5143848fb7c523b39f91b9b213d208', BITLY_ACCESS_TOKEN: 'ffc4c1a31e5143848fb7c523b39f91b9b213d208',
DEFAULT_DERIVATION_PATH: `44'/60'/0'`, DEFAULT_DERIVATION_PATH: `44'/60'/0'`,

View File

@@ -24,6 +24,8 @@ import * as u2f from 'ts/vendor/u2f_api';
const LG_MIN_EM = 64; const LG_MIN_EM = 64;
const MD_MIN_EM = 52; const MD_MIN_EM = 52;
const isDogfood = (): boolean => _.includes(window.location.href, configs.DOMAIN_DOGFOOD);
export const utils = { export const utils = {
assert(condition: boolean, message: string): void { assert(condition: boolean, message: string): void {
if (!condition) { if (!condition) {
@@ -302,13 +304,14 @@ export const utils = {
} }
return parsedProviderName; return parsedProviderName;
}, },
getBackendBaseUrl(): string {
return isDogfood() ? configs.BACKEND_BASE_STAGING_URL : configs.BACKEND_BASE_PROD_URL;
},
isDevelopment(): boolean { isDevelopment(): boolean {
return configs.ENVIRONMENT === Environments.DEVELOPMENT; return configs.ENVIRONMENT === Environments.DEVELOPMENT;
}, },
isStaging(): boolean { isStaging(): boolean {
return _.includes(window.location.href, configs.DOMAIN_STAGING); return _.includes(window.location.href, configs.DOMAIN_STAGING);
}, },
isDogfood(): boolean { isDogfood,
return _.includes(window.location.href, configs.DOMAIN_DOGFOOD);
},
}; };