Update contracts/exchange-forwarder to 0.5.5 (#1796)

* Cherry-pick updated `@0x/contracts-exchange-forwarder` from `3.0` branch.

* Add PR numbers to changelogs
This commit is contained in:
Lawrence Forman 2019-04-28 22:21:13 -04:00 committed by GitHub
parent d303e9f347
commit bbc06be091
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 59 additions and 49 deletions

View File

@ -1,4 +1,13 @@
[ [
{
"version": "3.0.0",
"changes": [
{
"note": "Update contracts to solidity ^0.5.5 and unpin dependencies",
"pr": 1796
}
]
},
{ {
"version": "2.1.1", "version": "2.1.1",
"changes": [ "changes": [

View File

@ -16,7 +16,7 @@
*/ */
pragma solidity 0.4.24; pragma solidity ^0.5.5;
pragma experimental ABIEncoderV2; pragma experimental ABIEncoderV2;
import "./MixinWeth.sol"; import "./MixinWeth.sol";
@ -40,6 +40,7 @@ contract Forwarder is
bytes memory _wethAssetData bytes memory _wethAssetData
) )
public public
Ownable()
LibConstants( LibConstants(
_exchange, _exchange,
_zrxAssetData, _zrxAssetData,

View File

@ -16,7 +16,7 @@
*/ */
pragma solidity ^0.4.24; pragma solidity ^0.5.5;
import "@0x/contracts-utils/contracts/src/LibBytes.sol"; import "@0x/contracts-utils/contracts/src/LibBytes.sol";
import "@0x/contracts-utils/contracts/src/Ownable.sol"; import "@0x/contracts-utils/contracts/src/Ownable.sol";
@ -35,13 +35,13 @@ contract MixinAssets is
bytes4 constant internal ERC20_TRANSFER_SELECTOR = bytes4(keccak256("transfer(address,uint256)")); bytes4 constant internal ERC20_TRANSFER_SELECTOR = bytes4(keccak256("transfer(address,uint256)"));
/// @dev Withdraws assets from this contract. The contract requires a ZRX balance in order to /// @dev Withdraws assets from this contract. The contract requires a ZRX balance in order to
/// function optimally, and this function allows the ZRX to be withdrawn by owner. It may also be /// function optimally, and this function allows the ZRX to be withdrawn by owner. It may also be
/// used to withdraw assets that were accidentally sent to this contract. /// used to withdraw assets that were accidentally sent to this contract.
/// @param assetData Byte array encoded for the respective asset proxy. /// @param assetData Byte array encoded for the respective asset proxy.
/// @param amount Amount of ERC20 token to withdraw. /// @param amount Amount of ERC20 token to withdraw.
function withdrawAsset( function withdrawAsset(
bytes assetData, bytes calldata assetData,
uint256 amount uint256 amount
) )
external external
@ -84,7 +84,7 @@ contract MixinAssets is
// Transfer tokens. // Transfer tokens.
// We do a raw call so we can check the success separate // We do a raw call so we can check the success separate
// from the return data. // from the return data.
bool success = token.call(abi.encodeWithSelector( (bool success,) = token.call(abi.encodeWithSelector(
ERC20_TRANSFER_SELECTOR, ERC20_TRANSFER_SELECTOR,
msg.sender, msg.sender,
amount amount
@ -93,7 +93,7 @@ contract MixinAssets is
success, success,
"TRANSFER_FAILED" "TRANSFER_FAILED"
); );
// Check return data. // Check return data.
// If there is no return data, we assume the token incorrectly // If there is no return data, we assume the token incorrectly
// does not return a bool. In this case we expect it to revert // does not return a bool. In this case we expect it to revert

View File

@ -16,7 +16,7 @@
*/ */
pragma solidity ^0.4.24; pragma solidity ^0.5.5;
pragma experimental ABIEncoderV2; pragma experimental ABIEncoderV2;
import "./libs/LibConstants.sol"; import "./libs/LibConstants.sol";
@ -144,6 +144,7 @@ contract MixinExchangeWrapper is
bytes memory wethAssetData = WETH_ASSET_DATA; bytes memory wethAssetData = WETH_ASSET_DATA;
uint256 ordersLength = orders.length; uint256 ordersLength = orders.length;
uint256 makerAssetFilledAmount = 0;
for (uint256 i = 0; i != ordersLength; i++) { 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 bought by taker is the same for each order.
@ -175,7 +176,7 @@ contract MixinExchangeWrapper is
addFillResults(totalFillResults, singleFillResults); addFillResults(totalFillResults, singleFillResults);
// Stop execution if the entire amount of makerAsset has been bought // Stop execution if the entire amount of makerAsset has been bought
uint256 makerAssetFilledAmount = totalFillResults.makerAssetFilledAmount; makerAssetFilledAmount = totalFillResults.makerAssetFilledAmount;
if (makerAssetFilledAmount >= makerAssetFillAmount) { if (makerAssetFilledAmount >= makerAssetFillAmount) {
break; break;
} }
@ -192,7 +193,7 @@ contract MixinExchangeWrapper is
/// that at least zrxBuyAmount of ZRX is purchased (sometimes slightly over due to rounding issues). /// that at least zrxBuyAmount of ZRX is purchased (sometimes slightly over due to rounding issues).
/// It is possible that a request to buy 200 ZRX will require purchasing 202 ZRX /// It is possible that a request to buy 200 ZRX will require purchasing 202 ZRX
/// as 2 ZRX is required to purchase the 200 ZRX fee tokens. This guarantees at least 200 ZRX for future purchases. /// as 2 ZRX is required to purchase the 200 ZRX fee tokens. This guarantees at least 200 ZRX for future purchases.
/// The asset being sold by taker must always be WETH. /// The asset being sold by taker must always be WETH.
/// @param orders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. /// @param orders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset.
/// @param zrxBuyAmount Desired amount of ZRX to buy. /// @param zrxBuyAmount Desired amount of ZRX to buy.
/// @param signatures Proofs that orders have been created by makers. /// @param signatures Proofs that orders have been created by makers.
@ -230,7 +231,7 @@ contract MixinExchangeWrapper is
// of the Maker. In this case we want to overestimate the amount of takerAsset. // of the Maker. In this case we want to overestimate the amount of takerAsset.
uint256 remainingWethSellAmount = getPartialAmountCeil( uint256 remainingWethSellAmount = getPartialAmountCeil(
orders[i].takerAssetAmount, orders[i].takerAssetAmount,
safeSub(orders[i].makerAssetAmount, orders[i].takerFee), // our exchange rate after fees safeSub(orders[i].makerAssetAmount, orders[i].takerFee), // our exchange rate after fees
remainingZrxBuyAmount remainingZrxBuyAmount
); );

View File

@ -16,7 +16,7 @@
*/ */
pragma solidity ^0.4.24; pragma solidity ^0.5.5;
pragma experimental ABIEncoderV2; pragma experimental ABIEncoderV2;
import "./libs/LibConstants.sol"; import "./libs/LibConstants.sol";
@ -58,7 +58,7 @@ contract MixinForwarderCore is
/// Any ZRX required to pay fees for primary orders will automatically be purchased by this contract. /// Any ZRX required to pay fees for primary orders will automatically be purchased by this contract.
/// 5% of ETH value is reserved for paying fees to order feeRecipients (in ZRX) and forwarding contract feeRecipient (in ETH). /// 5% of ETH value is reserved for paying fees to order feeRecipients (in ZRX) and forwarding contract feeRecipient (in ETH).
/// Any ETH not spent will be refunded to sender. /// Any ETH not spent will be refunded to sender.
/// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset. /// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset.
/// @param signatures Proofs that orders have been created by makers. /// @param signatures Proofs that orders have been created by makers.
/// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees. /// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees.
/// @param feeSignatures Proofs that feeOrders have been created by makers. /// @param feeSignatures Proofs that feeOrders have been created by makers.
@ -70,8 +70,8 @@ contract MixinForwarderCore is
bytes[] memory signatures, bytes[] memory signatures,
LibOrder.Order[] memory feeOrders, LibOrder.Order[] memory feeOrders,
bytes[] memory feeSignatures, bytes[] memory feeSignatures,
uint256 feePercentage, uint256 feePercentage,
address feeRecipient address payable feeRecipient
) )
public public
payable payable
@ -142,7 +142,7 @@ contract MixinForwarderCore is
/// @dev Attempt to purchase makerAssetFillAmount of makerAsset by selling ETH provided with transaction. /// @dev Attempt to purchase makerAssetFillAmount of makerAsset by selling ETH provided with transaction.
/// Any ZRX required to pay fees for primary orders will automatically be purchased by this contract. /// Any ZRX required to pay fees for primary orders will automatically be purchased by this contract.
/// Any ETH not spent will be refunded to sender. /// Any ETH not spent will be refunded to sender.
/// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset. /// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset.
/// @param makerAssetFillAmount Desired amount of makerAsset to purchase. /// @param makerAssetFillAmount Desired amount of makerAsset to purchase.
/// @param signatures Proofs that orders have been created by makers. /// @param signatures Proofs that orders have been created by makers.
/// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees. /// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees.
@ -156,8 +156,8 @@ contract MixinForwarderCore is
bytes[] memory signatures, bytes[] memory signatures,
LibOrder.Order[] memory feeOrders, LibOrder.Order[] memory feeOrders,
bytes[] memory feeSignatures, bytes[] memory feeSignatures,
uint256 feePercentage, uint256 feePercentage,
address feeRecipient address payable feeRecipient
) )
public public
payable payable

View File

@ -16,7 +16,7 @@
*/ */
pragma solidity ^0.4.24; pragma solidity ^0.5.5;
import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol"; import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
import "./libs/LibConstants.sol"; import "./libs/LibConstants.sol";
@ -30,7 +30,7 @@ contract MixinWeth is
{ {
/// @dev Default payabale function, this allows us to withdraw WETH /// @dev Default payabale function, this allows us to withdraw WETH
function () function ()
public external
payable payable
{ {
require( require(
@ -60,7 +60,7 @@ contract MixinWeth is
uint256 wethSoldExcludingFeeOrders, uint256 wethSoldExcludingFeeOrders,
uint256 wethSoldForZrx, uint256 wethSoldForZrx,
uint256 feePercentage, uint256 feePercentage,
address feeRecipient address payable feeRecipient
) )
internal internal
{ {
@ -92,7 +92,7 @@ contract MixinWeth is
ethFee <= wethRemaining, ethFee <= wethRemaining,
"INSUFFICIENT_ETH_REMAINING" "INSUFFICIENT_ETH_REMAINING"
); );
// Do nothing if no WETH remaining // Do nothing if no WETH remaining
if (wethRemaining > 0) { if (wethRemaining > 0) {
// Convert remaining WETH to ETH // Convert remaining WETH to ETH

View File

@ -16,18 +16,18 @@
*/ */
pragma solidity ^0.4.24; pragma solidity ^0.5.5;
contract IAssets { contract IAssets {
/// @dev Withdraws assets from this contract. The contract requires a ZRX balance in order to /// @dev Withdraws assets from this contract. The contract requires a ZRX balance in order to
/// function optimally, and this function allows the ZRX to be withdrawn by owner. It may also be /// function optimally, and this function allows the ZRX to be withdrawn by owner. It may also be
/// used to withdraw assets that were accidentally sent to this contract. /// used to withdraw assets that were accidentally sent to this contract.
/// @param assetData Byte array encoded for the respective asset proxy. /// @param assetData Byte array encoded for the respective asset proxy.
/// @param amount Amount of ERC20 token to withdraw. /// @param amount Amount of ERC20 token to withdraw.
function withdrawAsset( function withdrawAsset(
bytes assetData, bytes calldata assetData,
uint256 amount uint256 amount
) )
external; external;

View File

@ -16,7 +16,7 @@
*/ */
pragma solidity ^0.4.24; pragma solidity ^0.5.5;
pragma experimental ABIEncoderV2; pragma experimental ABIEncoderV2;
import "./IForwarderCore.sol"; import "./IForwarderCore.sol";

View File

@ -16,7 +16,7 @@
*/ */
pragma solidity ^0.4.24; pragma solidity ^0.5.5;
pragma experimental ABIEncoderV2; pragma experimental ABIEncoderV2;
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol"; import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
@ -29,7 +29,7 @@ contract IForwarderCore {
/// Any ZRX required to pay fees for primary orders will automatically be purchased by this contract. /// Any ZRX required to pay fees for primary orders will automatically be purchased by this contract.
/// 5% of ETH value is reserved for paying fees to order feeRecipients (in ZRX) and forwarding contract feeRecipient (in ETH). /// 5% of ETH value is reserved for paying fees to order feeRecipients (in ZRX) and forwarding contract feeRecipient (in ETH).
/// Any ETH not spent will be refunded to sender. /// Any ETH not spent will be refunded to sender.
/// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset. /// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset.
/// @param signatures Proofs that orders have been created by makers. /// @param signatures Proofs that orders have been created by makers.
/// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees. /// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees.
/// @param feeSignatures Proofs that feeOrders have been created by makers. /// @param feeSignatures Proofs that feeOrders have been created by makers.
@ -41,8 +41,8 @@ contract IForwarderCore {
bytes[] memory signatures, bytes[] memory signatures,
LibOrder.Order[] memory feeOrders, LibOrder.Order[] memory feeOrders,
bytes[] memory feeSignatures, bytes[] memory feeSignatures,
uint256 feePercentage, uint256 feePercentage,
address feeRecipient address payable feeRecipient
) )
public public
payable payable
@ -54,7 +54,7 @@ contract IForwarderCore {
/// @dev Attempt to purchase makerAssetFillAmount of makerAsset by selling ETH provided with transaction. /// @dev Attempt to purchase makerAssetFillAmount of makerAsset by selling ETH provided with transaction.
/// Any ZRX required to pay fees for primary orders will automatically be purchased by this contract. /// Any ZRX required to pay fees for primary orders will automatically be purchased by this contract.
/// Any ETH not spent will be refunded to sender. /// Any ETH not spent will be refunded to sender.
/// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset. /// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset.
/// @param makerAssetFillAmount Desired amount of makerAsset to purchase. /// @param makerAssetFillAmount Desired amount of makerAsset to purchase.
/// @param signatures Proofs that orders have been created by makers. /// @param signatures Proofs that orders have been created by makers.
/// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees. /// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees.
@ -68,8 +68,8 @@ contract IForwarderCore {
bytes[] memory signatures, bytes[] memory signatures,
LibOrder.Order[] memory feeOrders, LibOrder.Order[] memory feeOrders,
bytes[] memory feeSignatures, bytes[] memory feeSignatures,
uint256 feePercentage, uint256 feePercentage,
address feeRecipient address payable feeRecipient
) )
public public
payable payable

View File

@ -16,7 +16,7 @@
*/ */
pragma solidity ^0.4.24; pragma solidity ^0.5.5;
import "@0x/contracts-utils/contracts/src/LibBytes.sol"; import "@0x/contracts-utils/contracts/src/LibBytes.sol";
import "@0x/contracts-exchange/contracts/src/interfaces/IExchange.sol"; import "@0x/contracts-exchange/contracts/src/interfaces/IExchange.sol";
@ -31,10 +31,10 @@ contract LibConstants {
bytes4 constant internal ERC20_DATA_ID = bytes4(keccak256("ERC20Token(address)")); bytes4 constant internal ERC20_DATA_ID = bytes4(keccak256("ERC20Token(address)"));
bytes4 constant internal ERC721_DATA_ID = bytes4(keccak256("ERC721Token(address,uint256)")); bytes4 constant internal ERC721_DATA_ID = bytes4(keccak256("ERC721Token(address,uint256)"));
uint256 constant internal MAX_UINT = 2**256 - 1; uint256 constant internal MAX_UINT = 2**256 - 1;
uint256 constant internal PERCENTAGE_DENOMINATOR = 10**18; uint256 constant internal PERCENTAGE_DENOMINATOR = 10**18;
uint256 constant internal MAX_FEE_PERCENTAGE = 5 * PERCENTAGE_DENOMINATOR / 100; // 5% uint256 constant internal MAX_FEE_PERCENTAGE = 5 * PERCENTAGE_DENOMINATOR / 100; // 5%
uint256 constant internal MAX_WETH_FILL_PERCENTAGE = 95 * PERCENTAGE_DENOMINATOR / 100; // 95% uint256 constant internal MAX_WETH_FILL_PERCENTAGE = 95 * PERCENTAGE_DENOMINATOR / 100; // 95%
// solhint-disable var-name-mixedcase // solhint-disable var-name-mixedcase
IExchange internal EXCHANGE; IExchange internal EXCHANGE;
IEtherToken internal ETHER_TOKEN; IEtherToken internal ETHER_TOKEN;

View File

@ -17,7 +17,7 @@
*/ */
// solhint-disable // solhint-disable
pragma solidity ^0.4.24; pragma solidity ^0.5.5;
/// This contract is intended to serve as a reference, but is not actually used for efficiency reasons. /// This contract is intended to serve as a reference, but is not actually used for efficiency reasons.

View File

@ -16,7 +16,7 @@
*/ */
pragma solidity ^0.4.24; pragma solidity ^0.5.5;
import "../interfaces/IAssets.sol"; import "../interfaces/IAssets.sol";

View File

@ -16,7 +16,7 @@
*/ */
pragma solidity ^0.4.24; pragma solidity ^0.5.5;
pragma experimental ABIEncoderV2; pragma experimental ABIEncoderV2;
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol"; import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
@ -72,7 +72,7 @@ contract MExchangeWrapper {
/// that at least zrxBuyAmount of ZRX is purchased (sometimes slightly over due to rounding issues). /// that at least zrxBuyAmount of ZRX is purchased (sometimes slightly over due to rounding issues).
/// It is possible that a request to buy 200 ZRX will require purchasing 202 ZRX /// It is possible that a request to buy 200 ZRX will require purchasing 202 ZRX
/// as 2 ZRX is required to purchase the 200 ZRX fee tokens. This guarantees at least 200 ZRX for future purchases. /// as 2 ZRX is required to purchase the 200 ZRX fee tokens. This guarantees at least 200 ZRX for future purchases.
/// The asset being sold by taker must always be WETH. /// The asset being sold by taker must always be WETH.
/// @param orders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. /// @param orders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset.
/// @param zrxBuyAmount Desired amount of ZRX to buy. /// @param zrxBuyAmount Desired amount of ZRX to buy.
/// @param signatures Proofs that orders have been created by makers. /// @param signatures Proofs that orders have been created by makers.

View File

@ -16,7 +16,7 @@
*/ */
pragma solidity ^0.4.24; pragma solidity ^0.5.5;
contract MWeth { contract MWeth {
@ -35,7 +35,7 @@ contract MWeth {
uint256 wethSoldExcludingFeeOrders, uint256 wethSoldExcludingFeeOrders,
uint256 wethSoldForZrx, uint256 wethSoldForZrx,
uint256 feePercentage, uint256 feePercentage,
address feeRecipient address payable feeRecipient
) )
internal; internal;
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@0x/contracts-exchange-forwarder", "name": "@0x/contracts-exchange-forwarder",
"version": "2.1.1", "version": "2.1.0",
"engines": { "engines": {
"node": ">=6.12" "node": ">=6.12"
}, },
@ -24,7 +24,6 @@
"clean": "shx rm -rf lib generated-artifacts generated-wrappers", "clean": "shx rm -rf lib generated-artifacts generated-wrappers",
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers", "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers",
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
"coverage:report:text": "istanbul report text", "coverage:report:text": "istanbul report text",
"coverage:report:html": "istanbul report html && open coverage/index.html", "coverage:report:html": "istanbul report html && open coverage/index.html",
"profiler:report:html": "istanbul report html && open coverage/index.html", "profiler:report:html": "istanbul report html && open coverage/index.html",
@ -71,14 +70,14 @@
"dependencies": { "dependencies": {
"@0x/base-contract": "^5.0.5", "@0x/base-contract": "^5.0.5",
"@0x/contracts-asset-proxy": "^2.1.1", "@0x/contracts-asset-proxy": "^2.1.1",
"@0x/contracts-erc20": "1.0.8", "@0x/contracts-erc20": "^2.2.0",
"@0x/contracts-erc721": "1.0.8", "@0x/contracts-erc721": "^2.1.0",
"@0x/contracts-exchange": "1.0.2", "@0x/contracts-exchange": "^2.1.1",
"@0x/contracts-exchange-libs": "1.0.2", "@0x/contracts-exchange-libs": "^2.1.1",
"@0x/contracts-utils": "2.0.1", "@0x/contracts-utils": "^3.1.1",
"@0x/order-utils": "^7.2.0", "@0x/order-utils": "^7.2.0",
"@0x/types": "^2.2.2", "@0x/types": "^2.2.2",
"@0x/typescript-typings": "^4.2.2", "@0x/typescript-typings": "^4.2.1",
"@0x/utils": "^4.3.1", "@0x/utils": "^4.3.1",
"@0x/web3-wrapper": "^6.0.5", "@0x/web3-wrapper": "^6.0.5",
"ethereum-types": "^2.1.2", "ethereum-types": "^2.1.2",