Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
@0x/contracts-dev-utils: Rebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
merklejerk committed Feb 19, 2020
1 parent a04722b commit 3ec8924
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions contracts/dev-utils/contracts/src/OrderValidationUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 3ec8924

Please sign in to comment.