Skip to content
Verified contractExactMIT

ResolverMarketData

Address0x0f7b6e514fa052908bf3210468db3f9c4865f03e
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.38

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.38+commit.1835d247
Language
solidity
Optimization
Yes, 200 runs
EVM version
osaka
Via IR
yes
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,361,965
Creation transaction
0xc9d2941b3d…cec79e2542

ResolverMarketData.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.38;

import {ICollection, ICanonicalArtwork} from "./ICollection.sol";
import {JsonValue} from "./JsonValue.sol";
import {ResolverListings} from "./ResolverListings.sol";
import {OriginalArtData, MoonbirdFeatures} from "./OriginalArt.sol";

/// @title The website's data fields, rendered on demand from chain state.
/// @notice Implements ABX's `IAbxFieldRenderer.render(token, tokenId, field)`.
/// The website collection declares each field once; the requesting website
/// token's ID selects the page ("tokens are pages"). Fields:
///  - `market`     collection summary (supply, caps, listings zone, sources)
///  - `documents`  manifesto and CC0 proof references
///  - `recent`     the latest `RECENT_COUNT` cc0pies
///  - `page`       64 cc0py tokens per website token: owner + listing state
///  - `art`        64 cc0py tokens per website token: source metadata URIs
///  - `s0`…`s7`    128 original tokens per website token for source 0…7:
///                 the exact `tokenURI` result (or, for Nouns and Moonbirds,
///                 the inputs the browser renderer needs)
/// Every response is recomputed from live state; there is no event-log
/// backend. Gas-capped `try` calls keep one slow source from failing a page.
/// @dev Immutable; a bug is fixed by deploying a new renderer and re-pointing
/// the website's fields (until those fields are locked).
contract ResolverMarketData {
    using JsonValue for uint256;

    ICollection public immutable collection;
    ResolverListings public immutable registry;
    OriginalArtData public immutable originalArt;

    /// @notice cc0py tokens per `page`/`art` page.
    uint256 public constant PAGE_SIZE = 64;
    /// @notice ceil(6969 / 64): the website mints this many page tokens.
    uint256 public constant MAX_COPY_PAGES = 109;
    /// @notice original tokens per `s0`…`s7` page.
    uint256 public constant SOURCE_PAGE_SIZE = 128;
    /// @notice Latest cc0pies shown on the website's front page.
    uint256 public constant RECENT_COUNT = 4;
    /// @dev Number of source collections in the manifesto.
    uint256 internal constant SOURCE_COUNT = 8;
    /// @dev cc0py token ID = sourceId * TOKEN_ID_RADIX + originalTokenId.
    uint256 internal constant TOKEN_ID_RADIX = 1_000_000_000_000;
    /// @dev Gas allowed for one source `tokenURI` inside a 128-row page. The
    /// largest honest responders (CrypToadz, mfers, XCOPY) finish well under
    /// this; Nouns and Moonbirds are never called (see `_browserRendered`).
    uint256 internal constant SOURCE_URI_GAS = 150_000;
    /// @dev Gas allowed for a cc0py `tokenURI` in `recent` (four calls per read).
    uint256 internal constant RECENT_URI_GAS = 2_000_000;
    /// @dev Gas allowed for XCOPY's `tokenIPFSHash` (a storage read).
    uint256 internal constant CANONICAL_IMAGE_GAS = 50_000;
    /// @dev Longest `tokenURI` string accepted into a response (128 KiB).
    uint256 internal constant MAX_URI_BYTES = 131_072;
    /// @dev Source IDs whose artwork the browser renders from on-chain data.
    uint256 internal constant SOURCE_NOUNS = 0;
    uint256 internal constant SOURCE_XCOPY = 1;
    uint256 internal constant SOURCE_MOONBIRDS = 2;

    /// @param nft The cc0py collection.
    /// @param book The `ResolverListings` zone.
    /// @param art The `OriginalArtData` bundle reader.
    constructor(address nft, address book, address art) {
        collection = ICollection(nft);
        registry = ResolverListings(book);
        originalArt = OriginalArtData(art);
    }

    // ---- ABX field renderer -------------------------------------------------

    /// @notice ABX entry point. `tokenId` is the requesting website token.
    function render(
        address,
        uint256 tokenId,
        bytes32 field
    ) external view returns (string memory, bytes memory) {
        if (field == bytes32("market")) return ("application/json", summary());
        if (field == bytes32("documents"))
            return ("application/json", documents());
        if (field == bytes32("recent")) return ("application/json", recent());
        if (field == bytes32("page")) {
            if (tokenId >= MAX_COPY_PAGES)
                return (
                    "application/json",
                    bytes('{"error":"Page outside collection limit"}')
                );
            return ("application/json", tokens(tokenId));
        }
        if (field == bytes32("art")) {
            if (tokenId >= MAX_COPY_PAGES)
                return (
                    "application/json",
                    bytes('{"error":"Artwork page outside collection limit"}')
                );
            return ("application/json", artwork(tokenId));
        }
        bytes memory key = abi.encodePacked(field);
        if (key[0] == "s" && key[1] >= "0" && key[1] <= "7" && key[2] == 0)
            return (
                "application/json",
                sourceArtwork(uint8(key[1]) - 48, tokenId)
            );
        return ("application/json", bytes('{"error":"Unknown field"}'));
    }

    // ---- collection-level fields -------------------------------------------

    /// @notice `market`: supply, caps, zone/guardian state and the eight sources.
    function summary() public view returns (bytes memory) {
        bytes memory out = abi.encodePacked(
            '{"version":2,"chainId":',
            block.chainid.number(),
            ',"head":',
            block.number.number(),
            ',"timestamp":',
            block.timestamp.number(),
            ',"collection":"',
            JsonValue.addr(address(collection)),
            '","registry":"',
            JsonValue.addr(address(registry)),
            '","seaport":"',
            JsonValue.addr(address(registry.seaport())),
            '","disabled":',
            registry.disabled() ? "true" : "false",
            ',"guardian":"',
            JsonValue.addr(registry.guardian()),
            '","supply":',
            collection.totalSupply().number(),
            ',"max":',
            collection.maxNFTs().number(),
            ',"cap":',
            collection.maxPerAddress().number(),
            ',"perCollection":',
            collection.maxPerCollection().number(),
            ',"pageSize":64,"collections":['
        );
        for (uint256 i; i < SOURCE_COUNT; i++) {
            ICollection.Source memory s = collection.collectionData(i);
            uint256 sourceSupply;
            // Nouns grows daily; its mintable range follows the live supply.
            if (i == SOURCE_NOUNS) {
                try ICollection(s.token).totalSupply() returns (uint256 value) {
                    sourceSupply = value;
                } catch {}
            }
            out = abi.encodePacked(
                out,
                i == 0 ? "" : ",",
                '{"id":',
                i.number(),
                ',"token":"',
                JsonValue.addr(s.token),
                '","count":',
                uint256(s.count).number(),
                ',"sourceSupply":',
                sourceSupply.number(),
                ',"open":',
                s.open ? "true" : "false",
                "}"
            );
        }
        return abi.encodePacked(out, "]}");
    }

    /// @notice `documents`: the manifesto text and each source's CC0 proof reference.
    function documents() public view returns (bytes memory) {
        bytes[] memory parts = new bytes[](SOURCE_COUNT + 2);
        parts[0] = abi.encodePacked(
            '{"version":1,"chainId":',
            block.chainid.number(),
            ',"head":',
            block.number.number(),
            ',"collection":"',
            JsonValue.addr(address(collection)),
            '","manifesto":',
            JsonValue.quote(collection.manifesto()),
            ',"collections":['
        );
        for (uint256 i; i < SOURCE_COUNT; i++) {
            ICollection.Source memory s = collection.collectionData(i);
            parts[i + 1] = abi.encodePacked(
                i == 0 ? "" : ",",
                '{"id":',
                i.number(),
                ',"token":"',
                JsonValue.addr(s.token),
                '","name":',
                JsonValue.quote(s.name),
                ',"proof":',
                JsonValue.quote(s.proof),
                "}"
            );
        }
        parts[SOURCE_COUNT + 1] = bytes("]}");
        return JsonValue.join(parts);
    }

    /// @notice `recent`: the newest `RECENT_COUNT` cc0pies with their metadata URIs.
    function recent() public view returns (bytes memory) {
        uint256 supply = collection.totalSupply();
        uint256 count = supply < RECENT_COUNT ? supply : RECENT_COUNT;
        bytes[] memory parts = new bytes[](count + 2);
        parts[0] = abi.encodePacked(
            '{"head":',
            block.number.number(),
            ',"tokens":['
        );
        for (uint256 i; i < count; i++) {
            uint256 id = collection.tokenByIndex(supply - 1 - i);
            string memory uri;
            // Nouns and Moonbirds copies render in the browser from on-chain
            // art; their tokenURI cannot complete in any read budget.
            if (!_browserRendered(id))
                try collection.tokenURI{gas: RECENT_URI_GAS}(id) returns (
                    string memory value
                ) {
                    if (bytes(value).length <= MAX_URI_BYTES) uri = value;
                } catch {}
            parts[i + 1] = abi.encodePacked(
                i == 0 ? "" : ",",
                '{"id":"',
                id.number(),
                '","metadataUri":',
                JsonValue.quote(uri),
                ',"imageUri":',
                JsonValue.quote(
                    _canonicalImageUri(id / TOKEN_ID_RADIX, id % TOKEN_ID_RADIX)
                ),
                "}"
            );
        }
        parts[count + 1] = bytes("]}");
        return JsonValue.join(parts);
    }

    // ---- paged fields --------------------------------------------------------

    /// @notice `page`: 64 cc0py tokens with owner, revision and listing state.
    function tokens(uint256 page) public view returns (bytes memory) {
        require(page < MAX_COPY_PAGES, "Page limit");
        uint256 start = page * PAGE_SIZE;
        uint256 end = start + PAGE_SIZE;
        uint256 supply = collection.totalSupply();
        if (end > supply) end = supply;
        bytes[] memory parts = new bytes[]((end > start ? end - start : 0) + 2);
        parts[0] = abi.encodePacked(
            '{"page":',
            page.number(),
            ',"head":',
            block.number.number(),
            ',"timestamp":',
            block.timestamp.number(),
            ',"tokens":['
        );
        for (uint256 i = start; i < end; i++) {
            uint256 id = collection.tokenByIndex(i);
            address owner = collection.ownerOf(id);
            (
                ResolverListings.Listing memory l,
                bool isActive,
                bool isClosed
            ) = registry.listing(id);
            bytes memory row = abi.encodePacked(
                i == start ? "" : ",",
                '{"id":"',
                id.number(),
                '","owner":"',
                JsonValue.addr(owner),
                '","revision":"',
                registry.revisions(id).number(),
                '","listing":'
            );
            if (l.hash == 0)
                parts[i - start + 1] = abi.encodePacked(row, "null}");
            else
                parts[i - start + 1] = abi.encodePacked(
                    row,
                    '{"seller":"',
                    JsonValue.addr(l.seller),
                    '","price":"',
                    l.price.number(),
                    '","start":"',
                    l.start.number(),
                    '","end":"',
                    l.end.number(),
                    '","salt":"',
                    l.salt.number(),
                    '","counter":"',
                    l.counter.number(),
                    '","hash":"',
                    JsonValue.hexValue(abi.encodePacked(l.hash)),
                    '","revision":"',
                    l.revision.number(),
                    '","active":',
                    isActive ? "true" : "false",
                    ',"closed":',
                    isClosed ? "true" : "false",
                    "}}"
                );
        }
        parts[parts.length - 1] = bytes("]}");
        return JsonValue.join(parts);
    }

    /// @notice `art`: 64 cc0py tokens with the current cc0py `tokenURI` (empty
    /// for browser-rendered sources) and XCOPY's canonical image CID.
    function artwork(uint256 page) public view returns (bytes memory) {
        require(page < MAX_COPY_PAGES, "Artwork page limit");
        uint256 start = page * PAGE_SIZE;
        uint256 end = start + PAGE_SIZE;
        uint256 supply = collection.totalSupply();
        if (end > supply) end = supply;
        bytes[] memory parts = new bytes[]((end > start ? end - start : 0) + 2);
        parts[0] = abi.encodePacked(
            '{"head":',
            block.number.number(),
            ',"page":',
            page.number(),
            ',"tokens":['
        );
        for (uint256 i = start; i < end; i++) {
            uint256 id = collection.tokenByIndex(i);
            parts[i - start + 1] = abi.encodePacked(
                i == start ? "" : ",",
                '{"id":"',
                id.number(),
                '","metadataUri":',
                JsonValue.quote(
                    _browserRendered(id)
                        ? ""
                        : _metadataUri(address(collection), id)
                ),
                ',"imageUri":',
                JsonValue.quote(
                    _canonicalImageUri(id / TOKEN_ID_RADIX, id % TOKEN_ID_RADIX)
                ),
                "}"
            );
        }
        parts[parts.length - 1] = bytes("]}");
        return JsonValue.join(parts);
    }

    /// @notice `s<n>`: 128 original tokens of source `n`, in the manifesto's
    /// ID order. Rows carry the exact `tokenURI` result, or for Nouns and
    /// Moonbirds the per-token inputs of the browser renderer. Beyond the
    /// source's range a page is empty, never a revert.
    function sourceArtwork(
        uint256 sourceId,
        uint256 page
    ) public view returns (bytes memory) {
        require(sourceId < SOURCE_COUNT, "Invalid source");
        ICollection.Source memory source = collection.collectionData(sourceId);
        uint256 count = _sourceCount(sourceId, source.token);
        uint256 start = page * SOURCE_PAGE_SIZE;
        uint256 end = start + SOURCE_PAGE_SIZE;
        if (end > count) end = count;
        bytes[] memory parts = new bytes[]((end > start ? end - start : 0) + 2);
        parts[0] = abi.encodePacked(
            '{"head":',
            block.number.number(),
            ',"source":',
            sourceId.number(),
            ',"page":',
            page.number(),
            ',"tokens":['
        );
        for (uint256 i = start; i < end; i++) {
            uint256 id = _sourceTokenId(sourceId, i);
            if (sourceId == SOURCE_NOUNS || sourceId == SOURCE_MOONBIRDS)
                parts[i - start + 1] = abi.encodePacked(
                    i == start ? "" : ",",
                    '{"id":"',
                    id.number(),
                    '","metadataUri":"","imageUri":"",',
                    sourceId == SOURCE_NOUNS ? _nounRow(id) : _moonbirdRow(id),
                    "}"
                );
            else
                parts[i - start + 1] = abi.encodePacked(
                    i == start ? "" : ",",
                    '{"id":"',
                    id.number(),
                    '","metadataUri":',
                    JsonValue.quote(_metadataUri(source.token, id)),
                    ',"imageUri":',
                    JsonValue.quote(_canonicalImageUri(sourceId, id)),
                    "}"
                );
        }
        parts[parts.length - 1] = bytes("]}");
        return JsonValue.join(parts);
    }

    // ---- source ranges (from the manifesto) ---------------------------------

    /// @dev Number of original tokens per source. Nouns follows its live supply;
    /// the others are the manifesto's fixed ranges: XCOPY 50 listed tokens,
    /// Moonbirds 0–9999, Grifters 0–665, CryptoDickbutts 160–5360 (5201),
    /// CrypToadz 1–6969 plus 56 one-of-ones (7025), goblintown 0–9998, mfers 0–10020.
    function _sourceCount(
        uint256 sourceId,
        address token
    ) internal view returns (uint256) {
        if (sourceId == SOURCE_NOUNS) return ICollection(token).totalSupply();
        if (sourceId == SOURCE_XCOPY) return 50;
        if (sourceId == SOURCE_MOONBIRDS) return 10000;
        if (sourceId == 3) return 666;
        if (sourceId == 4) return 5201;
        if (sourceId == 5) return 7025;
        if (sourceId == 6) return 9999;
        return 10021;
    }

    /// @dev Ordinal `i` within a source → that source's original token ID.
    /// XCOPY's 50 tokens are three editions (10 + 20 + 20); CryptoDickbutts
    /// start at 160; CrypToadz are 1–6969 then 1M, 2M, … 56M.
    function _sourceTokenId(
        uint256 sourceId,
        uint256 i
    ) internal pure returns (uint256) {
        if (sourceId == SOURCE_XCOPY)
            return
                i < 10
                    ? 4300010001 + i
                    : i < 30
                        ? 4300020001 + i - 10
                        : 4300030001 + i - 30;
        if (sourceId == 4) return i + 160;
        if (sourceId == 5) return i < 6969 ? i + 1 : (i - 6969 + 1) * 1000000;
        return i;
    }

    // ---- per-token helpers ------------------------------------------------------

    /// @dev Nouns and Moonbirds artwork is composed in the browser from
    /// `OriginalArtData` bundles; their `tokenURI` is never called.
    function _browserRendered(uint256 id) internal pure returns (bool) {
        uint256 source = id / TOKEN_ID_RADIX;
        return source == SOURCE_NOUNS || source == SOURCE_MOONBIRDS;
    }

    /// @dev A source `tokenURI` under a gas cap and a length ceiling. Heavy or
    /// reverting renderers yield an empty URI (the UI explains); artwork is
    /// never substituted.
    function _metadataUri(
        address token,
        uint256 id
    ) internal view returns (string memory uri) {
        try ICollection(token).tokenURI{gas: SOURCE_URI_GAS}(id) returns (
            string memory value
        ) {
            if (bytes(value).length <= MAX_URI_BYTES) uri = value;
        } catch {}
    }

    /// @dev Nouns row: the five seed indices the browser renderer needs.
    function _nounRow(uint256 id) internal view returns (bytes memory) {
        (bool exists, uint48[5] memory s) = originalArt.nounSeeds(id);
        if (!exists) return bytes('"seeds":null');
        return
            abi.encodePacked(
                '"seeds":[',
                uint256(s[0]).number(),
                ",",
                uint256(s[1]).number(),
                ",",
                uint256(s[2]).number(),
                ",",
                uint256(s[3]).number(),
                ",",
                uint256(s[4]).number(),
                "]"
            );
    }

    /// @dev Moonbirds row: user-overridden features (or null for the bucket
    /// defaults) and the active background from PROOF's registries.
    function _moonbirdRow(uint256 id) internal view returns (bytes memory) {
        (
            bool ok,
            bool overridden,
            MoonbirdFeatures memory f,
            uint96 background
        ) = originalArt.moonbirdState(id);
        if (!ok) return bytes('"features":null,"background":null');
        bytes memory features =
            overridden
                ? abi.encodePacked(
                    "[",
                    uint256(f.background).number(),
                    ",",
                    uint256(f.beak).number(),
                    ",",
                    uint256(f.body).number(),
                    ",",
                    uint256(f.eyes).number(),
                    ",",
                    uint256(f.eyewear).number(),
                    ",",
                    uint256(f.headwear).number(),
                    ",",
                    uint256(f.outerwear).number(),
                    "]"
                )
                : bytes("null");
        return
            abi.encodePacked(
                '"features":',
                features,
                ',"background":',
                uint256(background).number()
            );
    }

    /// @dev XCOPY only: `ipfs://<CIDv0>` from the original contract's
    /// `tokenIPFSHash`, so the browser can load the image through a gateway.
    function _canonicalImageUri(
        uint256 sourceId,
        uint256 id
    ) internal view returns (string memory) {
        if (sourceId != SOURCE_XCOPY) return "";
        ICollection.Source memory source = collection.collectionData(
            SOURCE_XCOPY
        );
        try
            ICanonicalArtwork(source.token).tokenIPFSHash{
                gas: CANONICAL_IMAGE_GAS
            }(id)
        returns (string memory cid) {
            bytes memory value = bytes(cid);
            if (value.length == 46 && value[0] == "Q" && value[1] == "m")
                return string.concat("ipfs://", cid);
        } catch {}
        return "";
    }
}

