export type GetApiBadgesBadgeValidateAddressArgs = {address: string, badge: string}; export type GetApiBadgesBadgeValidateAddressOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Validates that a given user holds a badge * * GET /badges/{badge}/validate/{address} */ export const getApiBadgesBadgeValidateAddress = async (args: GetApiBadgesBadgeValidateAddressArgs, options?: GetApiBadgesBadgeValidateAddressOptions) => { const {baseUrl = "https://api.unstoppabledomains.com/profile", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() const url = `${baseUrl.replace(/\/+$/, '')}/badges/${encodeURIComponent(String(args.badge))}/validate/${encodeURIComponent(String(args.address))}${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 };