aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-06-08 03:44:22 +0800
committerGitHub <noreply@github.com>2018-06-08 03:44:22 +0800
commit9bc6ebde4e4425799ed3ddfb50495029865e3ae8 (patch)
treefe15c8c1abbe77d5e10914ae509b653295862fc6
parent96b31f39749fb32bd89978245c79aa637791336c (diff)
parent011f14d1155fd3f61e53aaa16681afd5c9c9f892 (diff)
downloaddexon-sol-tools-9bc6ebde4e4425799ed3ddfb50495029865e3ae8.tar
dexon-sol-tools-9bc6ebde4e4425799ed3ddfb50495029865e3ae8.tar.gz
dexon-sol-tools-9bc6ebde4e4425799ed3ddfb50495029865e3ae8.tar.bz2
dexon-sol-tools-9bc6ebde4e4425799ed3ddfb50495029865e3ae8.tar.lz
dexon-sol-tools-9bc6ebde4e4425799ed3ddfb50495029865e3ae8.tar.xz
dexon-sol-tools-9bc6ebde4e4425799ed3ddfb50495029865e3ae8.tar.zst
dexon-sol-tools-9bc6ebde4e4425799ed3ddfb50495029865e3ae8.zip
Merge pull request #671 from 0xProject/refactor/move-spawn-switch-to-utils
Move spawnSwitchErr to @0xproject/utils
-rw-r--r--packages/contract-wrappers/src/utils/utils.ts3
-rw-r--r--packages/order-watcher/src/order_watcher/order_watcher.ts5
-rw-r--r--packages/order-watcher/src/utils/utils.ts3
-rw-r--r--packages/react-docs/src/components/type.tsx4
-rw-r--r--packages/react-docs/src/components/type_definition.tsx4
-rw-r--r--packages/react-docs/src/utils/typedoc_utils.ts4
-rw-r--r--packages/utils/CHANGELOG.json8
-rw-r--r--packages/utils/src/error_utils.ts (renamed from packages/react-docs/src/utils/utils.ts)2
-rw-r--r--packages/utils/src/index.ts1
-rw-r--r--packages/website/ts/components/token_balances.tsx4
-rw-r--r--packages/website/ts/components/ui/lifecycle_raised_button.tsx4
-rw-r--r--packages/website/ts/components/wallet/wallet.tsx4
-rw-r--r--packages/website/ts/utils/utils.ts3
13 files changed, 24 insertions, 25 deletions
diff --git a/packages/contract-wrappers/src/utils/utils.ts b/packages/contract-wrappers/src/utils/utils.ts
index 7cf9450a0..689a7ee0a 100644
--- a/packages/contract-wrappers/src/utils/utils.ts
+++ b/packages/contract-wrappers/src/utils/utils.ts
@@ -1,9 +1,6 @@
import { BigNumber } from '@0xproject/utils';
export const utils = {
- spawnSwitchErr(name: string, value: any): Error {
- return new Error(`Unexpected switch value: ${value} encountered for ${name}`);
- },
getCurrentUnixTimestampSec(): BigNumber {
const milisecondsInSecond = 1000;
return new BigNumber(Date.now() / milisecondsInSecond).round();
diff --git a/packages/order-watcher/src/order_watcher/order_watcher.ts b/packages/order-watcher/src/order_watcher/order_watcher.ts
index c1f6c9230..140aa341b 100644
--- a/packages/order-watcher/src/order_watcher/order_watcher.ts
+++ b/packages/order-watcher/src/order_watcher/order_watcher.ts
@@ -14,7 +14,7 @@ import {
Provider,
SignedOrder,
} from '@0xproject/types';
-import { intervalUtils } from '@0xproject/utils';
+import { errorUtils, intervalUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
@@ -39,7 +39,6 @@ import {
} from '../generated_contract_wrappers/token';
import { OnOrderStateChangeCallback, OrderWatcherConfig, OrderWatcherError } from '../types';
import { assert } from '../utils/assert';
-import { utils } from '../utils/utils';
import { EventWatcher } from './event_watcher';
import { ExpirationWatcher } from './expiration_watcher';
@@ -344,7 +343,7 @@ export class OrderWatcher {
return; // noop
default:
- throw utils.spawnSwitchErr('decodedLog.event', decodedLog.event);
+ throw errorUtils.spawnSwitchErr('decodedLog.event', decodedLog.event);
}
}
private async _emitRevalidateOrdersAsync(orderHashes: string[]): Promise<void> {
diff --git a/packages/order-watcher/src/utils/utils.ts b/packages/order-watcher/src/utils/utils.ts
index d34f6b99f..087fc635e 100644
--- a/packages/order-watcher/src/utils/utils.ts
+++ b/packages/order-watcher/src/utils/utils.ts
@@ -1,9 +1,6 @@
import { BigNumber } from '@0xproject/utils';
export const utils = {
- spawnSwitchErr(name: string, value: any): Error {
- return new Error(`Unexpected switch value: ${value} encountered for ${name}`);
- },
getCurrentUnixTimestampSec(): BigNumber {
const milisecondsInASecond = 1000;
return new BigNumber(Date.now() / milisecondsInASecond).round();
diff --git a/packages/react-docs/src/components/type.tsx b/packages/react-docs/src/components/type.tsx
index caf0796ee..e453349ef 100644
--- a/packages/react-docs/src/components/type.tsx
+++ b/packages/react-docs/src/components/type.tsx
@@ -1,4 +1,5 @@
import { colors, constants as sharedConstants, utils as sharedUtils } from '@0xproject/react-shared';
+import { errorUtils } from '@0xproject/utils';
import * as _ from 'lodash';
import * as React from 'react';
import { Link as ScrollLink } from 'react-scroll';
@@ -6,7 +7,6 @@ import * as ReactTooltip from 'react-tooltip';
import { DocsInfo } from '../docs_info';
import { Type as TypeDef, TypeDefinitionByName, TypeDocTypes } from '../types';
-import { utils } from '../utils/utils';
import { Signature } from './signature';
import { TypeDefinition } from './type_definition';
@@ -129,7 +129,7 @@ export function Type(props: TypeProps): any {
break;
default:
- throw utils.spawnSwitchErr('type.typeDocType', type.typeDocType);
+ throw errorUtils.spawnSwitchErr('type.typeDocType', type.typeDocType);
}
// HACK: Normalize BigNumber to simply BigNumber. For some reason the type
// name is unpredictably one or the other.
diff --git a/packages/react-docs/src/components/type_definition.tsx b/packages/react-docs/src/components/type_definition.tsx
index fdaad556b..c4bd7359a 100644
--- a/packages/react-docs/src/components/type_definition.tsx
+++ b/packages/react-docs/src/components/type_definition.tsx
@@ -1,11 +1,11 @@
import { AnchorTitle, colors, HeaderSizes } from '@0xproject/react-shared';
+import { errorUtils } from '@0xproject/utils';
import * as _ from 'lodash';
import * as React from 'react';
import { DocsInfo } from '../docs_info';
import { CustomType, CustomTypeChild, KindString, TypeDocTypes } from '../types';
import { constants } from '../utils/constants';
-import { utils } from '../utils/utils';
import { Comment } from './comment';
import { CustomEnum } from './custom_enum';
@@ -96,7 +96,7 @@ export class TypeDefinition extends React.Component<TypeDefinitionProps, TypeDef
break;
default:
- throw utils.spawnSwitchErr('type.kindString', customType.kindString);
+ throw errorUtils.spawnSwitchErr('type.kindString', customType.kindString);
}
const typeDefinitionAnchorId = `${this.props.sectionName}-${customType.name}`;
diff --git a/packages/react-docs/src/utils/typedoc_utils.ts b/packages/react-docs/src/utils/typedoc_utils.ts
index 5a672f10f..5633d9040 100644
--- a/packages/react-docs/src/utils/typedoc_utils.ts
+++ b/packages/react-docs/src/utils/typedoc_utils.ts
@@ -1,3 +1,4 @@
+import { errorUtils } from '@0xproject/utils';
import * as _ from 'lodash';
import { DocsInfo } from '../docs_info';
@@ -19,7 +20,6 @@ import {
TypescriptFunction,
TypescriptMethod,
} from '../types';
-import { utils } from '../utils/utils';
export const typeDocUtils = {
isType(entity: TypeDocNode): boolean {
@@ -197,7 +197,7 @@ export const typeDocUtils = {
break;
default:
- throw utils.spawnSwitchErr('kindString', entity.kindString);
+ throw errorUtils.spawnSwitchErr('kindString', entity.kindString);
}
});
return docSection;
diff --git a/packages/utils/CHANGELOG.json b/packages/utils/CHANGELOG.json
index 616a17d62..339d73e05 100644
--- a/packages/utils/CHANGELOG.json
+++ b/packages/utils/CHANGELOG.json
@@ -1,5 +1,13 @@
[
{
+ "version": "0.6.3",
+ "changes": [
+ {
+ "note": "Added errorUtils.spawnSwitchErr"
+ }
+ ]
+ },
+ {
"timestamp": 1527009133,
"version": "0.6.2",
"changes": [
diff --git a/packages/react-docs/src/utils/utils.ts b/packages/utils/src/error_utils.ts
index e3dd1fc62..735d3940b 100644
--- a/packages/react-docs/src/utils/utils.ts
+++ b/packages/utils/src/error_utils.ts
@@ -1,4 +1,4 @@
-export const utils = {
+export const errorUtils = {
spawnSwitchErr(name: string, value: any): Error {
return new Error(`Unexpected switch value: ${value} encountered for ${name}`);
},
diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts
index 709ec93b2..fd102cecb 100644
--- a/packages/utils/src/index.ts
+++ b/packages/utils/src/index.ts
@@ -7,3 +7,4 @@ export { AbiDecoder } from './abi_decoder';
export { logUtils } from './log_utils';
export { abiUtils } from './abi_utils';
export { NULL_BYTES } from './constants';
+export { errorUtils } from './error_utils';
diff --git a/packages/website/ts/components/token_balances.tsx b/packages/website/ts/components/token_balances.tsx
index 6f5aa756e..555a59830 100644
--- a/packages/website/ts/components/token_balances.tsx
+++ b/packages/website/ts/components/token_balances.tsx
@@ -5,7 +5,7 @@ import {
Styles,
utils as sharedUtils,
} from '@0xproject/react-shared';
-import { BigNumber, logUtils } from '@0xproject/utils';
+import { BigNumber, errorUtils, logUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import Dialog from 'material-ui/Dialog';
@@ -500,7 +500,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
return null; // No error to show
default:
- throw utils.spawnSwitchErr('errorType', this.state.errorType);
+ throw errorUtils.spawnSwitchErr('errorType', this.state.errorType);
}
}
private _onErrorOccurred(errorType: BalanceErrs): void {
diff --git a/packages/website/ts/components/ui/lifecycle_raised_button.tsx b/packages/website/ts/components/ui/lifecycle_raised_button.tsx
index 0c3ebcc0c..380fbc77d 100644
--- a/packages/website/ts/components/ui/lifecycle_raised_button.tsx
+++ b/packages/website/ts/components/ui/lifecycle_raised_button.tsx
@@ -1,7 +1,7 @@
import { colors } from '@0xproject/react-shared';
+import { errorUtils } from '@0xproject/utils';
import RaisedButton from 'material-ui/RaisedButton';
import * as React from 'react';
-import { utils } from 'ts/utils/utils';
const COMPLETE_STATE_SHOW_LENGTH_MS = 2000;
@@ -62,7 +62,7 @@ export class LifeCycleRaisedButton extends React.Component<LifeCycleRaisedButton
label = this.props.labelComplete;
break;
default:
- throw utils.spawnSwitchErr('ButtonState', this.state.buttonState);
+ throw errorUtils.spawnSwitchErr('ButtonState', this.state.buttonState);
}
return (
<RaisedButton
diff --git a/packages/website/ts/components/wallet/wallet.tsx b/packages/website/ts/components/wallet/wallet.tsx
index 977902103..bc2ee227d 100644
--- a/packages/website/ts/components/wallet/wallet.tsx
+++ b/packages/website/ts/components/wallet/wallet.tsx
@@ -1,5 +1,5 @@
import { EtherscanLinkSuffixes, Styles, utils as sharedUtils } from '@0xproject/react-shared';
-import { BigNumber } from '@0xproject/utils';
+import { BigNumber, errorUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import CircularProgress from 'material-ui/CircularProgress';
@@ -491,7 +491,7 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
buttonIconName = 'zmdi-long-arrow-up';
break;
default:
- throw utils.spawnSwitchErr('wrappedEtherDirection', wrappedEtherDirection);
+ throw errorUtils.spawnSwitchErr('wrappedEtherDirection', wrappedEtherDirection);
}
}
const onClick = isWrappedEtherDirectionOpen
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index 2c8c06c01..6961784c6 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -33,9 +33,6 @@ export const utils = {
throw new Error(message);
}
},
- spawnSwitchErr(name: string, value: any): Error {
- return new Error(`Unexpected switch value: ${value} encountered for ${name}`);
- },
isNumeric(n: string): boolean {
return !isNaN(parseFloat(n)) && isFinite(Number(n));
},