export type ChainEnum = 'ethereum' | 'abstract' | 'apechain' | 'arbitrum' | 'base' | 'berachain' | 'bsc' | 'polygon' | 'sei' | 'avalanche' | 'monad'; export type GetApiAssetsUserAssetsArgs = {chain: ChainEnum, 'walletAddresses[]': Array, 'assetIds[]'?: Array | undefined, 'collectionIds[]'?: Array | undefined, onlyListed?: boolean | undefined, includeTopBid?: boolean | undefined, sortBy?: ('listingPrice' | 'listedAt' | 'receivedAt' | 'lastSalePrice') | undefined, sortDir?: ('asc' | 'desc') | undefined, limit?: number | undefined, continuation?: string | undefined}; export type GetApiAssetsUserAssetsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * User Assets * * GET /assets/user-assets */ export const getApiAssetsUserAssets = async (args: GetApiAssetsUserAssetsArgs, options?: GetApiAssetsUserAssetsOptions) => { 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['walletAddresses[]'] ?? []) query.append("walletAddresses[]", String(item)) for (const item of args['assetIds[]'] ?? []) query.append("assetIds[]", String(item)) for (const item of args['collectionIds[]'] ?? []) query.append("collectionIds[]", String(item)) if (args.onlyListed != null) query.append("onlyListed", String(args.onlyListed)) if (args.includeTopBid != null) query.append("includeTopBid", String(args.includeTopBid)) 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(/\/+$/, '')}/assets/user-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() };