Skip to content

Commit

Permalink
format helm
Browse files Browse the repository at this point in the history
  • Loading branch information
djviau committed Sep 18, 2023
1 parent 24dbd7d commit 2605fed
Showing 1 changed file with 95 additions and 126 deletions.
221 changes: 95 additions & 126 deletions src/helm.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,23 @@ import {LibString} from "solady/src/utils/LibString.sol";

import {BasicOrderType, ItemType, OrderType, Side} from "seaport-types/src/lib/ConsiderationEnums.sol";

import {AdditionalRecipient, AdvancedOrder, BasicOrderParameters, ConsiderationItem, CriteriaResolver, Execution, Fulfillment, FulfillmentComponent, OfferItem, Order, OrderComponents, OrderParameters, ReceivedItem, SpentItem, ZoneParameters} from "seaport-types/src/lib/ConsiderationStructs.sol";
import {
AdditionalRecipient,
AdvancedOrder,
BasicOrderParameters,
ConsiderationItem,
CriteriaResolver,
Execution,
Fulfillment,
FulfillmentComponent,
OfferItem,
Order,
OrderComponents,
OrderParameters,
ReceivedItem,
SpentItem,
ZoneParameters
} from "seaport-types/src/lib/ConsiderationStructs.sol";

/**
* @title helm
Expand Down Expand Up @@ -66,9 +82,7 @@ library helm {
console.log(gStr(i, "OfferItem: {"));
console.log(gStr(i + 1, "itemType", _itemTypeStr(oi.itemType)));
console.log(gStr(i + 1, "token", oi.token));
console.log(
gStr(i + 1, "identifierOrCriteria", oi.identifierOrCriteria)
);
console.log(gStr(i + 1, "identifierOrCriteria", oi.identifierOrCriteria));
console.log(gStr(i + 1, "startAmount", oi.startAmount));
console.log(gStr(i + 1, "endAmount", oi.endAmount));
console.log(gStr(i, "}"));
Expand All @@ -78,9 +92,7 @@ library helm {
logConsiderationItem(considerationItem, 0);
}

function log(
ConsiderationItem[] memory considerationItemArray
) public view {
function log(ConsiderationItem[] memory considerationItemArray) public view {
console.log(gStr(0, "considerationItemArray: ["));
for (uint256 j = 0; j < considerationItemArray.length; j++) {
logConsiderationItem(considerationItemArray[j], 1);
Expand All @@ -95,9 +107,7 @@ library helm {
console.log(gStr(i, "ConsiderationItem: {"));
console.log(gStr(i + 1, "itemType", _itemTypeStr(ci.itemType)));
console.log(gStr(i + 1, "token", ci.token));
console.log(
gStr(i + 1, "identifierOrCriteria", ci.identifierOrCriteria)
);
console.log(gStr(i + 1, "identifierOrCriteria", ci.identifierOrCriteria));
console.log(gStr(i + 1, "startAmount", ci.startAmount));
console.log(gStr(i + 1, "endAmount", ci.endAmount));
console.log(gStr(i, "}"));
Expand Down Expand Up @@ -156,9 +166,7 @@ library helm {
logBasicOrderParameters(basicOrderParameters, 0);
}

function log(
BasicOrderParameters[] memory basicOrderParametersArray
) public view {
function log(BasicOrderParameters[] memory basicOrderParametersArray) public view {
console.log(gStr(0, "basicOrderParametersArray: ["));
for (uint256 j = 0; j < basicOrderParametersArray.length; j++) {
logBasicOrderParameters(basicOrderParametersArray[j], 1);
Expand All @@ -172,39 +180,21 @@ library helm {
) internal view {
console.log(gStr(i, "BasicOrderParameters: {"));
console.log(gStr(i + 1, "considerationToken", bop.considerationToken));
console.log(
gStr(i + 1, "considerationIdentifier", bop.considerationIdentifier)
);
console.log(
gStr(i + 1, "considerationAmount", bop.considerationAmount)
);
console.log(gStr(i + 1, "considerationIdentifier", bop.considerationIdentifier));
console.log(gStr(i + 1, "considerationAmount", bop.considerationAmount));
console.log(gStr(i + 1, "offerer", bop.offerer));
console.log(gStr(i + 1, "zone", bop.zone));
console.log(gStr(i + 1, "offerToken", bop.offerToken));
console.log(gStr(i + 1, "offerIdentifier", bop.offerIdentifier));
console.log(gStr(i + 1, "offerAmount", bop.offerAmount));
console.log(
gStr(
i + 1,
"basicOrderType",
_basicOrderTypeStr(bop.basicOrderType)
)
);
console.log(gStr(i + 1, "basicOrderType", _basicOrderTypeStr(bop.basicOrderType)));
console.log(gStr(i + 1, "startTime", bop.startTime));
console.log(gStr(i + 1, "endTime", bop.endTime));
console.log(gStr(i + 1, "zoneHash", bop.zoneHash));
console.log(gStr(i + 1, "salt", bop.salt));
console.log(gStr(i + 1, "offererConduitKey", bop.offererConduitKey));
console.log(
gStr(i + 1, "fulfillerConduitKey", bop.fulfillerConduitKey)
);
console.log(
gStr(
i + 1,
"totalOriginalAdditionalRecipients",
bop.totalOriginalAdditionalRecipients
)
);
console.log(gStr(i + 1, "fulfillerConduitKey", bop.fulfillerConduitKey));
console.log(gStr(i + 1, "totalOriginalAdditionalRecipients", bop.totalOriginalAdditionalRecipients));
console.log(gStr(i + 1, "additionalRecipients: ["));
for (uint256 j = 0; j < bop.additionalRecipients.length; j++) {
logAdditionalRecipient(bop.additionalRecipients[j], i + 1);
Expand All @@ -218,9 +208,7 @@ library helm {
logAdditionalRecipient(additionalRecipient, 0);
}

function log(
AdditionalRecipient[] memory additionalRecipientArray
) public view {
function log(AdditionalRecipient[] memory additionalRecipientArray) public view {
console.log(gStr(0, "additionalRecipientArray: ["));
for (uint256 j = 0; j < additionalRecipientArray.length; j++) {
logAdditionalRecipient(additionalRecipientArray[j], 1);
Expand Down Expand Up @@ -265,13 +253,7 @@ library helm {
console.log(gStr(i + 1, "zoneHash", op.zoneHash));
console.log(gStr(i + 1, "salt", op.salt));
console.log(gStr(i + 1, "conduitKey", op.conduitKey));
console.log(
gStr(
i + 1,
"totalOriginalConsiderationItems",
op.totalOriginalConsiderationItems
)
);
console.log(gStr(i + 1, "totalOriginalConsiderationItems", op.totalOriginalConsiderationItems));
console.log(gStr(i, "}"));
}

Expand All @@ -287,10 +269,7 @@ library helm {
console.log(gStr(0, "]"));
}

function logOrder(
Order memory order,
uint256 i /* indent */
) internal view {
function logOrder(Order memory order, uint256 i /* indent */ ) internal view {
console.log(gStr(i, "Order: {"));
logOrderParameters(order.parameters, i + 1);
console.log(gStr(i + 1, "signature", order.signature));
Expand Down Expand Up @@ -383,9 +362,7 @@ library helm {
logFulfillmentComponent(fulfillmentComponent, 0);
}

function log(
FulfillmentComponent[] memory fulfillmentComponentArray
) public view {
function log(FulfillmentComponent[] memory fulfillmentComponentArray) public view {
console.log(gStr(0, "fulfillmentComponentArray: ["));
for (uint256 j = 0; j < fulfillmentComponentArray.length; j++) {
logFulfillmentComponent(fulfillmentComponentArray[j], 1);
Expand Down Expand Up @@ -497,11 +474,7 @@ library helm {
string memory valueString
) public pure returns (string memory) {
string memory indentString = generateIndentString(i);
return
string.concat(
indentString,
string.concat(labelString, ": ", valueString)
);
return string.concat(indentString, string.concat(labelString, ": ", valueString));
}

function gStr(
Expand All @@ -510,11 +483,7 @@ library helm {
uint256 value
) public pure returns (string memory) {
string memory indentString = generateIndentString(i);
return
string.concat(
indentString,
string.concat(labelString, ": ", LibString.toString(value))
);
return string.concat(indentString, string.concat(labelString, ": ", LibString.toString(value)));
}

function gStr(
Expand All @@ -523,11 +492,7 @@ library helm {
address value
) public pure returns (string memory) {
string memory indentString = generateIndentString(i);
return
string.concat(
indentString,
string.concat(labelString, ": ", LibString.toHexString(value))
);
return string.concat(indentString, string.concat(labelString, ": ", LibString.toHexString(value)));
}

function gStr(
Expand All @@ -536,15 +501,7 @@ library helm {
bytes32 value
) public pure returns (string memory) {
string memory indentString = generateIndentString(i);
return
string.concat(
indentString,
string.concat(
labelString,
": ",
LibString.toHexString(uint256(value))
)
);
return string.concat(indentString, string.concat(labelString, ": ", LibString.toHexString(uint256(value))));
}

function gStr(
Expand All @@ -553,21 +510,14 @@ library helm {
bytes memory value
) public pure returns (string memory) {
string memory indentString = generateIndentString(i);
return
string.concat(
indentString,
string.concat(labelString, ": ", LibString.toHexString(value))
);
return string.concat(indentString, string.concat(labelString, ": ", LibString.toHexString(value)));
}

////////////////////////////////////////////////////////////////////////////
// Log Arrays //
////////////////////////////////////////////////////////////////////////////

function logOffer(
OfferItem[] memory offer,
uint256 i /* indent */
) public view {
function logOffer(OfferItem[] memory offer, uint256 i /* indent */ ) public view {
console.log(gStr(i, "offer: ["));
for (uint256 j = 0; j < offer.length; j++) {
logOfferItem(offer[j], i + 1);
Expand All @@ -590,87 +540,106 @@ library helm {
// Get Enum String Values //
////////////////////////////////////////////////////////////////////////////

function _itemTypeStr(
ItemType itemType
) internal pure returns (string memory) {
function _itemTypeStr(ItemType itemType) internal pure returns (string memory) {
if (itemType == ItemType.NATIVE) return "NATIVE";
if (itemType == ItemType.ERC20) return "ERC20";
if (itemType == ItemType.ERC721) return "ERC721";
if (itemType == ItemType.ERC1155) return "ERC1155";
if (itemType == ItemType.ERC721_WITH_CRITERIA)
if (itemType == ItemType.ERC721_WITH_CRITERIA) {
return "ERC721_WITH_CRITERIA";
if (itemType == ItemType.ERC1155_WITH_CRITERIA)
}
if (itemType == ItemType.ERC1155_WITH_CRITERIA) {
return "ERC1155_WITH_CRITERIA";
}

return "UNKNOWN";
}

function _orderTypeStr(
OrderType orderType
) internal pure returns (string memory) {
function _orderTypeStr(OrderType orderType) internal pure returns (string memory) {
if (orderType == OrderType.FULL_OPEN) return "FULL_OPEN";
if (orderType == OrderType.PARTIAL_OPEN) return "PARTIAL_OPEN";
if (orderType == OrderType.FULL_RESTRICTED) return "FULL_RESTRICTED";
if (orderType == OrderType.PARTIAL_RESTRICTED)
if (orderType == OrderType.PARTIAL_RESTRICTED) {
return "PARTIAL_RESTRICTED";
}
if (orderType == OrderType.CONTRACT) return "CONTRACT";

return "UNKNOWN";
}

function _basicOrderTypeStr(
BasicOrderType basicOrderType
) internal pure returns (string memory) {
if (basicOrderType == BasicOrderType.ETH_TO_ERC721_FULL_OPEN)
function _basicOrderTypeStr(BasicOrderType basicOrderType) internal pure returns (string memory) {
if (basicOrderType == BasicOrderType.ETH_TO_ERC721_FULL_OPEN) {
return "ETH_TO_ERC721_FULL_OPEN";
if (basicOrderType == BasicOrderType.ETH_TO_ERC721_PARTIAL_OPEN)
}
if (basicOrderType == BasicOrderType.ETH_TO_ERC721_PARTIAL_OPEN) {
return "ETH_TO_ERC721_PARTIAL_OPEN";
if (basicOrderType == BasicOrderType.ETH_TO_ERC721_FULL_RESTRICTED)
}
if (basicOrderType == BasicOrderType.ETH_TO_ERC721_FULL_RESTRICTED) {
return "ETH_TO_ERC721_FULL_RESTRICTED";
if (basicOrderType == BasicOrderType.ETH_TO_ERC721_PARTIAL_RESTRICTED)
}
if (basicOrderType == BasicOrderType.ETH_TO_ERC721_PARTIAL_RESTRICTED) {
return "ETH_TO_ERC721_PARTIAL_RESTRICTED";
if (basicOrderType == BasicOrderType.ETH_TO_ERC1155_FULL_OPEN)
}
if (basicOrderType == BasicOrderType.ETH_TO_ERC1155_FULL_OPEN) {
return "ETH_TO_ERC1155_FULL_OPEN";
if (basicOrderType == BasicOrderType.ETH_TO_ERC1155_PARTIAL_OPEN)
}
if (basicOrderType == BasicOrderType.ETH_TO_ERC1155_PARTIAL_OPEN) {
return "ETH_TO_ERC1155_PARTIAL_OPEN";
if (basicOrderType == BasicOrderType.ETH_TO_ERC1155_FULL_RESTRICTED)
}
if (basicOrderType == BasicOrderType.ETH_TO_ERC1155_FULL_RESTRICTED) {
return "ETH_TO_ERC1155_FULL_RESTRICTED";
if (basicOrderType == BasicOrderType.ETH_TO_ERC1155_PARTIAL_RESTRICTED)
}
if (basicOrderType == BasicOrderType.ETH_TO_ERC1155_PARTIAL_RESTRICTED) {
return "ETH_TO_ERC1155_PARTIAL_RESTRICTED";
if (basicOrderType == BasicOrderType.ERC20_TO_ERC721_FULL_OPEN)
}
if (basicOrderType == BasicOrderType.ERC20_TO_ERC721_FULL_OPEN) {
return "ERC20_TO_ERC721_FULL_OPEN";
if (basicOrderType == BasicOrderType.ERC20_TO_ERC721_PARTIAL_OPEN)
}
if (basicOrderType == BasicOrderType.ERC20_TO_ERC721_PARTIAL_OPEN) {
return "ERC20_TO_ERC721_PARTIAL_OPEN";
if (basicOrderType == BasicOrderType.ERC20_TO_ERC721_FULL_RESTRICTED)
}
if (basicOrderType == BasicOrderType.ERC20_TO_ERC721_FULL_RESTRICTED) {
return "ERC20_TO_ERC721_FULL_RESTRICTED";
if (basicOrderType == BasicOrderType.ERC20_TO_ERC721_PARTIAL_RESTRICTED)
}
if (basicOrderType == BasicOrderType.ERC20_TO_ERC721_PARTIAL_RESTRICTED) {
return "ERC20_TO_ERC721_PARTIAL_RESTRICTED";
if (basicOrderType == BasicOrderType.ERC20_TO_ERC1155_FULL_OPEN)
}
if (basicOrderType == BasicOrderType.ERC20_TO_ERC1155_FULL_OPEN) {
return "ERC20_TO_ERC1155_FULL_OPEN";
if (basicOrderType == BasicOrderType.ERC20_TO_ERC1155_PARTIAL_OPEN)
}
if (basicOrderType == BasicOrderType.ERC20_TO_ERC1155_PARTIAL_OPEN) {
return "ERC20_TO_ERC1155_PARTIAL_OPEN";
if (basicOrderType == BasicOrderType.ERC20_TO_ERC1155_FULL_RESTRICTED)
}
if (basicOrderType == BasicOrderType.ERC20_TO_ERC1155_FULL_RESTRICTED) {
return "ERC20_TO_ERC1155_FULL_RESTRICTED";
if (
basicOrderType == BasicOrderType.ERC20_TO_ERC1155_PARTIAL_RESTRICTED
) return "ERC20_TO_ERC1155_PARTIAL_RESTRICTED";
if (basicOrderType == BasicOrderType.ERC721_TO_ERC20_FULL_OPEN)
}
if (basicOrderType == BasicOrderType.ERC20_TO_ERC1155_PARTIAL_RESTRICTED) {
return "ERC20_TO_ERC1155_PARTIAL_RESTRICTED";
}
if (basicOrderType == BasicOrderType.ERC721_TO_ERC20_FULL_OPEN) {
return "ERC721_TO_ERC20_FULL_OPEN";
if (basicOrderType == BasicOrderType.ERC721_TO_ERC20_PARTIAL_OPEN)
}
if (basicOrderType == BasicOrderType.ERC721_TO_ERC20_PARTIAL_OPEN) {
return "ERC721_TO_ERC20_PARTIAL_OPEN";
if (basicOrderType == BasicOrderType.ERC721_TO_ERC20_FULL_RESTRICTED)
}
if (basicOrderType == BasicOrderType.ERC721_TO_ERC20_FULL_RESTRICTED) {
return "ERC721_TO_ERC20_FULL_RESTRICTED";
if (basicOrderType == BasicOrderType.ERC721_TO_ERC20_PARTIAL_RESTRICTED)
}
if (basicOrderType == BasicOrderType.ERC721_TO_ERC20_PARTIAL_RESTRICTED) {
return "ERC721_TO_ERC20_PARTIAL_RESTRICTED";
if (basicOrderType == BasicOrderType.ERC1155_TO_ERC20_FULL_OPEN)
}
if (basicOrderType == BasicOrderType.ERC1155_TO_ERC20_FULL_OPEN) {
return "ERC1155_TO_ERC20_FULL_OPEN";
if (basicOrderType == BasicOrderType.ERC1155_TO_ERC20_PARTIAL_OPEN)
}
if (basicOrderType == BasicOrderType.ERC1155_TO_ERC20_PARTIAL_OPEN) {
return "ERC1155_TO_ERC20_PARTIAL_OPEN";
if (basicOrderType == BasicOrderType.ERC1155_TO_ERC20_FULL_RESTRICTED)
}
if (basicOrderType == BasicOrderType.ERC1155_TO_ERC20_FULL_RESTRICTED) {
return "ERC1155_TO_ERC20_FULL_RESTRICTED";
if (
basicOrderType == BasicOrderType.ERC1155_TO_ERC20_PARTIAL_RESTRICTED
) return "ERC1155_TO_ERC20_PARTIAL_RESTRICTED";
}
if (basicOrderType == BasicOrderType.ERC1155_TO_ERC20_PARTIAL_RESTRICTED) {
return "ERC1155_TO_ERC20_PARTIAL_RESTRICTED";
}

return "UNKNOWN";
}
Expand Down

0 comments on commit 2605fed

Please sign in to comment.