import { type AbiTypeWithGenerics, type StructType } from './abi_type_with_generics.js'; export interface DemonomorphizerConfig { leaveArrayLengthsUnbounded: boolean; leaveStringLengthsUnbounded: boolean; } /** * Demonomorphizes a list of ABI types adding generics to structs. * Since monomorphization of the generics destroys information, this process is not guaranteed to return the original structure. * However, it should successfully unify all struct types that share the same name and field names. */ export declare class Demonomorphizer { private types; private config; private variantsMap; private visitedStructs; private lastBindingId; /** * Demonomorphizes the passed in ABI types, mutating them. */ static demonomorphize(abiTypes: AbiTypeWithGenerics[], config: DemonomorphizerConfig): void; private constructor(); /** * Finds all the variants of the structs in the types. * A variant is every use of a struct with the same name and fields. */ private fillVariantsMap; private demonomorphizeStructs; /** * Demonomorphizes a struct, by demonomorphizing its dependencies first. * Then it'll unify the types of the variants generating a unique generic type. * It'll also generate args that instantiate the generic type with the concrete arguments for each variant. */ private demonomorphizeStruct; /** * Tries to unify the types of a set of variants recursively. * Unification will imply replacing some properties with bindings and pushing bindings to the generics of the struct. */ private unifyTypes; /** * We consider a struct to be the same if it has the same name and field names. * Structs with the same id will be unified into a single type by the demonomorphizer. */ static buildIdForStruct(struct: StructType): string; private buildBindingAndPushToVariants; private buildNumericBindingAndPushToVariants; }