ICollection.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.38;

/// @title The original cc0py collection, as read by the marketplace contracts.
/// @notice Only the views used here. `collectionData(i)` describes source
/// collection `i` (0 Nouns … 7 mfers) as recorded in the manifesto; a cc0py
/// token ID is `sourceId * 1e12 + originalTokenId`.
interface ICollection {
    struct Source {
        address token;
        string name;
        string proof;
        uint128 count;
        uint64 testMints;
        bool open;
    }
    function totalSupply() external view returns (uint256);
    function maxNFTs() external view returns (uint256);
    function maxPerCollection() external view returns (uint256);
    function maxPerAddress() external view returns (uint256);
    function manifesto() external view returns (string memory);
    function collectionData(uint256) external view returns (Source memory);
    function tokenByIndex(uint256) external view returns (uint256);
    function tokenURI(uint256) external view returns (string memory);
    function ownerOf(uint256) external view returns (address);
    function getApproved(uint256) external view returns (address);
    function isApprovedForAll(address, address) external view returns (bool);
}

/// @notice XCOPY's original contract publishes each token's image CID
/// separately from `tokenURI`; the reader uses it so the browser can load the
/// image from an IPFS gateway instead of the metadata host (no CORS there).
interface ICanonicalArtwork {
    function tokenIPFSHash(
        uint256 tokenId
    ) external view returns (string memory);
}

