@0x/contracts-exchange-libs: Add new revert types and use abi.decode() instead of LibBytes.

This commit is contained in:
Lawrence Forman 2019-08-16 16:49:01 -04:00
parent fb6e8a4608
commit d8372f73bc

View File

@ -126,14 +126,22 @@ library LibExchangeRichErrors {
bytes4 internal constant TRANSACTION_EXECUTION_ERROR_SELECTOR = bytes4 internal constant TRANSACTION_EXECUTION_ERROR_SELECTOR =
0x20d11f61; 0x20d11f61;
// bytes4(keccak256("IncompleteFillError(bytes32)")) // bytes4(keccak256("IncompleteFillError(uint256,bytes32)"))
bytes4 internal constant INCOMPLETE_FILL_ERROR_SELECTOR = bytes4 internal constant INCOMPLETE_FILL_ERROR_SELECTOR =
0x152aa60e; 0x7db7f6fa;
// bytes4(keccak256("BatchMatchOrdersError(uint8)")) // bytes4(keccak256("BatchMatchOrdersError(uint8)"))
bytes4 internal constant BATCH_MATCH_ORDERS_ERROR_SELECTOR = bytes4 internal constant BATCH_MATCH_ORDERS_ERROR_SELECTOR =
0xd4092f4f; 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 // solhint-disable func-name-mixedcase
function SignatureErrorSelector() function SignatureErrorSelector()
internal internal
@ -279,6 +287,22 @@ library LibExchangeRichErrors {
return INCOMPLETE_FILL_ERROR_SELECTOR; 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() function BatchMatchOrdersErrorSelector()
internal internal
pure pure
@ -576,6 +600,7 @@ library LibExchangeRichErrors {
} }
function IncompleteFillError( function IncompleteFillError(
uint256 takerAssetFillAmount,
bytes32 orderHash bytes32 orderHash
) )
internal internal
@ -584,7 +609,38 @@ library LibExchangeRichErrors {
{ {
return abi.encodeWithSelector( return abi.encodeWithSelector(
INCOMPLETE_FILL_ERROR_SELECTOR, INCOMPLETE_FILL_ERROR_SELECTOR,
takerAssetFillAmount,
orderHash 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
);
}
} }