From b6172c396563af179b7d89c8eab2982601d042cf Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Fri, 13 Jul 2018 13:32:06 -0700 Subject: Reorder checks in getOrderInfo --- .../src/2.0.0/protocol/Exchange/MixinExchangeCore.sol | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'packages/contracts/src/2.0.0/protocol/Exchange') diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/MixinExchangeCore.sol b/packages/contracts/src/2.0.0/protocol/Exchange/MixinExchangeCore.sol index ec84b1e19..6f435892b 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/MixinExchangeCore.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/MixinExchangeCore.sol @@ -154,6 +154,9 @@ contract MixinExchangeCore is // Compute the order hash orderInfo.orderHash = getOrderHash(order); + // Fetch filled amount + orderInfo.orderTakerAssetFilledAmount = filled[orderInfo.orderHash]; + // If order.makerAssetAmount is zero, we also reject the order. // While the Exchange contract handles them correctly, they create // edge cases in the supporting infrastructure because they have @@ -172,6 +175,12 @@ contract MixinExchangeCore is return orderInfo; } + // Validate order availability + if (orderInfo.orderTakerAssetFilledAmount >= order.takerAssetAmount) { + orderInfo.orderStatus = uint8(OrderStatus.FULLY_FILLED); + return orderInfo; + } + // Validate order expiration // solhint-disable-next-line not-rely-on-time if (block.timestamp >= order.expirationTimeSeconds) { @@ -189,13 +198,6 @@ contract MixinExchangeCore is return orderInfo; } - // Fetch filled amount and validate order availability - orderInfo.orderTakerAssetFilledAmount = filled[orderInfo.orderHash]; - if (orderInfo.orderTakerAssetFilledAmount >= order.takerAssetAmount) { - orderInfo.orderStatus = uint8(OrderStatus.FULLY_FILLED); - return orderInfo; - } - // All other statuses are ruled out: order is Fillable orderInfo.orderStatus = uint8(OrderStatus.FILLABLE); return orderInfo; -- cgit