export type GetApiEventsTokenAddressArgs = {tokenAddress: string}; export type GetApiEventsTokenAddressOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get Token Events * * GET /events/{tokenAddress} */ export const getApiEventsTokenAddress = async (args: GetApiEventsTokenAddressArgs, options?: GetApiEventsTokenAddressOptions) => { const {baseUrl = "https://data.solanatracker.io", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (apiKey !== undefined) headers.set("x-api-key", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/events/${encodeURIComponent(String(args.tokenAddress))}${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() };