-
Notifications
You must be signed in to change notification settings - Fork 465
[3.0] Add LibExchangeRichErrorDecoder to exchange package #1790
[3.0] Add LibExchangeRichErrorDecoder to exchange package #1790
Conversation
LibOrder.OrderStatus orderStatus, | ||
bytes32 orderHash | ||
bytes32 orderHash, | ||
LibOrder.OrderStatus orderStatus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swapped the order of these for consistency with other errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
ALREADY_EXECUTED | ||
} | ||
|
||
bytes4 internal constant SIGNATURE_ERROR_SELECTOR = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that these constant's will be evaluated everywhere they're referenced. May not matter for decoding, but if gas is important then something like this would be more efficient.
// bytes4(keccak256("SignatureError(uint8,bytes32,address,bytes)"))
bytes4 internal constant SIGNATURE_ERROR_SELECTOR = 0x7e5a2318;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, wow, I had no idea. That makes no sense to me. Definitely worth changing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hysz does the new constantOptimizer
optimizer flag change this? I haven't really looked into it, but I'm not sure what else it would do (this is already set to true
in our compiler.json
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 8243a6f
9fcb2ec
to
8243a6f
Compare
Update coordinator tests for new tooling. Remove unecessary `chainId` parameter in `eip712_utils.createCoordinatorApprovalTypeData`
…abi-gen-wrappers` to use new domain schema and `Order` format.
…e rich revert errors. In `@0x/order-utils`: Change parameter order for `OrderStatusError`.
…RichErrors` into `MExchangeRichErrorTypes`. In `@0x/contracts-utils`: Pull types and constants from `MRichErrors` into `MRichErrorTypes`.
…rit from `@0x/contracts-exchange/.../MExchangeRichErrorTypes.sol`.
…s/src/libs/LibExchangeRichErrorDecoder`.
…ror_decoder` tests.
Run prettier/linter.
…revert selector constants.
…`0.5.8` docker image is released.
d3e8fb6
to
a587aa2
Compare
… to constantinople.
Description
Summary
This PR adds a
LibExchangeRichErrorDecoder
contract to the@0x/contracts-exchange
package. This contract exposes decoding (more like decomposing) functionality for ABI-encoded rich revert reasons (#1761).Notes
Exchange
does not use this new contract (but it could). It's designed to be inherited by a TBD standalone contract, that will likely live in separate package.exchange-libs
is not this contract's home for two reasons:exchange
'sMExchangeRichErrorTypes
. An alternative would be to moveMExchangeRichErrorTypes
intoexchange-libs
, but that seems like overkill since no other packages use that mixin.exchange-libs
because they aren't really Exchange related. Rich reverts are defined and used within their contract package, so they might as well host their own decoder libraries.Testing instructions
You can find the new tests for this contract in
contracts/exchange/test/src/lib_exchange_rich_error_decoder.ts
.Types of changes
Checklist:
[WIP]
if necessary.