export type ChainEnum = 'ethereum' | 'abstract' | 'apechain' | 'arbitrum' | 'base' | 'berachain' | 'bsc' | 'polygon' | 'sei' | 'avalanche' | 'monad'; export type NftActivityTypeEnum = 'ASK_CREATED' | 'ASK_CANCELLED' | 'BID_CREATED' | 'BID_CANCELLED' | 'BURN' | 'MINT' | 'TRANSFER' | 'TRADE'; export type GetApiActivitiesArgs = {chain: ChainEnum, 'activityTypes[]': Array, fromTime?: string | undefined, toTime?: string | undefined, assetId: string, collectionId: string, walletAddress: string, limit?: number | undefined, continuation?: string | undefined}; export type GetApiActivitiesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * NFT Activity * * GET /activities */ export const getApiActivities = async (args: GetApiActivitiesArgs, options?: GetApiActivitiesOptions) => { 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['activityTypes[]'] ?? []) query.append("activityTypes[]", String(item)) if (args.fromTime != null) query.append("fromTime", String(args.fromTime)) if (args.toTime != null) query.append("toTime", String(args.toTime)) if (args.assetId != null) query.append("assetId", String(args.assetId)) if (args.collectionId != null) query.append("collectionId", String(args.collectionId)) if (args.walletAddress != null) query.append("walletAddress", String(args.walletAddress)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.continuation != null) query.append("continuation", String(args.continuation)) const url = `${baseUrl.replace(/\/+$/, '')}/activities${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() };