export type ChainEnum = 'ethereum' | 'abstract' | 'apechain' | 'arbitrum' | 'base' | 'berachain' | 'bsc' | 'polygon' | 'sei' | 'avalanche' | 'monad'; export type AssetFloorAskSourceEnum = 'any' | 'opensea.io' | 'magiceden'; export type GetApiAssetsCollectionAssetsArgs = {chain: ChainEnum, collectionId: string, 'assetIds[]'?: Array | undefined, 'includeFloorAskSource[]'?: Array | undefined, name?: string | undefined, includeTopBid?: boolean | undefined, limit?: number | undefined, sortBy?: ('price' | 'listedAt') | undefined, sortDir?: ('asc' | 'desc') | undefined, continuation?: string | undefined}; export type GetApiAssetsCollectionAssetsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Collection Assets * * GET /assets/collection-assets */ export const getApiAssetsCollectionAssets = async (args: GetApiAssetsCollectionAssetsArgs, options?: GetApiAssetsCollectionAssetsOptions) => { const {baseUrl = "https://api-mainnet.magiceden.dev/v2", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.chain != null) query.append("chain", String(args.chain)) if (args.collectionId != null) query.append("collectionId", String(args.collectionId)) for (const item of args['assetIds[]'] ?? []) query.append("assetIds[]", String(item)) for (const item of args['includeFloorAskSource[]'] ?? []) query.append("includeFloorAskSource[]", String(item)) if (args.name != null) query.append("name", String(args.name)) if (args.includeTopBid != null) query.append("includeTopBid", String(args.includeTopBid)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.sortBy != null) query.append("sortBy", String(args.sortBy)) if (args.sortDir != null) query.append("sortDir", String(args.sortDir)) if (args.continuation != null) query.append("continuation", String(args.continuation)) const url = `${baseUrl.replace(/\/+$/, '')}/assets/collection-assets${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };