import type { Hex } from 'viem'; import type { ClientWithEns } from '../../contracts/consts.js'; import type { TransactionRequestWithPassthrough } from '../../types.js'; import { type BatchFunctionResult, type GeneratedFunction } from '../../utils/generateFunction.js'; type ExtractResult = TFunction extends { decode: (...args: any[]) => Promise; } ? U : never; export type BatchParameters = BatchFunctionResult[]; export type BatchReturnType = { [TFunctionName in keyof TFunctions]: ExtractResult; }; declare const encode: (client: ClientWithEns, ...items: BatchFunctionResult[]) => TransactionRequestWithPassthrough; declare const decode: (client: ClientWithEns, data: Hex, passthrough: TransactionRequestWithPassthrough[], ...items: I) => Promise>; type BatchableFunctionObject = GeneratedFunction; /** * Batches multiple read functions into a single call. * @param client - {@link ClientWithEns} * @param ...parameters - Array of {@link BatchFunctionResult} objects * @returns Array of return values from each function * * @example * import { createPublicClient, http } from 'viem' * import { mainnet } from 'viem/chains' * import { addEnsContracts } from '@etn-sc/ensjs' * import { batch, getTextRecord, getAddressRecord } from '@etn-sc/ensjs/public' * * const client = createPublicClient({ * chain: addEnsContracts(mainnet), * transport: http(), * }) * const result = await batch( * client, * getTextRecord.batch({ name: 'ens.eth', key: 'com.twitter' }), * getAddressRecord.batch({ name: 'ens.eth', coin: 'ETH' }), * ) * // ['ensdomains', { id: 60, name: 'ETH', value: '0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7 }] */ declare const batch: ((client: ClientWithEns, ...args: I) => Promise>) & BatchableFunctionObject; export default batch;