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 /src/utils/order_validation_utils.ts | |
parent | 45c4042e2bb6d4c13510a5922602ba49bb5108ef (diff) | |
download | dexon-0x-contracts-744a9b89312c825ee94195106b9aa8aa11f43b77.tar dexon-0x-contracts-744a9b89312c825ee94195106b9aa8aa11f43b77.tar.gz dexon-0x-contracts-744a9b89312c825ee94195106b9aa8aa11f43b77.tar.bz2 dexon-0x-contracts-744a9b89312c825ee94195106b9aa8aa11f43b77.tar.lz dexon-0x-contracts-744a9b89312c825ee94195106b9aa8aa11f43b77.tar.xz dexon-0x-contracts-744a9b89312c825ee94195106b9aa8aa11f43b77.tar.zst dexon-0x-contracts-744a9b89312c825ee94195106b9aa8aa11f43b77.zip |
Upgrade bignumber to the version with native typings and remove typings
Diffstat (limited to 'src/utils/order_validation_utils.ts')
-rw-r--r-- | src/utils/order_validation_utils.ts | 23 |
1 files changed, 12 insertions, 11 deletions
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) |