From d2e422cd5eab26108e6c7a9f73c944f4b6fb4fdd Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Fri, 6 Jul 2018 09:51:23 -0700 Subject: Apply new linter rules --- packages/contracts/.solhint.json | 2 +- .../contracts/src/2.0.0/forwarder/Forwarder.sol | 5 +- .../src/2.0.0/forwarder/MixinConstants.sol | 15 ++- .../contracts/src/2.0.0/forwarder/MixinERC20.sol | 6 +- .../contracts/src/2.0.0/forwarder/MixinERC721.sol | 8 +- .../src/2.0.0/forwarder/MixinErrorMessages.sol | 4 +- .../src/2.0.0/forwarder/MixinExpectedResults.sol | 127 +++++++++++---------- .../src/2.0.0/forwarder/MixinMarketBuyTokens.sol | 5 +- .../src/2.0.0/forwarder/MixinMarketBuyZrx.sol | 4 +- .../src/2.0.0/forwarder/MixinMarketSellTokens.sol | 5 +- .../src/2.0.0/forwarder/MixinWethFees.sol | 3 +- .../src/2.0.0/multisig/MultiSigWallet.sol | 2 +- .../2.0.0/multisig/MultiSigWalletWithTimeLock.sol | 2 +- .../src/2.0.0/protocol/AssetProxy/ERC20Proxy.sol | 6 +- .../src/2.0.0/protocol/AssetProxy/ERC721Proxy.sol | 6 +- .../protocol/AssetProxy/MixinAuthorizable.sol | 2 +- .../protocol/AssetProxy/interfaces/IAssetData.sol | 5 +- .../protocol/AssetProxy/interfaces/IAssetProxy.sol | 2 +- .../AssetProxy/interfaces/IAuthorizable.sol | 16 +-- .../AssetProxy/libs/LibAssetProxyErrors.sol | 3 +- .../protocol/AssetProxy/mixins/MAuthorizable.sol | 2 +- .../protocol/AssetProxyOwner/AssetProxyOwner.sol | 3 +- .../src/2.0.0/protocol/Exchange/Exchange.sol | 3 +- .../Exchange/MixinAssetProxyDispatcher.sol | 3 +- .../2.0.0/protocol/Exchange/MixinExchangeCore.sol | 5 +- .../2.0.0/protocol/Exchange/MixinMatchOrders.sol | 2 +- .../protocol/Exchange/MixinSignatureValidator.sol | 2 +- .../2.0.0/protocol/Exchange/MixinTransactions.sol | 74 ++++++------ .../protocol/Exchange/MixinWrapperFunctions.sol | 2 +- .../Exchange/interfaces/IAssetProxyDispatcher.sol | 2 +- .../protocol/Exchange/interfaces/IExchange.sol | 3 +- .../protocol/Exchange/interfaces/IExchangeCore.sol | 2 +- .../protocol/Exchange/interfaces/IMatchOrders.sol | 2 +- .../Exchange/interfaces/ISignatureValidator.sol | 2 +- .../protocol/Exchange/interfaces/ITransactions.sol | 2 +- .../protocol/Exchange/interfaces/IValidator.sol | 2 +- .../2.0.0/protocol/Exchange/interfaces/IWallet.sol | 2 +- .../Exchange/interfaces/IWrapperFunctions.sol | 2 +- .../2.0.0/protocol/Exchange/libs/LibConstants.sol | 2 +- .../src/2.0.0/protocol/Exchange/libs/LibEIP712.sol | 8 +- .../protocol/Exchange/libs/LibExchangeErrors.sol | 3 +- .../protocol/Exchange/libs/LibFillResults.sol | 2 +- .../src/2.0.0/protocol/Exchange/libs/LibMath.sol | 2 +- .../src/2.0.0/protocol/Exchange/libs/LibOrder.sol | 6 +- .../Exchange/mixins/MAssetProxyDispatcher.sol | 2 +- .../protocol/Exchange/mixins/MExchangeCore.sol | 3 +- .../protocol/Exchange/mixins/MMatchOrders.sol | 2 +- .../Exchange/mixins/MSignatureValidator.sol | 2 +- .../protocol/Exchange/mixins/MTransactions.sol | 2 +- .../2.0.0/test/DummyERC20Token/DummyERC20Token.sol | 2 +- .../DummyERC721Receiver/DummyERC721Receiver.sol | 2 +- .../test/DummyERC721Token/DummyERC721Token.sol | 3 +- .../2.0.0/test/ExchangeWrapper/ExchangeWrapper.sol | 62 +++++----- .../contracts/src/2.0.0/test/Mintable/Mintable.sol | 2 +- .../TestAssetProxyDispatcher.sol | 2 +- .../TestAssetProxyOwner/TestAssetProxyOwner.sol | 8 +- .../src/2.0.0/test/TestLibBytes/TestLibBytes.sol | 2 +- .../contracts/src/2.0.0/test/TestLibs/TestLibs.sol | 2 +- .../TestSignatureValidator.sol | 2 +- .../src/2.0.0/test/TestValidator/TestValidator.sol | 6 +- .../src/2.0.0/test/TestWallet/TestWallet.sol | 8 +- .../src/2.0.0/test/Whitelist/Whitelist.sol | 64 +++++------ .../src/2.0.0/tokens/ERC20Token/ERC20Token.sol | 23 ++-- .../src/2.0.0/tokens/ERC20Token/IERC20Token.sol | 3 +- .../src/2.0.0/tokens/ERC721Token/ERC721Token.sol | 6 +- .../2.0.0/tokens/ERC721Token/IERC721Receiver.sol | 4 +- .../src/2.0.0/tokens/ERC721Token/IERC721Token.sol | 20 +++- .../UnlimitedAllowanceToken.sol | 10 +- .../contracts/src/2.0.0/tokens/WETH9/WETH9.sol | 1 + .../src/2.0.0/tokens/ZRXToken/ZRXToken.sol | 10 +- .../src/2.0.0/utils/LibBytes/LibBytes.sol | 25 +++- .../contracts/src/2.0.0/utils/Ownable/IOwnable.sol | 2 +- .../contracts/src/2.0.0/utils/Ownable/Ownable.sol | 2 +- .../src/2.0.0/utils/SafeMath/SafeMath.sol | 2 +- 74 files changed, 351 insertions(+), 299 deletions(-) (limited to 'packages') diff --git a/packages/contracts/.solhint.json b/packages/contracts/.solhint.json index 594fce677..076afe9f3 100644 --- a/packages/contracts/.solhint.json +++ b/packages/contracts/.solhint.json @@ -4,7 +4,7 @@ "avoid-low-level-calls": false, "avoid-tx-origin": "warn", "bracket-align": false, - "code-complexity": "false", + "code-complexity": false, "const-name-snakecase": "error", "expression-indent": "error", "function-max-lines": false, diff --git a/packages/contracts/src/2.0.0/forwarder/Forwarder.sol b/packages/contracts/src/2.0.0/forwarder/Forwarder.sol index 71a4aff13..38128d93e 100644 --- a/packages/contracts/src/2.0.0/forwarder/Forwarder.sol +++ b/packages/contracts/src/2.0.0/forwarder/Forwarder.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "./MixinWethFees.sol"; @@ -25,6 +25,7 @@ import "./MixinMarketBuyTokens.sol"; import "./MixinConstants.sol"; import "../utils/Ownable/Ownable.sol"; + contract Forwarder is Ownable, MixinConstants, @@ -33,7 +34,7 @@ contract Forwarder is MixinMarketBuyTokens, MixinMarketSellTokens { - uint256 MAX_UINT = 2**256 - 1; + uint256 constant internal MAX_UINT = 2**256 - 1; constructor ( address _exchange, diff --git a/packages/contracts/src/2.0.0/forwarder/MixinConstants.sol b/packages/contracts/src/2.0.0/forwarder/MixinConstants.sol index 18f2ba3bc..ea82e9d64 100644 --- a/packages/contracts/src/2.0.0/forwarder/MixinConstants.sol +++ b/packages/contracts/src/2.0.0/forwarder/MixinConstants.sol @@ -16,19 +16,22 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; import "../protocol/Exchange/Exchange.sol"; import { WETH9 as EtherToken } from "../tokens/WETH9/WETH9.sol"; import "../tokens/ERC20Token/IERC20Token.sol"; + contract MixinConstants { - Exchange EXCHANGE; - EtherToken ETHER_TOKEN; - IERC20Token ZRX_TOKEN; - bytes ZRX_ASSET_DATA; - bytes WETH_ASSET_DATA; + // solhint-disable var-name-mixedcase + Exchange internal EXCHANGE; + EtherToken internal ETHER_TOKEN; + IERC20Token internal ZRX_TOKEN; + bytes internal ZRX_ASSET_DATA; + bytes internal WETH_ASSET_DATA; + // solhint-enable var-name-mixedcase constructor ( address _exchange, diff --git a/packages/contracts/src/2.0.0/forwarder/MixinERC20.sol b/packages/contracts/src/2.0.0/forwarder/MixinERC20.sol index 53d4116d7..387c3de6b 100644 --- a/packages/contracts/src/2.0.0/forwarder/MixinERC20.sol +++ b/packages/contracts/src/2.0.0/forwarder/MixinERC20.sol @@ -16,13 +16,13 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; + contract MixinERC20 { - string constant ERROR_TRANSFER_FAILED = "TRANSFER_FAILED"; - bytes4 constant ERC20_TRANSFER_SELECTOR = bytes4(keccak256("transfer(address,uint256)")); + bytes4 constant internal ERC20_TRANSFER_SELECTOR = bytes4(keccak256("transfer(address,uint256)")); function transferToken( address token, diff --git a/packages/contracts/src/2.0.0/forwarder/MixinERC721.sol b/packages/contracts/src/2.0.0/forwarder/MixinERC721.sol index b2e8803a9..b5be223b6 100644 --- a/packages/contracts/src/2.0.0/forwarder/MixinERC721.sol +++ b/packages/contracts/src/2.0.0/forwarder/MixinERC721.sol @@ -16,17 +16,19 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../utils/LibBytes/LibBytes.sol"; import "../tokens/ERC721Token/IERC721Token.sol"; + contract MixinERC721 { using LibBytes for bytes; - bytes4 constant ERC721_RECEIVED = bytes4(keccak256("onERC721Received(address,uint256,bytes)")); - bytes4 constant ERC721_RECEIVED_OPERATOR = bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); + + bytes4 constant internal ERC721_RECEIVED = bytes4(keccak256("onERC721Received(address,uint256,bytes)")); + bytes4 constant internal ERC721_RECEIVED_OPERATOR = bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); function onERC721Received(address, uint256, bytes memory) public diff --git a/packages/contracts/src/2.0.0/forwarder/MixinErrorMessages.sol b/packages/contracts/src/2.0.0/forwarder/MixinErrorMessages.sol index c2a6ea0a4..1b3e3f488 100644 --- a/packages/contracts/src/2.0.0/forwarder/MixinErrorMessages.sol +++ b/packages/contracts/src/2.0.0/forwarder/MixinErrorMessages.sol @@ -16,7 +16,9 @@ */ -pragma solidity ^0.4.24; +// solhint-disable +pragma solidity 0.4.24; + /// This contract is intended to serve as a reference, but is not actually used for efficiency reasons. contract MixinErrorMessages { diff --git a/packages/contracts/src/2.0.0/forwarder/MixinExpectedResults.sol b/packages/contracts/src/2.0.0/forwarder/MixinExpectedResults.sol index 0bca7dc80..6406d1d37 100644 --- a/packages/contracts/src/2.0.0/forwarder/MixinExpectedResults.sol +++ b/packages/contracts/src/2.0.0/forwarder/MixinExpectedResults.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../utils/LibBytes/LibBytes.sol"; @@ -25,74 +25,13 @@ import "../protocol/Exchange/libs/LibMath.sol"; import "../protocol/Exchange/libs/LibOrder.sol"; import "./MixinConstants.sol"; + contract MixinExpectedResults is LibMath, LibFillResults, MixinConstants { - /// @dev Simulates the 0x Exchange fillOrder validation and calculations, without performing any state changes. - /// @param order An Order struct containing order specifications. - /// @param takerAssetFillAmount A number representing the amount of this order to fill. - /// @return fillResults Amounts filled and fees paid by maker and taker. - function calculateFillResults( - LibOrder.Order memory order, - uint256 takerAssetFillAmount - ) - internal - view - returns (FillResults memory fillResults) - { - LibOrder.OrderInfo memory orderInfo = EXCHANGE.getOrderInfo(order); - if (orderInfo.orderStatus != uint8(LibOrder.OrderStatus.FILLABLE)) { - return fillResults; - } - uint256 remainingTakerAssetAmount = safeSub(order.takerAssetAmount, orderInfo.orderTakerAssetFilledAmount); - uint256 takerAssetFilledAmount = min256(takerAssetFillAmount, remainingTakerAssetAmount); - - fillResults.takerAssetFilledAmount = takerAssetFilledAmount; - fillResults.makerAssetFilledAmount = getPartialAmount( - takerAssetFilledAmount, - order.takerAssetAmount, - order.makerAssetAmount - ); - fillResults.makerFeePaid = getPartialAmount( - takerAssetFilledAmount, - order.takerAssetAmount, - order.makerFee - ); - fillResults.takerFeePaid = getPartialAmount( - takerAssetFilledAmount, - order.takerAssetAmount, - order.takerFee - ); - return fillResults; - } - - /// @dev Calculates a FillResults total for selling takerAssetFillAmount over all orders. - /// Including the fees required to be paid. - /// @param orders An array of Order struct containing order specifications. - /// @param takerAssetFillAmount A number representing the amount of this order to fill. - /// @return totalFillResults Amounts filled and fees paid by maker and taker. - function calculateMarketSellResults( - LibOrder.Order[] memory orders, - uint256 takerAssetFillAmount - ) - internal - view - returns (FillResults memory totalFillResults) - { - for (uint256 i = 0; i < orders.length; i++) { - uint256 remainingTakerAssetFillAmount = safeSub(takerAssetFillAmount, totalFillResults.takerAssetFilledAmount); - FillResults memory singleFillResult = calculateFillResults(orders[i], remainingTakerAssetFillAmount); - addFillResults(totalFillResults, singleFillResult); - if (totalFillResults.takerAssetFilledAmount == takerAssetFillAmount) { - break; - } - } - return totalFillResults; - } - /// @dev Calculates a total FillResults for buying makerAssetFillAmount over all orders. /// Including the fees required to be paid. /// @param orders An array of Order struct containing order specifications. @@ -155,4 +94,66 @@ contract MixinExpectedResults is } return totalFillResults; } + + /// @dev Simulates the 0x Exchange fillOrder validation and calculations, without performing any state changes. + /// @param order An Order struct containing order specifications. + /// @param takerAssetFillAmount A number representing the amount of this order to fill. + /// @return fillResults Amounts filled and fees paid by maker and taker. + function calculateFillResults( + LibOrder.Order memory order, + uint256 takerAssetFillAmount + ) + internal + view + returns (FillResults memory fillResults) + { + LibOrder.OrderInfo memory orderInfo = EXCHANGE.getOrderInfo(order); + if (orderInfo.orderStatus != uint8(LibOrder.OrderStatus.FILLABLE)) { + return fillResults; + } + uint256 remainingTakerAssetAmount = safeSub(order.takerAssetAmount, orderInfo.orderTakerAssetFilledAmount); + uint256 takerAssetFilledAmount = min256(takerAssetFillAmount, remainingTakerAssetAmount); + + fillResults.takerAssetFilledAmount = takerAssetFilledAmount; + fillResults.makerAssetFilledAmount = getPartialAmount( + takerAssetFilledAmount, + order.takerAssetAmount, + order.makerAssetAmount + ); + fillResults.makerFeePaid = getPartialAmount( + takerAssetFilledAmount, + order.takerAssetAmount, + order.makerFee + ); + fillResults.takerFeePaid = getPartialAmount( + takerAssetFilledAmount, + order.takerAssetAmount, + order.takerFee + ); + return fillResults; + } + + /// @dev Calculates a FillResults total for selling takerAssetFillAmount over all orders. + /// Including the fees required to be paid. + /// @param orders An array of Order struct containing order specifications. + /// @param takerAssetFillAmount A number representing the amount of this order to fill. + /// @return totalFillResults Amounts filled and fees paid by maker and taker. + function calculateMarketSellResults( + LibOrder.Order[] memory orders, + uint256 takerAssetFillAmount + ) + internal + view + returns (FillResults memory totalFillResults) + { + for (uint256 i = 0; i < orders.length; i++) { + uint256 remainingTakerAssetFillAmount = safeSub(takerAssetFillAmount, totalFillResults.takerAssetFilledAmount); + FillResults memory singleFillResult = calculateFillResults(orders[i], remainingTakerAssetFillAmount); + addFillResults(totalFillResults, singleFillResult); + if (totalFillResults.takerAssetFilledAmount == takerAssetFillAmount) { + break; + } + } + return totalFillResults; + } } diff --git a/packages/contracts/src/2.0.0/forwarder/MixinMarketBuyTokens.sol b/packages/contracts/src/2.0.0/forwarder/MixinMarketBuyTokens.sol index ef06fe519..165fec61f 100644 --- a/packages/contracts/src/2.0.0/forwarder/MixinMarketBuyTokens.sol +++ b/packages/contracts/src/2.0.0/forwarder/MixinMarketBuyTokens.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../utils/LibBytes/LibBytes.sol"; @@ -28,6 +28,7 @@ import "./MixinERC721.sol"; import "./MixinConstants.sol"; import "../protocol/Exchange/libs/LibOrder.sol"; + contract MixinMarketBuyTokens is MixinConstants, MixinWethFees, @@ -62,8 +63,8 @@ contract MixinMarketBuyTokens is uint16 feeProportion, address feeRecipient ) - payable public + payable returns (FillResults memory totalFillResults) { uint256 takerEthAmount = msg.value; diff --git a/packages/contracts/src/2.0.0/forwarder/MixinMarketBuyZrx.sol b/packages/contracts/src/2.0.0/forwarder/MixinMarketBuyZrx.sol index 4dbb34de3..cc98cb63d 100644 --- a/packages/contracts/src/2.0.0/forwarder/MixinMarketBuyZrx.sol +++ b/packages/contracts/src/2.0.0/forwarder/MixinMarketBuyZrx.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../protocol/Exchange/Exchange.sol"; @@ -25,11 +25,13 @@ import "../protocol/Exchange/libs/LibOrder.sol"; import "../protocol/Exchange/libs/LibMath.sol"; import "./MixinConstants.sol"; + contract MixinMarketBuyZrx is LibMath, LibFillResults, MixinConstants { + /// @dev Buys zrxBuyAmount of ZRX fee tokens, taking into account the fees on buying fee tokens. This will guarantee /// At least zrxBuyAmount of ZRX fee tokens are purchased (sometimes slightly over due to rounding issues). /// It is possible that a request to buy 200 ZRX fee tokens will require purchasing 202 ZRX tokens diff --git a/packages/contracts/src/2.0.0/forwarder/MixinMarketSellTokens.sol b/packages/contracts/src/2.0.0/forwarder/MixinMarketSellTokens.sol index 8c9cdb8d5..f4f509846 100644 --- a/packages/contracts/src/2.0.0/forwarder/MixinMarketSellTokens.sol +++ b/packages/contracts/src/2.0.0/forwarder/MixinMarketSellTokens.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../protocol/Exchange/libs/LibOrder.sol"; @@ -27,6 +27,7 @@ import "./MixinERC20.sol"; import "./MixinConstants.sol"; import "./MixinMarketBuyZrx.sol"; + contract MixinMarketSellTokens is MixinConstants, MixinWethFees, @@ -55,8 +56,8 @@ contract MixinMarketSellTokens is uint16 feeProportion, address feeRecipient ) - payable public + payable returns (FillResults memory totalFillResults) { uint256 takerEthAmount = msg.value; diff --git a/packages/contracts/src/2.0.0/forwarder/MixinWethFees.sol b/packages/contracts/src/2.0.0/forwarder/MixinWethFees.sol index 9206c5fe0..92e2cebe8 100644 --- a/packages/contracts/src/2.0.0/forwarder/MixinWethFees.sol +++ b/packages/contracts/src/2.0.0/forwarder/MixinWethFees.sol @@ -16,13 +16,14 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import { WETH9 as EtherToken } from "../tokens/WETH9/WETH9.sol"; import "../protocol/Exchange/libs/LibMath.sol"; import "./MixinConstants.sol"; + contract MixinWethFees is LibMath, MixinConstants diff --git a/packages/contracts/src/2.0.0/multisig/MultiSigWallet.sol b/packages/contracts/src/2.0.0/multisig/MultiSigWallet.sol index 1ceecd907..eb54fe047 100644 --- a/packages/contracts/src/2.0.0/multisig/MultiSigWallet.sol +++ b/packages/contracts/src/2.0.0/multisig/MultiSigWallet.sol @@ -1,6 +1,6 @@ +// solhint-disable pragma solidity ^0.4.10; -// solhint-disable /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution. /// @author Stefan George - diff --git a/packages/contracts/src/2.0.0/multisig/MultiSigWalletWithTimeLock.sol b/packages/contracts/src/2.0.0/multisig/MultiSigWalletWithTimeLock.sol index d714b661d..8c5e6e1e6 100644 --- a/packages/contracts/src/2.0.0/multisig/MultiSigWalletWithTimeLock.sol +++ b/packages/contracts/src/2.0.0/multisig/MultiSigWalletWithTimeLock.sol @@ -16,11 +16,11 @@ */ +// solhint-disable pragma solidity ^0.4.10; import "./MultiSigWallet.sol"; -// solhint-disable /// @title Multisignature wallet with time lock- Allows multiple parties to execute a transaction after a time lock has passed. /// @author Amir Bandeali - diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC20Proxy.sol b/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC20Proxy.sol index aed62f54f..295974f97 100644 --- a/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC20Proxy.sol +++ b/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC20Proxy.sol @@ -16,18 +16,20 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../../utils/LibBytes/LibBytes.sol"; import "./MixinAuthorizable.sol"; + contract ERC20Proxy is MixinAuthorizable { // Id of this proxy. - bytes4 constant PROXY_ID = bytes4(keccak256("ERC20Token(address)")); + bytes4 constant internal PROXY_ID = bytes4(keccak256("ERC20Token(address)")); + // solhint-disable-next-line payable-fallback function () external { diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC721Proxy.sol b/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC721Proxy.sol index b73dc36cc..43777d374 100644 --- a/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC721Proxy.sol +++ b/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC721Proxy.sol @@ -16,18 +16,20 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../../utils/LibBytes/LibBytes.sol"; import "./MixinAuthorizable.sol"; + contract ERC721Proxy is MixinAuthorizable { // Id of this proxy. - bytes4 constant PROXY_ID = bytes4(keccak256("ERC721Token(address,uint256,bytes)")); + bytes4 constant internal PROXY_ID = bytes4(keccak256("ERC721Token(address,uint256,bytes)")); + // solhint-disable-next-line payable-fallback function () external { diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxy/MixinAuthorizable.sol b/packages/contracts/src/2.0.0/protocol/AssetProxy/MixinAuthorizable.sol index 5bc5f3a47..d21eac618 100644 --- a/packages/contracts/src/2.0.0/protocol/AssetProxy/MixinAuthorizable.sol +++ b/packages/contracts/src/2.0.0/protocol/AssetProxy/MixinAuthorizable.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../../utils/Ownable/Ownable.sol"; diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAssetData.sol b/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAssetData.sol index b4ff2d900..3e76e38dd 100644 --- a/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAssetData.sol +++ b/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAssetData.sol @@ -16,7 +16,8 @@ */ -pragma solidity ^0.4.23; +// solhint-disable +pragma solidity 0.4.24; // @dev Interface of the asset proxy's assetData. @@ -24,12 +25,10 @@ pragma solidity ^0.4.23; // This argument is ABI encoded as one of the methods of this interface. interface IAssetData { - // solhint-disable-next-line func-name-mixedcase function ERC20Token(address tokenContract) external pure; - // solhint-disable-next-line func-name-mixedcase function ERC721Token( address tokenContract, uint256 tokenId, diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAssetProxy.sol b/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAssetProxy.sol index 0ef1ed2e0..71491f7bb 100644 --- a/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAssetProxy.sol +++ b/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAssetProxy.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "./IAuthorizable.sol"; diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAuthorizable.sol b/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAuthorizable.sol index 286db74aa..dd4c5fc65 100644 --- a/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAuthorizable.sol +++ b/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAuthorizable.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../../../utils/Ownable/IOwnable.sol"; @@ -26,13 +26,6 @@ contract IAuthorizable is IOwnable { - /// @dev Gets all authorized addresses. - /// @return Array of authorized addresses. - function getAuthorizedAddresses() - external - view - returns (address[]); - /// @dev Authorizes an address. /// @param target Address to authorize. function addAuthorizedAddress(address target) @@ -51,4 +44,11 @@ contract IAuthorizable is uint256 index ) external; + + /// @dev Gets all authorized addresses. + /// @return Array of authorized addresses. + function getAuthorizedAddresses() + external + view + returns (address[] memory); } diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxy/libs/LibAssetProxyErrors.sol b/packages/contracts/src/2.0.0/protocol/AssetProxy/libs/LibAssetProxyErrors.sol index 4b460ea9a..1d9a70cc1 100644 --- a/packages/contracts/src/2.0.0/protocol/AssetProxy/libs/LibAssetProxyErrors.sol +++ b/packages/contracts/src/2.0.0/protocol/AssetProxy/libs/LibAssetProxyErrors.sol @@ -16,7 +16,8 @@ */ -pragma solidity ^0.4.24; +// solhint-disable +pragma solidity 0.4.24; /// @dev This contract documents the revert reasons used in the AssetProxy contracts. diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxy/mixins/MAuthorizable.sol b/packages/contracts/src/2.0.0/protocol/AssetProxy/mixins/MAuthorizable.sol index 66c259a23..312e1bde9 100644 --- a/packages/contracts/src/2.0.0/protocol/AssetProxy/mixins/MAuthorizable.sol +++ b/packages/contracts/src/2.0.0/protocol/AssetProxy/mixins/MAuthorizable.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../interfaces/IAuthorizable.sol"; diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxyOwner/AssetProxyOwner.sol b/packages/contracts/src/2.0.0/protocol/AssetProxyOwner/AssetProxyOwner.sol index 232155a6b..e7cf4ab5c 100644 --- a/packages/contracts/src/2.0.0/protocol/AssetProxyOwner/AssetProxyOwner.sol +++ b/packages/contracts/src/2.0.0/protocol/AssetProxyOwner/AssetProxyOwner.sol @@ -33,7 +33,7 @@ contract AssetProxyOwner is // if this contract is allowed to call the AssetProxy's `removeAuthorizedAddressAtIndex` method without a time lock. mapping (address => bool) public isAssetProxyRegistered; - bytes4 constant REMOVE_AUTHORIZED_ADDRESS_AT_INDEX_SELECTOR = bytes4(keccak256("removeAuthorizedAddressAtIndex(address,uint256)")); + bytes4 constant internal REMOVE_AUTHORIZED_ADDRESS_AT_INDEX_SELECTOR = bytes4(keccak256("removeAuthorizedAddressAtIndex(address,uint256)")); /// @dev Function will revert if the transaction does not call `removeAuthorizedAddressAtIndex` /// on an approved AssetProxy contract. @@ -89,6 +89,7 @@ contract AssetProxyOwner is { Transaction storage tx = transactions[transactionId]; tx.executed = true; + // solhint-disable-next-line avoid-call-value if (tx.destination.call.value(tx.value)(tx.data)) Execution(transactionId); else { diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/Exchange.sol b/packages/contracts/src/2.0.0/protocol/Exchange/Exchange.sol index effff82e0..7507d3da1 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/Exchange.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/Exchange.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "./libs/LibConstants.sol"; @@ -28,6 +28,7 @@ import "./MixinTransactions.sol"; import "./MixinMatchOrders.sol"; +// solhint-disable no-empty-blocks contract Exchange is MixinExchangeCore, MixinMatchOrders, diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/MixinAssetProxyDispatcher.sol b/packages/contracts/src/2.0.0/protocol/Exchange/MixinAssetProxyDispatcher.sol index dcfe9e1de..e9f882194 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/MixinAssetProxyDispatcher.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/MixinAssetProxyDispatcher.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; import "../../utils/Ownable/Ownable.sol"; import "../../utils/LibBytes/LibBytes.sol"; @@ -151,6 +151,7 @@ contract MixinAssetProxyDispatcher is /////// Setup Data Area /////// // This area holds `assetData`. let dataArea := add(cdStart, 132) + // solhint-disable-next-line no-empty-blocks for {} lt(dataArea, cdEnd) {} { mstore(dataArea, mload(assetData)) dataArea := add(dataArea, 32) 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 9e63dc1c0..cf53c3176 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/MixinExchangeCore.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/MixinExchangeCore.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "./libs/LibConstants.sol"; @@ -49,8 +49,6 @@ contract MixinExchangeCore is // Orders with specified senderAddress and with a salt less than their epoch to are considered cancelled mapping (address => mapping (address => uint256)) public orderEpoch; - ////// Core exchange functions ////// - /// @dev Cancels all orders created by makerAddress with a salt less than or equal to the targetOrderEpoch /// and senderAddress equal to msg.sender (or null address if msg.sender == makerAddress). /// @param targetOrderEpoch Orders created with a salt less or equal to this value will be cancelled. @@ -175,6 +173,7 @@ contract MixinExchangeCore is } // Validate order expiration + // solhint-disable-next-line not-rely-on-time if (block.timestamp >= order.expirationTimeSeconds) { orderInfo.orderStatus = uint8(OrderStatus.EXPIRED); return orderInfo; diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/MixinMatchOrders.sol b/packages/contracts/src/2.0.0/protocol/Exchange/MixinMatchOrders.sol index bfe838837..ba687543a 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/MixinMatchOrders.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/MixinMatchOrders.sol @@ -11,7 +11,7 @@ limitations under the License. */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "./libs/LibConstants.sol"; diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/MixinSignatureValidator.sol b/packages/contracts/src/2.0.0/protocol/Exchange/MixinSignatureValidator.sol index 78f13286f..822701459 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/MixinSignatureValidator.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/MixinSignatureValidator.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; import "../../utils/LibBytes/LibBytes.sol"; import "./mixins/MSignatureValidator.sol"; diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/MixinTransactions.sol b/packages/contracts/src/2.0.0/protocol/Exchange/MixinTransactions.sol index 3b18ac733..823e14316 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/MixinTransactions.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/MixinTransactions.sol @@ -15,7 +15,7 @@ limitations under the License. */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; import "./libs/LibExchangeErrors.sol"; import "./mixins/MSignatureValidator.sol"; @@ -37,7 +37,7 @@ contract MixinTransactions is address public currentContextAddress; // Hash for the EIP712 ZeroEx Transaction Schema - bytes32 constant EIP712_ZEROEX_TRANSACTION_SCHEMA_HASH = keccak256(abi.encodePacked( + bytes32 constant internal EIP712_ZEROEX_TRANSACTION_SCHEMA_HASH = keccak256(abi.encodePacked( "ZeroExTransaction(", "uint256 salt,", "address signerAddress,", @@ -45,41 +45,6 @@ contract MixinTransactions is ")" )); - /// @dev Calculates EIP712 hash of the Transaction. - /// @param salt Arbitrary number to ensure uniqueness of transaction hash. - /// @param signerAddress Address of transaction signer. - /// @param data AbiV2 encoded calldata. - /// @return EIP712 hash of the Transaction. - function hashZeroExTransaction( - uint256 salt, - address signerAddress, - bytes memory data - ) - internal - pure - returns (bytes32 result) - { - bytes32 schemaHash = EIP712_ZEROEX_TRANSACTION_SCHEMA_HASH; - bytes32 dataHash = keccak256(data); - // Assembly for more efficiently computing: - // keccak256(abi.encode( - // EIP712_ZEROEX_TRANSACTION_SCHEMA_HASH, - // salt, - // signerAddress, - // keccak256(data) - // )); - assembly { - let memPtr := mload(64) - mstore(memPtr, schemaHash) - mstore(add(memPtr, 32), salt) - mstore(add(memPtr, 64), and(signerAddress, 0xffffffffffffffffffffffffffffffffffffffff)) - mstore(add(memPtr, 96), dataHash) - result := keccak256(memPtr, 128) - } - - return result; - } - /// @dev Executes an exchange method call in the context of signer. /// @param salt Arbitrary number to ensure uniqueness of transaction hash. /// @param signerAddress Address of transaction signer. @@ -139,6 +104,41 @@ contract MixinTransactions is currentContextAddress = address(0); } + /// @dev Calculates EIP712 hash of the Transaction. + /// @param salt Arbitrary number to ensure uniqueness of transaction hash. + /// @param signerAddress Address of transaction signer. + /// @param data AbiV2 encoded calldata. + /// @return EIP712 hash of the Transaction. + function hashZeroExTransaction( + uint256 salt, + address signerAddress, + bytes memory data + ) + internal + pure + returns (bytes32 result) + { + bytes32 schemaHash = EIP712_ZEROEX_TRANSACTION_SCHEMA_HASH; + bytes32 dataHash = keccak256(data); + // Assembly for more efficiently computing: + // keccak256(abi.encode( + // EIP712_ZEROEX_TRANSACTION_SCHEMA_HASH, + // salt, + // signerAddress, + // keccak256(data) + // )); + assembly { + let memPtr := mload(64) + mstore(memPtr, schemaHash) + mstore(add(memPtr, 32), salt) + mstore(add(memPtr, 64), and(signerAddress, 0xffffffffffffffffffffffffffffffffffffffff)) + mstore(add(memPtr, 96), dataHash) + result := keccak256(memPtr, 128) + } + + return result; + } + /// @dev The current function will be called in the context of this address (either 0x transaction signer or `msg.sender`). /// If calling a fill function, this address will represent the taker. /// If calling a cancel function, this address will represent the maker. 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 678d0252a..a16d2f897 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/MixinWrapperFunctions.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/MixinWrapperFunctions.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "./libs/LibMath.sol"; diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol index b73881c07..8db8d6f6c 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; contract IAssetProxyDispatcher { diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IExchange.sol b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IExchange.sol index 05e5dedf4..b92abba04 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IExchange.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IExchange.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "./IExchangeCore.sol"; @@ -27,6 +27,7 @@ import "./IAssetProxyDispatcher.sol"; import "./IWrapperFunctions.sol"; +// solhint-disable no-empty-blocks contract IExchange is IExchangeCore, IMatchOrders, diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IExchangeCore.sol b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IExchangeCore.sol index 2b573eb1a..9995e0385 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IExchangeCore.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IExchangeCore.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../libs/LibOrder.sol"; diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IMatchOrders.sol b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IMatchOrders.sol index d44116474..cea5adbbb 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IMatchOrders.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IMatchOrders.sol @@ -15,7 +15,7 @@ limitations under the License. */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../libs/LibOrder.sol"; diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/ISignatureValidator.sol b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/ISignatureValidator.sol index c5a4a57e1..1fd0eccf0 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/ISignatureValidator.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/ISignatureValidator.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; contract ISignatureValidator { diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/ITransactions.sol b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/ITransactions.sol index aaaee389f..4446c55ce 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/ITransactions.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/ITransactions.sol @@ -15,7 +15,7 @@ limitations under the License. */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; contract ITransactions { diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IValidator.sol b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IValidator.sol index 2c0a5dbe2..2dd69100c 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IValidator.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IValidator.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.23; +pragma solidity 0.4.24; contract IValidator { diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IWallet.sol b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IWallet.sol index c2db4a5b1..c97161ca6 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IWallet.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IWallet.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; contract IWallet { diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IWrapperFunctions.sol b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IWrapperFunctions.sol index 04257b883..7c8b12724 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IWrapperFunctions.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IWrapperFunctions.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../libs/LibOrder.sol"; diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibConstants.sol b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibConstants.sol index 76200ec44..6918d755e 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibConstants.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibConstants.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; contract LibConstants { diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibEIP712.sol b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibEIP712.sol index 2bd7b60d4..1fc41dafd 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibEIP712.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibEIP712.sol @@ -16,18 +16,18 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; contract LibEIP712 { // EIP191 header for EIP712 prefix - string constant EIP191_HEADER = "\x19\x01"; + string constant internal EIP191_HEADER = "\x19\x01"; // EIP712 Domain Name value - string constant EIP712_DOMAIN_NAME = "0x Protocol"; + string constant internal EIP712_DOMAIN_NAME = "0x Protocol"; // EIP712 Domain Version value - string constant EIP712_DOMAIN_VERSION = "2"; + string constant internal EIP712_DOMAIN_VERSION = "2"; // Hash of the EIP712 Domain Separator Schema bytes32 public constant EIP712_DOMAIN_SEPARATOR_SCHEMA_HASH = keccak256(abi.encodePacked( diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibExchangeErrors.sol b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibExchangeErrors.sol index 99f683e1a..a0f75bc06 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibExchangeErrors.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibExchangeErrors.sol @@ -16,7 +16,8 @@ */ -pragma solidity ^0.4.24; +// solhint-disable +pragma solidity 0.4.24; /// @dev This contract documents the revert reasons used in the Exchange contract. diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibFillResults.sol b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibFillResults.sol index 35fa9ac0f..1b4181d94 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibFillResults.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibFillResults.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; import "../../../utils/SafeMath/SafeMath.sol"; diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibMath.sol b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibMath.sol index 9da784854..46c13d390 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibMath.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibMath.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; import "../../../utils/SafeMath/SafeMath.sol"; diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibOrder.sol b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibOrder.sol index dda581d9f..2ea864a5a 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibOrder.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibOrder.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; import "./LibEIP712.sol"; @@ -26,7 +26,7 @@ contract LibOrder is { // Hash for the EIP712 Order Schema - bytes32 constant EIP712_ORDER_SCHEMA_HASH = keccak256(abi.encodePacked( + bytes32 constant internal EIP712_ORDER_SCHEMA_HASH = keccak256(abi.encodePacked( "Order(", "address makerAddress,", "address takerAddress,", @@ -55,6 +55,7 @@ contract LibOrder is CANCELLED // Order has been cancelled } + // solhint-disable max-line-length struct Order { address makerAddress; // Address that created the order. address takerAddress; // Address that is allowed to fill the order. If set to 0, any address is allowed to fill the order. @@ -69,6 +70,7 @@ contract LibOrder is bytes makerAssetData; // Encoded data that can be decoded by a specified proxy contract when transferring makerAsset. The last byte references the id of this proxy. bytes takerAssetData; // Encoded data that can be decoded by a specified proxy contract when transferring takerAsset. The last byte references the id of this proxy. } + // solhint-enable max-line-length struct OrderInfo { uint8 orderStatus; // Status that describes order's validity and fillability. diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MAssetProxyDispatcher.sol b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MAssetProxyDispatcher.sol index 367b37e80..9207dfdc2 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MAssetProxyDispatcher.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MAssetProxyDispatcher.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../interfaces/IAssetProxyDispatcher.sol"; 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 e28d9d25b..9e3b5a2e2 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 @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../libs/LibOrder.sol"; @@ -102,7 +102,6 @@ contract MExchangeCore is internal view; - /// @dev Validates context for cancelOrder. Succeeds or throws. /// @param order to be cancelled. /// @param orderInfo OrderStatus, orderHash, and amount already filled of order. diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MMatchOrders.sol b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MMatchOrders.sol index 289514b24..a31ec1585 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MMatchOrders.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MMatchOrders.sol @@ -15,7 +15,7 @@ limitations under the License. */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../libs/LibOrder.sol"; diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MSignatureValidator.sol b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MSignatureValidator.sol index 83650b4aa..f14f2ba00 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MSignatureValidator.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MSignatureValidator.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; import "../interfaces/ISignatureValidator.sol"; diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MTransactions.sol b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MTransactions.sol index a9fa6d4e2..f2b5e4b16 100644 --- a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MTransactions.sol +++ b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MTransactions.sol @@ -15,7 +15,7 @@ limitations under the License. */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; import "../interfaces/ITransactions.sol"; diff --git a/packages/contracts/src/2.0.0/test/DummyERC20Token/DummyERC20Token.sol b/packages/contracts/src/2.0.0/test/DummyERC20Token/DummyERC20Token.sol index 7a2702449..44b0777b8 100644 --- a/packages/contracts/src/2.0.0/test/DummyERC20Token/DummyERC20Token.sol +++ b/packages/contracts/src/2.0.0/test/DummyERC20Token/DummyERC20Token.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../Mintable/Mintable.sol"; diff --git a/packages/contracts/src/2.0.0/test/DummyERC721Receiver/DummyERC721Receiver.sol b/packages/contracts/src/2.0.0/test/DummyERC721Receiver/DummyERC721Receiver.sol index b027ac960..5dce74a14 100644 --- a/packages/contracts/src/2.0.0/test/DummyERC721Receiver/DummyERC721Receiver.sol +++ b/packages/contracts/src/2.0.0/test/DummyERC721Receiver/DummyERC721Receiver.sol @@ -23,7 +23,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; import "../../tokens/ERC721Token/IERC721Receiver.sol"; diff --git a/packages/contracts/src/2.0.0/test/DummyERC721Token/DummyERC721Token.sol b/packages/contracts/src/2.0.0/test/DummyERC721Token/DummyERC721Token.sol index de76f10c5..ba647fea4 100644 --- a/packages/contracts/src/2.0.0/test/DummyERC721Token/DummyERC721Token.sol +++ b/packages/contracts/src/2.0.0/test/DummyERC721Token/DummyERC721Token.sol @@ -16,13 +16,14 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../../tokens/ERC721Token/ERC721Token.sol"; import "../../utils/Ownable/Ownable.sol"; +// solhint-disable no-empty-blocks contract DummyERC721Token is Ownable, ERC721Token diff --git a/packages/contracts/src/2.0.0/test/ExchangeWrapper/ExchangeWrapper.sol b/packages/contracts/src/2.0.0/test/ExchangeWrapper/ExchangeWrapper.sol index f20e2a944..2fa0e3c5e 100644 --- a/packages/contracts/src/2.0.0/test/ExchangeWrapper/ExchangeWrapper.sol +++ b/packages/contracts/src/2.0.0/test/ExchangeWrapper/ExchangeWrapper.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../../protocol/Exchange/interfaces/IExchange.sol"; @@ -27,7 +27,7 @@ contract ExchangeWrapper { // Exchange contract. // solhint-disable-next-line var-name-mixedcase - IExchange EXCHANGE; + IExchange internal EXCHANGE; constructor (address _exchange) public @@ -35,6 +35,35 @@ contract ExchangeWrapper { EXCHANGE = IExchange(_exchange); } + /// @dev Cancels all orders created by sender with a salt less than or equal to the targetOrderEpoch + /// and senderAddress equal to this contract. + /// @param targetOrderEpoch Orders created with a salt less or equal to this value will be cancelled. + /// @param salt Arbitrary value to gaurantee uniqueness of 0x transaction hash. + /// @param makerSignature Proof that maker wishes to call this function with given params. + function cancelOrdersUpTo( + uint256 targetOrderEpoch, + uint256 salt, + bytes makerSignature + ) + external + { + address makerAddress = msg.sender; + + // Encode arguments into byte array. + bytes memory data = abi.encodeWithSelector( + EXCHANGE.cancelOrdersUpTo.selector, + targetOrderEpoch + ); + + // Call `cancelOrdersUpTo` via `executeTransaction`. + EXCHANGE.executeTransaction( + salt, + makerAddress, + data, + makerSignature + ); + } + /// @dev Fills an order using `msg.sender` as the taker. /// @param order Order struct containing order specifications. /// @param takerAssetFillAmount Desired amount of takerAsset to sell. @@ -68,33 +97,4 @@ contract ExchangeWrapper { takerSignature ); } - - /// @dev Cancels all orders created by sender with a salt less than or equal to the targetOrderEpoch - /// and senderAddress equal to this contract. - /// @param targetOrderEpoch Orders created with a salt less or equal to this value will be cancelled. - /// @param salt Arbitrary value to gaurantee uniqueness of 0x transaction hash. - /// @param makerSignature Proof that maker wishes to call this function with given params. - function cancelOrdersUpTo( - uint256 targetOrderEpoch, - uint256 salt, - bytes makerSignature - ) - external - { - address makerAddress = msg.sender; - - // Encode arguments into byte array. - bytes memory data = abi.encodeWithSelector( - EXCHANGE.cancelOrdersUpTo.selector, - targetOrderEpoch - ); - - // Call `cancelOrdersUpTo` via `executeTransaction`. - EXCHANGE.executeTransaction( - salt, - makerAddress, - data, - makerSignature - ); - } } diff --git a/packages/contracts/src/2.0.0/test/Mintable/Mintable.sol b/packages/contracts/src/2.0.0/test/Mintable/Mintable.sol index bccb74ce8..747ac7a86 100644 --- a/packages/contracts/src/2.0.0/test/Mintable/Mintable.sol +++ b/packages/contracts/src/2.0.0/test/Mintable/Mintable.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../../tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol"; diff --git a/packages/contracts/src/2.0.0/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol b/packages/contracts/src/2.0.0/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol index be7fea7d3..76f1c6290 100644 --- a/packages/contracts/src/2.0.0/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol +++ b/packages/contracts/src/2.0.0/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../../protocol/Exchange/MixinAssetProxyDispatcher.sol"; diff --git a/packages/contracts/src/2.0.0/test/TestAssetProxyOwner/TestAssetProxyOwner.sol b/packages/contracts/src/2.0.0/test/TestAssetProxyOwner/TestAssetProxyOwner.sol index ddcc62f35..d6b6b29f2 100644 --- a/packages/contracts/src/2.0.0/test/TestAssetProxyOwner/TestAssetProxyOwner.sol +++ b/packages/contracts/src/2.0.0/test/TestAssetProxyOwner/TestAssetProxyOwner.sol @@ -16,14 +16,16 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; import "../../protocol/AssetProxyOwner/AssetProxyOwner.sol"; +// solhint-disable no-empty-blocks contract TestAssetProxyOwner is AssetProxyOwner { + constructor( address[] memory _owners, address[] memory _assetProxyContracts, @@ -32,11 +34,11 @@ contract TestAssetProxyOwner is ) public AssetProxyOwner(_owners, _assetProxyContracts, _required, _secondsTimeLocked) - { - } + {} function testValidRemoveAuthorizedAddressAtIndexTx(uint256 id) public + view validRemoveAuthorizedAddressAtIndexTx(id) returns (bool) { diff --git a/packages/contracts/src/2.0.0/test/TestLibBytes/TestLibBytes.sol b/packages/contracts/src/2.0.0/test/TestLibBytes/TestLibBytes.sol index f52f635e1..8b9c00590 100644 --- a/packages/contracts/src/2.0.0/test/TestLibBytes/TestLibBytes.sol +++ b/packages/contracts/src/2.0.0/test/TestLibBytes/TestLibBytes.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../../utils/LibBytes/LibBytes.sol"; diff --git a/packages/contracts/src/2.0.0/test/TestLibs/TestLibs.sol b/packages/contracts/src/2.0.0/test/TestLibs/TestLibs.sol index df8eb55ce..40e2c84dc 100644 --- a/packages/contracts/src/2.0.0/test/TestLibs/TestLibs.sol +++ b/packages/contracts/src/2.0.0/test/TestLibs/TestLibs.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../../protocol/Exchange/libs/LibMath.sol"; diff --git a/packages/contracts/src/2.0.0/test/TestSignatureValidator/TestSignatureValidator.sol b/packages/contracts/src/2.0.0/test/TestSignatureValidator/TestSignatureValidator.sol index 591ae3378..235c77d17 100644 --- a/packages/contracts/src/2.0.0/test/TestSignatureValidator/TestSignatureValidator.sol +++ b/packages/contracts/src/2.0.0/test/TestSignatureValidator/TestSignatureValidator.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../../protocol/Exchange/MixinSignatureValidator.sol"; diff --git a/packages/contracts/src/2.0.0/test/TestValidator/TestValidator.sol b/packages/contracts/src/2.0.0/test/TestValidator/TestValidator.sol index 5076dedc9..6278aede0 100644 --- a/packages/contracts/src/2.0.0/test/TestValidator/TestValidator.sol +++ b/packages/contracts/src/2.0.0/test/TestValidator/TestValidator.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; import "../../protocol/Exchange/interfaces/IValidator.sol"; @@ -27,7 +27,7 @@ contract TestValidator is // The single valid signer for this wallet. // solhint-disable-next-line var-name-mixedcase - address VALID_SIGNER; + address internal VALID_SIGNER; /// @dev constructs a new `TestValidator` with a single valid signer. /// @param validSigner The sole, valid signer. @@ -40,6 +40,7 @@ contract TestValidator is /// @param signerAddress Address that should have signed the given hash. /// @param signature Proof of signing. /// @return Validity of signature. + // solhint-disable no-unused-vars function isValidSignature( bytes32 hash, address signerAddress, @@ -51,4 +52,5 @@ contract TestValidator is { return (signerAddress == VALID_SIGNER); } + // solhint-enable no-unused-vars } diff --git a/packages/contracts/src/2.0.0/test/TestWallet/TestWallet.sol b/packages/contracts/src/2.0.0/test/TestWallet/TestWallet.sol index 07dfac588..0415823e3 100644 --- a/packages/contracts/src/2.0.0/test/TestWallet/TestWallet.sol +++ b/packages/contracts/src/2.0.0/test/TestWallet/TestWallet.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; import "../../protocol/Exchange/interfaces/IWallet.sol"; import "../../utils/LibBytes/LibBytes.sol"; @@ -27,11 +27,9 @@ contract TestWallet is { using LibBytes for bytes; - string constant LENGTH_65_REQUIRED = "LENGTH_65_REQUIRED"; - // The owner of this wallet. // solhint-disable-next-line var-name-mixedcase - address WALLET_OWNER; + address internal WALLET_OWNER; /// @dev constructs a new `TestWallet` with a single owner. /// @param walletOwner The owner of this wallet. @@ -54,7 +52,7 @@ contract TestWallet is { require( eip712Signature.length == 65, - LENGTH_65_REQUIRED + "LENGTH_65_REQUIRED" ); uint8 v = uint8(eip712Signature[0]); diff --git a/packages/contracts/src/2.0.0/test/Whitelist/Whitelist.sol b/packages/contracts/src/2.0.0/test/Whitelist/Whitelist.sol index 07bd7d531..60cac26ea 100644 --- a/packages/contracts/src/2.0.0/test/Whitelist/Whitelist.sol +++ b/packages/contracts/src/2.0.0/test/Whitelist/Whitelist.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../../protocol/Exchange/interfaces/IExchange.sol"; @@ -27,28 +27,22 @@ import "../../utils/Ownable/Ownable.sol"; contract Whitelist is Ownable { - // Revert reasons - string constant MAKER_NOT_WHITELISTED = "MAKER_NOT_WHITELISTED"; // Maker address not whitelisted. - string constant TAKER_NOT_WHITELISTED = "TAKER_NOT_WHITELISTED"; // Taker address not whitelisted. - string constant INVALID_SENDER = "INVALID_SENDER"; // Sender must equal transaction origin. // Mapping of address => whitelist status. mapping (address => bool) public isWhitelisted; // Exchange contract. - // solhint-disable-next-line var-name-mixedcase - IExchange EXCHANGE; + // solhint-disable var-name-mixedcase + IExchange internal EXCHANGE; + bytes internal TX_ORIGIN_SIGNATURE; + // solhint-enable var-name-mixedcase - byte constant VALIDATOR_SIGNATURE_BYTE = "\x06"; - // solhint-disable-next-line var-name-mixedcase - bytes TX_ORIGIN_SIGNATURE; + byte constant internal VALIDATOR_SIGNATURE_BYTE = "\x06"; constructor (address _exchange) public { - // solhint-disable-next-line var-name-mixedcase EXCHANGE = IExchange(_exchange); - // solhint-disable-next-line var-name-mixedcase TX_ORIGIN_SIGNATURE = abi.encodePacked(address(this), VALIDATOR_SIGNATURE_BYTE); } @@ -65,6 +59,27 @@ contract Whitelist is isWhitelisted[target] = isApproved; } + /// @dev Verifies signer is same as signer of current Ethereum transaction. + /// NOTE: This function can currently be used to validate signatures coming from outside of this contract. + /// Extra safety checks can be added for a production contract. + /// @param signerAddress Address that should have signed the given hash. + /// @param signature Proof of signing. + /// @return Validity of order signature. + // solhint-disable no-unused-vars + function isValidSignature( + bytes32 hash, + address signerAddress, + bytes signature + ) + external + view + returns (bool isValid) + { + // solhint-disable-next-line avoid-tx-origin + return signerAddress == tx.origin; + } + // solhint-enable no-unused-vars + /// @dev Fills an order using `msg.sender` as the taker. /// The transaction will revert if both the maker and taker are not whitelisted. /// Orders should specify this contract as the `senderAddress` in order to gaurantee @@ -85,20 +100,21 @@ contract Whitelist is // This contract must be the entry point for the transaction. require( + // solhint-disable-next-line avoid-tx-origin takerAddress == tx.origin, - INVALID_SENDER + "INVALID_SENDER" ); // Check if maker is on the whitelist. require( isWhitelisted[order.makerAddress], - MAKER_NOT_WHITELISTED + "MAKER_NOT_WHITELISTED" ); // Check if taker is on the whitelist. require( isWhitelisted[takerAddress], - TAKER_NOT_WHITELISTED + "TAKER_NOT_WHITELISTED" ); // Encode arguments into byte array. @@ -117,22 +133,4 @@ contract Whitelist is TX_ORIGIN_SIGNATURE ); } - - /// @dev Verifies signer is same as signer of current Ethereum transaction. - /// NOTE: This function can currently be used to validate signatures coming from outside of this contract. - /// Extra safety checks can be added for a production contract. - /// @param signerAddress Address that should have signed the given hash. - /// @param signature Proof of signing. - /// @return Validity of order signature. - function isValidSignature( - bytes32 hash, - address signerAddress, - bytes signature - ) - external - view - returns (bool isValid) - { - return signerAddress == tx.origin; - } } diff --git a/packages/contracts/src/2.0.0/tokens/ERC20Token/ERC20Token.sol b/packages/contracts/src/2.0.0/tokens/ERC20Token/ERC20Token.sol index 59dc7d7bf..58ffdfcb6 100644 --- a/packages/contracts/src/2.0.0/tokens/ERC20Token/ERC20Token.sol +++ b/packages/contracts/src/2.0.0/tokens/ERC20Token/ERC20Token.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "./IERC20Token.sol"; @@ -24,12 +24,8 @@ import "./IERC20Token.sol"; contract ERC20Token is IERC20Token { - string constant INSUFFICIENT_BALANCE = "ERC20_INSUFFICIENT_BALANCE"; - string constant INSUFFICIENT_ALLOWANCE = "ERC20_INSUFFICIENT_ALLOWANCE"; - string constant OVERFLOW = "Transfer would result in an overflow."; - - mapping (address => uint256) balances; - mapping (address => mapping (address => uint256)) allowed; + mapping (address => uint256) internal balances; + mapping (address => mapping (address => uint256)) internal allowed; uint256 public totalSupply; @@ -39,11 +35,11 @@ contract ERC20Token is IERC20Token { { require( balances[msg.sender] >= _value, - INSUFFICIENT_BALANCE + "ERC20_INSUFFICIENT_BALANCE" ); require( balances[_to] + _value >= balances[_to], - OVERFLOW + "OVERFLOW" ); balances[msg.sender] -= _value; balances[_to] += _value; @@ -57,15 +53,15 @@ contract ERC20Token is IERC20Token { { require( balances[_from] >= _value, - INSUFFICIENT_BALANCE + "ERC20_INSUFFICIENT_BALANCE" ); require( allowed[_from][msg.sender] >= _value, - INSUFFICIENT_ALLOWANCE + "ERC20_INSUFFICIENT_ALLOWANCE" ); require( balances[_to] + _value >= balances[_to], - OVERFLOW + "OVERFLOW" ); balances[_to] += _value; balances[_from] -= _value; @@ -84,7 +80,8 @@ contract ERC20Token is IERC20Token { } function balanceOf(address _owner) - public view + public + view returns (uint256) { return balances[_owner]; diff --git a/packages/contracts/src/2.0.0/tokens/ERC20Token/IERC20Token.sol b/packages/contracts/src/2.0.0/tokens/ERC20Token/IERC20Token.sol index de4ed2af9..e3e193666 100644 --- a/packages/contracts/src/2.0.0/tokens/ERC20Token/IERC20Token.sol +++ b/packages/contracts/src/2.0.0/tokens/ERC20Token/IERC20Token.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; @@ -60,6 +60,7 @@ contract IERC20Token { public view returns (uint256); + // solhint-disable-next-line no-simple-event-func-name event Transfer( address indexed _from, address indexed _to, diff --git a/packages/contracts/src/2.0.0/tokens/ERC721Token/ERC721Token.sol b/packages/contracts/src/2.0.0/tokens/ERC721Token/ERC721Token.sol index defb506a8..60603aa19 100644 --- a/packages/contracts/src/2.0.0/tokens/ERC721Token/ERC721Token.sol +++ b/packages/contracts/src/2.0.0/tokens/ERC721Token/ERC721Token.sol @@ -23,7 +23,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; import "./IERC721Token.sol"; import "./IERC721Receiver.sol"; @@ -41,7 +41,7 @@ contract ERC721Token is { // Equals to `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))` // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` - bytes4 constant ERC721_RECEIVED = 0xf0b9e5ba; + bytes4 constant internal ERC721_RECEIVED = 0xf0b9e5ba; // Mapping from token ID to owner mapping (uint256 => address) internal tokenOwner; @@ -73,7 +73,7 @@ contract ERC721Token is _; } - function ERC721Token( + constructor ( string _name, string _symbol) public diff --git a/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Receiver.sol b/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Receiver.sol index f72c75638..f2e8f3c88 100644 --- a/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Receiver.sol +++ b/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Receiver.sol @@ -23,7 +23,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; /** @@ -38,7 +38,7 @@ contract IERC721Receiver { * Equals to `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`, * which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` */ - bytes4 constant ERC721_RECEIVED = 0xf0b9e5ba; + bytes4 constant internal ERC721_RECEIVED = 0xf0b9e5ba; /** * @notice Handle the receipt of an NFT diff --git a/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Token.sol b/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Token.sol index 0d64ee861..4d57ece38 100644 --- a/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Token.sol +++ b/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Token.sol @@ -23,7 +23,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; /** @@ -40,11 +40,13 @@ contract IERC721Token { address indexed _to, uint256 _tokenId ); + event Approval( address indexed _owner, address indexed _approved, uint256 _tokenId ); + event ApprovalForAll( address indexed _owner, address indexed _operator, @@ -55,6 +57,7 @@ contract IERC721Token { public view returns (string); + function symbol() public view @@ -64,10 +67,12 @@ contract IERC721Token { public view returns (uint256 _balance); + function ownerOf(uint256 _tokenId) public view returns (address _owner); + function exists(uint256 _tokenId) public view @@ -75,6 +80,7 @@ contract IERC721Token { function approve(address _to, uint256 _tokenId) public; + function getApproved(uint256 _tokenId) public view @@ -82,6 +88,7 @@ contract IERC721Token { function setApprovalForAll(address _operator, bool _approved) public; + function isApprovedForAll(address _owner, address _operator) public view @@ -90,17 +97,22 @@ contract IERC721Token { function transferFrom( address _from, address _to, - uint256 _tokenId) + uint256 _tokenId + ) public; + function safeTransferFrom( address _from, address _to, - uint256 _tokenId) + uint256 _tokenId + ) public; + function safeTransferFrom( address _from, address _to, uint256 _tokenId, - bytes _data) + bytes _data + ) public; } diff --git a/packages/contracts/src/2.0.0/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol b/packages/contracts/src/2.0.0/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol index 845324e4e..a974503ca 100644 --- a/packages/contracts/src/2.0.0/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol +++ b/packages/contracts/src/2.0.0/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; import "../ERC20Token/ERC20Token.sol"; @@ -24,7 +24,7 @@ import "../ERC20Token/ERC20Token.sol"; contract UnlimitedAllowanceToken is ERC20Token { - uint256 constant MAX_UINT = 2**256 - 1; + uint256 constant internal MAX_UINT = 2**256 - 1; /// @dev ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited allowance. See https://github.com/ethereum/EIPs/issues/717 /// @param _from Address to transfer from. @@ -38,15 +38,15 @@ contract UnlimitedAllowanceToken is ERC20Token { uint256 allowance = allowed[_from][msg.sender]; require( balances[_from] >= _value, - INSUFFICIENT_BALANCE + "ERC20_INSUFFICIENT_BALANCE" ); require( allowance >= _value, - INSUFFICIENT_ALLOWANCE + "ERC20_INSUFFICIENT_ALLOWANCE" ); require( balances[_to] + _value >= balances[_to], - OVERFLOW + "OVERFLOW" ); balances[_to] += _value; balances[_from] -= _value; diff --git a/packages/contracts/src/2.0.0/tokens/WETH9/WETH9.sol b/packages/contracts/src/2.0.0/tokens/WETH9/WETH9.sol index 378a507b9..1fdb04de5 100644 --- a/packages/contracts/src/2.0.0/tokens/WETH9/WETH9.sol +++ b/packages/contracts/src/2.0.0/tokens/WETH9/WETH9.sol @@ -13,6 +13,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +// solhint-disable pragma solidity ^0.4.18; diff --git a/packages/contracts/src/2.0.0/tokens/ZRXToken/ZRXToken.sol b/packages/contracts/src/2.0.0/tokens/ZRXToken/ZRXToken.sol index ed0670072..28c0b2fb3 100644 --- a/packages/contracts/src/2.0.0/tokens/ZRXToken/ZRXToken.sol +++ b/packages/contracts/src/2.0.0/tokens/ZRXToken/ZRXToken.sol @@ -16,20 +16,24 @@ */ -pragma solidity ^0.4.11; +pragma solidity 0.4.11; +// solhint-disable-next-line max-line-length import { UnlimitedAllowanceToken_v1 as UnlimitedAllowanceToken } from "../../../1.0.0/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol"; - contract ZRXToken is UnlimitedAllowanceToken { + // solhint-disable const-name-snakecase uint8 constant public decimals = 18; uint public totalSupply = 10**27; // 1 billion tokens, 18 decimal places string constant public name = "0x Protocol Token"; string constant public symbol = "ZRX"; + // solhint-enableconst-name-snakecase - function ZRXToken() { + function ZRXToken() + public + { balances[msg.sender] = totalSupply; } } diff --git a/packages/contracts/src/2.0.0/utils/LibBytes/LibBytes.sol b/packages/contracts/src/2.0.0/utils/LibBytes/LibBytes.sol index c2fff5efb..01d34fa8f 100644 --- a/packages/contracts/src/2.0.0/utils/LibBytes/LibBytes.sol +++ b/packages/contracts/src/2.0.0/utils/LibBytes/LibBytes.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; library LibBytes { @@ -115,6 +115,7 @@ library LibBytes { // Copy whole words front to back // Note: the first check is always true, // this could have been a do-while loop. + // solhint-disable-next-line no-empty-blocks for {} lt(source, sEnd) {} { mstore(dest, mload(source)) source := add(source, 32) @@ -145,6 +146,7 @@ library LibBytes { // 2**255, so they can be safely re-interpreted as signed. // Note: the first check is always true, // this could have been a do-while loop. + // solhint-disable-next-line no-empty-blocks for {} slt(dest, dEnd) {} { mstore(dEnd, mload(sEnd)) sEnd := sub(sEnd, 32) @@ -157,13 +159,17 @@ library LibBytes { } } } - + /// @dev Returns a slices from a byte array. /// @param b The byte array to take a slice from. /// @param from The starting index for the slice (inclusive). /// @param to The final index for the slice (exclusive). /// @return result The slice containing bytes at indices [from, to) - function slice(bytes memory b, uint256 from, uint256 to) + function slice( + bytes memory b, + uint256 from, + uint256 to + ) internal pure returns (bytes memory result) @@ -192,7 +198,11 @@ library LibBytes { /// @param to The final index for the slice (exclusive). /// @return result The slice containing bytes at indices [from, to) /// @dev When `from == 0`, the original array will match the slice. In other cases its state will be corrupted. - function sliceDestructive(bytes memory b, uint256 from, uint256 to) + function sliceDestructive( + bytes memory b, + uint256 from, + uint256 to + ) internal pure returns (bytes memory result) @@ -344,7 +354,10 @@ library LibBytes { // 1. Add index to address of bytes array // 2. Load 32-byte word from memory // 3. Apply 12-byte mask to obtain extra bytes occupying word of memory where we'll store the address - let neighbors := and(mload(add(b, index)), 0xffffffffffffffffffffffff0000000000000000000000000000000000000000) + let neighbors := and( + mload(add(b, index)), + 0xffffffffffffffffffffffff0000000000000000000000000000000000000000 + ) // Make sure input address is clean. // (Solidity does not guarantee this) @@ -509,7 +522,7 @@ library LibBytes { // Assert length of is valid, given // length of input require( - b.length >= index + 32 /* 32 bytes to store length */ + input.length, + b.length >= index + 32 + input.length, // 32 bytes to store length "GREATER_OR_EQUAL_TO_NESTED_BYTES_LENGTH_REQUIRED" ); diff --git a/packages/contracts/src/2.0.0/utils/Ownable/IOwnable.sol b/packages/contracts/src/2.0.0/utils/Ownable/IOwnable.sol index e77680903..36563d837 100644 --- a/packages/contracts/src/2.0.0/utils/Ownable/IOwnable.sol +++ b/packages/contracts/src/2.0.0/utils/Ownable/IOwnable.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; /* diff --git a/packages/contracts/src/2.0.0/utils/Ownable/Ownable.sol b/packages/contracts/src/2.0.0/utils/Ownable/Ownable.sol index 489793a95..81a14a447 100644 --- a/packages/contracts/src/2.0.0/utils/Ownable/Ownable.sol +++ b/packages/contracts/src/2.0.0/utils/Ownable/Ownable.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; /* 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 ec0a3fe76..8cbb8e526 100644 --- a/packages/contracts/src/2.0.0/utils/SafeMath/SafeMath.sol +++ b/packages/contracts/src/2.0.0/utils/SafeMath/SafeMath.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.24; +pragma solidity 0.4.24; pragma experimental ABIEncoderV2; -- cgit v1.2.3