aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/utils
diff options
context:
space:
mode:
Diffstat (limited to 'packages/website/ts/utils')
-rw-r--r--packages/website/ts/utils/constants.ts10
-rw-r--r--packages/website/ts/utils/doc_utils.ts16
-rw-r--r--packages/website/ts/utils/doxity_utils.ts14
-rw-r--r--packages/website/ts/utils/error_reporter.ts8
-rw-r--r--packages/website/ts/utils/typedoc_utils.ts28
-rw-r--r--packages/website/ts/utils/utils.ts76
6 files changed, 100 insertions, 52 deletions
diff --git a/packages/website/ts/utils/constants.ts b/packages/website/ts/utils/constants.ts
index 7fc52b035..77a6e3e38 100644
--- a/packages/website/ts/utils/constants.ts
+++ b/packages/website/ts/utils/constants.ts
@@ -1,14 +1,14 @@
+import BigNumber from 'bignumber.js';
import {
+ ContractAddresses,
+ Docs,
ExchangeContractErrs,
+ Networks,
PublicNodeUrlsByNetworkId,
- ZeroExJsDocSections,
SmartContractsDocSections,
- Docs,
- ContractAddresses,
- Networks,
WebsitePaths,
+ ZeroExJsDocSections,
} from 'ts/types';
-import BigNumber from 'bignumber.js';
const INFURA_API_KEY = 'T5WSC8cautR4KXyYgsRs';
diff --git a/packages/website/ts/utils/doc_utils.ts b/packages/website/ts/utils/doc_utils.ts
index ca6e0dc52..594e3bae6 100644
--- a/packages/website/ts/utils/doc_utils.ts
+++ b/packages/website/ts/utils/doc_utils.ts
@@ -1,9 +1,9 @@
-import * as _ from 'lodash';
import findVersions = require('find-versions');
-import convert = require('xml-js');
+import * as _ from 'lodash';
+import {DoxityDocObj, S3FileObject, TypeDocNode, VersionToFileName} from 'ts/types';
import {constants} from 'ts/utils/constants';
import {utils} from 'ts/utils/utils';
-import {VersionToFileName, S3FileObject, TypeDocNode, DoxityDocObj} from 'ts/types';
+import convert = require('xml-js');
export const docUtils = {
async getVersionToFileNameAsync(s3DocJsonRoot: string):
@@ -29,12 +29,10 @@ export const docUtils = {
compact: true,
});
const responseObj = JSON.parse(responseJSONString);
- let fileObjs: S3FileObject[];
- if (_.isArray(responseObj.ListBucketResult.Contents)) {
- fileObjs = responseObj.ListBucketResult.Contents as S3FileObject[];
- } else {
- fileObjs = [responseObj.ListBucketResult.Contents];
- }
+ const fileObjs: S3FileObject[] = (_.isArray(responseObj.ListBucketResult.Contents)) ?
+ responseObj.ListBucketResult.Contents as S3FileObject[] :
+ [responseObj.ListBucketResult.Contents];
+
const versionFileNames = _.map(fileObjs, fileObj => {
return fileObj.Key._text;
});
diff --git a/packages/website/ts/utils/doxity_utils.ts b/packages/website/ts/utils/doxity_utils.ts
index 3bab0a69d..26e555b16 100644
--- a/packages/website/ts/utils/doxity_utils.ts
+++ b/packages/website/ts/utils/doxity_utils.ts
@@ -1,18 +1,18 @@
import * as _ from 'lodash';
import {
- DoxityDocObj,
- DoxityContractObj,
- DoxityAbiDoc,
- DoxityInput,
+ AbiTypes,
DocAgnosticFormat,
DocSection,
+ DoxityAbiDoc,
+ DoxityContractObj,
+ DoxityDocObj,
+ DoxityInput,
+ EventArg,
Parameter,
Property,
+ SolidityMethod,
Type,
TypeDocTypes,
- EventArg,
- AbiTypes,
- SolidityMethod,
} from 'ts/types';
export const doxityUtils = {
diff --git a/packages/website/ts/utils/error_reporter.ts b/packages/website/ts/utils/error_reporter.ts
index a9731c4d4..40991afbf 100644
--- a/packages/website/ts/utils/error_reporter.ts
+++ b/packages/website/ts/utils/error_reporter.ts
@@ -1,7 +1,7 @@
-import {utils} from 'ts/utils/utils';
-import {constants} from 'ts/utils/constants';
-import {configs} from 'ts/utils/configs';
import {Environments} from 'ts/types';
+import {configs} from 'ts/utils/configs';
+import {constants} from 'ts/utils/constants';
+import {utils} from 'ts/utils/utils';
// Suggested way to include Rollbar with Webpack
// https://github.com/rollbar/rollbar.js/tree/master/examples/webpack
@@ -32,7 +32,7 @@ import Rollbar = require('../../public/js/rollbar.umd.nojson.min.js');
const rollbar = Rollbar.init(rollbarConfig);
export const errorReporter = {
- reportAsync(err: Error): Promise<any> {
+ async reportAsync(err: Error): Promise<any> {
if (configs.ENVIRONMENT === Environments.DEVELOPMENT) {
return; // Let's not log development errors to rollbar
}
diff --git a/packages/website/ts/utils/typedoc_utils.ts b/packages/website/ts/utils/typedoc_utils.ts
index b3d0f7d90..bb2f7745a 100644
--- a/packages/website/ts/utils/typedoc_utils.ts
+++ b/packages/website/ts/utils/typedoc_utils.ts
@@ -1,25 +1,25 @@
-import * as _ from 'lodash';
import compareVersions = require('compare-versions');
-import {constants} from 'ts/utils/constants';
-import {utils} from 'ts/utils/utils';
+import * as _ from 'lodash';
import {
- TypeDocNode,
- KindString,
- ZeroExJsDocSections,
- MenuSubsectionsBySection,
- TypeDocType,
- Type,
+ CustomType,
+ CustomTypeChild,
DocAgnosticFormat,
DocSection,
- TypescriptMethod,
+ IndexSignature,
+ KindString,
+ MenuSubsectionsBySection,
Parameter,
Property,
- CustomType,
- IndexSignature,
- CustomTypeChild,
- TypeParameter,
+ Type,
+ TypeDocNode,
+ TypeDocType,
TypeDocTypes,
+ TypeParameter,
+ TypescriptMethod,
+ ZeroExJsDocSections,
} from 'ts/types';
+import {constants} from 'ts/utils/constants';
+import {utils} from 'ts/utils/utils';
const TYPES_MODULE_PATH = '"src/types"';
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index eb4c5be3a..8b23b6a40 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -1,23 +1,24 @@
+import {ExchangeContractErrs, ZeroExError} from '0x.js';
+import BigNumber from 'bignumber.js';
+import deepEqual = require('deep-equal');
+import ethUtil = require('ethereumjs-util');
+import isMobile = require('is-mobile');
import * as _ from 'lodash';
+import * as moment from 'moment';
import {
- SideToAssetToken,
- SignatureData,
+ EtherscanLinkSuffixes,
+ Networks,
Order,
- Side,
- TokenByAddress,
OrderParty,
ScreenWidths,
- EtherscanLinkSuffixes,
+ Side,
+ SideToAssetToken,
+ SignatureData,
Token,
- Networks,
+ TokenByAddress,
} from 'ts/types';
-import * as moment from 'moment';
-import isMobile = require('is-mobile');
-import * as u2f from 'ts/vendor/u2f_api';
-import deepEqual = require('deep-equal');
-import ethUtil = require('ethereumjs-util');
-import BigNumber from 'bignumber.js';
import {constants} from 'ts/utils/constants';
+import * as u2f from 'ts/vendor/u2f_api';
const LG_MIN_EM = 64;
const MD_MIN_EM = 52;
@@ -101,7 +102,7 @@ export const utils = {
console.log(message);
/* tslint:enable */
},
- sleepAsync(ms: number) {
+ async sleepAsync(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
},
deepEqual(actual: any, expected: any, opts?: {strict: boolean}) {
@@ -212,4 +213,53 @@ export const utils = {
const isUniqueSymbol = _.isUndefined(tokenWithSameSymbolIfExists);
return isUniqueName && isUniqueSymbol;
},
+ zeroExErrToHumanReadableErrMsg(error: ZeroExError|ExchangeContractErrs, takerAddress: string): string {
+ const ZeroExErrorToHumanReadableError: {[error: string]: string} = {
+ [ZeroExError.ExchangeContractDoesNotExist]: 'Exchange contract does not exist',
+ [ZeroExError.EtherTokenContractDoesNotExist]: 'EtherToken contract does not exist',
+ [ZeroExError.TokenTransferProxyContractDoesNotExist]: 'TokenTransferProxy contract does not exist',
+ [ZeroExError.TokenRegistryContractDoesNotExist]: 'TokenRegistry contract does not exist',
+ [ZeroExError.TokenContractDoesNotExist]: 'Token contract does not exist',
+ [ZeroExError.ZRXContractDoesNotExist]: 'ZRX contract does not exist',
+ [ZeroExError.UnhandledError]: 'Unhandled error occured',
+ [ZeroExError.UserHasNoAssociatedAddress]: 'User has no addresses available',
+ [ZeroExError.InvalidSignature]: 'Order signature is not valid',
+ [ZeroExError.ContractNotDeployedOnNetwork]: 'Contract is not deployed on the detected network',
+ [ZeroExError.InvalidJump]: 'Invalid jump occured while executing the transaction',
+ [ZeroExError.OutOfGas]: 'Transaction ran out of gas',
+ [ZeroExError.NoNetworkId]: 'No network id detected',
+ };
+ const exchangeContractErrorToHumanReadableError: {[error: string]: string} = {
+ [ExchangeContractErrs.OrderFillExpired]: 'This order has expired',
+ [ExchangeContractErrs.OrderCancelExpired]: 'This order has expired',
+ [ExchangeContractErrs.OrderCancelAmountZero]: 'Order cancel amount can\'t be 0',
+ [ExchangeContractErrs.OrderAlreadyCancelledOrFilled]:
+ 'This order has already been completely filled or cancelled',
+ [ExchangeContractErrs.OrderFillAmountZero]: 'Order fill amount can\'t be 0',
+ [ExchangeContractErrs.OrderRemainingFillAmountZero]:
+ 'This order has already been completely filled or cancelled',
+ [ExchangeContractErrs.OrderFillRoundingError]: 'Rounding error will occur when filling this order',
+ [ExchangeContractErrs.InsufficientTakerBalance]:
+ 'Taker no longer has a sufficient balance to complete this order',
+ [ExchangeContractErrs.InsufficientTakerAllowance]:
+ 'Taker no longer has a sufficient allowance to complete this order',
+ [ExchangeContractErrs.InsufficientMakerBalance]:
+ 'Maker no longer has a sufficient balance to complete this order',
+ [ExchangeContractErrs.InsufficientMakerAllowance]:
+ 'Maker no longer has a sufficient allowance to complete this order',
+ [ExchangeContractErrs.InsufficientTakerFeeBalance]: 'Taker no longer has a sufficient balance to pay fees',
+ [ExchangeContractErrs.InsufficientTakerFeeAllowance]:
+ 'Taker no longer has a sufficient allowance to pay fees',
+ [ExchangeContractErrs.InsufficientMakerFeeBalance]: 'Maker no longer has a sufficient balance to pay fees',
+ [ExchangeContractErrs.InsufficientMakerFeeAllowance]:
+ 'Maker no longer has a sufficient allowance to pay fees',
+ [ExchangeContractErrs.TransactionSenderIsNotFillOrderTaker]:
+ `This order can only be filled by ${takerAddress}`,
+ [ExchangeContractErrs.InsufficientRemainingFillAmount]:
+ 'Insufficient remaining fill amount',
+ };
+ const humanReadableErrorMsg = exchangeContractErrorToHumanReadableError[error] ||
+ ZeroExErrorToHumanReadableError[error];
+ return humanReadableErrorMsg;
+ },
};