JsonValue.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.38;

/// @title Minimal JSON building blocks for resolver responses.
/// @notice Pure helpers: decimal numbers, 0x-hex, addresses, and strings
/// escaped per RFC 8259 (quotes, backslashes and control characters). No
/// parsing, no unicode normalisation — values are emitted, never read back.
library JsonValue {
    /// @notice Concatenate parts into one allocation.
    /// @dev Repeated `abi.encodePacked` on a growing page is quadratic in
    /// copying and memory expansion; this computes the total once.
    function join(
        bytes[] memory parts
    ) internal pure returns (bytes memory out) {
        uint256 length;
        for (uint256 i; i < parts.length; i++) length += parts[i].length;
        out = new bytes(length);
        uint256 cursor;
        for (uint256 i; i < parts.length; i++) {
            bytes memory part = parts[i];
            assembly ("memory-safe") {
                mcopy(add(add(out, 32), cursor), add(part, 32), mload(part))
            }
            cursor += part.length;
        }
    }
    /// @notice Unsigned decimal without leading zeros.
    function number(uint256 v) internal pure returns (string memory) {
        if (v == 0) return "0";
        uint256 n = v;
        uint256 len;
        while (n != 0) {
            len++;
            n /= 10;
        }
        bytes memory s = new bytes(len);
        while (v != 0) {
            s[--len] = bytes1(uint8(48 + (v % 10)));
            v /= 10;
        }
        return string(s);
    }
    /// @notice Lower-case `0x…` hex of arbitrary bytes.
    function hexValue(
        bytes memory input
    ) internal pure returns (string memory) {
        bytes memory chars = "0123456789abcdef";
        bytes memory out = new bytes(input.length * 2 + 2);
        out[0] = "0";
        out[1] = "x";
        for (uint256 i; i < input.length; i++) {
            out[2 + i * 2] = chars[uint8(input[i]) >> 4];
            out[3 + i * 2] = chars[uint8(input[i]) & 15];
        }
        return string(out);
    }
    /// @notice Lower-case hex address (no checksum; consumers compare case-insensitively).
    function addr(address v) internal pure returns (string memory) {
        return hexValue(abi.encodePacked(v));
    }
    /// @notice A double-quoted JSON string with `"`, `\` and control
    /// characters escaped. Bytes >= 0x20 pass through unchanged (UTF-8 is
    /// valid JSON as-is).
    function quote(
        string memory value
    ) internal pure returns (bytes memory out) {
        bytes memory input = bytes(value);
        // Worst case: every byte becomes a 6-byte \u00XX escape, plus quotes.
        out = new bytes(input.length * 6 + 2);
        uint256 cursor = 1;
        out[0] = '"';
        bytes memory hexChars = "0123456789abcdef";
        for (uint256 i; i < input.length; i++) {
            uint8 c = uint8(input[i]);
            if (c == 34 || c == 92) {
                out[cursor++] = bytes1(uint8(92));
                out[cursor++] = input[i];
            } else if (c < 32) {
                out[cursor++] = bytes1(uint8(92));
                out[cursor++] = "u";
                out[cursor++] = "0";
                out[cursor++] = "0";
                out[cursor++] = hexChars[c >> 4];
                out[cursor++] = hexChars[c & 15];
            } else out[cursor++] = input[i];
        }
        out[cursor++] = '"';
        assembly ("memory-safe") {
            mstore(out, cursor)
        }
    }
}

