export type ChainEnum = 'ethereum' | 'abstract' | 'apechain' | 'arbitrum' | 'base' | 'berachain' | 'bsc' | 'polygon' | 'sei' | 'avalanche' | 'monad'; export type BidTypeEnum = 'ASSET' | 'COLLECTION' | 'ATTRIBUTE'; export type FilterOrderSourceEnum = 'any' | 'opensea.io' | 'magiceden'; export type OrderStatusEnum = 'active' | 'inactive' | 'expired' | 'filled' | 'cancelled'; export type GetApiOrdersBidsArgs = {chain: ChainEnum, 'ids[]': Array, 'bidTypes[]': Array, collectionId: string, 'assetIds[]'?: Array | undefined, 'attributes[]'?: Array | undefined, 'makers[]'?: Array | undefined, 'sources[]'?: Array | undefined, 'status[]'?: Array | undefined, createAfter: string, updateAfter: string, sortBy?: ('price' | 'createdAt' | 'updatedAt') | undefined, sortDir?: ('asc' | 'desc') | undefined, limit?: number | undefined, continuation?: string | undefined}; export type GetApiOrdersBidsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Bids (offers) * * GET /orders/bids */ export const getApiOrdersBids = async (args: GetApiOrdersBidsArgs, options?: GetApiOrdersBidsOptions) => { 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)) for (const item of args['ids[]'] ?? []) query.append("ids[]", String(item)) for (const item of args['bidTypes[]'] ?? []) query.append("bidTypes[]", String(item)) 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['attributes[]'] ?? []) query.append("attributes[]", String(item)) for (const item of args['makers[]'] ?? []) query.append("makers[]", String(item)) for (const item of args['sources[]'] ?? []) query.append("sources[]", String(item)) for (const item of args['status[]'] ?? []) query.append("status[]", String(item)) if (args.createAfter != null) query.append("createAfter", String(args.createAfter)) if (args.updateAfter != null) query.append("updateAfter", String(args.updateAfter)) if (args.sortBy != null) query.append("sortBy", String(args.sortBy)) if (args.sortDir != null) query.append("sortDir", String(args.sortDir)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.continuation != null) query.append("continuation", String(args.continuation)) const url = `${baseUrl.replace(/\/+$/, '')}/orders/bids${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() };