aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'packages/0x.js/src/utils')
-rw-r--r--packages/0x.js/src/utils/assert.ts10
-rw-r--r--packages/0x.js/src/utils/class_utils.ts18
-rw-r--r--packages/0x.js/src/utils/interval_utils.ts20
-rw-r--r--packages/0x.js/src/utils/order_state_utils.ts5
-rw-r--r--packages/0x.js/src/utils/order_validation_utils.ts5
5 files changed, 6 insertions, 52 deletions
diff --git a/packages/0x.js/src/utils/assert.ts b/packages/0x.js/src/utils/assert.ts
index 4cf6caf77..86a6a7c01 100644
--- a/packages/0x.js/src/utils/assert.ts
+++ b/packages/0x.js/src/utils/assert.ts
@@ -1,15 +1,15 @@
import {assert as sharedAssert} from '@0xproject/assert';
-import {Schema, SchemaValidator} from '@0xproject/json-schemas';
+// We need those two unused imports because they're actually used by sharedAssert which gets injected here
+// tslint:disable-next-line:no-unused-variable
+import {Schema} from '@0xproject/json-schemas';
import {Web3Wrapper} from '@0xproject/web3-wrapper';
-import BigNumber from 'bignumber.js';
+// tslint:disable-next-line:no-unused-variable
+import * as BigNumber from 'bignumber.js';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
import {ECSignature} from '../types';
import {signatureUtils} from '../utils/signature_utils';
-const HEX_REGEX = /^0x[0-9A-F]*$/i;
-
export const assert = {
...sharedAssert,
isValidSignature(orderHash: string, ecSignature: ECSignature, signerAddress: string) {
diff --git a/packages/0x.js/src/utils/class_utils.ts b/packages/0x.js/src/utils/class_utils.ts
deleted file mode 100644
index 04e60ee57..000000000
--- a/packages/0x.js/src/utils/class_utils.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import * as _ from 'lodash';
-
-export const classUtils = {
- // This is useful for classes that have nested methods. Nested methods don't get bound out of the box.
- bindAll(self: any, exclude: string[] = ['contructor'], thisArg?: any): void {
- for (const key of Object.getOwnPropertyNames(self)) {
- const val = self[key];
- if (!_.includes(exclude, key)) {
- if (_.isFunction(val)) {
- self[key] = val.bind(thisArg || self);
- } else if (_.isObject(val)) {
- classUtils.bindAll(val, exclude, self);
- }
- }
- }
- return self;
- },
-};
diff --git a/packages/0x.js/src/utils/interval_utils.ts b/packages/0x.js/src/utils/interval_utils.ts
deleted file mode 100644
index 62b79f2f5..000000000
--- a/packages/0x.js/src/utils/interval_utils.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import * as _ from 'lodash';
-
-export const intervalUtils = {
- setAsyncExcludingInterval(fn: () => Promise<void>, intervalMs: number) {
- let locked = false;
- const intervalId = setInterval(async () => {
- if (locked) {
- return;
- } else {
- locked = true;
- await fn();
- locked = false;
- }
- }, intervalMs);
- return intervalId;
- },
- clearAsyncExcludingInterval(intervalId: NodeJS.Timer): void {
- clearInterval(intervalId);
- },
-};
diff --git a/packages/0x.js/src/utils/order_state_utils.ts b/packages/0x.js/src/utils/order_state_utils.ts
index 6b7f811ae..a0985d028 100644
--- a/packages/0x.js/src/utils/order_state_utils.ts
+++ b/packages/0x.js/src/utils/order_state_utils.ts
@@ -1,24 +1,19 @@
import BigNumber from 'bignumber.js';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
import {ZeroEx} from '../0x';
import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
-import {TokenWrapper} from '../contract_wrappers/token_wrapper';
import {RemainingFillableCalculator} from '../order_watcher/remaining_fillable_calculator';
import {BalanceAndProxyAllowanceLazyStore} from '../stores/balance_proxy_allowance_lazy_store';
import {OrderFilledCancelledLazyStore} from '../stores/order_filled_cancelled_lazy_store';
import {
ExchangeContractErrs,
- MethodOpts,
OrderRelevantState,
OrderState,
OrderStateInvalid,
OrderStateValid,
SignedOrder,
} from '../types';
-import {constants} from '../utils/constants';
-import {utils} from '../utils/utils';
const ACCEPTABLE_RELATIVE_ROUNDING_ERROR = 0.0001;
diff --git a/packages/0x.js/src/utils/order_validation_utils.ts b/packages/0x.js/src/utils/order_validation_utils.ts
index d514483e0..9185eef2b 100644
--- a/packages/0x.js/src/utils/order_validation_utils.ts
+++ b/packages/0x.js/src/utils/order_validation_utils.ts
@@ -3,7 +3,6 @@ import * as _ from 'lodash';
import {ZeroEx} from '../0x';
import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
-import {TokenWrapper} from '../contract_wrappers/token_wrapper';
import {ExchangeContractErrs, Order, SignedOrder, TradeSide, TransferType, ZeroExError} from '../types';
import {constants} from '../utils/constants';
import {utils} from '../utils/utils';
@@ -11,7 +10,6 @@ import {utils} from '../utils/utils';
import {ExchangeTransferSimulator} from './exchange_transfer_simulator';
export class OrderValidationUtils {
- private tokenWrapper: TokenWrapper;
private exchangeWrapper: ExchangeWrapper;
public static validateCancelOrderThrowIfInvalid(
order: Order, cancelTakerTokenAmount: BigNumber, unavailableTakerTokenAmount: BigNumber,
@@ -84,8 +82,7 @@ export class OrderValidationUtils {
.round(0);
return fillMakerTokenAmount;
}
- constructor(tokenWrapper: TokenWrapper, exchangeWrapper: ExchangeWrapper) {
- this.tokenWrapper = tokenWrapper;
+ constructor(exchangeWrapper: ExchangeWrapper) {
this.exchangeWrapper = exchangeWrapper;
}
public async validateOrderFillableOrThrowAsync(