Fix 0x.js unused vars
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
* This file is auto-generated using abi-gen. Don't edit directly.
|
* This file is auto-generated using abi-gen. Don't edit directly.
|
||||||
* Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates.
|
* Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates.
|
||||||
*/
|
*/
|
||||||
|
// tslint:disable-next-line:no-unused-variable
|
||||||
import {TxData, TxDataPayable} from '@0xproject/types';
|
import {TxData, TxDataPayable} from '@0xproject/types';
|
||||||
import {classUtils, promisify} from '@0xproject/utils';
|
import {classUtils, promisify} from '@0xproject/utils';
|
||||||
import {BigNumber} from 'bignumber.js';
|
import {BigNumber} from 'bignumber.js';
|
||||||
|
@@ -16,7 +16,6 @@ import {zeroExConfigSchema} from './schemas/zero_ex_config_schema';
|
|||||||
import {
|
import {
|
||||||
ECSignature,
|
ECSignature,
|
||||||
Order,
|
Order,
|
||||||
OrderStateWatcherConfig,
|
|
||||||
SignedOrder,
|
SignedOrder,
|
||||||
TransactionReceiptWithDecodedLogs,
|
TransactionReceiptWithDecodedLogs,
|
||||||
Web3Provider,
|
Web3Provider,
|
||||||
@@ -26,7 +25,6 @@ import {
|
|||||||
import {AbiDecoder} from './utils/abi_decoder';
|
import {AbiDecoder} from './utils/abi_decoder';
|
||||||
import {assert} from './utils/assert';
|
import {assert} from './utils/assert';
|
||||||
import {constants} from './utils/constants';
|
import {constants} from './utils/constants';
|
||||||
import {OrderStateUtils} from './utils/order_state_utils';
|
|
||||||
import {signatureUtils} from './utils/signature_utils';
|
import {signatureUtils} from './utils/signature_utils';
|
||||||
import {utils} from './utils/utils';
|
import {utils} from './utils/utils';
|
||||||
|
|
||||||
|
@@ -15,9 +15,7 @@ import {
|
|||||||
ExchangeContractEventArgs,
|
ExchangeContractEventArgs,
|
||||||
ExchangeEvents,
|
ExchangeEvents,
|
||||||
IndexedFilterValues,
|
IndexedFilterValues,
|
||||||
LogCancelContractEventArgs,
|
|
||||||
LogErrorContractEventArgs,
|
LogErrorContractEventArgs,
|
||||||
LogFillContractEventArgs,
|
|
||||||
LogWithDecodedArgs,
|
LogWithDecodedArgs,
|
||||||
MethodOpts,
|
MethodOpts,
|
||||||
Order,
|
Order,
|
||||||
@@ -26,7 +24,6 @@ import {
|
|||||||
OrderFillRequest,
|
OrderFillRequest,
|
||||||
OrderTransactionOpts,
|
OrderTransactionOpts,
|
||||||
OrderValues,
|
OrderValues,
|
||||||
RawLog,
|
|
||||||
SignedOrder,
|
SignedOrder,
|
||||||
SubscriptionOpts,
|
SubscriptionOpts,
|
||||||
ValidateOrderFillableOpts,
|
ValidateOrderFillableOpts,
|
||||||
@@ -88,7 +85,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
tokenWrapper: TokenWrapper, contractAddressIfExists?: string) {
|
tokenWrapper: TokenWrapper, contractAddressIfExists?: string) {
|
||||||
super(web3Wrapper, networkId, abiDecoder);
|
super(web3Wrapper, networkId, abiDecoder);
|
||||||
this._tokenWrapper = tokenWrapper;
|
this._tokenWrapper = tokenWrapper;
|
||||||
this._orderValidationUtils = new OrderValidationUtils(tokenWrapper, this);
|
this._orderValidationUtils = new OrderValidationUtils(this);
|
||||||
this._contractAddressIfExists = contractAddressIfExists;
|
this._contractAddressIfExists = contractAddressIfExists;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@@ -2,7 +2,7 @@ import {Web3Wrapper} from '@0xproject/web3-wrapper';
|
|||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import {artifacts} from '../artifacts';
|
import {artifacts} from '../artifacts';
|
||||||
import {Token, TokenMetadata, ZeroExError} from '../types';
|
import {Token, TokenMetadata} from '../types';
|
||||||
import {assert} from '../utils/assert';
|
import {assert} from '../utils/assert';
|
||||||
import {constants} from '../utils/constants';
|
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.
|
* @return An array of objects that conform to the Token interface.
|
||||||
*/
|
*/
|
||||||
public async getTokensAsync(): Promise<Token[]> {
|
public async getTokensAsync(): Promise<Token[]> {
|
||||||
const tokenRegistryContract = await this._getTokenRegistryContractAsync();
|
|
||||||
|
|
||||||
const addresses = await this.getTokenAddressesAsync();
|
const addresses = await this.getTokenAddressesAsync();
|
||||||
const tokenPromises: Array<Promise<Token|undefined>> = _.map(
|
const tokenPromises: Array<Promise<Token|undefined>> = _.map(
|
||||||
addresses,
|
addresses,
|
||||||
|
@@ -2,7 +2,6 @@ import {Web3Wrapper} from '@0xproject/web3-wrapper';
|
|||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import {artifacts} from '../artifacts';
|
import {artifacts} from '../artifacts';
|
||||||
import {ZeroExError} from '../types';
|
|
||||||
|
|
||||||
import {ContractWrapper} from './contract_wrapper';
|
import {ContractWrapper} from './contract_wrapper';
|
||||||
import {TokenTransferProxyContract} from './generated/token_transfer_proxy';
|
import {TokenTransferProxyContract} from './generated/token_transfer_proxy';
|
||||||
|
@@ -23,8 +23,6 @@ import {ContractWrapper} from './contract_wrapper';
|
|||||||
import {TokenContract} from './generated/token';
|
import {TokenContract} from './generated/token';
|
||||||
import {TokenTransferProxyWrapper} from './token_transfer_proxy_wrapper';
|
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.
|
* 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
|
* All ERC20 method calls are supported, along with some convenience methods for getting/setting allowances
|
||||||
|
@@ -5,13 +5,10 @@ import * as Web3 from 'web3';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
BlockParamLiteral,
|
BlockParamLiteral,
|
||||||
EventCallback,
|
|
||||||
EventWatcherCallback,
|
EventWatcherCallback,
|
||||||
ZeroExError,
|
ZeroExError,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import {AbiDecoder} from '../utils/abi_decoder';
|
|
||||||
import {assert} from '../utils/assert';
|
import {assert} from '../utils/assert';
|
||||||
import {utils} from '../utils/utils';
|
|
||||||
|
|
||||||
const DEFAULT_EVENT_POLLING_INTERVAL_MS = 200;
|
const DEFAULT_EVENT_POLLING_INTERVAL_MS = 200;
|
||||||
|
|
||||||
|
@@ -3,8 +3,7 @@ import {BigNumber} from 'bignumber.js';
|
|||||||
import {RBTree} from 'bintrees';
|
import {RBTree} from 'bintrees';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import {ZeroEx} from '../0x';
|
import {ZeroExError} from '../types';
|
||||||
import {SignedOrder, ZeroExError} from '../types';
|
|
||||||
import {utils} from '../utils/utils';
|
import {utils} from '../utils/utils';
|
||||||
|
|
||||||
const DEFAULT_EXPIRATION_MARGIN_MS = 0;
|
const DEFAULT_EXPIRATION_MARGIN_MS = 0;
|
||||||
|
@@ -4,7 +4,6 @@ import {Web3Wrapper} from '@0xproject/web3-wrapper';
|
|||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import {ZeroEx} from '../0x';
|
import {ZeroEx} from '../0x';
|
||||||
import {artifacts} from '../artifacts';
|
|
||||||
import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
|
import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
|
||||||
import {TokenWrapper} from '../contract_wrappers/token_wrapper';
|
import {TokenWrapper} from '../contract_wrappers/token_wrapper';
|
||||||
import {BalanceAndProxyAllowanceLazyStore} from '../stores/balance_proxy_allowance_lazy_store';
|
import {BalanceAndProxyAllowanceLazyStore} from '../stores/balance_proxy_allowance_lazy_store';
|
||||||
@@ -25,7 +24,6 @@ import {
|
|||||||
SignedOrder,
|
SignedOrder,
|
||||||
TokenEvents,
|
TokenEvents,
|
||||||
TransferContractEventArgs,
|
TransferContractEventArgs,
|
||||||
Web3Provider,
|
|
||||||
ZeroExError,
|
ZeroExError,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import {AbiDecoder} from '../utils/abi_decoder';
|
import {AbiDecoder} from '../utils/abi_decoder';
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import {BigNumber} from 'bignumber.js';
|
import {BigNumber} from 'bignumber.js';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import * as Web3 from 'web3';
|
|
||||||
|
|
||||||
import {TokenWrapper} from '../contract_wrappers/token_wrapper';
|
import {TokenWrapper} from '../contract_wrappers/token_wrapper';
|
||||||
import {BlockParamLiteral} from '../types';
|
import {BlockParamLiteral} from '../types';
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import {BigNumber} from 'bignumber.js';
|
import {BigNumber} from 'bignumber.js';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import * as Web3 from 'web3';
|
|
||||||
|
|
||||||
import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
|
import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
|
||||||
import {BlockParamLiteral} from '../types';
|
import {BlockParamLiteral} from '../types';
|
||||||
|
@@ -1,15 +1,15 @@
|
|||||||
import {assert as sharedAssert} from '@0xproject/assert';
|
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 {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 _ from 'lodash';
|
||||||
import * as Web3 from 'web3';
|
|
||||||
|
|
||||||
import {ECSignature} from '../types';
|
import {ECSignature} from '../types';
|
||||||
import {signatureUtils} from '../utils/signature_utils';
|
import {signatureUtils} from '../utils/signature_utils';
|
||||||
|
|
||||||
const HEX_REGEX = /^0x[0-9A-F]*$/i;
|
|
||||||
|
|
||||||
export const assert = {
|
export const assert = {
|
||||||
...sharedAssert,
|
...sharedAssert,
|
||||||
isValidSignature(orderHash: string, ecSignature: ECSignature, signerAddress: string) {
|
isValidSignature(orderHash: string, ecSignature: ECSignature, signerAddress: string) {
|
||||||
|
@@ -1,24 +1,19 @@
|
|||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import * as Web3 from 'web3';
|
|
||||||
|
|
||||||
import {ZeroEx} from '../0x';
|
import {ZeroEx} from '../0x';
|
||||||
import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
|
import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
|
||||||
import {TokenWrapper} from '../contract_wrappers/token_wrapper';
|
|
||||||
import {RemainingFillableCalculator} from '../order_watcher/remaining_fillable_calculator';
|
import {RemainingFillableCalculator} from '../order_watcher/remaining_fillable_calculator';
|
||||||
import {BalanceAndProxyAllowanceLazyStore} from '../stores/balance_proxy_allowance_lazy_store';
|
import {BalanceAndProxyAllowanceLazyStore} from '../stores/balance_proxy_allowance_lazy_store';
|
||||||
import {OrderFilledCancelledLazyStore} from '../stores/order_filled_cancelled_lazy_store';
|
import {OrderFilledCancelledLazyStore} from '../stores/order_filled_cancelled_lazy_store';
|
||||||
import {
|
import {
|
||||||
ExchangeContractErrs,
|
ExchangeContractErrs,
|
||||||
MethodOpts,
|
|
||||||
OrderRelevantState,
|
OrderRelevantState,
|
||||||
OrderState,
|
OrderState,
|
||||||
OrderStateInvalid,
|
OrderStateInvalid,
|
||||||
OrderStateValid,
|
OrderStateValid,
|
||||||
SignedOrder,
|
SignedOrder,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import {constants} from '../utils/constants';
|
|
||||||
import {utils} from '../utils/utils';
|
|
||||||
|
|
||||||
const ACCEPTABLE_RELATIVE_ROUNDING_ERROR = 0.0001;
|
const ACCEPTABLE_RELATIVE_ROUNDING_ERROR = 0.0001;
|
||||||
|
|
||||||
|
@@ -3,7 +3,6 @@ import * as _ from 'lodash';
|
|||||||
|
|
||||||
import {ZeroEx} from '../0x';
|
import {ZeroEx} from '../0x';
|
||||||
import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
|
import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
|
||||||
import {TokenWrapper} from '../contract_wrappers/token_wrapper';
|
|
||||||
import {ExchangeContractErrs, Order, SignedOrder, TradeSide, TransferType, ZeroExError} from '../types';
|
import {ExchangeContractErrs, Order, SignedOrder, TradeSide, TransferType, ZeroExError} from '../types';
|
||||||
import {constants} from '../utils/constants';
|
import {constants} from '../utils/constants';
|
||||||
import {utils} from '../utils/utils';
|
import {utils} from '../utils/utils';
|
||||||
@@ -11,7 +10,6 @@ import {utils} from '../utils/utils';
|
|||||||
import {ExchangeTransferSimulator} from './exchange_transfer_simulator';
|
import {ExchangeTransferSimulator} from './exchange_transfer_simulator';
|
||||||
|
|
||||||
export class OrderValidationUtils {
|
export class OrderValidationUtils {
|
||||||
private tokenWrapper: TokenWrapper;
|
|
||||||
private exchangeWrapper: ExchangeWrapper;
|
private exchangeWrapper: ExchangeWrapper;
|
||||||
public static validateCancelOrderThrowIfInvalid(
|
public static validateCancelOrderThrowIfInvalid(
|
||||||
order: Order, cancelTakerTokenAmount: BigNumber, unavailableTakerTokenAmount: BigNumber,
|
order: Order, cancelTakerTokenAmount: BigNumber, unavailableTakerTokenAmount: BigNumber,
|
||||||
@@ -84,8 +82,7 @@ export class OrderValidationUtils {
|
|||||||
.round(0);
|
.round(0);
|
||||||
return fillMakerTokenAmount;
|
return fillMakerTokenAmount;
|
||||||
}
|
}
|
||||||
constructor(tokenWrapper: TokenWrapper, exchangeWrapper: ExchangeWrapper) {
|
constructor(exchangeWrapper: ExchangeWrapper) {
|
||||||
this.tokenWrapper = tokenWrapper;
|
|
||||||
this.exchangeWrapper = exchangeWrapper;
|
this.exchangeWrapper = exchangeWrapper;
|
||||||
}
|
}
|
||||||
public async validateOrderFillableOrThrowAsync(
|
public async validateOrderFillableOrThrowAsync(
|
||||||
|
@@ -5,7 +5,7 @@ import * as _ from 'lodash';
|
|||||||
import 'mocha';
|
import 'mocha';
|
||||||
import * as Sinon from 'sinon';
|
import * as Sinon from 'sinon';
|
||||||
|
|
||||||
import {ApprovalContractEventArgs, LogWithDecodedArgs, Order, TokenEvents, ZeroEx, ZeroExError} from '../src';
|
import {ApprovalContractEventArgs, LogWithDecodedArgs, Order, TokenEvents, ZeroEx} from '../src';
|
||||||
|
|
||||||
import {chaiSetup} from './utils/chai_setup';
|
import {chaiSetup} from './utils/chai_setup';
|
||||||
import {constants} from './utils/constants';
|
import {constants} from './utils/constants';
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import * as chai from 'chai';
|
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import HDWalletProvider = require('truffle-hdwallet-provider');
|
import HDWalletProvider = require('truffle-hdwallet-provider');
|
||||||
|
|
||||||
@@ -8,7 +7,6 @@ import {chaiSetup} from './utils/chai_setup';
|
|||||||
import {constants} from './utils/constants';
|
import {constants} from './utils/constants';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
|
||||||
|
|
||||||
// Those tests are slower cause they're talking to a remote node
|
// Those tests are slower cause they're talking to a remote node
|
||||||
const TIMEOUT = 10000;
|
const TIMEOUT = 10000;
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import {Web3Wrapper} from '@0xproject/web3-wrapper';
|
import {Web3Wrapper} from '@0xproject/web3-wrapper';
|
||||||
import BigNumber from 'bignumber.js';
|
|
||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import 'mocha';
|
import 'mocha';
|
||||||
@@ -7,15 +6,12 @@ import * as Sinon from 'sinon';
|
|||||||
import * as Web3 from 'web3';
|
import * as Web3 from 'web3';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DecodedLogEvent,
|
|
||||||
LogEvent,
|
LogEvent,
|
||||||
ZeroEx,
|
|
||||||
} from '../src';
|
} from '../src';
|
||||||
import {EventWatcher} from '../src/order_watcher/event_watcher';
|
import {EventWatcher} from '../src/order_watcher/event_watcher';
|
||||||
import {DoneCallback} from '../src/types';
|
import {DoneCallback} from '../src/types';
|
||||||
|
|
||||||
import {chaiSetup} from './utils/chai_setup';
|
import {chaiSetup} from './utils/chai_setup';
|
||||||
import {constants} from './utils/constants';
|
|
||||||
import {web3Factory} from './utils/web3_factory';
|
import {web3Factory} from './utils/web3_factory';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
@@ -26,7 +22,6 @@ describe('EventWatcher', () => {
|
|||||||
let stubs: Sinon.SinonStub[] = [];
|
let stubs: Sinon.SinonStub[] = [];
|
||||||
let eventWatcher: EventWatcher;
|
let eventWatcher: EventWatcher;
|
||||||
let web3Wrapper: Web3Wrapper;
|
let web3Wrapper: Web3Wrapper;
|
||||||
const numConfirmations = 0;
|
|
||||||
const logA: Web3.LogEntry = {
|
const logA: Web3.LogEntry = {
|
||||||
address: '0x71d271f8b14adef568f8f28f1587ce7271ac4ca5',
|
address: '0x71d271f8b14adef568f8f28f1587ce7271ac4ca5',
|
||||||
blockHash: null,
|
blockHash: null,
|
||||||
|
@@ -9,7 +9,6 @@ import {
|
|||||||
ExchangeContractErrs,
|
ExchangeContractErrs,
|
||||||
ExchangeEvents,
|
ExchangeEvents,
|
||||||
LogCancelContractEventArgs,
|
LogCancelContractEventArgs,
|
||||||
LogEvent,
|
|
||||||
LogFillContractEventArgs,
|
LogFillContractEventArgs,
|
||||||
OrderCancellationRequest,
|
OrderCancellationRequest,
|
||||||
OrderFillRequest,
|
OrderFillRequest,
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import {BlockchainLifecycle} from '@0xproject/dev-utils';
|
import {BlockchainLifecycle} from '@0xproject/dev-utils';
|
||||||
import {Web3Wrapper} from '@0xproject/web3-wrapper';
|
|
||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import {BlockchainLifecycle} from '@0xproject/dev-utils';
|
import {BlockchainLifecycle} from '@0xproject/dev-utils';
|
||||||
import {Web3Wrapper} from '@0xproject/web3-wrapper';
|
|
||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
@@ -7,19 +6,15 @@ import 'mocha';
|
|||||||
import * as Web3 from 'web3';
|
import * as Web3 from 'web3';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DecodedLogEvent,
|
|
||||||
ExchangeContractErrs,
|
ExchangeContractErrs,
|
||||||
LogEvent,
|
|
||||||
OrderState,
|
OrderState,
|
||||||
OrderStateInvalid,
|
OrderStateInvalid,
|
||||||
OrderStateValid,
|
OrderStateValid,
|
||||||
SignedOrder,
|
SignedOrder,
|
||||||
Token,
|
Token,
|
||||||
ZeroEx,
|
ZeroEx,
|
||||||
ZeroExConfig,
|
|
||||||
ZeroExError,
|
ZeroExError,
|
||||||
} from '../src';
|
} from '../src';
|
||||||
import {OrderStateWatcher} from '../src/order_watcher/order_state_watcher';
|
|
||||||
import {DoneCallback} from '../src/types';
|
import {DoneCallback} from '../src/types';
|
||||||
|
|
||||||
import {chaiSetup} from './utils/chai_setup';
|
import {chaiSetup} from './utils/chai_setup';
|
||||||
@@ -48,7 +43,6 @@ describe('OrderStateWatcher', () => {
|
|||||||
let takerToken: Token;
|
let takerToken: Token;
|
||||||
let maker: string;
|
let maker: string;
|
||||||
let taker: string;
|
let taker: string;
|
||||||
let web3Wrapper: Web3Wrapper;
|
|
||||||
let signedOrder: SignedOrder;
|
let signedOrder: SignedOrder;
|
||||||
const config = {
|
const config = {
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
@@ -67,7 +61,6 @@ describe('OrderStateWatcher', () => {
|
|||||||
fillScenarios = new FillScenarios(zeroEx, userAddresses, tokens, zrxTokenAddress, exchangeContractAddress);
|
fillScenarios = new FillScenarios(zeroEx, userAddresses, tokens, zrxTokenAddress, exchangeContractAddress);
|
||||||
await fillScenarios.initTokenBalancesAsync();
|
await fillScenarios.initTokenBalancesAsync();
|
||||||
[makerToken, takerToken] = tokenUtils.getDummyTokens();
|
[makerToken, takerToken] = tokenUtils.getDummyTokens();
|
||||||
web3Wrapper = (zeroEx as any)._web3Wrapper;
|
|
||||||
});
|
});
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await blockchainLifecycle.startAsync();
|
await blockchainLifecycle.startAsync();
|
||||||
@@ -142,7 +135,6 @@ describe('OrderStateWatcher', () => {
|
|||||||
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||||
makerToken.address, takerToken.address, maker, taker, fillableAmount,
|
makerToken.address, takerToken.address, maker, taker, fillableAmount,
|
||||||
);
|
);
|
||||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
|
||||||
zeroEx.orderStateWatcher.addOrder(signedOrder);
|
zeroEx.orderStateWatcher.addOrder(signedOrder);
|
||||||
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
|
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
|
||||||
throw new Error('OrderState callback fired for irrelevant order');
|
throw new Error('OrderState callback fired for irrelevant order');
|
||||||
@@ -151,7 +143,6 @@ describe('OrderStateWatcher', () => {
|
|||||||
const notTheMaker = userAddresses[0];
|
const notTheMaker = userAddresses[0];
|
||||||
const anyRecipient = taker;
|
const anyRecipient = taker;
|
||||||
const transferAmount = new BigNumber(2);
|
const transferAmount = new BigNumber(2);
|
||||||
const notTheMakerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, notTheMaker);
|
|
||||||
await zeroEx.token.transferAsync(makerToken.address, notTheMaker, anyRecipient, transferAmount);
|
await zeroEx.token.transferAsync(makerToken.address, notTheMaker, anyRecipient, transferAmount);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
done();
|
done();
|
||||||
@@ -208,8 +199,6 @@ describe('OrderStateWatcher', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
|
const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
|
||||||
const takerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, taker);
|
|
||||||
|
|
||||||
const fillAmountInBaseUnits = new BigNumber(2);
|
const fillAmountInBaseUnits = new BigNumber(2);
|
||||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||||
zeroEx.orderStateWatcher.addOrder(signedOrder);
|
zeroEx.orderStateWatcher.addOrder(signedOrder);
|
||||||
@@ -242,8 +231,6 @@ describe('OrderStateWatcher', () => {
|
|||||||
signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
|
signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
|
||||||
makerToken.address, takerToken.address, makerFee, takerFee, maker, taker, fillableAmount,
|
makerToken.address, takerToken.address, makerFee, takerFee, maker, taker, fillableAmount,
|
||||||
taker);
|
taker);
|
||||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
|
||||||
zeroEx.orderStateWatcher.addOrder(signedOrder);
|
|
||||||
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
|
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@@ -260,8 +247,6 @@ describe('OrderStateWatcher', () => {
|
|||||||
makerToken.address, takerToken.address, maker, taker, makerFillableAmount,
|
makerToken.address, takerToken.address, maker, taker, makerFillableAmount,
|
||||||
takerFillableAmount,
|
takerFillableAmount,
|
||||||
);
|
);
|
||||||
const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
|
|
||||||
const takerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, taker);
|
|
||||||
const fillAmountInBaseUnits = ZeroEx.toBaseUnitAmount(new BigNumber(2), decimals);
|
const fillAmountInBaseUnits = ZeroEx.toBaseUnitAmount(new BigNumber(2), decimals);
|
||||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||||
zeroEx.orderStateWatcher.addOrder(signedOrder);
|
zeroEx.orderStateWatcher.addOrder(signedOrder);
|
||||||
@@ -289,8 +274,6 @@ describe('OrderStateWatcher', () => {
|
|||||||
makerToken.address, takerToken.address, maker, taker, fillableAmount,
|
makerToken.address, takerToken.address, maker, taker, fillableAmount,
|
||||||
);
|
);
|
||||||
|
|
||||||
const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
|
|
||||||
|
|
||||||
const changedMakerApprovalAmount = ZeroEx.toBaseUnitAmount(new BigNumber(3), decimals);
|
const changedMakerApprovalAmount = ZeroEx.toBaseUnitAmount(new BigNumber(3), decimals);
|
||||||
zeroEx.orderStateWatcher.addOrder(signedOrder);
|
zeroEx.orderStateWatcher.addOrder(signedOrder);
|
||||||
|
|
||||||
@@ -343,8 +326,6 @@ describe('OrderStateWatcher', () => {
|
|||||||
makerToken.address, takerToken.address, makerFee, takerFee, maker,
|
makerToken.address, takerToken.address, makerFee, takerFee, maker,
|
||||||
taker, fillableAmount, feeRecipient);
|
taker, fillableAmount, feeRecipient);
|
||||||
|
|
||||||
const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
|
|
||||||
|
|
||||||
const remainingTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(4), decimals);
|
const remainingTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(4), decimals);
|
||||||
const transferTokenAmount = makerFee.sub(remainingTokenAmount);
|
const transferTokenAmount = makerFee.sub(remainingTokenAmount);
|
||||||
zeroEx.orderStateWatcher.addOrder(signedOrder);
|
zeroEx.orderStateWatcher.addOrder(signedOrder);
|
||||||
@@ -370,10 +351,7 @@ describe('OrderStateWatcher', () => {
|
|||||||
makerToken.address, takerToken.address, makerFee, takerFee, maker,
|
makerToken.address, takerToken.address, makerFee, takerFee, maker,
|
||||||
taker, fillableAmount, feeRecipient);
|
taker, fillableAmount, feeRecipient);
|
||||||
|
|
||||||
const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
|
|
||||||
|
|
||||||
const remainingFeeAmount = ZeroEx.toBaseUnitAmount(new BigNumber(3), decimals);
|
const remainingFeeAmount = ZeroEx.toBaseUnitAmount(new BigNumber(3), decimals);
|
||||||
const transferFeeAmount = makerFee.sub(remainingFeeAmount);
|
|
||||||
|
|
||||||
const remainingTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(4), decimals);
|
const remainingTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(4), decimals);
|
||||||
const transferTokenAmount = makerFee.sub(remainingTokenAmount);
|
const transferTokenAmount = makerFee.sub(remainingTokenAmount);
|
||||||
@@ -401,7 +379,6 @@ describe('OrderStateWatcher', () => {
|
|||||||
makerToken.address, takerToken.address, makerFee, takerFee, maker,
|
makerToken.address, takerToken.address, makerFee, takerFee, maker,
|
||||||
taker, fillableAmount, feeRecipient);
|
taker, fillableAmount, feeRecipient);
|
||||||
|
|
||||||
const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
|
|
||||||
zeroEx.orderStateWatcher.addOrder(signedOrder);
|
zeroEx.orderStateWatcher.addOrder(signedOrder);
|
||||||
|
|
||||||
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
|
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
|
||||||
@@ -434,7 +411,6 @@ describe('OrderStateWatcher', () => {
|
|||||||
});
|
});
|
||||||
zeroEx.orderStateWatcher.subscribe(callback);
|
zeroEx.orderStateWatcher.subscribe(callback);
|
||||||
|
|
||||||
const shouldThrowOnInsufficientBalanceOrAllowance = true;
|
|
||||||
await zeroEx.exchange.cancelOrderAsync(signedOrder, fillableAmount);
|
await zeroEx.exchange.cancelOrderAsync(signedOrder, fillableAmount);
|
||||||
})().catch(done);
|
})().catch(done);
|
||||||
});
|
});
|
||||||
@@ -466,9 +442,6 @@ describe('OrderStateWatcher', () => {
|
|||||||
makerToken.address, takerToken.address, maker, taker, fillableAmount,
|
makerToken.address, takerToken.address, maker, taker, fillableAmount,
|
||||||
);
|
);
|
||||||
|
|
||||||
const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
|
|
||||||
const takerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, taker);
|
|
||||||
|
|
||||||
const cancelAmountInBaseUnits = new BigNumber(2);
|
const cancelAmountInBaseUnits = new BigNumber(2);
|
||||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||||
zeroEx.orderStateWatcher.addOrder(signedOrder);
|
zeroEx.orderStateWatcher.addOrder(signedOrder);
|
||||||
|
@@ -34,7 +34,6 @@ describe('OrderValidation', () => {
|
|||||||
let makerAddress: string;
|
let makerAddress: string;
|
||||||
let takerAddress: string;
|
let takerAddress: string;
|
||||||
let feeRecipient: string;
|
let feeRecipient: string;
|
||||||
let orderValidationUtils: OrderValidationUtils;
|
|
||||||
const fillableAmount = new BigNumber(5);
|
const fillableAmount = new BigNumber(5);
|
||||||
const fillTakerAmount = new BigNumber(5);
|
const fillTakerAmount = new BigNumber(5);
|
||||||
const config = {
|
const config = {
|
||||||
@@ -53,7 +52,6 @@ describe('OrderValidation', () => {
|
|||||||
const [makerToken, takerToken] = tokenUtils.getDummyTokens();
|
const [makerToken, takerToken] = tokenUtils.getDummyTokens();
|
||||||
makerTokenAddress = makerToken.address;
|
makerTokenAddress = makerToken.address;
|
||||||
takerTokenAddress = takerToken.address;
|
takerTokenAddress = takerToken.address;
|
||||||
orderValidationUtils = new OrderValidationUtils(zeroEx.token, zeroEx.exchange);
|
|
||||||
});
|
});
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await blockchainLifecycle.startAsync();
|
await blockchainLifecycle.startAsync();
|
||||||
@@ -181,7 +179,6 @@ describe('OrderValidation', () => {
|
|||||||
});
|
});
|
||||||
describe('validateCancelOrderAndThrowIfInvalidAsync', () => {
|
describe('validateCancelOrderAndThrowIfInvalidAsync', () => {
|
||||||
let signedOrder: SignedOrder;
|
let signedOrder: SignedOrder;
|
||||||
let orderHashHex: string;
|
|
||||||
const cancelAmount = new BigNumber(3);
|
const cancelAmount = new BigNumber(3);
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
[coinbase, makerAddress, takerAddress] = userAddresses;
|
[coinbase, makerAddress, takerAddress] = userAddresses;
|
||||||
@@ -191,7 +188,6 @@ describe('OrderValidation', () => {
|
|||||||
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||||
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
|
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
|
||||||
);
|
);
|
||||||
orderHashHex = ZeroEx.getOrderHashHex(signedOrder);
|
|
||||||
});
|
});
|
||||||
it('should throw when cancel amount is zero', async () => {
|
it('should throw when cancel amount is zero', async () => {
|
||||||
const zeroCancelAmount = new BigNumber(0);
|
const zeroCancelAmount = new BigNumber(0);
|
||||||
@@ -204,7 +200,6 @@ describe('OrderValidation', () => {
|
|||||||
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress,
|
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress,
|
||||||
fillableAmount, expirationInPast,
|
fillableAmount, expirationInPast,
|
||||||
);
|
);
|
||||||
orderHashHex = ZeroEx.getOrderHashHex(expiredSignedOrder);
|
|
||||||
return expect(zeroEx.exchange.validateCancelOrderThrowIfInvalidAsync(expiredSignedOrder, cancelAmount))
|
return expect(zeroEx.exchange.validateCancelOrderThrowIfInvalidAsync(expiredSignedOrder, cancelAmount))
|
||||||
.to.be.rejectedWith(ExchangeContractErrs.OrderCancelExpired);
|
.to.be.rejectedWith(ExchangeContractErrs.OrderCancelExpired);
|
||||||
});
|
});
|
||||||
|
@@ -7,7 +7,6 @@ import { RemainingFillableCalculator } from '../src/order_watcher/remaining_fill
|
|||||||
import { ECSignature, SignedOrder } from '../src/types';
|
import { ECSignature, SignedOrder } from '../src/types';
|
||||||
|
|
||||||
import { chaiSetup } from './utils/chai_setup';
|
import { chaiSetup } from './utils/chai_setup';
|
||||||
import { TokenUtils } from './utils/token_utils';
|
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
|
@@ -12,14 +12,12 @@ import {
|
|||||||
Token,
|
Token,
|
||||||
TokenEvents,
|
TokenEvents,
|
||||||
ZeroEx,
|
ZeroEx,
|
||||||
ZeroExError,
|
|
||||||
} from '../src';
|
} from '../src';
|
||||||
import {BlockParamLiteral, DoneCallback} from '../src/types';
|
import {DoneCallback} from '../src/types';
|
||||||
|
|
||||||
import {chaiSetup} from './utils/chai_setup';
|
import {chaiSetup} from './utils/chai_setup';
|
||||||
import {constants} from './utils/constants';
|
import {constants} from './utils/constants';
|
||||||
import {reportCallbackErrors} from './utils/report_callback_errors';
|
import {reportCallbackErrors} from './utils/report_callback_errors';
|
||||||
import {TokenUtils} from './utils/token_utils';
|
|
||||||
import {web3Factory} from './utils/web3_factory';
|
import {web3Factory} from './utils/web3_factory';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
@@ -31,7 +29,6 @@ describe('SubscriptionTest', () => {
|
|||||||
let zeroEx: ZeroEx;
|
let zeroEx: ZeroEx;
|
||||||
let userAddresses: string[];
|
let userAddresses: string[];
|
||||||
let tokens: Token[];
|
let tokens: Token[];
|
||||||
let tokenUtils: TokenUtils;
|
|
||||||
let coinbase: string;
|
let coinbase: string;
|
||||||
let addressWithoutFunds: string;
|
let addressWithoutFunds: string;
|
||||||
const config = {
|
const config = {
|
||||||
@@ -42,7 +39,6 @@ describe('SubscriptionTest', () => {
|
|||||||
zeroEx = new ZeroEx(web3.currentProvider, config);
|
zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||||
tokenUtils = new TokenUtils(tokens);
|
|
||||||
coinbase = userAddresses[0];
|
coinbase = userAddresses[0];
|
||||||
addressWithoutFunds = userAddresses[1];
|
addressWithoutFunds = userAddresses[1];
|
||||||
});
|
});
|
||||||
@@ -54,9 +50,7 @@ describe('SubscriptionTest', () => {
|
|||||||
});
|
});
|
||||||
describe('#subscribe', () => {
|
describe('#subscribe', () => {
|
||||||
const indexFilterValues = {};
|
const indexFilterValues = {};
|
||||||
const shouldThrowOnInsufficientBalanceOrAllowance = true;
|
|
||||||
let tokenAddress: string;
|
let tokenAddress: string;
|
||||||
const transferAmount = new BigNumber(42);
|
|
||||||
const allowanceAmount = new BigNumber(42);
|
const allowanceAmount = new BigNumber(42);
|
||||||
let stubs: Sinon.SinonStub[] = [];
|
let stubs: Sinon.SinonStub[] = [];
|
||||||
before(() => {
|
before(() => {
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
|
|
||||||
import {ZeroEx} from '../src';
|
import {ZeroEx} from '../src';
|
||||||
import {TokenTransferProxyWrapper} from '../src/contract_wrappers/token_transfer_proxy_wrapper';
|
|
||||||
|
|
||||||
import {chaiSetup} from './utils/chai_setup';
|
import {chaiSetup} from './utils/chai_setup';
|
||||||
import {constants} from './utils/constants';
|
import {constants} from './utils/constants';
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import {BlockchainLifecycle} from '@0xproject/dev-utils';
|
import {BlockchainLifecycle} from '@0xproject/dev-utils';
|
||||||
import {promisify} from '@0xproject/utils';
|
|
||||||
import {Web3Wrapper} from '@0xproject/web3-wrapper';
|
import {Web3Wrapper} from '@0xproject/web3-wrapper';
|
||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
@@ -8,13 +7,9 @@ import * as Web3 from 'web3';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
ApprovalContractEventArgs,
|
ApprovalContractEventArgs,
|
||||||
ContractEvent,
|
|
||||||
DecodedLogEvent,
|
DecodedLogEvent,
|
||||||
LogEvent,
|
|
||||||
LogWithDecodedArgs,
|
|
||||||
SubscriptionOpts,
|
SubscriptionOpts,
|
||||||
Token,
|
Token,
|
||||||
TokenContractEventArgs,
|
|
||||||
TokenEvents,
|
TokenEvents,
|
||||||
TransferContractEventArgs,
|
TransferContractEventArgs,
|
||||||
ZeroEx,
|
ZeroEx,
|
||||||
@@ -71,8 +66,7 @@ describe('TokenWrapper', () => {
|
|||||||
const toAddress = addressWithoutFunds;
|
const toAddress = addressWithoutFunds;
|
||||||
const preBalance = await zeroEx.token.getBalanceAsync(token.address, toAddress);
|
const preBalance = await zeroEx.token.getBalanceAsync(token.address, toAddress);
|
||||||
expect(preBalance).to.be.bignumber.equal(0);
|
expect(preBalance).to.be.bignumber.equal(0);
|
||||||
const txHash = await zeroEx.token.transferAsync(token.address, fromAddress, toAddress, transferAmount);
|
await zeroEx.token.transferAsync(token.address, fromAddress, toAddress, transferAmount);
|
||||||
const receipt = await zeroEx.awaitTransactionMinedAsync(txHash);
|
|
||||||
const postBalance = await zeroEx.token.getBalanceAsync(token.address, toAddress);
|
const postBalance = await zeroEx.token.getBalanceAsync(token.address, toAddress);
|
||||||
return expect(postBalance).to.be.bignumber.equal(transferAmount);
|
return expect(postBalance).to.be.bignumber.equal(transferAmount);
|
||||||
});
|
});
|
||||||
@@ -354,7 +348,6 @@ describe('TokenWrapper', () => {
|
|||||||
});
|
});
|
||||||
describe('#subscribe', () => {
|
describe('#subscribe', () => {
|
||||||
const indexFilterValues = {};
|
const indexFilterValues = {};
|
||||||
const shouldThrowOnInsufficientBalanceOrAllowance = true;
|
|
||||||
let tokenAddress: string;
|
let tokenAddress: string;
|
||||||
const transferAmount = new BigNumber(42);
|
const transferAmount = new BigNumber(42);
|
||||||
const allowanceAmount = new BigNumber(42);
|
const allowanceAmount = new BigNumber(42);
|
||||||
|
Reference in New Issue
Block a user