diff --git a/src/core/lib/BasicOrderFulfiller.sol b/src/core/lib/BasicOrderFulfiller.sol index d0a3ffe..a673cfc 100644 --- a/src/core/lib/BasicOrderFulfiller.sol +++ b/src/core/lib/BasicOrderFulfiller.sol @@ -91,6 +91,9 @@ import { OrderFulfilled_offer_body_offset, OrderFulfilled_offer_head_offset, OrderFulfilled_offer_length_baseOffset, + OrderFulfilled_offer_length_baseOffset_relativeTo_OrderFulfilled_baseOffset, + OrderFulfilled_offer_itemType_baseOffset_relativeTo_OrderFulfilled_baseOffset, + OrderFulfilled_offer_token_baseOffset_relativeTo_OrderFulfilled_baseOffset, OrderFulfilled_post_memory_region_reservedBytes, OrderFulfilled_selector, ReceivedItem_amount_offset, @@ -1006,16 +1009,31 @@ contract BasicOrderFulfiller is OrderValidator { ) // Set a length of 1 for the offer array. - mstore(add(eventDataPtr, 0x80), 1) + mstore( + add( + eventDataPtr, + OrderFulfilled_offer_length_baseOffset_relativeTo_OrderFulfilled_baseOffset + ), + 1 + ) // Write itemType to the SpentItem struct. - mstore(add(eventDataPtr, 0xa0), offeredItemType) + mstore( + add( + eventDataPtr, + OrderFulfilled_offer_itemType_baseOffset_relativeTo_OrderFulfilled_baseOffset + ), + offeredItemType + ) // Copy calldata region with (offerToken, offerIdentifier, // offerAmount) from OrderParameters to (token, identifier, // amount) in SpentItem struct. calldatacopy( - add(eventDataPtr, 0xc0), + add( + eventDataPtr, + OrderFulfilled_offer_token_baseOffset_relativeTo_OrderFulfilled_baseOffset + ), BasicOrder_offerToken_cdPtr, ThreeWords ) diff --git a/src/core/lib/OrderValidator.sol b/src/core/lib/OrderValidator.sol index b8dcf06..4582318 100644 --- a/src/core/lib/OrderValidator.sol +++ b/src/core/lib/OrderValidator.sol @@ -111,25 +111,27 @@ contract OrderValidator is Executor, ZoneInteraction { _runTimeConstantTrue() // Signifies to revert if order is invalid. ); - // If the order is not already validated, verify the supplied signature. - if (!orderStatus.isValidated) { - _verifySignature( - offerer, - orderHash, - _toBytesReturnType(_decodeBytes)( - // Wrap the absolute pointer to the order signature as a - // CalldataPointer. - CalldataPointer.wrap( - // Read the relative pointer to the order signature. - CalldataPointer - .wrap(BasicOrder_signature_cdPtr) - .readMaskedUint256() + - // Add the BasicOrderParameters struct offset to the - // relative pointer. - BasicOrder_basicOrderParameters_cd_offset + unchecked { + // If the order is not already validated, verify the supplied signature. + if (!orderStatus.isValidated) { + _verifySignature( + offerer, + orderHash, + _toBytesReturnType(_decodeBytes)( + // Wrap the absolute pointer to the order signature as a + // CalldataPointer. + CalldataPointer.wrap( + // Read the relative pointer to the order signature. + CalldataPointer + .wrap(BasicOrder_signature_cdPtr) + .readMaskedUint256() + + // Add the BasicOrderParameters struct offset to the + // relative pointer. + BasicOrder_basicOrderParameters_cd_offset + ) ) - ) - ); + ); + } } } diff --git a/src/types/lib/ConsiderationConstants.sol b/src/types/lib/ConsiderationConstants.sol index 7cc70f3..6f80468 100644 --- a/src/types/lib/ConsiderationConstants.sol +++ b/src/types/lib/ConsiderationConstants.sol @@ -288,6 +288,10 @@ uint256 constant OrderFulfilled_baseOffset = 0x180; uint256 constant OrderFulfilled_consideration_length_baseOffset = 0x2a0; uint256 constant OrderFulfilled_offer_length_baseOffset = 0x200; +uint256 constant OrderFulfilled_offer_length_baseOffset_relativeTo_OrderFulfilled_baseOffset = 0x80; +uint256 constant OrderFulfilled_offer_itemType_baseOffset_relativeTo_OrderFulfilled_baseOffset = 0xa0; +uint256 constant OrderFulfilled_offer_token_baseOffset_relativeTo_OrderFulfilled_baseOffset = 0xc0; + // Related constants used for restricted order checks on basic orders. uint256 constant OrderFulfilled_baseDataSize = 0x160; // uint256 constant ValidateOrder_offerDataOffset = 0x184; @@ -314,10 +318,10 @@ uint256 constant OrderFulfilled_post_memory_region_reservedBytes = 0x60; * pointing to the `OrderFulfilled`'s spent item array's length memory * position then we would have: * - * ptr - 0x0180 : padded calldata selector + * ptr - 0x0180 : zero-padded calldata selector * ptr - 0x0160 : ZoneParameter's struct head (0x20) * ptr - 0x0140 : order hash - * ptr - 0x0120 : fulfiller / msg.sender + * ptr - 0x0120 : fulfiller (msg.sender) * ptr - 0x0100 : offerer * ptr - 0x00e0 : spent items' head * ptr - 0x00c0 : received items' head @@ -326,7 +330,7 @@ uint256 constant OrderFulfilled_post_memory_region_reservedBytes = 0x60; * ptr - 0x0060 : start time * ptr - 0x0040 : end time * ptr - 0x0020 : zone hash - * ptr - 0x0000: offer.length (1) + * ptr - 0x0000 : offer.length (1) * ... * * Note that the padded calldata selector will be at minimum at the