OriginalArt.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.38;

/// @title Raw on-chain art data behind Nouns and Moonbirds.
/// @notice Their tokenURI() cannot be evaluated inside any resolver read
/// budget (Nouns ≈ 120M gas, Moonbirds ≈ 343M). This contract instead serves
/// the compressed art bytes as two ABX fields ("nounsart", "mbart") and the
/// per-token inputs (seeds; feature overrides and background), and the browser
/// composes the images itself. A fork test compares that output byte for byte
/// with the original renderers' tokenURI()/artworkPixels() under a 500M budget.
/// @dev Every address read here is fixed (see the pure getters): the data
/// behind them is permanent since Cancun (EIP-6780), and the mutable pointers
/// the original projects expose (Nouns' descriptor, Moonbirds' rendering
/// contract) are deliberately not followed. `npm run verify:upstream`
/// reports drift between these constants and the live pointers.

interface INouns {
    function descriptor() external view returns (address);
    function seeds(
        uint256
    ) external view returns (uint48, uint48, uint48, uint48, uint48);
    function ownerOf(uint256) external view returns (address);
}
interface INounsArt {
    struct NounArtStoragePage {
        uint16 imageCount;
        uint80 decompressedLength;
        address pointer;
    }
    struct Trait {
        NounArtStoragePage[] storagePages;
        uint256 storedImagesCount;
    }
    function getBodiesTrait() external view returns (Trait memory);
    function getAccessoriesTrait() external view returns (Trait memory);
    function getHeadsTrait() external view returns (Trait memory);
    function getGlassesTrait() external view returns (Trait memory);
    function palettes(uint8) external view returns (bytes memory);
    function backgrounds(uint256) external view returns (string memory);
    function backgroundCount() external view returns (uint256);
}
interface IBucketStorage {
    struct Compressed {
        uint256 uncompressedSize;
        bytes data;
    }
    function getBucket(uint256) external pure returns (Compressed memory);
    function numBuckets() external pure returns (uint256);
}
struct MoonbirdFeatures {
    uint8 background;
    uint8 beak;
    uint8 body;
    uint8 eyes;
    uint8 eyewear;
    uint8 headwear;
    uint8 outerwear;
}
interface IMoonbirds {
    function renderingContract() external view returns (address);
}
interface IFeaturesProvider {
    function hasFeatures(uint256) external view returns (bool);
    function getFeatures(
        uint256
    ) external view returns (MoonbirdFeatures memory);
}
interface IBackgroundRegistry {
    function getActiveBackground(uint256) external view returns (uint96);
}

