import type { MutateOptions, MutationOptions } from '@tanstack/query-core' import { type SendTransactionErrorType, type SendTransactionParameters, type SendTransactionReturnType, sendTransaction, } from '../actions/sendTransaction.js' import type { Config } from '../createConfig.js' import type { MutationParameter } from '../types/query.js' import type { Compute } from '../types/utils.js' export type SendTransactionOptions< config extends Config, context = unknown, > = MutationParameter< SendTransactionData, SendTransactionErrorType, SendTransactionVariables, context > export function sendTransactionMutationOptions( config: config, options: SendTransactionOptions = {}, ): SendTransactionMutationOptions { return { ...(options.mutation as any), mutationFn(variables) { return sendTransaction(config, variables) }, mutationKey: ['sendTransaction'], } } export type SendTransactionMutationOptions = MutationOptions< SendTransactionData, SendTransactionErrorType, SendTransactionVariables > export type SendTransactionData = Compute export type SendTransactionVariables< config extends Config, chainId extends config['chains'][number]['id'], > = SendTransactionParameters export type SendTransactionMutate = < chainId extends config['chains'][number]['id'], >( variables: SendTransactionVariables, options?: | Compute< MutateOptions< SendTransactionData, SendTransactionErrorType, Compute>, context > > | undefined, ) => void export type SendTransactionMutateAsync< config extends Config, context = unknown, > = ( variables: SendTransactionVariables, options?: | Compute< MutateOptions< SendTransactionData, SendTransactionErrorType, Compute>, context > > | undefined, ) => Promise