From 070147db52eea711bab5eeb4342e0da24aa41f9c Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Tue, 13 Aug 2019 16:43:55 -0700 Subject: [PATCH] Fix build errors --- .../contracts/src/LibExchangeRichErrors.sol | 3 ++- contracts/exchange-libs/package.json | 2 +- contracts/exchange-libs/src/artifacts.ts | 2 ++ contracts/exchange-libs/src/wrappers.ts | 1 + contracts/exchange-libs/tsconfig.json | 1 + .../contracts/src/MixinSignatureValidator.sol | 4 ++-- .../contracts/src/MixinWrapperFunctions.sol | 2 +- .../contracts/test/ReentrancyTester.sol | 15 ++++++++------ .../contracts/test/TestWrapperFunctions.sol | 20 ++++++++++--------- contracts/exchange/package.json | 2 +- contracts/exchange/src/artifacts.ts | 2 ++ contracts/exchange/src/wrappers.ts | 1 + contracts/exchange/tsconfig.json | 4 ++-- 13 files changed, 36 insertions(+), 23 deletions(-) diff --git a/contracts/exchange-libs/contracts/src/LibExchangeRichErrors.sol b/contracts/exchange-libs/contracts/src/LibExchangeRichErrors.sol index 5cb656f575..f47db479b8 100644 --- a/contracts/exchange-libs/contracts/src/LibExchangeRichErrors.sol +++ b/contracts/exchange-libs/contracts/src/LibExchangeRichErrors.sol @@ -48,7 +48,8 @@ library LibExchangeRichErrors { INVALID_LENGTH, UNSUPPORTED, ILLEGAL, - INAPPROPRIATE_SIGNATURE_TYPE + INAPPROPRIATE_SIGNATURE_TYPE, + INVALID_SIGNER } enum TransactionErrorCodes { diff --git a/contracts/exchange-libs/package.json b/contracts/exchange-libs/package.json index b093ceba72..58a389d546 100644 --- a/contracts/exchange-libs/package.json +++ b/contracts/exchange-libs/package.json @@ -35,7 +35,7 @@ "generate-exchange-selectors": "node lib/scripts/generate-exchange-selectors.js ../../../exchange/generated-artifacts/Exchange.json ./contracts/src/LibExchangeSelectors.sol" }, "config": { - "abis": "./generated-artifacts/@(LibEIP712ExchangeDomain|LibExchangeRichErrors|LibFillResults|LibMath|LibMathRichErrors|LibOrder|LibZeroExTransaction|TestLibEIP712ExchangeDomain|TestLibFillResults|TestLibMath|TestLibOrder|TestLibZeroExTransaction).json", + "abis": "./generated-artifacts/@(LibEIP712ExchangeDomain|LibExchangeRichErrors|LibExchangeSelectors|LibFillResults|LibMath|LibMathRichErrors|LibOrder|LibZeroExTransaction|TestLibEIP712ExchangeDomain|TestLibFillResults|TestLibMath|TestLibOrder|TestLibZeroExTransaction).json", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { diff --git a/contracts/exchange-libs/src/artifacts.ts b/contracts/exchange-libs/src/artifacts.ts index 7bfb67a9d3..d4b8c2c5b5 100644 --- a/contracts/exchange-libs/src/artifacts.ts +++ b/contracts/exchange-libs/src/artifacts.ts @@ -7,6 +7,7 @@ import { ContractArtifact } from 'ethereum-types'; import * as LibEIP712ExchangeDomain from '../generated-artifacts/LibEIP712ExchangeDomain.json'; import * as LibExchangeRichErrors from '../generated-artifacts/LibExchangeRichErrors.json'; +import * as LibExchangeSelectors from '../generated-artifacts/LibExchangeSelectors.json'; import * as LibFillResults from '../generated-artifacts/LibFillResults.json'; import * as LibMath from '../generated-artifacts/LibMath.json'; import * as LibMathRichErrors from '../generated-artifacts/LibMathRichErrors.json'; @@ -20,6 +21,7 @@ import * as TestLibZeroExTransaction from '../generated-artifacts/TestLibZeroExT export const artifacts = { LibEIP712ExchangeDomain: LibEIP712ExchangeDomain as ContractArtifact, LibExchangeRichErrors: LibExchangeRichErrors as ContractArtifact, + LibExchangeSelectors: LibExchangeSelectors as ContractArtifact, LibFillResults: LibFillResults as ContractArtifact, LibMath: LibMath as ContractArtifact, LibMathRichErrors: LibMathRichErrors as ContractArtifact, diff --git a/contracts/exchange-libs/src/wrappers.ts b/contracts/exchange-libs/src/wrappers.ts index 89a7ffc03b..a3a7e077ef 100644 --- a/contracts/exchange-libs/src/wrappers.ts +++ b/contracts/exchange-libs/src/wrappers.ts @@ -5,6 +5,7 @@ */ export * from '../generated-wrappers/lib_e_i_p712_exchange_domain'; export * from '../generated-wrappers/lib_exchange_rich_errors'; +export * from '../generated-wrappers/lib_exchange_selectors'; export * from '../generated-wrappers/lib_fill_results'; export * from '../generated-wrappers/lib_math'; export * from '../generated-wrappers/lib_math_rich_errors'; diff --git a/contracts/exchange-libs/tsconfig.json b/contracts/exchange-libs/tsconfig.json index 7e46a4852c..d2e67a44c2 100644 --- a/contracts/exchange-libs/tsconfig.json +++ b/contracts/exchange-libs/tsconfig.json @@ -5,6 +5,7 @@ "files": [ "generated-artifacts/LibEIP712ExchangeDomain.json", "generated-artifacts/LibExchangeRichErrors.json", + "generated-artifacts/LibExchangeSelectors.json", "generated-artifacts/LibFillResults.json", "generated-artifacts/LibMath.json", "generated-artifacts/LibMathRichErrors.json", diff --git a/contracts/exchange/contracts/src/MixinSignatureValidator.sol b/contracts/exchange/contracts/src/MixinSignatureValidator.sol index fdb533d4ba..c630687a44 100644 --- a/contracts/exchange/contracts/src/MixinSignatureValidator.sol +++ b/contracts/exchange/contracts/src/MixinSignatureValidator.sol @@ -389,8 +389,8 @@ contract MixinSignatureValidator is // Disallow address zero because it is ecrecover() returns zero on // failure. if (signerAddress == address(0)) { - LibRichErrors._rrevert(LibExchangeRichErrors.SignatureError( - IExchangeRichErrors.SignatureErrorCodes.INVALID_SIGNER, + LibRichErrors.rrevert(LibExchangeRichErrors.SignatureError( + LibExchangeRichErrors.SignatureErrorCodes.INVALID_SIGNER, hash, signerAddress, signature diff --git a/contracts/exchange/contracts/src/MixinWrapperFunctions.sol b/contracts/exchange/contracts/src/MixinWrapperFunctions.sol index 16ff04f38e..cd2381f966 100644 --- a/contracts/exchange/contracts/src/MixinWrapperFunctions.sol +++ b/contracts/exchange/contracts/src/MixinWrapperFunctions.sol @@ -82,7 +82,7 @@ contract MixinWrapperFunctions is (bool didSucceed, bytes memory returnData) = address(this).delegatecall(fillOrderCalldata); if (didSucceed) { assert(returnData.length == 128); - fillResults = abi.decode(returnData, (FillResults)); + fillResults = abi.decode(returnData, (LibFillResults.FillResults)); } // fillResults values will be 0 by default if call was unsuccessful return fillResults; diff --git a/contracts/exchange/contracts/test/ReentrancyTester.sol b/contracts/exchange/contracts/test/ReentrancyTester.sol index c50dec6662..5eb1d5d113 100644 --- a/contracts/exchange/contracts/test/ReentrancyTester.sol +++ b/contracts/exchange/contracts/test/ReentrancyTester.sol @@ -20,6 +20,9 @@ pragma solidity ^0.5.5; pragma experimental ABIEncoderV2; import "@0x/contracts-utils/contracts/src/LibReentrancyGuardRichErrors.sol"; +import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol"; +import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol"; +import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol"; import "../src/Exchange.sol"; @@ -71,27 +74,27 @@ contract ReentrancyTester is /// @dev Overriden to do nothing. function _fillOrder( - Order memory order, + LibOrder.Order memory order, uint256 takerAssetFillAmount, bytes memory signature ) internal - returns (FillResults memory fillResults) + returns (LibFillResults.FillResults memory fillResults) {} /// @dev Overriden to do nothing. function _fillOrKillOrder( - Order memory order, + LibOrder.Order memory order, uint256 takerAssetFillAmount, bytes memory signature ) internal - returns (FillResults memory fillResults) + returns (LibFillResults.FillResults memory fillResults) {} /// @dev Overridden to do nothing. function _executeTransaction( - ZeroExTransaction memory transaction, + LibZeroExTransaction.ZeroExTransaction memory transaction, bytes memory signature ) internal @@ -126,7 +129,7 @@ contract ReentrancyTester is {} /// @dev Overriden to do nothing. - function _cancelOrder(Order memory order) + function _cancelOrder(LibOrder.Order memory order) internal {} } diff --git a/contracts/exchange/contracts/test/TestWrapperFunctions.sol b/contracts/exchange/contracts/test/TestWrapperFunctions.sol index f360f641a0..1befc426b6 100644 --- a/contracts/exchange/contracts/test/TestWrapperFunctions.sol +++ b/contracts/exchange/contracts/test/TestWrapperFunctions.sol @@ -19,6 +19,8 @@ pragma solidity ^0.5.5; pragma experimental ABIEncoderV2; +import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol"; +import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol"; import "../src/Exchange.sol"; @@ -28,19 +30,19 @@ import "../src/Exchange.sol"; contract TestWrapperFunctions is Exchange { - uint8 internal constant MAX_ORDER_STATUS = uint8(OrderStatus.CANCELLED); + uint8 internal constant MAX_ORDER_STATUS = uint8(LibOrder.OrderStatus.CANCELLED); uint256 internal constant ALWAYS_FAILING_SALT = uint256(-1); string internal constant ALWAYS_FAILING_SALT_REVERT_REASON = "ALWAYS_FAILING_SALT"; // solhint-disable no-unused-vars event FillOrderCalled( - Order order, + LibOrder.Order order, uint256 takerAssetFillAmount, bytes signature ); event CancelOrderCalled( - Order order + LibOrder.Order order ); // solhint-disable no-empty-blocks @@ -51,10 +53,10 @@ contract TestWrapperFunctions is {} /// @dev Overridden to be deterministic and simplified. - function getOrderInfo(Order memory order) + function getOrderInfo(LibOrder.Order memory order) public view - returns (OrderInfo memory orderInfo) + returns (LibOrder.OrderInfo memory orderInfo) { // Lower uint128 of `order.salt` is the `orderTakerAssetFilledAmount`. orderInfo.orderTakerAssetFilledAmount = uint128(order.salt); @@ -65,12 +67,12 @@ contract TestWrapperFunctions is /// @dev Overridden to log arguments, be deterministic, and revert with certain inputs. function _fillOrder( - Order memory order, + LibOrder.Order memory order, uint256 takerAssetFillAmount, bytes memory signature ) internal - returns (FillResults memory fillResults) + returns (LibFillResults.FillResults memory fillResults) { emit FillOrderCalled( order, @@ -94,7 +96,7 @@ contract TestWrapperFunctions is /// @dev Overridden to only log arguments and revert with certain inputs. function _cancelOrder( - Order memory order + LibOrder.Order memory order ) internal { @@ -109,7 +111,7 @@ contract TestWrapperFunctions is } /// @dev Simplified order hashing. - function _getOrderHash(Order memory order) + function _getOrderHash(LibOrder.Order memory order) internal pure returns (bytes32 hash) diff --git a/contracts/exchange/package.json b/contracts/exchange/package.json index af8745683a..5246e81385 100644 --- a/contracts/exchange/package.json +++ b/contracts/exchange/package.json @@ -34,7 +34,7 @@ "lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol" }, "config": { - "abis": "./generated-artifacts/@(Exchange|ExchangeWrapper|IAssetProxy|IAssetProxyDispatcher|IEIP1271Wallet|IExchange|IExchangeCore|IMatchOrders|ISignatureValidator|ITransactions|ITransferSimulator|IWallet|IWrapperFunctions|IsolatedExchange|LibExchangeRichErrorDecoder|MixinAssetProxyDispatcher|MixinExchangeCore|MixinMatchOrders|MixinSignatureValidator|MixinTransactions|MixinTransferSimulator|MixinWrapperFunctions|ReentrantERC20Token|TestAssetProxyDispatcher|TestExchangeInternals|TestLibExchangeRichErrorDecoder|TestSignatureValidator|TestValidatorWallet|Whitelist).json", + "abis": "./generated-artifacts/@(Exchange|ExchangeWrapper|IAssetProxy|IAssetProxyDispatcher|IEIP1271Wallet|IExchange|IExchangeCore|IExchangeRichErrors|IMatchOrders|ISignatureValidator|ITransactions|ITransferSimulator|IWallet|IWrapperFunctions|IsolatedExchange|LibExchangeRichErrorDecoder|MixinAssetProxyDispatcher|MixinExchangeCore|MixinMatchOrders|MixinSignatureValidator|MixinTransactions|MixinTransferSimulator|MixinWrapperFunctions|ReentrancyTester|TestAssetProxyDispatcher|TestExchangeInternals|TestLibExchangeRichErrorDecoder|TestSignatureValidator|TestValidatorWallet|TestWrapperFunctions|Whitelist).json", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { diff --git a/contracts/exchange/src/artifacts.ts b/contracts/exchange/src/artifacts.ts index 8c1aedae3e..03f27aafc6 100644 --- a/contracts/exchange/src/artifacts.ts +++ b/contracts/exchange/src/artifacts.ts @@ -12,6 +12,7 @@ import * as IAssetProxyDispatcher from '../generated-artifacts/IAssetProxyDispat import * as IEIP1271Wallet from '../generated-artifacts/IEIP1271Wallet.json'; import * as IExchange from '../generated-artifacts/IExchange.json'; import * as IExchangeCore from '../generated-artifacts/IExchangeCore.json'; +import * as IExchangeRichErrors from '../generated-artifacts/IExchangeRichErrors.json'; import * as IMatchOrders from '../generated-artifacts/IMatchOrders.json'; import * as ISignatureValidator from '../generated-artifacts/ISignatureValidator.json'; import * as ITransactions from '../generated-artifacts/ITransactions.json'; @@ -51,6 +52,7 @@ export const artifacts = { IEIP1271Wallet: IEIP1271Wallet as ContractArtifact, IExchange: IExchange as ContractArtifact, IExchangeCore: IExchangeCore as ContractArtifact, + IExchangeRichErrors: IExchangeRichErrors as ContractArtifact, IMatchOrders: IMatchOrders as ContractArtifact, ISignatureValidator: ISignatureValidator as ContractArtifact, ITransactions: ITransactions as ContractArtifact, diff --git a/contracts/exchange/src/wrappers.ts b/contracts/exchange/src/wrappers.ts index 171f93ba3e..2efb88a2ed 100644 --- a/contracts/exchange/src/wrappers.ts +++ b/contracts/exchange/src/wrappers.ts @@ -10,6 +10,7 @@ export * from '../generated-wrappers/i_asset_proxy_dispatcher'; export * from '../generated-wrappers/i_e_i_p1271_wallet'; export * from '../generated-wrappers/i_exchange'; export * from '../generated-wrappers/i_exchange_core'; +export * from '../generated-wrappers/i_exchange_rich_errors'; export * from '../generated-wrappers/i_match_orders'; export * from '../generated-wrappers/i_signature_validator'; export * from '../generated-wrappers/i_transactions'; diff --git a/contracts/exchange/tsconfig.json b/contracts/exchange/tsconfig.json index f90e8ecc30..ee982946bd 100644 --- a/contracts/exchange/tsconfig.json +++ b/contracts/exchange/tsconfig.json @@ -10,6 +10,7 @@ "generated-artifacts/IEIP1271Wallet.json", "generated-artifacts/IExchange.json", "generated-artifacts/IExchangeCore.json", + "generated-artifacts/IExchangeRichErrors.json", "generated-artifacts/IMatchOrders.json", "generated-artifacts/ISignatureValidator.json", "generated-artifacts/ITransactions.json", @@ -17,7 +18,6 @@ "generated-artifacts/IWallet.json", "generated-artifacts/IWrapperFunctions.json", "generated-artifacts/IsolatedExchange.json", - "generated-artifacts/ReentrancyTester.json", "generated-artifacts/LibExchangeRichErrorDecoder.json", "generated-artifacts/MixinAssetProxyDispatcher.json", "generated-artifacts/MixinExchangeCore.json", @@ -26,7 +26,7 @@ "generated-artifacts/MixinTransactions.json", "generated-artifacts/MixinTransferSimulator.json", "generated-artifacts/MixinWrapperFunctions.json", - "generated-artifacts/ReentrantERC20Token.json", + "generated-artifacts/ReentrancyTester.json", "generated-artifacts/TestAssetProxyDispatcher.json", "generated-artifacts/TestExchangeInternals.json", "generated-artifacts/TestLibExchangeRichErrorDecoder.json",