export type EthAddress = string; export type GetApiProposalsGrantsAddressArgs = {address: EthAddress}; export type GetApiProposalsGrantsAddressOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get active and past enacted grants from the given address * * GET /proposals/grants/{address} */ export const getApiProposalsGrantsAddress = async (args: GetApiProposalsGrantsAddressArgs, options: GetApiProposalsGrantsAddressOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() const url = `${baseUrl.replace(/\/+$/, '')}/proposals/grants/${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 };