Skip to content

Commit

Permalink
handle extending contract order offers in reference
Browse files Browse the repository at this point in the history
  • Loading branch information
0age committed Feb 29, 2024
1 parent 9621516 commit 88bbe76
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 34 deletions.
19 changes: 2 additions & 17 deletions reference/lib/ReferenceOrderCombiner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -785,16 +785,14 @@ contract ReferenceOrderCombiner is

{
// Retrieve offer items.
OfferItem[] memory offer = parameters.offer;
SpentItem[] memory offer = orderToExecute.spentItems;

// Read length of offer array & place on the stack.
uint256 totalOfferItems = offer.length;

// Iterate over each offer item to restore it.
for (uint256 j = 0; j < totalOfferItems; ++j) {
SpentItem memory offerSpentItem = (
orderToExecute.spentItems[j]
);
SpentItem memory offerSpentItem = offer[j];

// Retrieve remaining amount on the offer item.
uint256 unspentAmount = offerSpentItem.amount;
Expand Down Expand Up @@ -845,19 +843,6 @@ contract ReferenceOrderCombiner is
);
}
}

{
// Get offer items as well.
SpentItem[] memory offer = orderToExecute.spentItems;

// Iterate over each consideration item to ensure it is met.
for (uint256 j = 0; j < offer.length; ++j) {
// Restore original amount.
offer[j].amount = (
orderToExecute.spentItemOriginalAmounts[j]
);
}
}
}

// Trigger any remaining accumulated transfers via call to the
Expand Down
17 changes: 0 additions & 17 deletions reference/lib/ReferenceOrderValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -481,21 +481,6 @@ contract ReferenceOrderValidator is
// Explicitly specified offer items cannot be removed.
if (originalOfferLength > newOfferLength) {
revert InvalidContractOrder(orderHash);
} else if (newOfferLength > originalOfferLength) {
{
// Extend the ordersToExecute array.
SpentItem[] memory extendedSpent = new SpentItem[](
newOfferLength
);

// Copy original spent items to new array.
for (uint256 i = 0; i < originalOfferLength; ++i) {
extendedSpent[i] = orderToExecute.spentItems[i];
}

// Update order to execute with extended items.
orderToExecute.spentItems = extendedSpent;
}
}

// Loop through each new offer and ensure the new amounts are at
Expand Down Expand Up @@ -605,8 +590,6 @@ contract ReferenceOrderValidator is
}
}

orderToExecute.numerator = 1;

// Return the order hash.
return orderHash;
}
Expand Down

0 comments on commit 88bbe76

Please sign in to comment.