library ArtBundle {
    // Container: "CC0PYART", version 1, kind, u32 entry count, then entries of
    // u8 tag, u32 a, u32 b, u32 length, bytes. Tags are documented per kind.
    function entry(
        uint8 tag,
        uint32 a,
        uint32 b,
        bytes memory data
    ) internal pure returns (bytes memory) {
        return abi.encodePacked(tag, a, b, uint32(data.length), data);
    }
    function pack(
        uint8 kind,
        bytes[] memory entries
    ) internal pure returns (bytes memory out) {
        uint256 length = 14;
        for (uint256 i; i < entries.length; i++) length += entries[i].length;
        out = new bytes(length);
        bytes memory head = abi.encodePacked(
            "CC0PYART",
            uint8(1),
            kind,
            uint32(entries.length)
        );
        uint256 cursor;
        assembly ("memory-safe") {
            mcopy(add(out, 32), add(head, 32), 14)
        }
        cursor = 14;
        for (uint256 i; i < entries.length; i++) {
            bytes memory part = entries[i];
            assembly ("memory-safe") {
                mcopy(add(add(out, 32), cursor), add(part, 32), mload(part))
            }
            cursor += part.length;
        }
    }
    // SSTORE2 data: the contract code minus its leading STOP byte.
    function sstore2(
        address pointer
    ) internal view returns (bytes memory data) {
        uint256 size = pointer.code.length;
        if (size == 0) return data;
        assembly ("memory-safe") {
            data := mload(0x40)
            let len := sub(size, 1)
            mstore(data, len)
            extcodecopy(pointer, add(data, 32), 1, len)
            mstore(0x40, add(add(data, 32), and(add(len, 31), not(31))))
        }
    }
}

