import { ABI } from "../chain/Abi.js";
import { ABIDecoder } from "./Decoder.js";
import { ABIEncoder } from "./Encoder.js";
/** A self-describing object that can be ABI encoded and decoded. */
export type ABISerializable = ABISerializableObject | string | boolean | ABISerializable[] | {
    [key: string]: ABISerializable;
};
/** Type describing an ABI type, either a string (e.g. `uint32[]`) or a ABI type class. */
export type ABISerializableType = string | ABISerializableConstructor | ABITypeDescriptor;
/** Interface that should be implemented by ABI serializable objects. */
export interface ABISerializableObject {
    /** Called when encoding to binary abi format. */
    toABI?(encoder: ABIEncoder): void;
    /** Called when encoding to json abi format. */
    toJSON(): any;
    /** Return true if the object equals the other object passed. */
    equals(other: any): boolean;
}
export interface ABITypeModifiers {
    /** Type is optional, defaults to false. */
    optional?: boolean;
    /** Type is an array, defaults to false. */
    array?: boolean;
    /** Type is a binary extension, defaults to false. */
    extension?: boolean;
}
export interface ABITypeDescriptor extends ABITypeModifiers {
    /** Type name or class. */
    type: ABISerializableConstructor | string;
}
export interface ABIField extends ABITypeDescriptor {
    /** Field name. */
    name: string;
}
export interface ABISerializableConstructor {
    /** Name of the type, e.g. `asset`. */
    abiName: string;
    /** For structs, the fields that this type contains. */
    abiFields?: ABIField[];
    /** For structs, the base class this type extends. */
    abiBase?: ABISerializableConstructor;
    /** For variants, the different types this type can represent. */
    abiVariant?: ABITypeDescriptor[];
    /** Alias to another type. */
    abiAlias?: ABITypeDescriptor;
    /** Return value to use when creating a new instance of this type, used when decoding binary extensions. */
    abiDefault?: () => ABISerializable;
    /**
     * Create new instance from JavaScript object.
     * Should also accept an instance of itself and return that unchanged.
     */
    from(value: any): ABISerializable;
    /**
     * Create instance from binary ABI data.
     * @param decoder Decoder instance to read from.
     */
    fromABI?(decoder: ABIDecoder): ABISerializable;
    /**
     * Static ABI encoding can be used to encode non-class types.
     * Will be used in favor of instance.toABI if both exists.
     * @param value The value to encode.
     * @param encoder The encoder to write the value to.
     */
    toABI?(value: any, encoder: ABIEncoder): void;
    /**
     * Create a new instance, don't use this other than from a custom `from` factory method.
     * @internal
     */
    new (...args: any[]): ABISerializableObject;
}
/** Return a ABI definition for given ABISerializableType. */
export declare function synthesizeABI(type: ABISerializableConstructor): {
    abi: ABI;
    types: ABISerializableConstructor[];
    root: string;
};
export declare function abiTypeString(type: ABITypeDescriptor): string;
export declare function isTypeDescriptor(type: ABISerializableType): type is ABITypeDescriptor;
export declare function toTypeDescriptor(type: ABISerializableType): ABITypeDescriptor;
/** Returns true if the given value conforms to ABISerializableObject. */
export declare function isABISerializableObject(value: any): value is ABISerializableObject;
//# sourceMappingURL=Serializable.d.ts.map