aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/2.0.0/protocol
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-08-31 04:07:51 +0800
committerGitHub <noreply@github.com>2018-08-31 04:07:51 +0800
commit81ba2a8411abc84ab052a65e1c674af44b8cf746 (patch)
treed113855536c875160d79434eb6967cd61d72e468 /packages/contracts/src/2.0.0/protocol
parenta6e8b28da56c94cb7548ca29ed478dc803237efc (diff)
parent09b4d5e0e4a7100ab591a8711c10a173fb6ea16c (diff)
downloaddexon-sol-tools-81ba2a8411abc84ab052a65e1c674af44b8cf746.tar
dexon-sol-tools-81ba2a8411abc84ab052a65e1c674af44b8cf746.tar.gz
dexon-sol-tools-81ba2a8411abc84ab052a65e1c674af44b8cf746.tar.bz2
dexon-sol-tools-81ba2a8411abc84ab052a65e1c674af44b8cf746.tar.lz
dexon-sol-tools-81ba2a8411abc84ab052a65e1c674af44b8cf746.tar.xz
dexon-sol-tools-81ba2a8411abc84ab052a65e1c674af44b8cf746.tar.zst
dexon-sol-tools-81ba2a8411abc84ab052a65e1c674af44b8cf746.zip
Merge pull request #1045 from 0xProject/feature/contracts/cancelOrderInternal
Add cancelOrderInternal, use within batchCancelOrders
Diffstat (limited to 'packages/contracts/src/2.0.0/protocol')
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/MixinExchangeCore.sol25
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/MixinWrapperFunctions.sol3
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/mixins/MExchangeCore.sol5
3 files changed, 24 insertions, 9 deletions
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 ff908917d..11bbe40fb 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/MixinExchangeCore.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/MixinExchangeCore.sol
@@ -107,14 +107,7 @@ contract MixinExchangeCore is
public
nonReentrant
{
- // Fetch current order status
- OrderInfo memory orderInfo = getOrderInfo(order);
-
- // Validate context
- assertValidCancel(order, orderInfo);
-
- // Perform cancel
- updateCancelledState(order, orderInfo.orderHash);
+ cancelOrderInternal(order);
}
/// @dev Gets information about an order: status, hash, and amount filled.
@@ -236,6 +229,22 @@ contract MixinExchangeCore is
return fillResults;
}
+ /// @dev After calling, the order can not be filled anymore.
+ /// Throws if order is invalid or sender does not have permission to cancel.
+ /// @param order Order to cancel. Order must be OrderStatus.FILLABLE.
+ function cancelOrderInternal(Order memory order)
+ internal
+ {
+ // Fetch current order status
+ OrderInfo memory orderInfo = getOrderInfo(order);
+
+ // Validate context
+ assertValidCancel(order, orderInfo);
+
+ // Perform cancel
+ updateCancelledState(order, orderInfo.orderHash);
+ }
+
/// @dev Updates state with results of a fill order.
/// @param order that was filled.
/// @param takerAddress Address of taker who filled the order.
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/MixinWrapperFunctions.sol b/packages/contracts/src/2.0.0/protocol/Exchange/MixinWrapperFunctions.sol
index a5459a21e..a149f95c9 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/MixinWrapperFunctions.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/MixinWrapperFunctions.sol
@@ -377,10 +377,11 @@ contract MixinWrapperFunctions is
/// @param orders Array of order specifications.
function batchCancelOrders(LibOrder.Order[] memory orders)
public
+ nonReentrant
{
uint256 ordersLength = orders.length;
for (uint256 i = 0; i != ordersLength; i++) {
- cancelOrder(orders[i]);
+ cancelOrderInternal(orders[i]);
}
}
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MExchangeCore.sol b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MExchangeCore.sol
index d85913e0f..742499568 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MExchangeCore.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MExchangeCore.sol
@@ -72,6 +72,11 @@ contract MExchangeCore is
internal
returns (LibFillResults.FillResults memory fillResults);
+ /// @dev After calling, the order can not be filled anymore.
+ /// @param order Order struct containing order specifications.
+ function cancelOrderInternal(LibOrder.Order memory order)
+ internal;
+
/// @dev Updates state with results of a fill order.
/// @param order that was filled.
/// @param takerAddress Address of taker who filled the order.