contract OriginalArtData {
    /// @notice The Nouns token (seeds, existence).
    INouns public immutable nouns;
    /// @notice The Moonbirds token; recorded for provenance, not read.
    IMoonbirds public immutable moonbirds;
    /// @dev Gas allowed for the user-override registry's reads (storage lookups).
    uint256 internal constant FEATURES_GAS = 100_000;
    /// @dev Gas allowed for the background registry's `getActiveBackground`.
    uint256 internal constant BACKGROUND_GAS = 500_000;
    // The in-chain Moonbirds art lives in immutable, pure bucket-storage
    // contracts. Their managers keep the addresses in private storage with no
    // getters, so they are fixed here; a fork test reads those private slots
    // and checks that every address below still matches.
    function layerStorage(uint256 i) public pure returns (address) {
        if (i == 0) return 0x39376eb7EA01398E8109fC0f7e8B48C888F2c435;
        if (i == 1) return 0x92b25103Cb72777453DA669F5c18C0B984ecE509;
        return 0xcC77E1776A151E23c7A129FDC77FE4367928a178;
    }
    function featureStorage(uint256 i) public pure returns (address) {
        if (i == 0) return 0x938F34aF000c494D65146E7Ab9822cf1659C0BD0;
        return 0x22A02bb3ff3E978e566672262168D4e1858B2B0e;
    }
    function traitStorage() public pure returns (address) {
        return 0xe64bE8D4D986Ab3393b8546a858F011BB12D87F7;
    }
    // ExtraBackgroundsStorageManager's bundle is owner-extensible; these are
    // the storages registered at the fork block.
    function backgroundStorage(uint256 i) public pure returns (address) {
        if (i == 0) return 0x5622e9C7b51dAde55f059230dCcB09f72F0C681B;
        if (i == 1) return 0x1600965eEcE63B2f644461f7Af369407745E4f50;
        if (i == 2) return 0xa532f7444226e0d794786558Ab5aDef4e842144A;
        if (i == 3) return 0x63759fEc0948379Fb30FD2657d24694100eB039F;
        return 0xFEFDb7d50CDB8ae5c92badc51337C5c13287AA76;
    }
    constructor(address nounsToken, address moonbirdsToken) {
        nouns = INouns(nounsToken);
        moonbirds = IMoonbirds(moonbirdsToken);
    }
    /// @notice ABX entry point: "nounsart" and "mbart" are binary bundles
    /// (see `ArtBundle`); other fields answer a JSON error.
    function render(
        address,
        uint256,
        bytes32 field
    ) external view returns (string memory, bytes memory) {
        if (field == bytes32("nounsart"))
            return ("application/octet-stream", nounsArt());
        if (field == bytes32("mbart"))
            return ("application/octet-stream", moonbirdsArt());
        return ("application/json", bytes('{"error":"Unknown field"}'));
    }
    // Tags: 1 palette (a = palette index); 2 background (a = index, ASCII hex
    // colour); 3 bodies, 4 accessories, 5 heads, 6 glasses pages
    // (a = imageCount, b = decompressedLength; raw-deflate bytes[] pages).
    /// The Nouns art contract that holds the palette, backgrounds and the
    /// SSTORE2 trait pages. Read directly rather than through
    /// nouns.descriptor().art(): the descriptor pointer can be swapped by the
    /// DAO, while the data behind this address is permanent (post-Cancun code
    /// cannot be destroyed) and only grows as traits are added.
    function nounsArtStorage() public pure returns (INounsArt) {
        return INounsArt(0x6544bC8A0dE6ECe429F14840BA74611cA5098A92);
    }
    function nounsArt() public view returns (bytes memory) {
        INounsArt art = nounsArtStorage();
        INounsArt.Trait[4] memory traits = [
            art.getBodiesTrait(),
            art.getAccessoriesTrait(),
            art.getHeadsTrait(),
            art.getGlassesTrait()
        ];
        uint256 backgroundCount = art.backgroundCount();
        uint256 pages;
        for (uint256 t; t < 4; t++) pages += traits[t].storagePages.length;
        bytes[] memory entries = new bytes[](1 + backgroundCount + pages);
        uint256 n;
        entries[n++] = ArtBundle.entry(1, 0, 0, art.palettes(0));
        for (uint256 i; i < backgroundCount; i++)
            entries[n++] = ArtBundle.entry(
                2,
                uint32(i),
                0,
                bytes(art.backgrounds(i))
            );
        for (uint256 t; t < 4; t++) {
            INounsArt.NounArtStoragePage[] memory storagePages = traits[t]
                .storagePages;
            for (uint256 i; i < storagePages.length; i++)
                entries[n++] = ArtBundle.entry(
                    uint8(3 + t),
                    storagePages[i].imageCount,
                    uint32(storagePages[i].decompressedLength),
                    ArtBundle.sstore2(storagePages[i].pointer)
                );
        }
        return ArtBundle.pack(0, entries);
    }
    // Tags: 10-12 layer storages, 20-21 feature storages, 30 trait names,
    // 40-44 extra background storages (a = bucket index, b = inflated size;
    // raw-deflate buckets in PROOF's solidify format).
    function moonbirdsArt() public view returns (bytes memory) {
        bytes[][] memory groups = new bytes[][](11);
        uint256 total;
        for (uint256 i; i < 3; i++) {
            groups[i] = buckets(10 + i, layerStorage(i));
            total += groups[i].length;
        }
        for (uint256 i; i < 2; i++) {
            groups[3 + i] = buckets(20 + i, featureStorage(i));
            total += groups[3 + i].length;
        }
        groups[5] = buckets(30, traitStorage());
        total += groups[5].length;
        for (uint256 i; i < 5; i++) {
            groups[6 + i] = buckets(40 + i, backgroundStorage(i));
            total += groups[6 + i].length;
        }
        bytes[] memory entries = new bytes[](total);
        uint256 n;
        for (uint256 g; g < groups.length; g++)
            for (uint256 i; i < groups[g].length; i++)
                entries[n++] = groups[g][i];
        return ArtBundle.pack(2, entries);
    }
    function buckets(
        uint256 tag,
        address storageContract
    ) internal view returns (bytes[] memory entries) {
        IBucketStorage store = IBucketStorage(storageContract);
        uint256 count = store.numBuckets();
        entries = new bytes[](count);
        for (uint256 i; i < count; i++) {
            IBucketStorage.Compressed memory bucket = store.getBucket(i);
            entries[i] = ArtBundle.entry(
                uint8(tag),
                uint32(i),
                uint32(bucket.uncompressedSize),
                bucket.data
            );
        }
    }
    // Per-token inputs the browser cannot derive from the static bundles.
    /// @notice Whether a Noun exists and its five seed indices (background,
    /// body, accessory, head, glasses) for the browser renderer.
    function nounSeeds(
        uint256 id
    ) external view returns (bool exists, uint48[5] memory seeds) {
        try nouns.ownerOf(id) returns (address owner) {
            exists = owner != address(0);
        } catch {}
        if (!exists) return (exists, seeds);
        (seeds[0], seeds[1], seeds[2], seeds[3], seeds[4]) = nouns.seeds(id);
    }
    /// Moonbirds per-token state registries, fixed at the addresses PROOF's
    /// in-chain renderer used when this was verified (user feature overrides
    /// and active backgrounds). Reading them directly avoids the mutable
    /// renderingContract() -> legacyRenderer() pointer chain; the pixel data
    /// itself comes from the permanent bucket storages above.
    function userRegistry() public pure returns (IFeaturesProvider) {
        return IFeaturesProvider(0xF8D83845DEb59EE43CF012e57731209A472baF8c);
    }
    function backgroundRegistry() public pure returns (IBackgroundRegistry) {
        return IBackgroundRegistry(0xB7f6618F9E20fb56d5337000a90e540F4005c696);
    }
    /// @notice Per-token renderer inputs: user-overridden features (if any)
    /// and the active background, read from PROOF's fixed registries.
    /// @return ok false if a registry call failed (the UI shows no artwork
    /// rather than a guess); overridden whether `features` apply.
    function moonbirdState(
        uint256 id
    )
        external
        view
        returns (
            bool ok,
            bool overridden,
            MoonbirdFeatures memory features,
            uint96 background
        )
    {
        try userRegistry().hasFeatures{gas: FEATURES_GAS}(id) returns (
            bool has
        ) {
            if (has) {
                features = userRegistry().getFeatures(id);
                overridden = true;
            }
        } catch {
            return (false, false, features, 0);
        }
        try
            backgroundRegistry().getActiveBackground{gas: BACKGROUND_GAS}(id)
        returns (uint96 value) {
            background = value;
        } catch {
            return (false, overridden, features, 0);
        }
        ok = true;
    }
}

ResolverListings.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.38;

import {
    OfferItem,
    ConsiderationItem,
    OrderComponents,
    OrderParameters,
    Order,
    ZoneParameters,
    Schema,
    IMarketZone,
    ISeaport
} from "./Seaport.sol";
import {ICollection} from "./ICollection.sol";

