import type { OrderComponents } from "@opensea/seaport-js/lib/types"; import type { CollectionOffer, Listing, Offer } from "../api/types"; import type { ProtocolData } from "../orders/types"; import { type Amount, type AssetWithTokenId, OrderSide } from "../types"; import type { SDKContext } from "./context"; /** * Result type for bulk operations that may partially succeed. * Contains successfully submitted orders and any failures with error information. * * Generic in the success type so listing-side callers see {@link Listing}[] and * offer-side callers see {@link Offer}[]. */ export interface BulkOrderResult { /** Successfully submitted orders */ successful: T[]; /** Failed order submissions with error information */ failed: Array<{ /** Index of the failed order in the original input array */ index: number; /** The signed order that failed to submit (undefined if order creation failed before signing) */ order?: ProtocolData; /** The error that occurred during submission */ error: Error; }>; } /** * Manager for order building and creation operations. * Handles listing creation, offer creation, and collection offers. */ export declare class OrdersManager { private context; private getPriceParametersCallback; constructor(context: SDKContext, getPriceParametersCallback: (orderSide: OrderSide, tokenAddress: string, amount: Amount) => Promise<{ basePrice: bigint; }>); private getAmountWithBasisPointsApplied; private isNotMarketplaceFee; private getNFTItems; private getFees; /** * Build listing order without submitting to API * @param options Listing parameters * @returns The seaport-js use case. Call `executeAllActions()` to approve and * sign it for API submission, or * {@link executeApprovalsAndGetOrderComponents} to approve it without a * signature for onchain validation. */ private _buildListingOrder; /** * Build listing order components without submitting to API. * * Runs any token approvals the order needs, but does not ask the wallet to * sign: the components are meant for onchain validation, which needs no * offchain signature. * * @param options Listing parameters * @returns OrderComponents ready for onchain validation */ buildListingOrderComponents({ 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; /** * Build offer order without submitting to API * @param options Offer parameters * @returns OrderWithCounter ready for API submission or onchain validation */ private _buildOfferOrder; /** * Build offer order components without submitting to API. * * Runs any token approvals the order needs, but does not ask the wallet to * sign: the components are meant for onchain validation, which needs no * offchain signature. * * @param options Offer parameters * @returns OrderComponents ready for onchain validation */ buildOfferOrderComponents({ 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; /** * Create and submit an offer on an asset. * @param options * @param options.asset The asset to trade. tokenAddress and tokenId must be defined. * @param options.accountAddress Address of the wallet making the offer. * @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units. * @param options.quantity Number of assets to bid for. Defaults to 1. * @param options.domain Optional domain for onchain attribution. Hashed and included in salt. * @param options.salt Arbitrary salt. Auto-generated if not provided. * @param options.expirationTime Expiration time for the order, in UTC seconds * @param options.zone Zone for order protection. Defaults to chain's signed zone. * * @returns The {@link Offer} that was created. * * @throws Error if the asset does not contain a token id. * @throws Error if the accountAddress is not available through wallet or provider. * @throws Error if the amount is not greater than 0. */ createOffer({ 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; /** * Create and submit a listing for an asset. * @param options * @param options.asset The asset to trade. tokenAddress and tokenId must be defined. * @param options.accountAddress Address of the wallet making the listing * @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units. * @param options.quantity Number of assets to list. Defaults to 1. * @param options.domain Optional domain for onchain attribution. Hashed and included in salt. This can be used for onchain order attribution to assist with analytics. * @param options.salt Arbitrary salt. Auto-generated if not provided. * @param options.listingTime Optional time when the order will become fulfillable, in UTC seconds. Undefined means it will start now. * @param options.expirationTime Expiration time for the order, in UTC seconds. * @param options.buyerAddress Optional address that's allowed to purchase this item. If specified, no other address will be able to take the order, unless its value is the null address. * @param options.includeOptionalCreatorFees If true, optional creator fees will be included in the listing. Default: false. * @param options.zone Zone for order protection. Defaults to no zone. * @returns The {@link Listing} that was created. * * @throws Error if the asset does not contain a token id. * @throws Error if the accountAddress is not available through wallet or provider. * @throws Error if the amount is not greater than 0. */ createListing({ 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 and submit multiple listings using Seaport's bulk order creation. * This method uses a single signature for all listings and submits them individually to the OpenSea API with rate limit handling. * All listings must be from the same account address. * * Note: If only one listing is provided, this method will use a normal order signature instead of a bulk signature, * as bulk signatures are more expensive to decode onchain due to the merkle proof verification. * * @param options * @param options.listings Array of listing parameters. Each listing requires asset, amount, and optionally other listing parameters. * @param options.accountAddress Address of the wallet making the listings * @param options.continueOnError If true, continue submitting remaining listings even if some fail. Default: false (throw on first error). * @param options.onProgress Optional callback for progress updates. Called after each listing is submitted (successfully or not). * @returns {@link BulkOrderResult} containing successful orders and any failures. * * @throws Error if listings array is empty * @throws Error if the accountAddress is not available through wallet or provider. * @throws Error if any asset does not contain a token id. * @throws Error if continueOnError is false and any submission fails. */ createBulkListings({ listings, accountAddress, continueOnError, onProgress, }: { listings: Array<{ asset: AssetWithTokenId; amount: Amount; quantity?: Amount; domain?: string; salt?: Amount; listingTime?: number; expirationTime?: number; buyerAddress?: string; includeOptionalCreatorFees?: boolean; zone?: string; }>; accountAddress: string; continueOnError?: boolean; onProgress?: (completed: number, total: number) => void; }): Promise>; /** * Create and submit multiple offers using Seaport's bulk order creation. * This method uses a single signature for all offers and submits them individually to the OpenSea API with rate limit handling. * All offers must be from the same account address. * * Note: If only one offer is provided, this method will use a normal order signature instead of a bulk signature, * as bulk signatures are more expensive to decode onchain due to the merkle proof verification. * * @param options * @param options.offers Array of offer parameters. Each offer requires asset, amount, and optionally other offer parameters. * @param options.accountAddress Address of the wallet making the offers * @param options.continueOnError If true, continue submitting remaining offers even if some fail. Default: false (throw on first error). * @param options.onProgress Optional callback for progress updates. Called after each offer is submitted (successfully or not). * @returns {@link BulkOrderResult} containing successful orders and any failures. * * @throws Error if offers array is empty * @throws Error if the accountAddress is not available through wallet or provider. * @throws Error if any asset does not contain a token id. * @throws Error if continueOnError is false and any submission fails. */ createBulkOffers({ offers, accountAddress, continueOnError, onProgress, }: { offers: Array<{ asset: AssetWithTokenId; amount: Amount; quantity?: Amount; domain?: string; salt?: Amount; expirationTime?: Amount; zone?: string; }>; accountAddress: string; continueOnError?: boolean; onProgress?: (completed: number, total: number) => void; }): Promise>; /** * Create and submit a collection offer. * @param options * @param options.collectionSlug Identifier for the collection. * @param options.accountAddress Address of the wallet making the offer. * @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units. * @param options.quantity Number of assets to bid for. * @param options.domain Optional domain for onchain attribution. Hashed and included in salt. This can be used for onchain order attribution to assist with analytics. * @param options.salt Arbitrary salt. Auto-generated if not provided. * @param options.expirationTime Expiration time for the order, in UTC seconds. * @param options.offerProtectionEnabled Use signed zone for protection against disabled items. Default: true. * @param options.traitType If defined, the trait name to create the collection offer for. * @param options.traitValue If defined, the trait value to create the collection offer for. * @param options.traits If defined, an array of traits to create the multi-trait collection offer for. * @param options.numericTraits If defined, an array of numeric trait criteria with min/max ranges. * @returns The {@link CollectionOffer} that was created. */ createCollectionOffer({ collectionSlug, accountAddress, amount, quantity, domain, salt, expirationTime, offerProtectionEnabled, traitType, traitValue, traits, numericTraits, }: { collectionSlug: string; accountAddress: string; amount: Amount; quantity: number; domain?: string; salt?: Amount; expirationTime?: number | string; offerProtectionEnabled?: boolean; traitType?: string; traitValue?: string; traits?: Array<{ type: string; value: string; }>; numericTraits?: Array<{ type: string; min?: number; max?: number; }>; }): Promise; }