aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-03-21 08:34:58 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-04-21 04:56:17 +0800
commit751f9b9240fef07de5a604fa2345453a7656dfb2 (patch)
tree900e7b71f0b0b9d86f405e5b77dcd9f760c1860d /packages/contracts/src
parent1efba5979f2c11aa70845d2ef9f32b60e1bc6971 (diff)
downloaddexon-sol-tools-751f9b9240fef07de5a604fa2345453a7656dfb2.tar.gz
dexon-sol-tools-751f9b9240fef07de5a604fa2345453a7656dfb2.tar.zst
dexon-sol-tools-751f9b9240fef07de5a604fa2345453a7656dfb2.zip
Change from cancelOrdersBefore to cancelOrdersUpTo. The effect is that orders with salt <= to maker epoch will be cancelled (previously, it was salt < maker epoch)
Diffstat (limited to 'packages/contracts/src')
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/IExchange.sol4
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol15
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/mixins/MExchangeCore.sol2
-rw-r--r--packages/contracts/src/utils/exchange_wrapper.ts4
4 files changed, 13 insertions, 12 deletions
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/IExchange.sol b/packages/contracts/src/contracts/current/protocol/Exchange/IExchange.sol
index 9e285e8bb..b7164a4e9 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/IExchange.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/IExchange.sol
@@ -163,8 +163,8 @@ contract IExchange {
returns (uint256 takerTokenCancelledAmount);
/// @dev Cancels all orders for a specified maker up to a certain time.
- /// @param salt Orders created with a lower salt value will be cancelled
- function cancelOrdersBefore(uint256 salt)
+ /// @param salt Orders created with a salt less or equal to this value will be cancelled.
+ function cancelOrdersUpTo(uint256 salt)
external;
/// @dev Fills an order with specified parameters and ECDSA signature. Throws if specified amount not filled entirely.
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol
index 6d69b1787..acbed1ad7 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol
@@ -70,9 +70,9 @@ contract MixinExchangeCore is
bytes32 indexed orderHash
);
- event LogCancelBefore(
+ event LogCancelUpTo(
address indexed maker,
- uint256 salt
+ uint256 makerEpoch
);
/*
@@ -202,13 +202,14 @@ contract MixinExchangeCore is
return takerTokenCancelledAmount;
}
- /// @param salt Orders created with a salt less than this value will be cancelled.
- function cancelOrdersBefore(uint256 salt)
+ /// @param salt Orders created with a salt less or equal to this value will be cancelled.
+ function cancelOrdersUpTo(uint256 salt)
external
{
- require(salt > makerEpoch[msg.sender]); // epoch must be monotonically increasing
- makerEpoch[msg.sender] = salt;
- LogCancelBefore(msg.sender, salt);
+ uint256 newMakerEpoch = salt + 1; // makerEpoch is initialized to 0, so to cancelUpTo we need salt+1
+ require(newMakerEpoch > makerEpoch[msg.sender]); // epoch must be monotonically increasing
+ makerEpoch[msg.sender] = newMakerEpoch;
+ LogCancelUpTo(msg.sender, newMakerEpoch);
}
/// @dev Checks if rounding error > 0.1%.
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 77300c0f8..6768e2376 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MExchangeCore.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MExchangeCore.sol
@@ -36,6 +36,6 @@ contract MExchangeCore is LibOrder {
public
returns (uint256 takerTokenCancelledAmount);
- function cancelOrdersBefore(uint256 salt)
+ function cancelOrdersUpTo(uint256 salt)
external;
}
diff --git a/packages/contracts/src/utils/exchange_wrapper.ts b/packages/contracts/src/utils/exchange_wrapper.ts
index 808ff0fd4..3f56fd52f 100644
--- a/packages/contracts/src/utils/exchange_wrapper.ts
+++ b/packages/contracts/src/utils/exchange_wrapper.ts
@@ -167,11 +167,11 @@ export class ExchangeWrapper {
const tx = await this._getTxWithDecodedExchangeLogsAsync(txHash);
return tx;
}
- public async cancelOrdersBeforeAsync(
+ public async cancelOrdersUpToAsync(
salt: BigNumber,
from: string,
): Promise<TransactionReceiptWithDecodedLogs> {
- const txHash = await this._exchange.cancelOrdersBefore.sendTransactionAsync(
+ const txHash = await this._exchange.cancelOrdersUpTo.sendTransactionAsync(
salt,
{ from },
);