export type CreateApiApiV2SolanaTransactionsArgs = {'X-Network'?: ('testnet' | 'mainnet') | undefined, Authorization: string, 'Content-Type': 'application/json' | 'application/x-www-form-urlencoded' | 'multipart/form-data', body: {from: string, to: string, amount: number, privatekey: string}}; export type CreateApiApiV2SolanaTransactionsOptions = {baseUrl?: string | undefined, defaultValue?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create SOL Transaction * * POST /api/v2/solana/transactions */ export const createApiApiV2SolanaTransactions = async (args: CreateApiApiV2SolanaTransactionsArgs, options?: CreateApiApiV2SolanaTransactionsOptions) => { const {baseUrl = "https://app.chaingateway.io", fetch: fetchFn = fetch, defaultValue} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['X-Network'] != null) headers.set("X-Network", String(args['X-Network'])) if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (args['Content-Type'] != null) headers.set("Content-Type", String(args['Content-Type'])) if (defaultValue !== undefined) headers.set('authorization', `Bearer ${defaultValue}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/solana/transactions${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 };