/// @title cc0py listings: an immutable Seaport 1.6 zone and on-chain registry.
/// @notice Sellers publish a signed, FULL_RESTRICTED Seaport order for one
/// cc0py token against native ETH. Publication validates the order on Seaport
/// and records it here in the same transaction, so the ABX resolver can serve
/// every active listing from chain state with no off-chain order book. Only a
/// published, current-revision order can fill: the zone callbacks reject
/// anything else.
/// @dev Trust model:
///  - No owner, no upgrade path, no funds ever held.
///  - `guardian` (immutable) has one power: `disable()`, which permanently
///    stops publication and fulfilment through this zone. It cannot re-enable,
///    alter orders, or move tokens. Owners keep `invalidateListings` and may
///    still cancel on Seaport.
///  - A token owner can invalidate every signed attempt for their token by
///    bumping its revision; orders carry the revision in `zoneHash`.
///  - `publishing` guards against re-entrancy during `seaport.validate`, which
///    runs external code (ERC-1271 signers).
contract ResolverListings is IMarketZone {
    /// @notice A registered listing. `revision` ties it to the owner's
    /// invalidation counter; `hash` is the Seaport order hash.
    struct Listing {
        address seller;
        uint256 price;
        uint256 start;
        uint256 end;
        uint256 salt;
        uint256 counter;
        bytes32 hash;
        uint256 revision;
    }

    /// @dev Seaport `OrderType.FULL_RESTRICTED`: only this zone may approve fills.
    uint8 internal constant ORDER_TYPE_FULL_RESTRICTED = 2;
    /// @dev Seaport `ItemType.NATIVE` and `ItemType.ERC721`.
    uint8 internal constant ITEM_NATIVE = 0;
    uint8 internal constant ITEM_ERC721 = 2;
    /// @dev ERC-165 `supportsInterface` selector.
    bytes4 internal constant ERC165_ID = 0x01ffc9a7;

    ICollection public immutable collection;
    ISeaport public immutable seaport;
    /// @notice The only privileged address; see `disable()`.
    address public immutable guardian;
    /// @notice Set once by the guardian; never cleared.
    bool public disabled;
    /// @notice Current listing per cc0py token ID (zero-valued when none).
    mapping(uint256 => Listing) public listings;
    /// @notice Owner invalidation counter per token; the next listing must use `revision + 1`.
    mapping(uint256 => uint256) public revisions;
    bool private publishing;

    event Registered(
        uint256 indexed tokenId,
        bytes32 indexed hash,
        address indexed seller
    );
    event Invalidated(
        uint256 indexed tokenId,
        address indexed owner,
        uint256 revision
    );
    event Disabled(address indexed guardian);

    /// @param nft The cc0py collection.
    /// @param market Seaport 1.6.
    /// @param emergencyGuardian Holder of the one-way emergency stop.
    constructor(address nft, address market, address emergencyGuardian) {
        require(emergencyGuardian != address(0), "Guardian required");
        collection = ICollection(nft);
        seaport = ISeaport(market);
        guardian = emergencyGuardian;
    }

    // ---- guardian --------------------------------------------------------

    /// @notice Permanently stop publication and fulfilment through this zone.
    /// @dev Idempotent. Nothing can undo it; a new deployment is the only way
    /// to resume trading, and existing registered orders become unfillable.
    function disable() external {
        require(msg.sender == guardian, "Only guardian");
        if (!disabled) {
            disabled = true;
            emit Disabled(msg.sender);
        }
    }

    // ---- owner -------------------------------------------------------------

    /// @notice Invalidate every listing and every signed-but-unpublished order
    /// for a token the caller owns, by advancing its revision.
    /// @dev Needs no saved order or signature. Works after `disable()`, so
    /// owners can always clean up.
    function invalidateListings(uint256 id) external {
        require(!publishing, "Reentrant publication");
        require(collection.ownerOf(id) == msg.sender, "Not token owner");
        uint256 revision = ++revisions[id];
        delete listings[id];
        emit Invalidated(id, msg.sender, revision);
    }

    // ---- views -------------------------------------------------------------

    /// @notice Whether a listing can never fill again (expired, cancelled,
    /// filled, counter bumped, or the zone is disabled).
    function closed(Listing memory l) public view returns (bool) {
        if (
            disabled ||
            l.seller == address(0) ||
            block.timestamp >= l.end ||
            seaport.getCounter(l.seller) != l.counter
        ) return true;
        (, bool cancelled, uint256 filled, uint256 size) = seaport
            .getOrderStatus(l.hash);
        return cancelled || (size != 0 && filled >= size);
    }

    /// @notice Whether a listing is fillable right now: in its time window,
    /// still owned by the seller, validated and unfilled on Seaport, and the
    /// token approved to Seaport.
    function active(
        uint256 id,
        Listing memory l,
        address owner
    ) public view returns (bool) {
        if (
            disabled ||
            l.seller == address(0) ||
            l.seller != owner ||
            block.timestamp < l.start ||
            block.timestamp >= l.end
        ) return false;
        if (seaport.getCounter(l.seller) != l.counter) return false;
        (bool validated, bool cancelled, uint256 filled, uint256 size) = seaport
            .getOrderStatus(l.hash);
        if (!validated || cancelled || (size != 0 && filled >= size))
            return false;
        return
            collection.getApproved(id) == address(seaport) ||
            collection.isApprovedForAll(l.seller, address(seaport));
    }

    /// @notice The registered listing for a token with its live status.
    function listing(
        uint256 id
    ) external view returns (Listing memory l, bool isActive, bool isClosed) {
        l = listings[id];
        isActive = active(id, l, collection.ownerOf(id));
        isClosed = closed(l);
    }

    // ---- publication -------------------------------------------------------

    /// @notice Validate a signed order on Seaport and register it here, atomically.
    /// @dev Accepted shape: one ERC-721 from this collection for one native-ETH
    /// consideration paid to the seller, FULL_RESTRICTED, zone = this, no
    /// conduit, `zoneHash` = the token's next revision. Re-publishing the
    /// identical order is a safe no-op (idempotent retry of an uncertain
    /// transaction). A still-active different listing must be cancelled or
    /// invalidated first.
    function publish(
        OrderComponents calldata o,
        bytes calldata signature
    ) external {
        require(!disabled, "Marketplace disabled");
        require(!publishing, "Reentrant publication");
        publishing = true;
        require(
            o.offerer == msg.sender &&
                o.zone == address(this) &&
                o.orderType == ORDER_TYPE_FULL_RESTRICTED &&
                o.conduitKey == bytes32(0),
            "Unsupported seller/order"
        );
        require(
            o.offer.length == 1 && o.consideration.length == 1,
            "One NFT for ETH"
        );
        OfferItem calldata a = o.offer[0];
        ConsiderationItem calldata b = o.consideration[0];
        require(
            a.itemType == ITEM_ERC721 &&
                a.token == address(collection) &&
                a.startAmount == 1 &&
                a.endAmount == 1,
            "Wrong NFT"
        );
        require(
            b.itemType == ITEM_NATIVE &&
                b.token == address(0) &&
                b.identifierOrCriteria == 0 &&
                b.startAmount > 0 &&
                b.startAmount == b.endAmount &&
                b.recipient == msg.sender,
            "Wrong payment"
        );
        uint256 id = a.identifierOrCriteria;
        address owner = collection.ownerOf(id);
        require(owner == msg.sender, "Not token owner");
        bytes32 hash = seaport.getOrderHash(o);
        Listing memory previous = listings[id];
        // Retrying an uncertain transaction with the identical order is safe.
        if (previous.hash == hash) {
            require(active(id, previous, owner), "Order no longer active");
            publishing = false;
            return;
        }
        require(!active(id, previous, owner), "Cancel previous listing first");
        uint256 revision = revisions[id] + 1;
        require(o.zoneHash == bytes32(revision), "Stale listing revision");
        Order[] memory orders = new Order[](1);
        orders[0] = Order(
            OrderParameters(
                o.offerer,
                o.zone,
                o.offer,
                o.consideration,
                o.orderType,
                o.startTime,
                o.endTime,
                o.zoneHash,
                o.salt,
                o.conduitKey,
                1
            ),
            signature
        );
        require(seaport.validate(orders), "Signature validation failed");
        Listing memory next = Listing(
            msg.sender,
            b.startAmount,
            o.startTime,
            o.endTime,
            o.salt,
            o.counter,
            hash,
            revision
        );
        // A failure here rolls back the preceding Seaport validation as well.
        require(active(id, next, owner), "Order not active/approved");
        listings[id] = next;
        revisions[id] = revision;
        publishing = false;
        emit Registered(id, hash, msg.sender);
    }

    // ---- Seaport zone callbacks -------------------------------------------

    /// @dev Shared checks for both callbacks: caller is Seaport, the offered
    /// item is one of this collection's tokens, and the order being filled is
    /// exactly the registered, current-revision listing for that token.
    function _current(
        ZoneParameters calldata z
    ) internal view returns (uint256 id) {
        require(!disabled, "Marketplace disabled");
        require(msg.sender == address(seaport), "Only Seaport");
        require(
            z.offer.length == 1 &&
                z.offer[0].itemType == ITEM_ERC721 &&
                z.offer[0].token == address(collection),
            "Wrong offered NFT"
        );
        id = z.offer[0].identifier;
        Listing memory l = listings[id];
        require(
            l.hash != 0 &&
                l.hash == z.orderHash &&
                l.seller == z.offerer &&
                bytes32(l.revision) == z.zoneHash,
            "Order unpublished or superseded"
        );
    }

    /// @notice Pre-fulfilment check (Seaport 1.6): the seller must still own the token.
    function authorizeOrder(
        ZoneParameters calldata z
    ) external view returns (bytes4) {
        uint256 id = _current(z);
        require(collection.ownerOf(id) == z.offerer, "Owner changed");
        return this.authorizeOrder.selector;
    }

    /// @notice Post-fulfilment check: ownership and fill status have changed by
    /// now, so only the registration is re-checked.
    function validateOrder(
        ZoneParameters calldata z
    ) external view returns (bytes4) {
        _current(z);
        return this.validateOrder.selector;
    }

    /// @notice SIP-5 metadata.
    function getSeaportMetadata()
        external
        pure
        returns (string memory, Schema[] memory)
    {
        return ("cc0py registered listings", new Schema[](0));
    }

    function supportsInterface(bytes4 id) external pure returns (bool) {
        return id == ERC165_ID || id == type(IMarketZone).interfaceId;
    }
}

