export type ChainIdentifier = 'base' | 'ethereum' | 'zora' | 'arbitrum' | 'sei' | 'avalanche' | 'polygon' | 'optimism' | 'ape_chain' | 'flow' | 'soneium' | 'ronin' | 'bera_chain' | 'solana' | 'shape' | 'unichain' | 'gunzilla' | 'abstract' | 'animechain' | 'hyperevm' | 'somnia' | 'monad' | 'hyperliquid' | 'megaeth' | 'ink' | 'robinhood' | 'stablechain'; export type GetApiApiV2AccountAddressCollectionsArgs = {address: string, after?: string | undefined, limit?: number | undefined, chains?: Array | undefined}; export type GetApiApiV2AccountAddressCollectionsOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get collections owned by an account * * GET /api/v2/account/{address}/collections */ export const getApiApiV2AccountAddressCollections = async (args: GetApiApiV2AccountAddressCollectionsArgs, options?: GetApiApiV2AccountAddressCollectionsOptions) => { const {baseUrl = "https://api.opensea.io", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.after != null) query.append("after", String(args.after)) if (args.limit != null) query.append("limit", String(args.limit)) for (const item of args.chains ?? []) query.append("chains", String(item)) if (ApiKeyAuth !== undefined) headers.set("x-api-key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/account/${encodeURIComponent(String(args.address))}/collections${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() };