export type GetApiApiTokenHoldersArgs = {address?: string | undefined, hash?: string | undefined, page?: number | undefined, limit?: number | undefined}; export type GetApiApiTokenHoldersOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get list trc20 token holder. Require 1 of 2 conditions - address | hash * * GET /api/token-holders */ export const getApiApiTokenHolders = async (args: GetApiApiTokenHoldersArgs, options: GetApiApiTokenHoldersOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.address != null) query.append("address", String(args.address)) if (args.hash != null) query.append("hash", String(args.hash)) if (args.page != null) query.append("page", String(args.page)) if (args.limit != null) query.append("limit", String(args.limit)) const url = `${baseUrl.replace(/\/+$/, '')}/api/token-holders${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 undefined };