aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/utils/utils.ts
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-07-13 06:50:13 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-07-13 06:56:01 +0800
commitac5588c7c436e2540f87e432446e103d35c9221a (patch)
tree75fb70ebf9cfb0aaa3450610f2072a43c3b2f1bc /packages/website/ts/utils/utils.ts
parentddb70a89ad99527e03844d23e7c0f3522e98a602 (diff)
downloaddexon-0x-contracts-ac5588c7c436e2540f87e432446e103d35c9221a.tar.gz
dexon-0x-contracts-ac5588c7c436e2540f87e432446e103d35c9221a.tar.zst
dexon-0x-contracts-ac5588c7c436e2540f87e432446e103d35c9221a.zip
Make error reporter not return a promise and add more environment possibilities
Diffstat (limited to 'packages/website/ts/utils/utils.ts')
-rw-r--r--packages/website/ts/utils/utils.ts36
1 files changed, 27 insertions, 9 deletions
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index 1d669d8f0..240170113 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -31,8 +31,6 @@ import { constants } from 'ts/utils/constants';
import { errorReporter } from 'ts/utils/error_reporter';
import * as u2f from 'ts/vendor/u2f_api';
-const isDogfood = (): boolean => _.includes(window.location.href, configs.DOMAIN_DOGFOOD);
-
export const utils = {
assert(condition: boolean, message: string): void {
if (!condition) {
@@ -347,10 +345,13 @@ export const utils = {
return parsedProviderName;
},
getBackendBaseUrl(): string {
- return isDogfood() ? configs.BACKEND_BASE_STAGING_URL : configs.BACKEND_BASE_PROD_URL;
+ return utils.isDogfood() ? configs.BACKEND_BASE_STAGING_URL : configs.BACKEND_BASE_PROD_URL;
},
isDevelopment(): boolean {
- return configs.ENVIRONMENT === Environments.DEVELOPMENT;
+ return _.includes(
+ ['https://0xproject.localhost:3572', 'https://localhost:3572', 'https://127.0.0.1'],
+ window.location.origin,
+ );
},
isStaging(): boolean {
return _.includes(window.location.href, configs.DOMAIN_STAGING);
@@ -358,7 +359,27 @@ export const utils = {
isExternallyInjected(providerType: ProviderType, injectedProviderName: string): boolean {
return providerType === ProviderType.Injected && injectedProviderName !== constants.PROVIDER_NAME_PUBLIC;
},
- isDogfood,
+ isDogfood(): boolean {
+ return _.includes(window.location.href, configs.DOMAIN_DOGFOOD);
+ },
+ isProduction(): boolean {
+ return _.includes(window.location.href, configs.DOMAIN_PRODUCTION);
+ },
+ getEnvironment(): Environments {
+ if (utils.isDogfood()) {
+ return Environments.DOGFOOD;
+ }
+ if (utils.isDevelopment()) {
+ return Environments.DEVELOPMENT;
+ }
+ if (utils.isStaging()) {
+ return Environments.STAGING;
+ }
+ if (utils.isProduction()) {
+ return Environments.PRODUCTION;
+ }
+ return undefined;
+ },
shouldShowJobsPage(): boolean {
return this.isDevelopment() || this.isStaging() || this.isDogfood();
},
@@ -391,10 +412,7 @@ export const utils = {
const format = `0,0.${_.repeat('0', precision)}`;
const formattedAmount = numeral(unitAmount).format(format);
if (_.isNaN(formattedAmount)) {
- // tslint:disable-next-line:no-floating-promises
- errorReporter.reportAsync(
- new Error(`amount ${BigNumber}, decimals ${decimals} could not be formatted and returned NaN.`),
- );
+ // https://github.com/adamwdraper/Numeral-js/issues/596
return format;
}
return formattedAmount;