From 274aa50d740e4f3af9e3d50468843ed19b555aa3 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 15 Dec 2017 13:14:57 +0100 Subject: Fix 0x.js unused vars --- packages/0x.js/src/0x.ts | 2 -- packages/0x.js/src/contract_wrappers/exchange_wrapper.ts | 5 +---- packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts | 4 +--- .../src/contract_wrappers/token_transfer_proxy_wrapper.ts | 1 - packages/0x.js/src/contract_wrappers/token_wrapper.ts | 2 -- packages/0x.js/src/order_watcher/event_watcher.ts | 3 --- packages/0x.js/src/order_watcher/expiration_watcher.ts | 3 +-- packages/0x.js/src/order_watcher/order_state_watcher.ts | 2 -- .../0x.js/src/stores/balance_proxy_allowance_lazy_store.ts | 1 - packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts | 1 - packages/0x.js/src/utils/assert.ts | 10 +++++----- packages/0x.js/src/utils/order_state_utils.ts | 5 ----- packages/0x.js/src/utils/order_validation_utils.ts | 5 +---- 13 files changed, 9 insertions(+), 35 deletions(-) (limited to 'packages/0x.js/src') diff --git a/packages/0x.js/src/0x.ts b/packages/0x.js/src/0x.ts index 83d470845..5a2d6cb05 100644 --- a/packages/0x.js/src/0x.ts +++ b/packages/0x.js/src/0x.ts @@ -16,7 +16,6 @@ import {zeroExConfigSchema} from './schemas/zero_ex_config_schema'; import { ECSignature, Order, - OrderStateWatcherConfig, SignedOrder, TransactionReceiptWithDecodedLogs, Web3Provider, @@ -26,7 +25,6 @@ import { import {AbiDecoder} from './utils/abi_decoder'; import {assert} from './utils/assert'; import {constants} from './utils/constants'; -import {OrderStateUtils} from './utils/order_state_utils'; import {signatureUtils} from './utils/signature_utils'; import {utils} from './utils/utils'; diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts index 1e9865395..9bed40079 100644 --- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts @@ -15,9 +15,7 @@ import { ExchangeContractEventArgs, ExchangeEvents, IndexedFilterValues, - LogCancelContractEventArgs, LogErrorContractEventArgs, - LogFillContractEventArgs, LogWithDecodedArgs, MethodOpts, Order, @@ -26,7 +24,6 @@ import { OrderFillRequest, OrderTransactionOpts, OrderValues, - RawLog, SignedOrder, SubscriptionOpts, ValidateOrderFillableOpts, @@ -88,7 +85,7 @@ export class ExchangeWrapper extends ContractWrapper { tokenWrapper: TokenWrapper, contractAddressIfExists?: string) { super(web3Wrapper, networkId, abiDecoder); this._tokenWrapper = tokenWrapper; - this._orderValidationUtils = new OrderValidationUtils(tokenWrapper, this); + this._orderValidationUtils = new OrderValidationUtils(this); this._contractAddressIfExists = contractAddressIfExists; } /** diff --git a/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts index 064b826d8..69e9d7e21 100644 --- a/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts @@ -2,7 +2,7 @@ import {Web3Wrapper} from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; import {artifacts} from '../artifacts'; -import {Token, TokenMetadata, ZeroExError} from '../types'; +import {Token, TokenMetadata} from '../types'; import {assert} from '../utils/assert'; import {constants} from '../utils/constants'; @@ -36,8 +36,6 @@ export class TokenRegistryWrapper extends ContractWrapper { * @return An array of objects that conform to the Token interface. */ public async getTokensAsync(): Promise { - const tokenRegistryContract = await this._getTokenRegistryContractAsync(); - const addresses = await this.getTokenAddressesAsync(); const tokenPromises: Array> = _.map( addresses, diff --git a/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts index 1a16e3540..c67ef87df 100644 --- a/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts @@ -2,7 +2,6 @@ import {Web3Wrapper} from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; import {artifacts} from '../artifacts'; -import {ZeroExError} from '../types'; import {ContractWrapper} from './contract_wrapper'; import {TokenTransferProxyContract} from './generated/token_transfer_proxy'; diff --git a/packages/0x.js/src/contract_wrappers/token_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_wrapper.ts index 684f291a5..d1553fa7b 100644 --- a/packages/0x.js/src/contract_wrappers/token_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/token_wrapper.ts @@ -23,8 +23,6 @@ import {ContractWrapper} from './contract_wrapper'; import {TokenContract} from './generated/token'; import {TokenTransferProxyWrapper} from './token_transfer_proxy_wrapper'; -const ALLOWANCE_TO_ZERO_GAS_AMOUNT = 47275; - /** * This class includes all the functionality related to interacting with ERC20 token contracts. * All ERC20 method calls are supported, along with some convenience methods for getting/setting allowances diff --git a/packages/0x.js/src/order_watcher/event_watcher.ts b/packages/0x.js/src/order_watcher/event_watcher.ts index c11079208..197dfae65 100644 --- a/packages/0x.js/src/order_watcher/event_watcher.ts +++ b/packages/0x.js/src/order_watcher/event_watcher.ts @@ -5,13 +5,10 @@ import * as Web3 from 'web3'; import { BlockParamLiteral, - EventCallback, EventWatcherCallback, ZeroExError, } from '../types'; -import {AbiDecoder} from '../utils/abi_decoder'; import {assert} from '../utils/assert'; -import {utils} from '../utils/utils'; const DEFAULT_EVENT_POLLING_INTERVAL_MS = 200; diff --git a/packages/0x.js/src/order_watcher/expiration_watcher.ts b/packages/0x.js/src/order_watcher/expiration_watcher.ts index 5faac43cf..91e8151fd 100644 --- a/packages/0x.js/src/order_watcher/expiration_watcher.ts +++ b/packages/0x.js/src/order_watcher/expiration_watcher.ts @@ -3,8 +3,7 @@ import {BigNumber} from 'bignumber.js'; import {RBTree} from 'bintrees'; import * as _ from 'lodash'; -import {ZeroEx} from '../0x'; -import {SignedOrder, ZeroExError} from '../types'; +import {ZeroExError} from '../types'; import {utils} from '../utils/utils'; const DEFAULT_EXPIRATION_MARGIN_MS = 0; diff --git a/packages/0x.js/src/order_watcher/order_state_watcher.ts b/packages/0x.js/src/order_watcher/order_state_watcher.ts index 9ae1579c6..c4a9eb1ad 100644 --- a/packages/0x.js/src/order_watcher/order_state_watcher.ts +++ b/packages/0x.js/src/order_watcher/order_state_watcher.ts @@ -4,7 +4,6 @@ import {Web3Wrapper} from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; import {ZeroEx} from '../0x'; -import {artifacts} from '../artifacts'; import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper'; import {TokenWrapper} from '../contract_wrappers/token_wrapper'; import {BalanceAndProxyAllowanceLazyStore} from '../stores/balance_proxy_allowance_lazy_store'; @@ -25,7 +24,6 @@ import { SignedOrder, TokenEvents, TransferContractEventArgs, - Web3Provider, ZeroExError, } from '../types'; import {AbiDecoder} from '../utils/abi_decoder'; diff --git a/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts b/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts index 6225e9e72..cde1ef095 100644 --- a/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts +++ b/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts @@ -1,6 +1,5 @@ import {BigNumber} from 'bignumber.js'; import * as _ from 'lodash'; -import * as Web3 from 'web3'; import {TokenWrapper} from '../contract_wrappers/token_wrapper'; import {BlockParamLiteral} from '../types'; diff --git a/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts b/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts index 28b32f9e2..b35355e38 100644 --- a/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts +++ b/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts @@ -1,6 +1,5 @@ import {BigNumber} from 'bignumber.js'; import * as _ from 'lodash'; -import * as Web3 from 'web3'; import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper'; import {BlockParamLiteral} from '../types'; 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/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( -- cgit v1.2.3