Seaport.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.38;

/// @title Seaport 1.6 types and the two interfaces this marketplace needs.
/// @notice Mirrors the subset of Seaport's `ConsiderationStructs` used by
/// `ResolverListings`: order components for hashing and validation, and the
/// zone callback parameters. Field order and types must match Seaport exactly;
/// `getOrderHash` is computed by Seaport over these structs.

/// @dev `itemType`: 0 = native ETH, 2 = ERC-721 (Seaport `ItemType`).
struct OfferItem {
    uint8 itemType;
    address token;
    uint256 identifierOrCriteria;
    uint256 startAmount;
    uint256 endAmount;
}
struct ConsiderationItem {
    uint8 itemType;
    address token;
    uint256 identifierOrCriteria;
    uint256 startAmount;
    uint256 endAmount;
    address payable recipient;
}
/// @dev The signed order: `OrderParameters` plus the offerer's Seaport counter.
struct OrderComponents {
    address offerer;
    address zone;
    OfferItem[] offer;
    ConsiderationItem[] consideration;
    uint8 orderType;
    uint256 startTime;
    uint256 endTime;
    bytes32 zoneHash;
    uint256 salt;
    bytes32 conduitKey;
    uint256 counter;
}
struct OrderParameters {
    address offerer;
    address zone;
    OfferItem[] offer;
    ConsiderationItem[] consideration;
    uint8 orderType;
    uint256 startTime;
    uint256 endTime;
    bytes32 zoneHash;
    uint256 salt;
    bytes32 conduitKey;
    uint256 totalOriginalConsiderationItems;
}
struct Order {
    OrderParameters parameters;
    bytes signature;
}
struct SpentItem {
    uint8 itemType;
    address token;
    uint256 identifier;
    uint256 amount;
}
struct ReceivedItem {
    uint8 itemType;
    address token;
    uint256 identifier;
    uint256 amount;
    address payable recipient;
}
/// @dev What Seaport hands a zone before (`authorizeOrder`) and after
/// (`validateOrder`) a restricted order is fulfilled.
struct ZoneParameters {
    bytes32 orderHash;
    address fulfiller;
    address offerer;
    SpentItem[] offer;
    ReceivedItem[] consideration;
    bytes extraData;
    bytes32[] orderHashes;
    uint256 startTime;
    uint256 endTime;
    bytes32 zoneHash;
}
struct Schema {
    uint256 id;
    bytes metadata;
}

/// @notice The Seaport zone interface (SIP-5 metadata included).
interface IMarketZone {
    function authorizeOrder(ZoneParameters calldata) external returns (bytes4);
    function validateOrder(ZoneParameters calldata) external returns (bytes4);
    function getSeaportMetadata()
        external
        view
        returns (string memory, Schema[] memory);
}

/// @notice The Seaport calls the listings zone makes.
interface ISeaport {
    function getOrderHash(
        OrderComponents calldata order
    ) external view returns (bytes32);
    function getCounter(address seller) external view returns (uint256);
    /// @return validated, cancelled, totalFilled, totalSize
    function getOrderStatus(
        bytes32 hash
    ) external view returns (bool, bool, uint256, uint256);
    function validate(Order[] calldata orders) external returns (bool);
}
Compiler settingsShow
{
  "viaIR": true,
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "osaka"
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.