From 71483e28656842a30c06a6fdc7dccea2e62ffcc8 Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Tue, 15 May 2018 22:06:12 -0700 Subject: Renamed "validate" functions to "assert" in mixin match. --- .../contracts/current/protocol/Exchange/Exchange.sol | 1 + .../current/protocol/Exchange/MixinExchangeCore.sol | 20 ++++++++++---------- .../current/protocol/Exchange/MixinMatchOrders.sol | 13 ++++++------- .../protocol/Exchange/mixins/MExchangeCore.sol | 4 ++-- .../protocol/Exchange/mixins/MMatchOrders.sol | 4 ++-- 5 files changed, 21 insertions(+), 21 deletions(-) (limited to 'packages/contracts') diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/Exchange.sol b/packages/contracts/src/contracts/current/protocol/Exchange/Exchange.sol index 438d50ecf..2d1729b1c 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/Exchange.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/Exchange.sol @@ -39,6 +39,7 @@ contract Exchange is string constant public VERSION = "2.0.1-alpha"; + // Mixins are instantiated in the order they are inherited constructor (bytes memory _zrxProxyData) public MixinExchangeCore() diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol index 29f0e17cf..7bd88a82c 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol @@ -90,7 +90,7 @@ contract MixinExchangeCore is address takerAddress = getCurrentContextAddress(); // Either our context is valid or we revert - validateFillOrRevert( + assertValidFill( order, orderStatus, orderHash, @@ -131,7 +131,7 @@ contract MixinExchangeCore is /// Throws if order is invalid or sender does not have permission to cancel. /// @param order Order to cancel. Order must be Status.FILLABLE. /// @return True if the order state changed to cancelled. - /// False if the order was order was in a valid, but + /// False if the order was valid, but in an /// unfillable state (see LibStatus.STATUS for order states) function cancelOrder(Order memory order) public @@ -143,7 +143,7 @@ contract MixinExchangeCore is (orderStatus, orderHash, ) = getOrderInfo(order); // Validate context - validateCancelOrRevert(order, orderStatus, orderHash); + assertValidCancel(order, orderStatus, orderHash); // Perform cancel return updateCancelledState(order, orderStatus, orderHash); @@ -157,7 +157,7 @@ contract MixinExchangeCore is /// @param takerAssetFilledAmount Amount of order already filled. /// @param takerAssetFillAmount Desired amount of order to fill by taker. /// @param signature Proof that the orders was created by its maker. - function validateFillOrRevert( + function assertValidFill( Order memory order, uint8 orderStatus, bytes32 orderHash, @@ -243,22 +243,22 @@ contract MixinExchangeCore is // Compute takerAssetFilledAmount uint256 remainingTakerAssetAmount = safeSub(order.takerAssetAmount, takerAssetFilledAmount); - fillResults.takerAssetFilledAmount = min256(takerAssetFillAmount, remainingTakerAssetAmount); + uint256 newTakerAssetFilledAmount = min256(takerAssetFillAmount, remainingTakerAssetAmount); // Validate fill order rounding if (isRoundingError( - fillResults.takerAssetFilledAmount, + newTakerAssetFilledAmount, order.takerAssetAmount, order.makerAssetAmount)) { status = uint8(Status.ROUNDING_ERROR_TOO_LARGE); - fillResults.takerAssetFilledAmount = 0; - return; + return (status, fillResults); } // Compute proportional transfer amounts // TODO: All three are multiplied by the same fraction. This can // potentially be optimized. + fillResults.takerAssetFilledAmount = newTakerAssetFilledAmount; fillResults.makerAssetFilledAmount = getPartialAmount( fillResults.takerAssetFilledAmount, order.takerAssetAmount, @@ -276,7 +276,7 @@ contract MixinExchangeCore is ); status = uint8(Status.SUCCESS); - return; + return (status, fillResults); } /// @dev Updates state with results of a fill order. @@ -315,7 +315,7 @@ contract MixinExchangeCore is /// @param order that was cancelled. /// @param orderStatus Status of order that was cancelled. /// @param orderHash Hash of order that was cancelled. - function validateCancelOrRevert( + function assertValidCancel( Order memory order, uint8 orderStatus, bytes32 orderHash diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinMatchOrders.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinMatchOrders.sol index 9f9ad6a52..744262da2 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinMatchOrders.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinMatchOrders.sol @@ -75,7 +75,7 @@ contract MixinMatchOrders is address takerAddress = getCurrentContextAddress(); // Either our context is valid or we revert - validateMatchOrThrow(leftOrder, rightOrder); + assertValidMatch(leftOrder, rightOrder); // Compute proportional fill amounts matchedFillResults = calculateMatchedFillResults( @@ -88,7 +88,7 @@ contract MixinMatchOrders is ); // Validate fill contexts - validateFillOrRevert( + assertValidFill( leftOrder, leftOrderInfo.orderStatus, leftOrderInfo.orderHash, @@ -97,7 +97,7 @@ contract MixinMatchOrders is matchedFillResults.left.takerAssetFilledAmount, leftSignature ); - validateFillOrRevert( + assertValidFill( rightOrder, rightOrderInfo.orderStatus, rightOrderInfo.orderHash, @@ -131,14 +131,13 @@ contract MixinMatchOrders is matchedFillResults.right ); - // Return results return matchedFillResults; } /// @dev Validates context for matchOrders. Succeeds or throws. /// @param leftOrder First order to match. /// @param rightOrder Second order to match. - function validateMatchOrThrow( + function assertValidMatch( Order memory leftOrder, Order memory rightOrder ) @@ -173,7 +172,7 @@ contract MixinMatchOrders is /// @dev Validates matched fill results. Succeeds or throws. /// @param matchedFillResults Amounts to fill and fees to pay by maker and taker of matched orders. - function validateMatchOrThrow(MatchedFillResults memory matchedFillResults) + function assertValidMatch(MatchedFillResults memory matchedFillResults) internal { // The left order must spend at least as much as we're sending to the combined @@ -308,7 +307,7 @@ contract MixinMatchOrders is ); // Validate the fill results - validateMatchOrThrow(matchedFillResults); + assertValidMatch(matchedFillResults); // Return fill results return matchedFillResults; diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MExchangeCore.sol b/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MExchangeCore.sol index f166abb71..c88dd92db 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MExchangeCore.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MExchangeCore.sol @@ -64,7 +64,7 @@ contract MExchangeCore is /// @param takerAssetFilledAmount Amount of order already filled. /// @param takerAssetFillAmount Desired amount of order to fill by taker. /// @param signature Proof that the orders was created by its maker. - function validateFillOrRevert( + function assertValidFill( LibOrder.Order memory order, uint8 orderStatus, bytes32 orderHash, @@ -113,7 +113,7 @@ contract MExchangeCore is /// @param order that was cancelled. /// @param orderStatus Status of order that was cancelled. /// @param orderHash Hash of order that was cancelled. - function validateCancelOrRevert( + function assertValidCancel( LibOrder.Order memory order, uint8 orderStatus, bytes32 orderHash diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MMatchOrders.sol b/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MMatchOrders.sol index d8b9a22c3..7c9a481f1 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MMatchOrders.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MMatchOrders.sol @@ -38,7 +38,7 @@ contract MMatchOrders is /// @dev Validates context for matchOrders. Succeeds or throws. /// @param leftOrder First order to match. /// @param rightOrder Second order to match. - function validateMatchOrThrow( + function assertValidMatch( LibOrder.Order memory leftOrder, LibOrder.Order memory rightOrder ) @@ -46,7 +46,7 @@ contract MMatchOrders is /// @dev Validates matched fill results. Succeeds or throws. /// @param matchedFillResults Amounts to fill and fees to pay by maker and taker of matched orders. - function validateMatchOrThrow(LibFillResults.MatchedFillResults memory matchedFillResults) + function assertValidMatch(LibFillResults.MatchedFillResults memory matchedFillResults) internal; /// @dev Calculates fill amounts for the matched orders. -- cgit v1.2.3