diff options
| author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-10-26 03:22:23 +0800 | 
|---|---|---|
| committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-10-26 03:22:23 +0800 | 
| commit | 744a9b89312c825ee94195106b9aa8aa11f43b77 (patch) | |
| tree | 29009ec3e75e9d0396e744993065c05ef04c650b | |
| parent | 45c4042e2bb6d4c13510a5922602ba49bb5108ef (diff) | |
| download | dexon-sol-tools-744a9b89312c825ee94195106b9aa8aa11f43b77.tar.gz dexon-sol-tools-744a9b89312c825ee94195106b9aa8aa11f43b77.tar.zst dexon-sol-tools-744a9b89312c825ee94195106b9aa8aa11f43b77.zip | |
Upgrade bignumber to the version with native typings and remove typings
| -rw-r--r-- | src/0x.ts | 8 | ||||
| -rw-r--r-- | src/bignumber_config.ts | 2 | ||||
| -rw-r--r-- | src/contract_wrappers/ether_token_wrapper.ts | 5 | ||||
| -rw-r--r-- | src/contract_wrappers/exchange_wrapper.ts | 28 | ||||
| -rw-r--r-- | src/contract_wrappers/token_wrapper.ts | 16 | ||||
| -rw-r--r-- | src/globals.d.ts | 8 | ||||
| -rw-r--r-- | src/types.ts | 99 | ||||
| -rw-r--r-- | src/utils/abi_decoder.ts | 2 | ||||
| -rw-r--r-- | src/utils/assert.ts | 6 | ||||
| -rw-r--r-- | src/utils/constants.ts | 2 | ||||
| -rw-r--r-- | src/utils/exchange_transfer_simulator.ts | 21 | ||||
| -rw-r--r-- | src/utils/order_validation_utils.ts | 23 | ||||
| -rw-r--r-- | src/utils/utils.ts | 6 | ||||
| -rw-r--r-- | src/web3_wrapper.ts | 6 | ||||
| -rw-r--r-- | test/0x.js_test.ts | 2 | ||||
| -rw-r--r-- | test/ether_token_wrapper_test.ts | 4 | ||||
| -rw-r--r-- | test/exchange_transfer_simulator_test.ts | 2 | ||||
| -rw-r--r-- | test/exchange_wrapper_test.ts | 8 | ||||
| -rw-r--r-- | test/order_validation_test.ts | 6 | ||||
| -rw-r--r-- | test/token_wrapper_test.ts | 4 | ||||
| -rw-r--r-- | test/utils/fill_scenarios.ts | 32 | ||||
| -rw-r--r-- | test/utils/order_factory.ts | 12 | 
22 files changed, 149 insertions, 153 deletions
| @@ -1,5 +1,5 @@  import * as _ from 'lodash'; -import * as BigNumber from 'bignumber.js'; +import BigNumber from 'bignumber.js';  import {SchemaValidator, schemas} from '0x-json-schemas';  import {bigNumberConfigs} from './bignumber_config';  import * as ethUtil from 'ethereumjs-util'; @@ -100,7 +100,7 @@ export class ZeroEx {       * and will not collide with other outstanding orders that are identical in all other parameters.       * @return  A pseudo-random 256-bit number that can be used as a salt.       */ -    public static generatePseudoRandomSalt(): BigNumber.BigNumber { +    public static generatePseudoRandomSalt(): BigNumber {          // BigNumber.random returns a pseudo-random number between 0 & 1 with a passed in number of decimal places.          // Source: https://mikemcl.github.io/bignumber.js/#random          const randomNumber = BigNumber.random(constants.MAX_DIGITS_IN_UNSIGNED_256_INT); @@ -131,7 +131,7 @@ export class ZeroEx {       * @param   decimals    The number of decimal places the unit amount has.       * @return  The amount in units.       */ -    public static toUnitAmount(amount: BigNumber.BigNumber, decimals: number): BigNumber.BigNumber { +    public static toUnitAmount(amount: BigNumber, decimals: number): BigNumber {          assert.isBigNumber('amount', amount);          assert.isNumber('decimals', decimals); @@ -147,7 +147,7 @@ export class ZeroEx {       * @param   decimals    The number of decimal places the unit amount has.       * @return  The amount in baseUnits.       */ -    public static toBaseUnitAmount(amount: BigNumber.BigNumber, decimals: number): BigNumber.BigNumber { +    public static toBaseUnitAmount(amount: BigNumber, decimals: number): BigNumber {          assert.isBigNumber('amount', amount);          assert.isNumber('decimals', decimals); diff --git a/src/bignumber_config.ts b/src/bignumber_config.ts index 9c1715f86..2d5214e6f 100644 --- a/src/bignumber_config.ts +++ b/src/bignumber_config.ts @@ -1,4 +1,4 @@ -import * as BigNumber from 'bignumber.js'; +import BigNumber from 'bignumber.js';  export const bigNumberConfigs = {      configure() { diff --git a/src/contract_wrappers/ether_token_wrapper.ts b/src/contract_wrappers/ether_token_wrapper.ts index f15e766f0..7c94e314a 100644 --- a/src/contract_wrappers/ether_token_wrapper.ts +++ b/src/contract_wrappers/ether_token_wrapper.ts @@ -1,4 +1,5 @@  import * as _ from 'lodash'; +import BigNumber from 'bignumber.js';  import {Web3Wrapper} from '../web3_wrapper';  import {ContractWrapper} from './contract_wrapper';  import {TokenWrapper} from './token_wrapper'; @@ -27,7 +28,7 @@ export class EtherTokenWrapper extends ContractWrapper {       * @param   depositor   The hex encoded user Ethereum address that would like to make the deposit.       * @return Transaction hash.       */ -    public async depositAsync(amountInWei: BigNumber.BigNumber, depositor: string): Promise<string> { +    public async depositAsync(amountInWei: BigNumber, depositor: string): Promise<string> {          assert.isBigNumber('amountInWei', amountInWei);          await assert.isSenderAddressAsync('depositor', depositor, this._web3Wrapper); @@ -48,7 +49,7 @@ export class EtherTokenWrapper extends ContractWrapper {       * @param   withdrawer   The hex encoded user Ethereum address that would like to make the withdrawl.       * @return Transaction hash.       */ -    public async withdrawAsync(amountInWei: BigNumber.BigNumber, withdrawer: string): Promise<string> { +    public async withdrawAsync(amountInWei: BigNumber, withdrawer: string): Promise<string> {          assert.isBigNumber('amountInWei', amountInWei);          await assert.isSenderAddressAsync('withdrawer', withdrawer, this._web3Wrapper); diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index bc0ac0634..d8e9edb67 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -1,6 +1,6 @@  import * as _ from 'lodash';  import * as Web3 from 'web3'; -import * as BigNumber from 'bignumber.js'; +import BigNumber from 'bignumber.js';  import {schemas} from '0x-json-schemas';  import {Web3Wrapper} from '../web3_wrapper';  import { @@ -97,7 +97,7 @@ export class ExchangeWrapper extends ContractWrapper {       * @return  The amount of the order (in taker tokens) that has either been filled or canceled.       */      public async getUnavailableTakerAmountAsync(orderHash: string, -                                                methodOpts?: MethodOpts): Promise<BigNumber.BigNumber> { +                                                methodOpts?: MethodOpts): Promise<BigNumber> {          assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);          const exchangeContract = await this._getExchangeContractAsync(); @@ -115,7 +115,7 @@ export class ExchangeWrapper extends ContractWrapper {       * @param   methodOpts   Optional arguments this method accepts.       * @return  The amount of the order (in taker tokens) that has already been filled.       */ -    public async getFilledTakerAmountAsync(orderHash: string, methodOpts?: MethodOpts): Promise<BigNumber.BigNumber> { +    public async getFilledTakerAmountAsync(orderHash: string, methodOpts?: MethodOpts): Promise<BigNumber> {          assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);          const exchangeContract = await this._getExchangeContractAsync(); @@ -132,7 +132,7 @@ export class ExchangeWrapper extends ContractWrapper {       * @param   methodOpts   Optional arguments this method accepts.       * @return  The amount of the order (in taker tokens) that has been cancelled.       */ -    public async getCanceledTakerAmountAsync(orderHash: string, methodOpts?: MethodOpts): Promise<BigNumber.BigNumber> { +    public async getCanceledTakerAmountAsync(orderHash: string, methodOpts?: MethodOpts): Promise<BigNumber> {          assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);          const exchangeContract = await this._getExchangeContractAsync(); @@ -162,7 +162,7 @@ export class ExchangeWrapper extends ContractWrapper {       * @return  Transaction hash.       */      @decorators.contractCallErrorHandler -    public async fillOrderAsync(signedOrder: SignedOrder, fillTakerTokenAmount: BigNumber.BigNumber, +    public async fillOrderAsync(signedOrder: SignedOrder, fillTakerTokenAmount: BigNumber,                                  shouldThrowOnInsufficientBalanceOrAllowance: boolean,                                  takerAddress: string,                                  orderTransactionOpts?: OrderTransactionOpts): Promise<string> { @@ -229,7 +229,7 @@ export class ExchangeWrapper extends ContractWrapper {       * @return  Transaction hash.       */      @decorators.contractCallErrorHandler -    public async fillOrdersUpToAsync(signedOrders: SignedOrder[], fillTakerTokenAmount: BigNumber.BigNumber, +    public async fillOrdersUpToAsync(signedOrders: SignedOrder[], fillTakerTokenAmount: BigNumber,                                       shouldThrowOnInsufficientBalanceOrAllowance: boolean,                                       takerAddress: string,                                       orderTransactionOpts?: OrderTransactionOpts): Promise<string> { @@ -405,7 +405,7 @@ export class ExchangeWrapper extends ContractWrapper {       * @return  Transaction hash.       */      @decorators.contractCallErrorHandler -    public async fillOrKillOrderAsync(signedOrder: SignedOrder, fillTakerTokenAmount: BigNumber.BigNumber, +    public async fillOrKillOrderAsync(signedOrder: SignedOrder, fillTakerTokenAmount: BigNumber,                                        takerAddress: string,                                        orderTransactionOpts?: OrderTransactionOpts): Promise<string> {          assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema); @@ -541,7 +541,7 @@ export class ExchangeWrapper extends ContractWrapper {       */      @decorators.contractCallErrorHandler      public async cancelOrderAsync(order: Order|SignedOrder, -                                  cancelTakerTokenAmount: BigNumber.BigNumber, +                                  cancelTakerTokenAmount: BigNumber,                                    orderTransactionOpts?: OrderTransactionOpts): Promise<string> {          assert.doesConformToSchema('order', order, schemas.orderSchema);          assert.isBigNumber('takerTokenCancelAmount', cancelTakerTokenAmount); @@ -736,7 +736,7 @@ export class ExchangeWrapper extends ContractWrapper {       *                                  Must be available via the supplied Web3.Provider passed to 0x.js.       */      public async validateFillOrderThrowIfInvalidAsync(signedOrder: SignedOrder, -                                                      fillTakerTokenAmount: BigNumber.BigNumber, +                                                      fillTakerTokenAmount: BigNumber,                                                        takerAddress: string): Promise<void> {          assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);          assert.isBigNumber('fillTakerTokenAmount', fillTakerTokenAmount); @@ -753,7 +753,7 @@ export class ExchangeWrapper extends ContractWrapper {       * @param   cancelTakerTokenAmount  The amount (specified in taker tokens) that you would like to cancel.       */      public async validateCancelOrderThrowIfInvalidAsync( -        order: Order, cancelTakerTokenAmount: BigNumber.BigNumber): Promise<void> { +        order: Order, cancelTakerTokenAmount: BigNumber): Promise<void> {          assert.doesConformToSchema('order', order, schemas.orderSchema);          assert.isBigNumber('cancelTakerTokenAmount', cancelTakerTokenAmount);          const orderHash = utils.getOrderHashHex(order); @@ -770,7 +770,7 @@ export class ExchangeWrapper extends ContractWrapper {       *                                  Must be available via the supplied Web3.Provider passed to 0x.js.       */      public async validateFillOrKillOrderThrowIfInvalidAsync(signedOrder: SignedOrder, -                                                            fillTakerTokenAmount: BigNumber.BigNumber, +                                                            fillTakerTokenAmount: BigNumber,                                                              takerAddress: string): Promise<void> {          assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);          assert.isBigNumber('fillTakerTokenAmount', fillTakerTokenAmount); @@ -789,9 +789,9 @@ export class ExchangeWrapper extends ContractWrapper {       * @param   takerTokenAmount       The order size on the taker side       * @param   makerTokenAmount       The order size on the maker side       */ -    public async isRoundingErrorAsync(fillTakerTokenAmount: BigNumber.BigNumber, -                                      takerTokenAmount: BigNumber.BigNumber, -                                      makerTokenAmount: BigNumber.BigNumber): Promise<boolean> { +    public async isRoundingErrorAsync(fillTakerTokenAmount: BigNumber, +                                      takerTokenAmount: BigNumber, +                                      makerTokenAmount: BigNumber): Promise<boolean> {          assert.isBigNumber('fillTakerTokenAmount', fillTakerTokenAmount);          assert.isBigNumber('takerTokenAmount', takerTokenAmount);          assert.isBigNumber('makerTokenAmount', makerTokenAmount); diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts index 70dbc5bfb..5d6d61cef 100644 --- a/src/contract_wrappers/token_wrapper.ts +++ b/src/contract_wrappers/token_wrapper.ts @@ -1,5 +1,5 @@  import * as _ from 'lodash'; -import * as BigNumber from 'bignumber.js'; +import BigNumber from 'bignumber.js';  import {schemas} from '0x-json-schemas';  import {Web3Wrapper} from '../web3_wrapper';  import {assert} from '../utils/assert'; @@ -46,7 +46,7 @@ export class TokenWrapper extends ContractWrapper {       * @return  The owner's ERC20 token balance in base units.       */      public async getBalanceAsync(tokenAddress: string, ownerAddress: string, -                                 methodOpts?: MethodOpts): Promise<BigNumber.BigNumber> { +                                 methodOpts?: MethodOpts): Promise<BigNumber> {          assert.isETHAddressHex('ownerAddress', ownerAddress);          assert.isETHAddressHex('tokenAddress', tokenAddress); @@ -68,7 +68,7 @@ export class TokenWrapper extends ContractWrapper {       * @return Transaction hash.       */      public async setAllowanceAsync(tokenAddress: string, ownerAddress: string, spenderAddress: string, -                                   amountInBaseUnits: BigNumber.BigNumber): Promise<string> { +                                   amountInBaseUnits: BigNumber): Promise<string> {          await assert.isSenderAddressAsync('ownerAddress', ownerAddress, this._web3Wrapper);          assert.isETHAddressHex('spenderAddress', spenderAddress);          assert.isETHAddressHex('tokenAddress', tokenAddress); @@ -113,7 +113,7 @@ export class TokenWrapper extends ContractWrapper {       * @param   methodOpts      Optional arguments this method accepts.       */      public async getAllowanceAsync(tokenAddress: string, ownerAddress: string, -                                   spenderAddress: string, methodOpts?: MethodOpts): Promise<BigNumber.BigNumber> { +                                   spenderAddress: string, methodOpts?: MethodOpts): Promise<BigNumber> {          assert.isETHAddressHex('ownerAddress', ownerAddress);          assert.isETHAddressHex('tokenAddress', tokenAddress); @@ -131,7 +131,7 @@ export class TokenWrapper extends ContractWrapper {       * @param   methodOpts      Optional arguments this method accepts.       */      public async getProxyAllowanceAsync(tokenAddress: string, ownerAddress: string, -                                        methodOpts?: MethodOpts): Promise<BigNumber.BigNumber> { +                                        methodOpts?: MethodOpts): Promise<BigNumber> {          assert.isETHAddressHex('ownerAddress', ownerAddress);          assert.isETHAddressHex('tokenAddress', tokenAddress); @@ -149,7 +149,7 @@ export class TokenWrapper extends ContractWrapper {       * @return Transaction hash.       */      public async setProxyAllowanceAsync(tokenAddress: string, ownerAddress: string, -                                        amountInBaseUnits: BigNumber.BigNumber): Promise<string> { +                                        amountInBaseUnits: BigNumber): Promise<string> {          assert.isETHAddressHex('ownerAddress', ownerAddress);          assert.isETHAddressHex('tokenAddress', tokenAddress);          assert.isBigNumber('amountInBaseUnits', amountInBaseUnits); @@ -183,7 +183,7 @@ export class TokenWrapper extends ContractWrapper {       * @return Transaction hash.       */      public async transferAsync(tokenAddress: string, fromAddress: string, toAddress: string, -                               amountInBaseUnits: BigNumber.BigNumber): Promise<string> { +                               amountInBaseUnits: BigNumber): Promise<string> {          assert.isETHAddressHex('tokenAddress', tokenAddress);          await assert.isSenderAddressAsync('fromAddress', fromAddress, this._web3Wrapper);          assert.isETHAddressHex('toAddress', toAddress); @@ -215,7 +215,7 @@ export class TokenWrapper extends ContractWrapper {       * @return Transaction hash.       */      public async transferFromAsync(tokenAddress: string, fromAddress: string, toAddress: string, -                                   senderAddress: string, amountInBaseUnits: BigNumber.BigNumber): +                                   senderAddress: string, amountInBaseUnits: BigNumber):                                     Promise<string> {          assert.isETHAddressHex('tokenAddress', tokenAddress);          assert.isETHAddressHex('fromAddress', fromAddress); diff --git a/src/globals.d.ts b/src/globals.d.ts index 05d7131c2..cb3800056 100644 --- a/src/globals.d.ts +++ b/src/globals.d.ts @@ -12,12 +12,6 @@ declare module 'web3-provider-engine/subproviders/rpc';  // disallow `namespace`, we disable tslint for the following.  /* tslint:disable */  declare namespace Chai { -    interface NumberComparer { -        (value: number|BigNumber.BigNumber, message?: string): Assertion; -    } -    interface NumericComparison { -        greaterThan: NumberComparer; -    }      interface Assertion {          bignumber: Assertion;          // HACK: In order to comply with chai-as-promised we make eventually a `PromisedAssertion` not an `Assertion` @@ -70,8 +64,6 @@ declare module 'truffle-hdwallet-provider' {  // abi-decoder declarations  interface DecodedLogArg { -    name: string; -    value: string|BigNumber.BigNumber;  }  interface DecodedLog {      name: string; diff --git a/src/types.ts b/src/types.ts index cb5fe4405..9ac726ef8 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,5 @@  import * as Web3 from 'web3'; +import BigNumber from 'bignumber.js';  export enum ZeroExError {      ContractDoesNotExist = 'CONTRACT_DOES_NOT_EXIST', @@ -33,8 +34,8 @@ export interface ECSignature {  export type OrderAddresses = [string, string, string, string, string]; -export type OrderValues = [BigNumber.BigNumber, BigNumber.BigNumber, BigNumber.BigNumber, -                           BigNumber.BigNumber, BigNumber.BigNumber, BigNumber.BigNumber]; +export type OrderValues = [BigNumber, BigNumber, BigNumber, +                           BigNumber, BigNumber, BigNumber];  export interface LogEvent<ArgsType> extends LogWithDecodedArgs<ArgsType> {      removed: boolean; @@ -54,77 +55,77 @@ export interface ExchangeContract extends Web3.ContractInstance {          callAsync: () => Promise<string>;      };      getUnavailableTakerTokenAmount: { -        callAsync: (orderHash: string, defaultBlock?: Web3.BlockParam) => Promise<BigNumber.BigNumber>; +        callAsync: (orderHash: string, defaultBlock?: Web3.BlockParam) => Promise<BigNumber>;      };      isRoundingError: { -        callAsync: (takerTokenFillAmount: BigNumber.BigNumber, takerTokenAmount: BigNumber.BigNumber, -                    makerTokenAmount: BigNumber.BigNumber, txOpts?: TxOpts) => Promise<boolean>; +        callAsync: (takerTokenFillAmount: BigNumber, takerTokenAmount: BigNumber, +                    makerTokenAmount: BigNumber, txOpts?: TxOpts) => Promise<boolean>;      };      fillOrder: {          sendTransactionAsync: (orderAddresses: OrderAddresses, orderValues: OrderValues, -                               fillTakerTokenAmount: BigNumber.BigNumber, +                               fillTakerTokenAmount: BigNumber,                                 shouldThrowOnInsufficientBalanceOrAllowance: boolean,                                 v: number, r: string, s: string, txOpts?: TxOpts) => Promise<string>;          estimateGasAsync: (orderAddresses: OrderAddresses, orderValues: OrderValues, -                           fillTakerTokenAmount: BigNumber.BigNumber, +                           fillTakerTokenAmount: BigNumber,                             shouldThrowOnInsufficientBalanceOrAllowance: boolean,                             v: number, r: string, s: string, txOpts?: TxOpts) => Promise<number>;      };      batchFillOrders: {          sendTransactionAsync: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], -                               fillTakerTokenAmounts: BigNumber.BigNumber[], +                               fillTakerTokenAmounts: BigNumber[],                                 shouldThrowOnInsufficientBalanceOrAllowance: boolean,                                 v: number[], r: string[], s: string[], txOpts?: TxOpts) => Promise<string>;          estimateGasAsync: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], -                           fillTakerTokenAmounts: BigNumber.BigNumber[], +                           fillTakerTokenAmounts: BigNumber[],                             shouldThrowOnInsufficientBalanceOrAllowance: boolean,                             v: number[], r: string[], s: string[], txOpts?: TxOpts) => Promise<number>;      };      fillOrdersUpTo: {          sendTransactionAsync: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], -                               fillTakerTokenAmount: BigNumber.BigNumber, +                               fillTakerTokenAmount: BigNumber,                                 shouldThrowOnInsufficientBalanceOrAllowance: boolean,                                 v: number[], r: string[], s: string[], txOpts?: TxOpts) => Promise<string>;          estimateGasAsync: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], -                           fillTakerTokenAmount: BigNumber.BigNumber, +                           fillTakerTokenAmount: BigNumber,                             shouldThrowOnInsufficientBalanceOrAllowance: boolean,                             v: number[], r: string[], s: string[], txOpts?: TxOpts) => Promise<number>;      };      cancelOrder: {          sendTransactionAsync: (orderAddresses: OrderAddresses, orderValues: OrderValues, -                               cancelTakerTokenAmount: BigNumber.BigNumber, txOpts?: TxOpts) => Promise<string>; +                               cancelTakerTokenAmount: BigNumber, txOpts?: TxOpts) => Promise<string>;          estimateGasAsync: (orderAddresses: OrderAddresses, orderValues: OrderValues, -                           cancelTakerTokenAmount: BigNumber.BigNumber, +                           cancelTakerTokenAmount: BigNumber,                             txOpts?: TxOpts) => Promise<number>;      };      batchCancelOrders: {          sendTransactionAsync: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], -                               cancelTakerTokenAmounts: BigNumber.BigNumber[], txOpts?: TxOpts) => Promise<string>; +                               cancelTakerTokenAmounts: BigNumber[], txOpts?: TxOpts) => Promise<string>;          estimateGasAsync: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], -                           cancelTakerTokenAmounts: BigNumber.BigNumber[], +                           cancelTakerTokenAmounts: BigNumber[],                             txOpts?: TxOpts) => Promise<number>;      };      fillOrKillOrder: {          sendTransactionAsync: (orderAddresses: OrderAddresses, orderValues: OrderValues, -                               fillTakerTokenAmount: BigNumber.BigNumber, +                               fillTakerTokenAmount: BigNumber,                                 v: number, r: string, s: string, txOpts?: TxOpts) => Promise<string>;          estimateGasAsync: (orderAddresses: OrderAddresses, orderValues: OrderValues, -                           fillTakerTokenAmount: BigNumber.BigNumber, +                           fillTakerTokenAmount: BigNumber,                             v: number, r: string, s: string, txOpts?: TxOpts) => Promise<number>;      };      batchFillOrKillOrders: {          sendTransactionAsync: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], -                               fillTakerTokenAmounts: BigNumber.BigNumber[], +                               fillTakerTokenAmounts: BigNumber[],                                 v: number[], r: string[], s: string[], txOpts: TxOpts) => Promise<string>;          estimateGasAsync: (orderAddresses: OrderAddresses[], orderValues: OrderValues[], -                           fillTakerTokenAmounts: BigNumber.BigNumber[], +                           fillTakerTokenAmounts: BigNumber[],                             v: number[], r: string[], s: string[], txOpts?: TxOpts) => Promise<number>;      };      filled: { -        callAsync: (orderHash: string, defaultBlock?: Web3.BlockParam) => Promise<BigNumber.BigNumber>; +        callAsync: (orderHash: string, defaultBlock?: Web3.BlockParam) => Promise<BigNumber>;      };      cancelled: { -        callAsync: (orderHash: string, defaultBlock?: Web3.BlockParam) => Promise<BigNumber.BigNumber>; +        callAsync: (orderHash: string, defaultBlock?: Web3.BlockParam) => Promise<BigNumber>;      };      getOrderHash: {          callAsync: (orderAddresses: OrderAddresses, orderValues: OrderValues) => Promise<string>; @@ -133,22 +134,22 @@ export interface ExchangeContract extends Web3.ContractInstance {  export interface TokenContract extends Web3.ContractInstance {      balanceOf: { -        callAsync: (address: string, defaultBlock?: Web3.BlockParam) => Promise<BigNumber.BigNumber>; +        callAsync: (address: string, defaultBlock?: Web3.BlockParam) => Promise<BigNumber>;      };      allowance: {          callAsync: (ownerAddress: string, allowedAddress: string, -                    defaultBlock?: Web3.BlockParam) => Promise<BigNumber.BigNumber>; +                    defaultBlock?: Web3.BlockParam) => Promise<BigNumber>;      };      transfer: { -        sendTransactionAsync: (toAddress: string, amountInBaseUnits: BigNumber.BigNumber, +        sendTransactionAsync: (toAddress: string, amountInBaseUnits: BigNumber,                                 txOpts?: TxOpts) => Promise<string>;      };      transferFrom: { -        sendTransactionAsync: (fromAddress: string, toAddress: string, amountInBaseUnits: BigNumber.BigNumber, +        sendTransactionAsync: (fromAddress: string, toAddress: string, amountInBaseUnits: BigNumber,                                 txOpts?: TxOpts) => Promise<string>;      };      approve: { -        sendTransactionAsync: (proxyAddress: string, amountInBaseUnits: BigNumber.BigNumber, +        sendTransactionAsync: (proxyAddress: string, amountInBaseUnits: BigNumber,                                 txOpts?: TxOpts) => Promise<string>;      };  } @@ -179,7 +180,7 @@ export interface EtherTokenContract extends Web3.ContractInstance {          sendTransactionAsync: (txOpts: TxOpts) => Promise<string>;      };      withdraw: { -        sendTransactionAsync: (amount: BigNumber.BigNumber, txOpts: TxOpts) => Promise<string>; +        sendTransactionAsync: (amount: BigNumber, txOpts: TxOpts) => Promise<string>;      };  } @@ -253,10 +254,10 @@ export interface LogFillContractEventArgs {      feeRecipient: string;      makerToken: string;      takerToken: string; -    filledMakerTokenAmount: BigNumber.BigNumber; -    filledTakerTokenAmount: BigNumber.BigNumber; -    paidMakerFee: BigNumber.BigNumber; -    paidTakerFee: BigNumber.BigNumber; +    filledMakerTokenAmount: BigNumber; +    filledTakerTokenAmount: BigNumber; +    paidMakerFee: BigNumber; +    paidTakerFee: BigNumber;      tokens: string;      orderHash: string;  } @@ -265,43 +266,43 @@ export interface LogCancelContractEventArgs {      feeRecipient: string;      makerToken: string;      takerToken: string; -    cancelledMakerTokenAmount: BigNumber.BigNumber; -    cancelledTakerTokenAmount: BigNumber.BigNumber; +    cancelledMakerTokenAmount: BigNumber; +    cancelledTakerTokenAmount: BigNumber;      tokens: string;      orderHash: string;  }  export interface LogErrorContractEventArgs { -    errorId: BigNumber.BigNumber; +    errorId: BigNumber;      orderHash: string;  }  export type ExchangeContractEventArgs = LogFillContractEventArgs|LogCancelContractEventArgs|LogErrorContractEventArgs;  export interface TransferContractEventArgs {      _from: string;      _to: string; -    _value: BigNumber.BigNumber; +    _value: BigNumber;  }  export interface ApprovalContractEventArgs {      _owner: string;      _spender: string; -    _value: BigNumber.BigNumber; +    _value: BigNumber;  }  export type TokenContractEventArgs = TransferContractEventArgs|ApprovalContractEventArgs;  export type ContractEventArgs = ExchangeContractEventArgs|TokenContractEventArgs; -export type ContractEventArg = string|BigNumber.BigNumber; +export type ContractEventArg = string|BigNumber;  export interface Order {      maker: string;      taker: string; -    makerFee: BigNumber.BigNumber; -    takerFee: BigNumber.BigNumber; -    makerTokenAmount: BigNumber.BigNumber; -    takerTokenAmount: BigNumber.BigNumber; +    makerFee: BigNumber; +    takerFee: BigNumber; +    makerTokenAmount: BigNumber; +    takerTokenAmount: BigNumber;      makerTokenAddress: string;      takerTokenAddress: string; -    salt: BigNumber.BigNumber; +    salt: BigNumber;      exchangeContractAddress: string;      feeRecipient: string; -    expirationUnixTimestampSec: BigNumber.BigNumber; +    expirationUnixTimestampSec: BigNumber;  }  export interface SignedOrder extends Order { @@ -309,7 +310,7 @@ export interface SignedOrder extends Order {  }  //                          [address, name, symbol, decimals, ipfsHash, swarmHash] -export type TokenMetadata = [string, string, string, BigNumber.BigNumber, string, string]; +export type TokenMetadata = [string, string, string, BigNumber, string, string];  export interface Token {      name: string; @@ -321,7 +322,7 @@ export interface Token {  export interface TxOpts {      from: string;      gas?: number; -    value?: BigNumber.BigNumber; +    value?: BigNumber;  }  export interface TokenAddressBySymbol { @@ -362,12 +363,12 @@ export type DoneCallback = (err?: Error) => void;  export interface OrderCancellationRequest {      order: Order|SignedOrder; -    takerTokenCancelAmount: BigNumber.BigNumber; +    takerTokenCancelAmount: BigNumber;  }  export interface OrderFillRequest {      signedOrder: SignedOrder; -    takerTokenFillAmount: BigNumber.BigNumber; +    takerTokenFillAmount: BigNumber;  }  export type AsyncMethod = (...args: any[]) => Promise<any>; @@ -395,7 +396,7 @@ export interface JSONRPCPayload {   * etherTokenContractAddress: The address of an ether token contract to use   */  export interface ZeroExConfig { -    gasPrice?: BigNumber.BigNumber; // Gas price to use with every transaction +    gasPrice?: BigNumber; // Gas price to use with every transaction      exchangeContractAddress?: string;      tokenRegistryContractAddress?: string;      etherTokenContractAddress?: string; @@ -439,7 +440,7 @@ export interface Artifact {   * allowance/balance to fill the entire remaining order amount.   */  export interface ValidateOrderFillableOpts { -    expectedFillTakerTokenAmount?: BigNumber.BigNumber; +    expectedFillTakerTokenAmount?: BigNumber;  }  /* diff --git a/src/utils/abi_decoder.ts b/src/utils/abi_decoder.ts index a6c45bee7..247ba0e5b 100644 --- a/src/utils/abi_decoder.ts +++ b/src/utils/abi_decoder.ts @@ -1,6 +1,6 @@  import * as Web3 from 'web3';  import * as _ from 'lodash'; -import * as BigNumber from 'bignumber.js'; +import BigNumber from 'bignumber.js';  import {AbiType, DecodedLogArgs, LogWithDecodedArgs, RawLog, SolidityTypes, ContractEventArgs} from '../types';  import * as SolidityCoder from 'web3/lib/solidity/coder'; diff --git a/src/utils/assert.ts b/src/utils/assert.ts index 099f4490f..286105345 100644 --- a/src/utils/assert.ts +++ b/src/utils/assert.ts @@ -1,5 +1,5 @@  import * as _ from 'lodash'; -import * as BigNumber from 'bignumber.js'; +import BigNumber from 'bignumber.js';  import * as Web3 from 'web3';  import {Web3Wrapper} from '../web3_wrapper';  import {SchemaValidator, Schema} from '0x-json-schemas'; @@ -7,8 +7,8 @@ import {SchemaValidator, Schema} from '0x-json-schemas';  const HEX_REGEX = /^0x[0-9A-F]*$/i;  export const assert = { -    isBigNumber(variableName: string, value: BigNumber.BigNumber): void { -        const isBigNumber = _.isObject(value) && value.isBigNumber; +    isBigNumber(variableName: string, value: BigNumber): void { +        const isBigNumber = _.isObject(value) && (value as any).isBigNumber;          this.assert(isBigNumber, this.typeAssertionMessage(variableName, 'BigNumber', value));      },      isUndefined(value: any, variableName?: string): void { diff --git a/src/utils/constants.ts b/src/utils/constants.ts index a066fe869..3de3f5bc1 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -1,4 +1,4 @@ -import * as BigNumber from 'bignumber.js'; +import BigNumber from 'bignumber.js';  export const constants = {      NULL_ADDRESS: '0x0000000000000000000000000000000000000000', diff --git a/src/utils/exchange_transfer_simulator.ts b/src/utils/exchange_transfer_simulator.ts index db12abd29..89b23c8ab 100644 --- a/src/utils/exchange_transfer_simulator.ts +++ b/src/utils/exchange_transfer_simulator.ts @@ -1,4 +1,5 @@  import * as _ from 'lodash'; +import BigNumber from 'bignumber.js';  import {ExchangeContractErrs, TradeSide, TransferType} from '../types';  import {TokenWrapper} from '../contract_wrappers/token_wrapper'; @@ -37,12 +38,12 @@ export class BalanceAndProxyAllowanceLazyStore {      protected _token: TokenWrapper;      private _balance: {          [tokenAddress: string]: { -            [userAddress: string]: BigNumber.BigNumber, +            [userAddress: string]: BigNumber,          },      };      private _proxyAllowance: {          [tokenAddress: string]: { -            [userAddress: string]: BigNumber.BigNumber, +            [userAddress: string]: BigNumber,          },      };      constructor(token: TokenWrapper) { @@ -50,7 +51,7 @@ export class BalanceAndProxyAllowanceLazyStore {          this._balance = {};          this._proxyAllowance = {};      } -    protected async getBalanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber.BigNumber> { +    protected async getBalanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> {          if (_.isUndefined(this._balance[tokenAddress]) || _.isUndefined(this._balance[tokenAddress][userAddress])) {              const balance = await this._token.getBalanceAsync(tokenAddress, userAddress);              this.setBalance(tokenAddress, userAddress, balance); @@ -58,13 +59,13 @@ export class BalanceAndProxyAllowanceLazyStore {          const cachedBalance = this._balance[tokenAddress][userAddress];          return cachedBalance;      } -    protected setBalance(tokenAddress: string, userAddress: string, balance: BigNumber.BigNumber): void { +    protected setBalance(tokenAddress: string, userAddress: string, balance: BigNumber): void {          if (_.isUndefined(this._balance[tokenAddress])) {              this._balance[tokenAddress] = {};          }          this._balance[tokenAddress][userAddress] = balance;      } -    protected async getProxyAllowanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber.BigNumber> { +    protected async getProxyAllowanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> {          if (_.isUndefined(this._proxyAllowance[tokenAddress]) ||              _.isUndefined(this._proxyAllowance[tokenAddress][userAddress])) {              const proxyAllowance = await this._token.getProxyAllowanceAsync(tokenAddress, userAddress); @@ -73,7 +74,7 @@ export class BalanceAndProxyAllowanceLazyStore {          const cachedProxyAllowance = this._proxyAllowance[tokenAddress][userAddress];          return cachedProxyAllowance;      } -    protected setProxyAllowance(tokenAddress: string, userAddress: string, proxyAllowance: BigNumber.BigNumber): void { +    protected setProxyAllowance(tokenAddress: string, userAddress: string, proxyAllowance: BigNumber): void {          if (_.isUndefined(this._proxyAllowance[tokenAddress])) {              this._proxyAllowance[tokenAddress] = {};          } @@ -92,7 +93,7 @@ export class ExchangeTransferSimulator extends BalanceAndProxyAllowanceLazyStore       * @param  transferType      Is it a fee payment or a value transfer       */      public async transferFromAsync(tokenAddress: string, from: string, to: string, -                                   amountInBaseUnits: BigNumber.BigNumber, tradeSide: TradeSide, +                                   amountInBaseUnits: BigNumber, tradeSide: TradeSide,                                     transferType: TransferType): Promise<void> {          const balance = await this.getBalanceAsync(tokenAddress, from);          const proxyAllowance = await this.getProxyAllowanceAsync(tokenAddress, from); @@ -107,19 +108,19 @@ export class ExchangeTransferSimulator extends BalanceAndProxyAllowanceLazyStore          await this.increaseBalanceAsync(tokenAddress, to, amountInBaseUnits);      }      private async decreaseProxyAllowanceAsync(tokenAddress: string, userAddress: string, -                                              amountInBaseUnits: BigNumber.BigNumber): Promise<void> { +                                              amountInBaseUnits: BigNumber): Promise<void> {          const proxyAllowance = await this.getProxyAllowanceAsync(tokenAddress, userAddress);          if (!proxyAllowance.eq(this._token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS)) {              this.setProxyAllowance(tokenAddress, userAddress, proxyAllowance.minus(amountInBaseUnits));          }      }      private async increaseBalanceAsync(tokenAddress: string, userAddress: string, -                                       amountInBaseUnits: BigNumber.BigNumber): Promise<void> { +                                       amountInBaseUnits: BigNumber): Promise<void> {          const balance = await this.getBalanceAsync(tokenAddress, userAddress);          this.setBalance(tokenAddress, userAddress, balance.plus(amountInBaseUnits));      }      private async decreaseBalanceAsync(tokenAddress: string, userAddress: string, -                                       amountInBaseUnits: BigNumber.BigNumber): Promise<void> { +                                       amountInBaseUnits: BigNumber): Promise<void> {          const balance = await this.getBalanceAsync(tokenAddress, userAddress);          this.setBalance(tokenAddress, userAddress, balance.minus(amountInBaseUnits));      } diff --git a/src/utils/order_validation_utils.ts b/src/utils/order_validation_utils.ts index b7eae7e2f..f03703c4e 100644 --- a/src/utils/order_validation_utils.ts +++ b/src/utils/order_validation_utils.ts @@ -1,4 +1,5 @@  import * as _ from 'lodash'; +import BigNumber from 'bignumber.js';  import {ExchangeContractErrs, SignedOrder, Order, ZeroExError, TradeSide, TransferType} from '../types';  import {ZeroEx} from '../0x';  import {TokenWrapper} from '../contract_wrappers/token_wrapper'; @@ -16,7 +17,7 @@ export class OrderValidationUtils {      }      public async validateOrderFillableOrThrowAsync(          exchangeTradeEmulator: ExchangeTransferSimulator, signedOrder: SignedOrder, zrxTokenAddress: string, -        expectedFillTakerTokenAmount?: BigNumber.BigNumber): Promise<void> { +        expectedFillTakerTokenAmount?: BigNumber): Promise<void> {          const orderHash = utils.getOrderHashHex(signedOrder);          const unavailableTakerTokenAmount = await this.exchangeWrapper.getUnavailableTakerAmountAsync(orderHash);          this.validateRemainingFillAmountNotZeroOrThrow( @@ -48,8 +49,8 @@ export class OrderValidationUtils {      }      public async validateFillOrderThrowIfInvalidAsync(          exchangeTradeEmulator: ExchangeTransferSimulator, signedOrder: SignedOrder, -        fillTakerTokenAmount: BigNumber.BigNumber, takerAddress: string, -        zrxTokenAddress: string): Promise<BigNumber.BigNumber> { +        fillTakerTokenAmount: BigNumber, takerAddress: string, +        zrxTokenAddress: string): Promise<BigNumber> {          if (fillTakerTokenAmount.eq(0)) {              throw new Error(ExchangeContractErrs.OrderFillAmountZero);          } @@ -83,7 +84,7 @@ export class OrderValidationUtils {      }      public async validateFillOrKillOrderThrowIfInvalidAsync(          exchangeTradeEmulator: ExchangeTransferSimulator, signedOrder: SignedOrder, -        fillTakerTokenAmount: BigNumber.BigNumber, takerAddress: string, zrxTokenAddress: string): Promise<void> { +        fillTakerTokenAmount: BigNumber, takerAddress: string, zrxTokenAddress: string): Promise<void> {          const filledTakerTokenAmount = await this.validateFillOrderThrowIfInvalidAsync(              exchangeTradeEmulator, signedOrder, fillTakerTokenAmount, takerAddress, zrxTokenAddress,          ); @@ -92,8 +93,8 @@ export class OrderValidationUtils {          }      }      public async validateCancelOrderThrowIfInvalidAsync(order: Order, -                                                        cancelTakerTokenAmount: BigNumber.BigNumber, -                                                        unavailableTakerTokenAmount: BigNumber.BigNumber, +                                                        cancelTakerTokenAmount: BigNumber, +                                                        unavailableTakerTokenAmount: BigNumber,      ): Promise<void> {          if (cancelTakerTokenAmount.eq(0)) {              throw new Error(ExchangeContractErrs.OrderCancelAmountZero); @@ -108,7 +109,7 @@ export class OrderValidationUtils {      }      public async validateFillOrderBalancesAllowancesThrowIfInvalidAsync(          exchangeTradeEmulator: ExchangeTransferSimulator, signedOrder: SignedOrder, -        fillTakerTokenAmount: BigNumber.BigNumber, senderAddress: string, zrxTokenAddress: string): Promise<void> { +        fillTakerTokenAmount: BigNumber, senderAddress: string, zrxTokenAddress: string): Promise<void> {          const fillMakerTokenAmount = this.getPartialAmount(              fillTakerTokenAmount,              signedOrder.takerTokenAmount, @@ -142,20 +143,20 @@ export class OrderValidationUtils {          );      }      private validateRemainingFillAmountNotZeroOrThrow( -        takerTokenAmount: BigNumber.BigNumber, unavailableTakerTokenAmount: BigNumber.BigNumber, +        takerTokenAmount: BigNumber, unavailableTakerTokenAmount: BigNumber,      ) {          if (takerTokenAmount.eq(unavailableTakerTokenAmount)) {              throw new Error(ExchangeContractErrs.OrderRemainingFillAmountZero);          }      } -    private validateOrderNotExpiredOrThrow(expirationUnixTimestampSec: BigNumber.BigNumber) { +    private validateOrderNotExpiredOrThrow(expirationUnixTimestampSec: BigNumber) {          const currentUnixTimestampSec = utils.getCurrentUnixTimestamp();          if (expirationUnixTimestampSec.lessThan(currentUnixTimestampSec)) {              throw new Error(ExchangeContractErrs.OrderFillExpired);          }      } -    private getPartialAmount(numerator: BigNumber.BigNumber, denominator: BigNumber.BigNumber, -                             target: BigNumber.BigNumber): BigNumber.BigNumber { +    private getPartialAmount(numerator: BigNumber, denominator: BigNumber, +                             target: BigNumber): BigNumber {          const fillMakerTokenAmount = numerator                                       .mul(target)                                       .div(denominator) diff --git a/src/utils/utils.ts b/src/utils/utils.ts index f2bf74860..280f3e979 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -2,7 +2,7 @@ import * as _ from 'lodash';  import * as ethABI from 'ethereumjs-abi';  import * as ethUtil from 'ethereumjs-util';  import {Order, SignedOrder, SolidityTypes} from '../types'; -import * as BigNumber from 'bignumber.js'; +import BigNumber from 'bignumber.js';  import BN = require('bn.js');  export const utils = { @@ -12,7 +12,7 @@ export const utils = {       * expects values of Solidity type `uint` to be passed as type `BN`.       * We do not use BN anywhere else in the codebase.       */ -    bigNumberToBN(value: BigNumber.BigNumber) { +    bigNumberToBN(value: BigNumber) {          return new BN(value.toString(), 10);      },      consoleLog(message: string): void { @@ -49,7 +49,7 @@ export const utils = {          const hashHex = ethUtil.bufferToHex(hashBuff);          return hashHex;      }, -    getCurrentUnixTimestamp(): BigNumber.BigNumber { +    getCurrentUnixTimestamp(): BigNumber {          return new BigNumber(Date.now() / 1000);      },  }; diff --git a/src/web3_wrapper.ts b/src/web3_wrapper.ts index ff5d25d9c..3b1e4477b 100644 --- a/src/web3_wrapper.ts +++ b/src/web3_wrapper.ts @@ -1,6 +1,6 @@  import * as _ from 'lodash';  import * as Web3 from 'web3'; -import * as BigNumber from 'bignumber.js'; +import BigNumber from 'bignumber.js';  import promisify = require('es6-promisify');  import {ZeroExError, Artifact} from './types';  import {Contract} from './contract'; @@ -75,11 +75,11 @@ export class Web3Wrapper {          );          return contractInstance;      } -    public toWei(ethAmount: BigNumber.BigNumber): BigNumber.BigNumber { +    public toWei(ethAmount: BigNumber): BigNumber {          const balanceWei = this.web3.toWei(ethAmount, 'ether');          return balanceWei;      } -    public async getBalanceInWeiAsync(owner: string): Promise<BigNumber.BigNumber> { +    public async getBalanceInWeiAsync(owner: string): Promise<BigNumber> {          let balanceInWei = await promisify(this.web3.eth.getBalance)(owner);          balanceInWei = new BigNumber(balanceInWei);          return balanceInWei; diff --git a/test/0x.js_test.ts b/test/0x.js_test.ts index dd5dd19b1..d56acc38b 100644 --- a/test/0x.js_test.ts +++ b/test/0x.js_test.ts @@ -2,7 +2,7 @@ import * as _ from 'lodash';  import * as chai from 'chai';  import {chaiSetup} from './utils/chai_setup';  import 'mocha'; -import * as BigNumber from 'bignumber.js'; +import BigNumber from 'bignumber.js';  import * as Sinon from 'sinon';  import {ZeroEx, Order, ZeroExError, LogWithDecodedArgs, ApprovalContractEventArgs, TokenEvents} from '../src';  import {constants} from './utils/constants'; diff --git a/test/ether_token_wrapper_test.ts b/test/ether_token_wrapper_test.ts index 389ec1619..ba679d1a1 100644 --- a/test/ether_token_wrapper_test.ts +++ b/test/ether_token_wrapper_test.ts @@ -2,7 +2,7 @@ import 'mocha';  import * as chai from 'chai';  import {chaiSetup} from './utils/chai_setup';  import * as Web3 from 'web3'; -import * as BigNumber from 'bignumber.js'; +import BigNumber from 'bignumber.js';  import {web3Factory} from './utils/web3_factory';  import {ZeroEx, ZeroExError} from '../src';  import {BlockchainLifecycle} from './utils/blockchain_lifecycle'; @@ -23,7 +23,7 @@ describe('EtherTokenWrapper', () => {      let userAddresses: string[];      let addressWithETH: string;      let wethContractAddress: string; -    let depositWeiAmount: BigNumber.BigNumber; +    let depositWeiAmount: BigNumber;      let decimalPlaces: number;      const gasPrice = new BigNumber(1);      const zeroExConfig = { diff --git a/test/exchange_transfer_simulator_test.ts b/test/exchange_transfer_simulator_test.ts index ee24f4fe4..3373ebf03 100644 --- a/test/exchange_transfer_simulator_test.ts +++ b/test/exchange_transfer_simulator_test.ts @@ -1,5 +1,5 @@  import * as chai from 'chai'; -import * as BigNumber from 'bignumber.js'; +import BigNumber from 'bignumber.js';  import {chaiSetup} from './utils/chai_setup';  import {web3Factory} from './utils/web3_factory';  import {ZeroEx, ExchangeContractErrs, Token} from '../src'; diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts index f3f16643e..7c76499d5 100644 --- a/test/exchange_wrapper_test.ts +++ b/test/exchange_wrapper_test.ts @@ -1,7 +1,7 @@  import 'mocha';  import * as chai from 'chai';  import * as Web3 from 'web3'; -import * as BigNumber from 'bignumber.js'; +import BigNumber from 'bignumber.js';  import {chaiSetup} from './utils/chai_setup';  import {web3Factory} from './utils/web3_factory';  import {BlockchainLifecycle} from './utils/blockchain_lifecycle'; @@ -545,8 +545,8 @@ describe('ExchangeWrapper', () => {          let makerTokenAddress: string;          let takerTokenAddress: string;          let takerAddress: string; -        let fillableAmount: BigNumber.BigNumber; -        let partialFillAmount: BigNumber.BigNumber; +        let fillableAmount: BigNumber; +        let partialFillAmount: BigNumber;          let signedOrder: SignedOrder;          let orderHash: string;          before(() => { @@ -621,7 +621,7 @@ describe('ExchangeWrapper', () => {          let coinbase: string;          let takerAddress: string;          let makerAddress: string; -        let fillableAmount: BigNumber.BigNumber; +        let fillableAmount: BigNumber;          let signedOrder: SignedOrder;          const takerTokenFillAmountInBaseUnits = new BigNumber(1);          const cancelTakerAmountInBaseUnits = new BigNumber(1); diff --git a/test/order_validation_test.ts b/test/order_validation_test.ts index dfcf1d43d..4f18742d3 100644 --- a/test/order_validation_test.ts +++ b/test/order_validation_test.ts @@ -1,6 +1,6 @@  import * as chai from 'chai';  import * as Web3 from 'web3'; -import * as BigNumber from 'bignumber.js'; +import BigNumber from 'bignumber.js';  import * as Sinon from 'sinon';  import {chaiSetup} from './utils/chai_setup';  import {web3Factory} from './utils/web3_factory'; @@ -211,8 +211,8 @@ describe('OrderValidation', () => {      describe('#validateFillOrderBalancesAllowancesThrowIfInvalidAsync', () => {          let exchangeTransferSimulator: ExchangeTransferSimulator;          let transferFromAsync: Sinon.SinonSpy; -        const bigNumberMatch = (expected: BigNumber.BigNumber) => { -            return Sinon.match((value: BigNumber.BigNumber) => value.eq(expected)); +        const bigNumberMatch = (expected: BigNumber) => { +            return Sinon.match((value: BigNumber) => value.eq(expected));          };          beforeEach('create exchangeTransferSimulator', async () => {              exchangeTransferSimulator = new ExchangeTransferSimulator(zeroEx.token); diff --git a/test/token_wrapper_test.ts b/test/token_wrapper_test.ts index f1f6543b7..b35fa43f9 100644 --- a/test/token_wrapper_test.ts +++ b/test/token_wrapper_test.ts @@ -2,7 +2,7 @@ import 'mocha';  import * as chai from 'chai';  import {chaiSetup} from './utils/chai_setup';  import * as Web3 from 'web3'; -import * as BigNumber from 'bignumber.js'; +import BigNumber from 'bignumber.js';  import promisify = require('es6-promisify');  import {web3Factory} from './utils/web3_factory';  import { @@ -51,7 +51,7 @@ describe('TokenWrapper', () => {      });      describe('#transferAsync', () => {          let token: Token; -        let transferAmount: BigNumber.BigNumber; +        let transferAmount: BigNumber;          before(() => {              token = tokens[0];              transferAmount = new BigNumber(42); diff --git a/test/utils/fill_scenarios.ts b/test/utils/fill_scenarios.ts index c399c7bf4..a0632b12c 100644 --- a/test/utils/fill_scenarios.ts +++ b/test/utils/fill_scenarios.ts @@ -1,4 +1,4 @@ -import * as BigNumber from 'bignumber.js'; +import BigNumber from 'bignumber.js';  import {ZeroEx, Token, SignedOrder} from '../../src';  import {orderFactory} from '../utils/order_factory';  import {constants} from './constants'; @@ -21,8 +21,8 @@ export class FillScenarios {      }      public async createFillableSignedOrderAsync(makerTokenAddress: string, takerTokenAddress: string,                                                  makerAddress: string, takerAddress: string, -                                                fillableAmount: BigNumber.BigNumber, -                                                expirationUnixTimestampSec?: BigNumber.BigNumber): +                                                fillableAmount: BigNumber, +                                                expirationUnixTimestampSec?: BigNumber):                                             Promise<SignedOrder> {          return this.createAsymmetricFillableSignedOrderAsync(              makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, @@ -31,10 +31,10 @@ export class FillScenarios {      }      public async createFillableSignedOrderWithFeesAsync(          makerTokenAddress: string, takerTokenAddress: string, -        makerFee: BigNumber.BigNumber, takerFee: BigNumber.BigNumber, +        makerFee: BigNumber, takerFee: BigNumber,          makerAddress: string, takerAddress: string, -        fillableAmount: BigNumber.BigNumber, -        feeRecepient: string, expirationUnixTimestampSec?: BigNumber.BigNumber, +        fillableAmount: BigNumber, +        feeRecepient: string, expirationUnixTimestampSec?: BigNumber,      ): Promise<SignedOrder> {          return this.createAsymmetricFillableSignedOrderWithFeesAsync(              makerTokenAddress, takerTokenAddress, makerFee, takerFee, makerAddress, takerAddress, @@ -43,8 +43,8 @@ export class FillScenarios {      }      public async createAsymmetricFillableSignedOrderAsync(          makerTokenAddress: string, takerTokenAddress: string, makerAddress: string, takerAddress: string, -        makerFillableAmount: BigNumber.BigNumber, takerFillableAmount: BigNumber.BigNumber, -        expirationUnixTimestampSec?: BigNumber.BigNumber): Promise<SignedOrder> { +        makerFillableAmount: BigNumber, takerFillableAmount: BigNumber, +        expirationUnixTimestampSec?: BigNumber): Promise<SignedOrder> {          const makerFee = new BigNumber(0);          const takerFee = new BigNumber(0);          const feeRecepient = constants.NULL_ADDRESS; @@ -54,8 +54,8 @@ export class FillScenarios {          );      }      public async createPartiallyFilledSignedOrderAsync(makerTokenAddress: string, takerTokenAddress: string, -                                                       takerAddress: string, fillableAmount: BigNumber.BigNumber, -                                                       partialFillAmount: BigNumber.BigNumber) { +                                                       takerAddress: string, fillableAmount: BigNumber, +                                                       partialFillAmount: BigNumber) {          const [makerAddress] = this.userAddresses;          const signedOrder = await this.createAsymmetricFillableSignedOrderAsync(              makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, @@ -69,10 +69,10 @@ export class FillScenarios {      }      private async createAsymmetricFillableSignedOrderWithFeesAsync(          makerTokenAddress: string, takerTokenAddress: string, -        makerFee: BigNumber.BigNumber, takerFee: BigNumber.BigNumber, +        makerFee: BigNumber, takerFee: BigNumber,          makerAddress: string, takerAddress: string, -        makerFillableAmount: BigNumber.BigNumber, takerFillableAmount: BigNumber.BigNumber, -        feeRecepient: string, expirationUnixTimestampSec?: BigNumber.BigNumber): Promise<SignedOrder> { +        makerFillableAmount: BigNumber, takerFillableAmount: BigNumber, +        feeRecepient: string, expirationUnixTimestampSec?: BigNumber): Promise<SignedOrder> {          await Promise.all([              this.increaseBalanceAndAllowanceAsync(makerTokenAddress, makerAddress, makerFillableAmount), @@ -90,7 +90,7 @@ export class FillScenarios {          return signedOrder;      }      private async increaseBalanceAndAllowanceAsync( -        tokenAddress: string, address: string, amount: BigNumber.BigNumber): Promise<void> { +        tokenAddress: string, address: string, amount: BigNumber): Promise<void> {          if (amount.isZero() || address === ZeroEx.NULL_ADDRESS) {              return; // noop          } @@ -100,11 +100,11 @@ export class FillScenarios {          ]);      }      private async increaseBalanceAsync( -        tokenAddress: string, address: string, amount: BigNumber.BigNumber): Promise<void> { +        tokenAddress: string, address: string, amount: BigNumber): Promise<void> {          await this.zeroEx.token.transferAsync(tokenAddress, this.coinbase, address, amount);      }      private async increaseAllowanceAsync( -        tokenAddress: string, address: string, amount: BigNumber.BigNumber): Promise<void> { +        tokenAddress: string, address: string, amount: BigNumber): Promise<void> {          const oldMakerAllowance = await this.zeroEx.token.getProxyAllowanceAsync(tokenAddress, address);          const newMakerAllowance = oldMakerAllowance.plus(amount);          await this.zeroEx.token.setProxyAllowanceAsync( diff --git a/test/utils/order_factory.ts b/test/utils/order_factory.ts index fc4adebd9..6086e09f7 100644 --- a/test/utils/order_factory.ts +++ b/test/utils/order_factory.ts @@ -1,5 +1,5 @@  import * as _ from 'lodash'; -import * as BigNumber from 'bignumber.js'; +import BigNumber from 'bignumber.js';  import {ZeroEx, SignedOrder} from '../../src';  export const orderFactory = { @@ -7,15 +7,15 @@ export const orderFactory = {          zeroEx: ZeroEx,          maker: string,          taker: string, -        makerFee: BigNumber.BigNumber, -        takerFee: BigNumber.BigNumber, -        makerTokenAmount: BigNumber.BigNumber, +        makerFee: BigNumber, +        takerFee: BigNumber, +        makerTokenAmount: BigNumber,          makerTokenAddress: string, -        takerTokenAmount: BigNumber.BigNumber, +        takerTokenAmount: BigNumber,          takerTokenAddress: string,          exchangeContractAddress: string,          feeRecipient: string, -        expirationUnixTimestampSec?: BigNumber.BigNumber): Promise<SignedOrder> { +        expirationUnixTimestampSec?: BigNumber): Promise<SignedOrder> {          const defaultExpirationUnixTimestampSec = new BigNumber(2524604400); // Close to infinite          expirationUnixTimestampSec = _.isUndefined(expirationUnixTimestampSec) ?              defaultExpirationUnixTimestampSec : | 
