@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 =
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
);
}
}