import type { Abi } from '../abi.js'; import type { Narrow } from '../narrow.js'; import type { Error, Filter } from '../types.js'; import type { ParseSignature, ParseStructs, Signature, Signatures } from './types/index.js'; /** * Parses human-readable ABI item (e.g. error, event, function) into {@link Abi} item * * @param TSignature - Human-readable ABI item * @returns Parsed {@link Abi} item * * @example * type Result = ParseAbiItem<'function balanceOf(address owner) view returns (uint256)'> * // ^? type Result = { name: "balanceOf"; type: "function"; stateMutability: "view";... * * @example * type Result = ParseAbiItem< * // ^? type Result = { name: "foo"; type: "function"; stateMutability: "view"; inputs:... * ['function foo(Baz bar) view returns (string)', 'struct Baz { string name; }'] * > */ export type ParseAbiItem = (TSignature extends string ? string extends TSignature ? Abi[number] : TSignature extends Signature ? ParseSignature : never : never) | (TSignature extends readonly string[] ? string[] extends TSignature ? Abi[number] : TSignature extends Signatures ? ParseStructs extends infer Structs ? { [K in keyof TSignature]: ParseSignature; } extends infer Mapped extends readonly unknown[] ? Filter[0] extends infer Result ? Result extends undefined ? never : Result : never : never : never : never : never); /** * Parses human-readable ABI item (e.g. error, event, function) into {@link Abi} item * * @param signature - Human-readable ABI item * @returns Parsed {@link Abi} item * * @example * const abiItem = parseAbiItem('function balanceOf(address owner) view returns (uint256)') * // ^? const abiItem: { name: "balanceOf"; type: "function"; stateMutability: "view";... * * @example * const abiItem = parseAbiItem([ * // ^? const abiItem: { name: "foo"; type: "function"; stateMutability: "view"; inputs:... * 'function foo(Baz bar) view returns (string)', * 'struct Baz { string name; }', * ]) */ export declare function parseAbiItem(signature: Narrow & ((TSignature extends string ? string extends TSignature ? unknown : Signature : never) | (TSignature extends readonly string[] ? TSignature extends readonly [] ? Error<'At least one signature required.'> : string[] extends TSignature ? unknown : Signatures : never))): ParseAbiItem; //# sourceMappingURL=parseAbiItem.d.ts.map