Open c4-submissions opened 1 year ago
Great refactoring imo
GalloDaSballo marked the issue as grade-a
This isn't possible to change, this is the interface that Seaport expects
0xfoobar (sponsor) disputed
This seems to compile
Rewriting the tests looks very laborious
CreateOfferer.sol
function generateOrder(address fulfiller, SpentItem[] calldata minimumReceived, SpentItem[] calldata maximumSpent, bytes calldata context)
external
checkStage(Enums.Stage.generate, Enums.Stage.transfer)
onlySeaport(msg.sender)
returns (SpentItem[] memory offer, ReceivedItem[] memory consideration)
{
if (context.length != 160) revert Errors.InvalidContextLength();
Structs.Context memory decodedContext = abi.decode(context, (Structs.Context));
/// @audit Add some validation here
(offer, consideration) = Helpers.processSpentItems(minimumReceived[0], maximumSpent[0]);
Helpers.updateTransientState(transientState, fulfiller, minimumReceived[0], maximumSpent[0], decodedContext);
}
CreateOffererLib.sol
function processSpentItems(SpentItem calldata minimumReceived, SpentItem calldata maximumSpent)
internal
view
returns (SpentItem[] memory offer, ReceivedItem[] memory consideration)
{
if (minimumReceived.itemType != ItemType.ERC721 || minimumReceived.token != address(this) || minimumReceived.amount != 1) {
revert CreateOffererErrors.MinimumReceivedInvalid(minimumReceived);
}
if (maximumSpent.itemType != ItemType.ERC721 && maximumSpent.itemType != ItemType.ERC20 && maximumSpent.itemType != ItemType.ERC1155) {
revert CreateOffererErrors.MaximumSpentInvalid(maximumSpent);
}
offer = new SpentItem[](1);
offer[0] = SpentItem({itemType: minimumReceived.itemType, token: minimumReceived.token, identifier: minimumReceived.identifier, amount: minimumReceived.amount});
consideration = new ReceivedItem[](1);
consideration[0] = ReceivedItem({
itemType: maximumSpent.itemType,
token: maximumSpent.token,
identifier: maximumSpent.identifier,
amount: maximumSpent.amount,
recipient: payable(address(this))
});
}
See the markdown file with the details of this report here.