From dcc0908617b83de8f45af3e9ca6854b897be3d72 Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Sun, 22 Jul 2018 23:04:49 -0500 Subject: Add more tests and fixes --- packages/contracts/src/2.0.0/forwarder/MixinExchangeWrapper.sol | 5 ++++- packages/contracts/src/2.0.0/forwarder/MixinWeth.sol | 2 +- packages/contracts/src/2.0.0/forwarder/libs/LibConstants.sol | 2 +- packages/contracts/src/2.0.0/forwarder/libs/LibForwarderErrors.sol | 2 +- packages/contracts/src/2.0.0/utils/SafeMath/SafeMath.sol | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) (limited to 'packages/contracts/src') diff --git a/packages/contracts/src/2.0.0/forwarder/MixinExchangeWrapper.sol b/packages/contracts/src/2.0.0/forwarder/MixinExchangeWrapper.sol index d80e06350..e230767b7 100644 --- a/packages/contracts/src/2.0.0/forwarder/MixinExchangeWrapper.sol +++ b/packages/contracts/src/2.0.0/forwarder/MixinExchangeWrapper.sol @@ -100,12 +100,15 @@ contract MixinExchangeWrapper is internal returns (FillResults memory totalFillResults) { + bytes memory makerAssetData = orders[0].makerAssetData; bytes memory wethAssetData = WETH_ASSET_DATA; uint256 ordersLength = orders.length; for (uint256 i = 0; i < ordersLength; i++) { + // We assume that asset being bought by taker is the same for each order. // We assume that asset being sold by taker is WETH for each order. + orders[i].makerAssetData = makerAssetData; orders[i].takerAssetData = wethAssetData; // Calculate the remaining amount of WETH to sell @@ -231,7 +234,7 @@ contract MixinExchangeWrapper is // Attempt to sell the remaining amount of WETH. FillResults memory singleFillResult = fillOrderNoThrow( orders[i], - safeAdd(remainingWethSellAmount, 1), + safeAdd(remainingWethSellAmount, 1), // we add 1 wei to the fill amount to make up for rounding errors signatures[i] ); diff --git a/packages/contracts/src/2.0.0/forwarder/MixinWeth.sol b/packages/contracts/src/2.0.0/forwarder/MixinWeth.sol index a50863a59..8ba236e7f 100644 --- a/packages/contracts/src/2.0.0/forwarder/MixinWeth.sol +++ b/packages/contracts/src/2.0.0/forwarder/MixinWeth.sol @@ -87,7 +87,7 @@ contract MixinWeth is // Ensure fee is less than amount of WETH remaining. require( ethFee <= wethRemaining, - "MAX_FEE_EXCEEDED" + "INSUFFICIENT_ETH_REMAINING" ); // Do nothing if no WETH remaining diff --git a/packages/contracts/src/2.0.0/forwarder/libs/LibConstants.sol b/packages/contracts/src/2.0.0/forwarder/libs/LibConstants.sol index 8abe1e42d..c26d7902c 100644 --- a/packages/contracts/src/2.0.0/forwarder/libs/LibConstants.sol +++ b/packages/contracts/src/2.0.0/forwarder/libs/LibConstants.sol @@ -26,7 +26,7 @@ import "../../tokens/ERC20Token/IERC20Token.sol"; contract LibConstants { bytes4 constant internal ERC20_DATA_ID = bytes4(keccak256("ERC20Token(address)")); - bytes4 constant internal ERC721_DATA_ID = bytes4(keccak256("ERC721Token(address,uint256,bytes)")); + bytes4 constant internal ERC721_DATA_ID = bytes4(keccak256("ERC721Token(address,uint256)")); uint256 constant internal MAX_UINT = 2**256 - 1; uint256 constant internal PERCENTAGE_DENOMINATOR = 10**18; uint256 constant internal MAX_FEE_PERCENTAGE = 5 * PERCENTAGE_DENOMINATOR / 100; // 5% diff --git a/packages/contracts/src/2.0.0/forwarder/libs/LibForwarderErrors.sol b/packages/contracts/src/2.0.0/forwarder/libs/LibForwarderErrors.sol index 69108738a..cdfb77a0b 100644 --- a/packages/contracts/src/2.0.0/forwarder/libs/LibForwarderErrors.sol +++ b/packages/contracts/src/2.0.0/forwarder/libs/LibForwarderErrors.sol @@ -23,7 +23,7 @@ pragma solidity 0.4.24; /// This contract is intended to serve as a reference, but is not actually used for efficiency reasons. contract LibForwarderErrors { string constant FEE_PERCENTAGE_TOO_LARGE = "FEE_PROPORTION_TOO_LARGE"; // Provided fee percentage greater than 5%. - string constant MAX_FEE_EXCEEDED = "MAX_FEE_EXCEEDED"; // Not enough ETH remaining to pay feeRecipient. + string constant INSUFFICIENT_ETH_REMAINING = "INSUFFICIENT_ETH_REMAINING"; // Not enough ETH remaining to pay feeRecipient. string constant OVERSOLD_WETH = "OVERSOLD_WETH"; // More WETH sold than provided with current message call. string constant COMPLETE_FILL_FAILED = "COMPLETE_FILL_FAILED"; // Desired purchase amount not completely filled (required for ZRX fees only). string constant TRANSFER_FAILED = "TRANSFER_FAILED"; // Asset transfer failed. diff --git a/packages/contracts/src/2.0.0/utils/SafeMath/SafeMath.sol b/packages/contracts/src/2.0.0/utils/SafeMath/SafeMath.sol index 190989181..63a2a085f 100644 --- a/packages/contracts/src/2.0.0/utils/SafeMath/SafeMath.sol +++ b/packages/contracts/src/2.0.0/utils/SafeMath/SafeMath.sol @@ -34,7 +34,7 @@ contract SafeMath { { require( b <= a, - "UINT256_OVERFLOW" + "UINT256_UNDERFLOW" ); return a - b; } -- cgit v1.2.3