From 3ec8924e7fb70364e41468b95ca74ece31b545ba Mon Sep 17 00:00:00 2001 From: Lawrence Forman Date: Wed, 19 Feb 2020 16:02:35 -0500 Subject: [PATCH] `@0x/contracts-dev-utils`: Rebase. --- .../contracts/src/OrderValidationUtils.sol | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/contracts/dev-utils/contracts/src/OrderValidationUtils.sol b/contracts/dev-utils/contracts/src/OrderValidationUtils.sol index ea319c07ee..948e1d8138 100644 --- a/contracts/dev-utils/contracts/src/OrderValidationUtils.sol +++ b/contracts/dev-utils/contracts/src/OrderValidationUtils.sol @@ -118,22 +118,14 @@ contract OrderValidationUtils is transferableTakerAssetAmount ); - // Execute the maker transfers. - fillableTakerAssetAmount = LibOrderTransferSimulation.getSimulatedOrderMakerTransferResults( - exchangeAddress, - order, - order.takerAddress, - fillableTakerAssetAmount - ) == LibOrderTransferSimulation.OrderTransferResults.TransfersSuccessful ? fillableTakerAssetAmount : 0; - - if (!_isAssetDataValid(order.takerAssetData)) { - fillableTakerAssetAmount = 0; - } - - if (order.takerFee != 0 && !_isAssetDataValid(order.takerFeeAssetData)) { + // Ensure that all of the asset data is valid. Fee asset data only needs + // to be valid if the fees are nonzero. + if (!_areOrderAssetDatasValid(order)) { fillableTakerAssetAmount = 0; } + // If the order is not fillable, then the fillable taker asset amount is + // zero by definition. if (orderInfo.orderStatus != LibOrder.OrderStatus.FILLABLE) { fillableTakerAssetAmount = 0; } @@ -210,6 +202,21 @@ contract OrderValidationUtils is return LibSafeMath.min256(transferableAssetAmount, order.makerAssetAmount); } + /// @dev Checks that the asset data contained in a ZeroEx is valid and returns + /// a boolean that indicates whether or not the asset data was found to be valid. + /// @param order A ZeroEx order to validate. + /// @return The validatity of the asset data. + function _areOrderAssetDatasValid(LibOrder.Order memory order) + internal + pure + returns (bool) + { + return _isAssetDataValid(order.makerAssetData) && + (order.makerFee == 0 || _isAssetDataValid(order.makerFeeAssetData)) && + _isAssetDataValid(order.takerAssetData) && + (order.takerFee == 0 || _isAssetDataValid(order.takerFeeAssetData)); + } + /// @dev This function handles the edge cases around taker validation. This function /// currently attempts to find duplicate ERC721 token's in the taker /// multiAssetData.