import type { MutateOptions, MutationOptions } from '@tanstack/query-core' import { type SendCallsErrorType, type SendCallsParameters, type SendCallsReturnType, sendCalls, } from '../actions/sendCalls.js' import type { Config } from '../createConfig.js' import type { MutationParameter } from '../types/query.js' import type { Compute } from '../types/utils.js' export type SendCallsOptions< config extends Config, context = unknown, > = MutationParameter< SendCallsData, SendCallsErrorType, SendCallsVariables, context > export function sendCallsMutationOptions( config: config, options: SendCallsOptions = {}, ): SendCallsMutationOptions { return { ...(options.mutation as any), mutationFn(variables) { return sendCalls(config, variables) }, mutationKey: ['sendCalls'], } } export type SendCallsMutationOptions = MutationOptions< SendCallsData, SendCallsErrorType, SendCallsVariables > export type SendCallsData = Compute export type SendCallsVariables< config extends Config, chainId extends config['chains'][number]['id'], calls extends readonly unknown[] = readonly unknown[], > = SendCallsParameters export type SendCallsMutate = < const calls extends readonly unknown[], chainId extends config['chains'][number]['id'], >( variables: SendCallsVariables, options?: | Compute< MutateOptions< SendCallsData, SendCallsErrorType, Compute>, context > > | undefined, ) => void export type SendCallsMutateAsync = < const calls extends readonly unknown[], chainId extends config['chains'][number]['id'], >( variables: SendCallsVariables, options?: | Compute< MutateOptions< SendCallsData, SendCallsErrorType, Compute>, context > > | undefined, ) => Promise