Fix enum name

This commit is contained in:
Fabio Berger
2018-06-26 23:17:20 +02:00
parent 2a82807be4
commit d66ca7b5cb

View File

@@ -1,4 +1,4 @@
import { RevertReasons, SignedOrder } from '@0xproject/types'; import { RevertReason, SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils'; import { BigNumber } from '@0xproject/utils';
import { Provider } from 'ethereum-types'; import { Provider } from 'ethereum-types';
import * as _ from 'lodash'; import * as _ from 'lodash';
@@ -87,7 +87,7 @@ export class OrderValidationUtils {
TransferType.Fee, TransferType.Fee,
); );
} catch (err) { } catch (err) {
throw new Error(RevertReasons.TransferFailed); throw new Error(RevertReason.TransferFailed);
} }
} }
private static _validateRemainingFillAmountNotZeroOrThrow( private static _validateRemainingFillAmountNotZeroOrThrow(
@@ -95,13 +95,13 @@ export class OrderValidationUtils {
filledTakerTokenAmount: BigNumber, filledTakerTokenAmount: BigNumber,
): void { ): void {
if (takerAssetAmount.eq(filledTakerTokenAmount)) { if (takerAssetAmount.eq(filledTakerTokenAmount)) {
throw new Error(RevertReasons.OrderUnfillable); throw new Error(RevertReason.OrderUnfillable);
} }
} }
private static _validateOrderNotExpiredOrThrow(expirationTimeSeconds: BigNumber): void { private static _validateOrderNotExpiredOrThrow(expirationTimeSeconds: BigNumber): void {
const currentUnixTimestampSec = utils.getCurrentUnixTimestampSec(); const currentUnixTimestampSec = utils.getCurrentUnixTimestampSec();
if (expirationTimeSeconds.lessThan(currentUnixTimestampSec)) { if (expirationTimeSeconds.lessThan(currentUnixTimestampSec)) {
throw new Error(RevertReasons.OrderUnfillable); throw new Error(RevertReason.OrderUnfillable);
} }
} }
constructor(orderFilledCancelledFetcher: AbstractOrderFilledCancelledFetcher) { constructor(orderFilledCancelledFetcher: AbstractOrderFilledCancelledFetcher) {
@@ -141,10 +141,10 @@ export class OrderValidationUtils {
zrxAssetData: string, zrxAssetData: string,
): Promise<BigNumber> { ): Promise<BigNumber> {
if (fillTakerAssetAmount.eq(0)) { if (fillTakerAssetAmount.eq(0)) {
throw new Error(RevertReasons.InvalidTakerAmount); throw new Error(RevertReason.InvalidTakerAmount);
} }
if (signedOrder.makerAssetAmount.eq(0) || signedOrder.takerAssetAmount.eq(0)) { if (signedOrder.makerAssetAmount.eq(0) || signedOrder.takerAssetAmount.eq(0)) {
throw new Error(RevertReasons.OrderUnfillable); throw new Error(RevertReason.OrderUnfillable);
} }
const orderHash = orderHashUtils.getOrderHashHex(signedOrder); const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
const isValid = await isValidSignatureAsync( const isValid = await isValidSignatureAsync(
@@ -162,7 +162,7 @@ export class OrderValidationUtils {
filledTakerTokenAmount, filledTakerTokenAmount,
); );
if (signedOrder.takerAddress !== constants.NULL_ADDRESS && signedOrder.takerAddress !== takerAddress) { if (signedOrder.takerAddress !== constants.NULL_ADDRESS && signedOrder.takerAddress !== takerAddress) {
throw new Error(RevertReasons.InvalidTaker); throw new Error(RevertReason.InvalidTaker);
} }
OrderValidationUtils._validateOrderNotExpiredOrThrow(signedOrder.expirationTimeSeconds); OrderValidationUtils._validateOrderNotExpiredOrThrow(signedOrder.expirationTimeSeconds);
const remainingTakerTokenAmount = signedOrder.takerAssetAmount.minus(filledTakerTokenAmount); const remainingTakerTokenAmount = signedOrder.takerAssetAmount.minus(filledTakerTokenAmount);
@@ -183,7 +183,7 @@ export class OrderValidationUtils {
signedOrder.makerAssetAmount, signedOrder.makerAssetAmount,
); );
if (wouldRoundingErrorOccur) { if (wouldRoundingErrorOccur) {
throw new Error(RevertReasons.RoundingError); throw new Error(RevertReason.RoundingError);
} }
return filledTakerTokenAmount; return filledTakerTokenAmount;
} }
@@ -204,7 +204,7 @@ export class OrderValidationUtils {
zrxAssetData, zrxAssetData,
); );
if (filledTakerTokenAmount !== fillTakerAssetAmount) { if (filledTakerTokenAmount !== fillTakerAssetAmount) {
throw new Error(RevertReasons.OrderUnfillable); throw new Error(RevertReason.OrderUnfillable);
} }
} }
} }