Skip to content

Commit

Permalink
Merge pull request #61 from ProjectOpenSea/small-formatting-tweaks
Browse files Browse the repository at this point in the history
general cleanup
  • Loading branch information
0age authored Mar 6, 2024
2 parents 5fb250d + eea3ac9 commit ddc0926
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 29 deletions.
25 changes: 14 additions & 11 deletions src/core/lib/BasicOrderFulfiller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +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_offer_length_offset_relativeTo_baseOffset,
OrderFulfilled_offer_itemType_offset_relativeTo_baseOffset,
OrderFulfilled_offer_token_offset_relativeTo_baseOffset,
OrderFulfilled_post_memory_region_reservedBytes,
OrderFulfilled_selector,
ReceivedItem_amount_offset,
Expand Down Expand Up @@ -1012,7 +1012,7 @@ contract BasicOrderFulfiller is OrderValidator {
mstore(
add(
eventDataPtr,
OrderFulfilled_offer_length_baseOffset_relativeTo_OrderFulfilled_baseOffset
OrderFulfilled_offer_length_offset_relativeTo_baseOffset
),
1
)
Expand All @@ -1021,7 +1021,7 @@ contract BasicOrderFulfiller is OrderValidator {
mstore(
add(
eventDataPtr,
OrderFulfilled_offer_itemType_baseOffset_relativeTo_OrderFulfilled_baseOffset
OrderFulfilled_offer_itemType_offset_relativeTo_baseOffset
),
offeredItemType
)
Expand All @@ -1032,7 +1032,7 @@ contract BasicOrderFulfiller is OrderValidator {
calldatacopy(
add(
eventDataPtr,
OrderFulfilled_offer_token_baseOffset_relativeTo_OrderFulfilled_baseOffset
OrderFulfilled_offer_token_offset_relativeTo_baseOffset
),
BasicOrder_offerToken_cdPtr,
ThreeWords
Expand Down Expand Up @@ -1074,11 +1074,14 @@ contract BasicOrderFulfiller is OrderValidator {
mstore(FreeMemoryPointerSlot,
add(
eventDataPtr,
// reserve extra 3 words to be used by `authorizeOrder` and
// `validatateOrder` if pre-post exection hook to the zone is
// required. These 3 memory slots will be used for the extra data/context
// and order hashes of the calldata.
add(dataSize, OrderFulfilled_post_memory_region_reservedBytes)
// Reserve extra 3 words to be used by `authorizeOrder` and
// `validatateOrder` if pre-post exection hook to the zone
// is required. These 3 memory slots will be used for the
// extra data/context and order hashes of the calldata.
add(
dataSize,
OrderFulfilled_post_memory_region_reservedBytes
)
)
)
}
Expand Down
9 changes: 5 additions & 4 deletions src/core/lib/ConsiderationDecoder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -890,8 +890,8 @@ contract ConsiderationDecoder {
// 1. offerOffset
// 2. considerationOffset
// 3. offerLength & considerationLength might occupy just one word
// if offerOffset & considerationOffset would point to the same offset
// and the arrays have length 0.
// if offerOffset & considerationOffset would point to the same
// offset and the arrays have length 0.
invalidEncoding := lt(returndatasize(), ThreeWords)

let offsetOffer
Expand All @@ -907,7 +907,8 @@ contract ConsiderationDecoder {
offsetOffer := mload(0)
offsetConsideration := mload(OneWord)

// If valid length, check that offsets word boundaries are within returndata.
// If valid length, check that offsets word boundaries are
// within returndata.
let invalidOfferOffset :=
gt(
add(offsetOffer, OneWord),
Expand All @@ -932,7 +933,7 @@ contract ConsiderationDecoder {
considerationLength := mload(OneWord)

{
// Calculate end offsets of offer & consideration arrays.
// Derive end offsets for offer & consideration arrays.
let offerEndOffset :=
add(
add(offsetOffer, OneWord),
Expand Down
12 changes: 7 additions & 5 deletions src/core/lib/ConsiderationEncoder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -555,11 +555,13 @@ contract ConsiderationEncoder {

/**
* @dev Takes an order hash and BasicOrderParameters struct (from calldata)
* and encodes it as `authorizeOrder` calldata. Note that memory data is reused
* from `OrderFulfilled` event data, and the rest of the calldata is prefixed and
* postfixed to this memory region. Importantly the memory region before the
* `OrderFulfilled`'s spent and received items are overwritten to. So this
* function will need to be modified if the layout of that event data changes.
* and encodes it as `authorizeOrder` calldata. Note that memory data
* is reused from `OrderFulfilled` event data, and the rest of the
* calldata is prefixed and postfixed to this memory region. Note that
* the memory region before the spent and received items on the
* `OrderFulfilled` event are overwritten, which implies that this
* function will need to be modified should the layout of that event
* data change in the future.
*
* @param orderHash The order hash.
*
Expand Down
6 changes: 5 additions & 1 deletion src/core/lib/FulfillmentApplier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ contract FulfillmentApplier is FulfillmentApplicationErrors {
* using supplied directives on which component items are candidates
* for aggregation, skipping items on orders that are not available.
* Note that this function depends on memory layout affected by an
* earlier call to _validateOrdersAndPrepareToFulfill. The memory for
* earlier call to _validateOrdersAndPrepareToFulfill. The memory for
* the consideration arrays needs to be updated before calling
* _aggregateValidFulfillmentConsiderationItems.
* _validateOrdersAndPrepareToFulfill is called in _matchAdvancedOrders
Expand All @@ -559,6 +559,10 @@ contract FulfillmentApplier is FulfillmentApplicationErrors {
* of each candidate consideration item for
* aggregation.
* @param execution The execution to apply the aggregation to.
* @param offerer The address of the offerer to set on the
* execution.
* @param conduitKey A bytes32 value indicating the conduit key
* to set on the execution.
*/
function _aggregateValidFulfillmentConsiderationItems(
AdvancedOrder[] memory advancedOrders,
Expand Down
2 changes: 1 addition & 1 deletion src/core/lib/OrderCombiner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ contract OrderCombiner is OrderFulfiller, FulfillmentApplier {
let considerationItemRecipientPtr :=
add(
considerationItem,
ConsiderationItem_recipient_offset // recipient
ConsiderationItem_recipient_offset
)

// Write recipient to endAmount, as endAmount is not
Expand Down
8 changes: 4 additions & 4 deletions src/core/lib/OrderValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ contract OrderValidator is Executor, ZoneInteraction {
);

unchecked {
// If the order is not already validated, verify the supplied signature.
// If the order is not already validated, verify supplied signature.
if (!orderStatus.isValidated) {
_verifySignature(
offerer,
Expand All @@ -125,8 +125,8 @@ contract OrderValidator is Executor, ZoneInteraction {
CalldataPointer
.wrap(BasicOrder_signature_cdPtr)
.readMaskedUint256() +
// Add the BasicOrderParameters struct offset to the
// relative pointer.
// Add the BasicOrderParameters struct offset to
// the relative pointer.
BasicOrder_basicOrderParameters_cd_offset
)
)
Expand Down Expand Up @@ -517,7 +517,7 @@ contract OrderValidator is Executor, ZoneInteraction {
out := _a
}

// Determine the amount to scale down the new filled fraction.
// Determine amount to scale down the new filled fraction.
let scaleDown := gcd(filledNumerator, denominator)

// Ensure that the divisor is at least one.
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,9 +288,13 @@ 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;
uint256 constant OrderFulfilled_offer_length_offset_relativeTo_baseOffset = (
0x80
);
uint256 constant OrderFulfilled_offer_itemType_offset_relativeTo_baseOffset = (
0xa0
);
uint256 constant OrderFulfilled_offer_token_offset_relativeTo_baseOffset = 0xc0;

// Related constants used for restricted order checks on basic orders.
uint256 constant OrderFulfilled_baseDataSize = 0x160;
Expand Down

0 comments on commit ddc0926

Please sign in to comment.