export type QuoteV2QuoteRequestDTO = {sourceChainID: number, destinationChainID: number, sourceToken: string, destinationToken: string, sourceAmount: string, funder: string, refundRecipient?: string | undefined, recipient: string}; export type QuoteV2ContractsRequestDTO = {sourcePortal?: string | undefined, destinationPortal?: string | undefined, prover?: string | undefined}; export type AllowanceOrTransferDTO = {chainID: number, modeOrExpiration: number, tokenKey: string, account: string, amountDelta: number}; export type Permit3DTO = {chainId: number, permitContract: string, owner: string, salt: string, signature: string, deadline: number, timestamp: number, merkleRoot: string, leaves: Array, allowanceOrTransfers: Array}; export type GaslessIntentDataV2DTO = {permit3: Permit3DTO, allowPartial?: boolean | undefined}; export type QuoteV2RequestDTO = {quoteID: string, dAppID: string, intentExecutionTypes: Array<'SELF_PUBLISH' | 'GASLESS'>, quoteRequest: QuoteV2QuoteRequestDTO, contracts?: QuoteV2ContractsRequestDTO | undefined, gaslessIntentData?: GaslessIntentDataV2DTO | undefined}; export type CreateApiApiV2QuoteArgs = {body: QuoteV2RequestDTO}; export type CreateApiApiV2QuoteOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * POST /api/v2/quote */ export const createApiApiV2Quote = async (args: CreateApiApiV2QuoteArgs, options?: CreateApiApiV2QuoteOptions) => { const {baseUrl = "https://quotes.eco.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/quote${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };