import type { OrderComponents } from "@opensea/seaport-js/lib/types"; import type { Listing, Offer, Order } from "../api/types"; import { type OrderV2 } from "../orders/types"; import { type Amount, type AssetWithTokenId } from "../types"; import type { SDKContext } from "./context"; import type { OrdersManager } from "./orders"; /** * Manager for order fulfillment and validation operations. * Handles fulfilling orders, validating orders onchain, and approving orders. */ export declare class FulfillmentManager { private context; private ordersManager; constructor(context: SDKContext, ordersManager: OrdersManager); /** * Fulfill a private order for a designated address. * The order must have a taker address set (i.e., it is a private listing). */ fulfillPrivateOrder({ order, accountAddress, domain, overrides, }: { order: OrderV2; accountAddress: string; domain?: string; overrides?: Record; }): Promise; /** * Fulfill an order for an asset. The order can be either a listing or an offer. * Uses the OpenSea API to generate fulfillment transaction data and executes it directly. * @param options * @param options.order The order to fulfill, a.k.a. "take" * @param options.accountAddress Address of the wallet taking the offer. * @param options.assetContractAddress Optional address of the NFT contract for criteria offers (e.g., collection offers). Required when fulfilling collection offers. * @param options.tokenId Optional token ID for criteria offers (e.g., collection offers). Required when fulfilling collection offers. * @param options.unitsToFill Optional number of units to fill. Defaults to 1 for both listings and offers. * @param options.recipientAddress Optional recipient address for the NFT when fulfilling a listing. Not applicable for offers. * @param options.includeOptionalCreatorFees Whether to include optional creator fees in the fulfillment. If creator fees are already required, this is a no-op. Defaults to false. * @param options.overrides Transaction overrides, ignored if not set. * @returns Transaction hash of the order. * * @throws Error if the accountAddress is not available through wallet or provider. * @throws Error if the order's protocol address is not supported by OpenSea. See {@link isValidProtocol}. * @throws Error if a signer is not provided (read-only providers cannot fulfill orders). * @throws Error if the order hash is not available. */ fulfillOrder({ order, accountAddress, assetContractAddress, tokenId, unitsToFill, recipientAddress, includeOptionalCreatorFees, overrides, }: { order: OrderV2 | Order | Listing | Offer; accountAddress: string; assetContractAddress?: string; tokenId?: string; unitsToFill?: Amount; recipientAddress?: string; includeOptionalCreatorFees?: boolean; overrides?: Record; }): Promise; /** * Throw an actionable error when the buyer cannot pay for an ERC20-priced * listing, because they hold too little of the payment token or have not * approved the address Seaport pulls it from. * * The check is skipped for native-priced listings, for offer fulfillments, and * for any response shape or RPC read it cannot interpret, so it never blocks a * purchase that would otherwise have succeeded. */ private requireErc20PaymentIsSpendable; /** * Resolve the address that will pull the payment token: Seaport itself when the * fulfiller conduit key is `bytes32(0)`, otherwise the conduit registered for * that key. Returns null when the key cannot be resolved. */ private resolveFulfillerSpender; /** Read the buyer's payment-token balance and allowance for a spender. */ private readErc20SpendState; /** * Returns whether an order is fulfillable. * An order may not be fulfillable if a target item's transfer function * is locked for some reason, e.g. an item is being rented within a game * or trading has been locked for an item type. * @param options * @param options.order Order to check * @param options.accountAddress The account address that will be fulfilling the order * @returns True if the order is fulfillable, else False. * * @throws Error if the order's protocol address is not supported by OpenSea. See {@link isValidProtocol}. */ isOrderFulfillable({ order, accountAddress, }: { order: OrderV2; accountAddress: string; }): Promise; /** * Instead of signing an off-chain order, this method allows you to approve an order * with an onchain transaction. * @param order Order to approve * @param domain An optional domain to be hashed and included at the end of fulfillment calldata. This can be used for onchain order attribution to assist with analytics. * @returns Transaction hash of the approval transaction * * @throws Error if the accountAddress is not available through wallet or provider. * @throws Error if the order's protocol address is not supported by OpenSea. See {@link isValidProtocol}. */ approveOrder(order: OrderV2, domain?: string): Promise; /** * Validates an order onchain using Seaport's validate() method. * * The order is left with an empty signature: Seaport takes the transaction * sender as proof the offerer approved it. This does not post the order to * OpenSea. It becomes discoverable only once OpenSea ingests the resulting * `OrderValidated` event. * * @param orderComponents The order to validate * @param accountAddress Address sending the validate transaction * @param protocolAddress Seaport protocol address the components were built * for. Defaults to {@link DEFAULT_SEAPORT_CONTRACT_ADDRESS}. * @returns Transaction hash of the validate transaction * * @throws Error if the accountAddress is not available through wallet or provider. * @throws Error if the protocol address is not supported by OpenSea. See {@link isValidProtocol}. */ validateOrderOnchain(orderComponents: OrderComponents, accountAddress: string, protocolAddress?: string): Promise; /** * Create a listing and validate it onchain, instead of signing it offchain. * * Runs any token approvals the listing needs, then sends one `validate()` * transaction. The wallet is never asked for an EIP-712 signature, so this * works for contract accounts that cannot produce one. * * Unlike {@link OrdersManager.createListing}, this does not post the listing * to OpenSea. It becomes discoverable only once OpenSea ingests the * `OrderValidated` event, so the returned hash is a transaction hash, not an * order hash. * * @returns Transaction hash of the validate transaction */ createListingAndValidateOnchain({ asset, accountAddress, amount, quantity, domain, salt, listingTime, expirationTime, buyerAddress, includeOptionalCreatorFees, zone, }: { asset: AssetWithTokenId; accountAddress: string; amount: Amount; quantity?: Amount; domain?: string; salt?: Amount; listingTime?: number; expirationTime?: number; buyerAddress?: string; includeOptionalCreatorFees?: boolean; zone?: string; }): Promise; /** * Create an offer and validate it onchain, instead of signing it offchain. * * Runs any token approvals the offer needs, then sends one `validate()` * transaction. The wallet is never asked for an EIP-712 signature, so this * works for contract accounts that cannot produce one. * * Unlike {@link OrdersManager.createOffer}, this does not post the offer to * OpenSea. It becomes discoverable only once OpenSea ingests the * `OrderValidated` event, so the returned hash is a transaction hash, not an * order hash. * * @returns Transaction hash of the validate transaction */ createOfferAndValidateOnchain({ asset, accountAddress, amount, quantity, domain, salt, expirationTime, zone, }: { asset: AssetWithTokenId; accountAddress: string; amount: Amount; quantity?: Amount; domain?: string; salt?: Amount; expirationTime?: Amount; zone?: string; }): Promise; }