Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cosmetic changes #56

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/core/lib/BasicOrderFulfiller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
)
Expand Down
38 changes: 20 additions & 18 deletions src/core/lib/OrderValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
)
);
);
}
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/types/lib/ConsiderationConstants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading