export type GetApiV1GasSuggestionChainArgs = {chain: string, fromChain?: string | undefined, fromToken?: string | undefined, 'x-lifi-api-key'?: string | undefined}; export type GetApiV1GasSuggestionChainOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get a gas suggestion for the specified chain * * GET /v1/gas/suggestion/{chain} */ export const getApiV1GasSuggestionChain = async (args: GetApiV1GasSuggestionChainArgs, options?: GetApiV1GasSuggestionChainOptions) => { const {baseUrl = "https://li.quest", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.fromChain != null) query.append("fromChain", String(args.fromChain)) if (args.fromToken != null) query.append("fromToken", String(args.fromToken)) if (args['x-lifi-api-key'] != null) headers.set("x-lifi-api-key", String(args['x-lifi-api-key'])) const url = `${baseUrl.replace(/\/+$/, '')}/v1/gas/suggestion/${encodeURIComponent(String(args.chain))}${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 };