From d8372f73bc8f35debd4edebc8354d7f5a33d5486 Mon Sep 17 00:00:00 2001 From: Lawrence Forman Date: Fri, 16 Aug 2019 16:49:01 -0400 Subject: [PATCH] `@0x/contracts-exchange-libs`: Add new revert types and use `abi.decode()` instead of `LibBytes`. --- .../contracts/src/LibExchangeRichErrors.sol | 60 ++++++++++++++++++- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/contracts/exchange-libs/contracts/src/LibExchangeRichErrors.sol b/contracts/exchange-libs/contracts/src/LibExchangeRichErrors.sol index f47db479b8..cfcd2cc5fe 100644 --- a/contracts/exchange-libs/contracts/src/LibExchangeRichErrors.sol +++ b/contracts/exchange-libs/contracts/src/LibExchangeRichErrors.sol @@ -126,14 +126,22 @@ library LibExchangeRichErrors { bytes4 internal constant TRANSACTION_EXECUTION_ERROR_SELECTOR = 0x20d11f61; - // bytes4(keccak256("IncompleteFillError(bytes32)")) + // bytes4(keccak256("IncompleteFillError(uint256,bytes32)")) bytes4 internal constant INCOMPLETE_FILL_ERROR_SELECTOR = - 0x152aa60e; + 0x7db7f6fa; // bytes4(keccak256("BatchMatchOrdersError(uint8)")) bytes4 internal constant BATCH_MATCH_ORDERS_ERROR_SELECTOR = 0xd4092f4f; + // bytes4(keccak256("IncompleteMarketSellError(uint256,bytes32[])")) + bytes4 internal constant INCOMPLETE_MARKET_SELL_ERROR_SELECTOR = + 0x3718c1f5; + + // bytes4(keccak256("IncompleteMarketBuyError(uint256,bytes32[])")) + bytes4 internal constant INCOMPLETE_MARKET_BUY_ERROR_SELECTOR = + 0x5599c1d8; + // solhint-disable func-name-mixedcase function SignatureErrorSelector() internal @@ -279,6 +287,22 @@ library LibExchangeRichErrors { return INCOMPLETE_FILL_ERROR_SELECTOR; } + function IncompleteMarketSellErrorSelector() + internal + pure + returns (bytes4) + { + return INCOMPLETE_MARKET_SELL_ERROR_SELECTOR; + } + + function IncompleteMarketBuyErrorSelector() + internal + pure + returns (bytes4) + { + return INCOMPLETE_MARKET_BUY_ERROR_SELECTOR; + } + function BatchMatchOrdersErrorSelector() internal pure @@ -576,6 +600,7 @@ library LibExchangeRichErrors { } function IncompleteFillError( + uint256 takerAssetFillAmount, bytes32 orderHash ) internal @@ -584,7 +609,38 @@ library LibExchangeRichErrors { { return abi.encodeWithSelector( INCOMPLETE_FILL_ERROR_SELECTOR, + takerAssetFillAmount, orderHash ); } + + function IncompleteMarketSellError( + uint256 takerAssetFillAmount, + bytes32[] memory orderHashes + ) + internal + pure + returns (bytes memory) + { + return abi.encodeWithSelector( + INCOMPLETE_MARKET_SELL_ERROR_SELECTOR, + takerAssetFillAmount, + orderHashes + ); + } + + function IncompleteMarketBuyError( + uint256 makerAssetFillAmount, + bytes32[] memory orderHashes + ) + internal + pure + returns (bytes memory) + { + return abi.encodeWithSelector( + INCOMPLETE_MARKET_BUY_ERROR_SELECTOR, + makerAssetFillAmount, + orderHashes + ); + } }