import { Gindex, HashComputationLevel, Node, Proof, Tree } from "@chainsafe/persistent-merkle-tree"; import { Require } from "../util/types.ts"; import { TreeView } from "../view/abstract.ts"; import { TreeViewDU } from "../viewDU/abstract.ts"; import { ByteViews, JsonPath, Type } from "./abstract.ts"; import { CompositeType } from "./composite.ts"; export type CompatibleUnion = { readonly selector: number; data: T; }; export type CompatibleUnionOpts = { typeName?: string; }; /** * CompatibleUnion: union type containing one of the given subtypes with compatible Merkleization. * - Notation: CompatibleUnion({selector: type}), e.g. CompatibleUnion({1: Square, 2: Circle}) * * The right leaf encodes the selector and reuses existing list length-node helpers for tree operations. */ export declare class CompatibleUnionType>> extends CompositeType, CompatibleUnionTreeView, CompatibleUnionTreeViewDU> { readonly typeName: string; readonly depth = 1; readonly maxChunkCount = 1; readonly fixedSize: null; readonly minSize: number; readonly maxSize: number; readonly isList = true; readonly isViewMutable = true; readonly mixInSelectorBlockBytes: Uint8Array; readonly mixInSelectorBuffer: Buffer; readonly selectors: number[]; private readonly selectorToType; private readonly representativeType; private readonly selectorType; constructor(options: Types, opts?: CompatibleUnionOpts); static named>>(options: Types, opts: Require): CompatibleUnionType; defaultValue(): CompatibleUnion; getView(tree: Tree): CompatibleUnionTreeView; getViewDU(node: Node): CompatibleUnionTreeViewDU; cacheOfViewDU(): unknown; commitView(view: CompatibleUnionTreeView): Node; commitViewDU(view: CompatibleUnionTreeViewDU, hcOffset?: number, hcByLevel?: HashComputationLevel[] | null): Node; value_serializedSize(value: CompatibleUnion): number; value_serializeToBytes(output: ByteViews, offset: number, value: CompatibleUnion): number; value_deserializeFromBytes(data: ByteViews, start: number, end: number, reuseBytes?: boolean): CompatibleUnion; tree_serializedSize(node: Node): number; tree_serializeToBytes(output: ByteViews, offset: number, node: Node): number; tree_deserializeFromBytes(data: ByteViews, start: number, end: number): Node; hashTreeRoot(value: CompatibleUnion): Uint8Array; hashTreeRootInto(value: CompatibleUnion, output: Uint8Array, offset: number): void; protected getBlocksBytes(value: CompatibleUnion): Uint8Array; getPropertyGindex(prop: string): Gindex; createFromProof(proof: Proof, root?: Uint8Array): CompatibleUnionTreeView; tree_createProof(node: Node, jsonPaths: JsonPath[]): Proof; tree_createProofGindexes(node: Node, jsonPaths: JsonPath[]): Gindex[]; getPropertyType(prop: string): Type; getIndexProperty(index: number): string; tree_getLeafGindices(rootGindex: Gindex, rootNode?: Node): Gindex[]; tree_fromProofNode(node: Node): { node: Node; done: boolean; }; fromJson(json: unknown): CompatibleUnion; toJson(value: CompatibleUnion): Record; clone(value: CompatibleUnion): CompatibleUnion; equals(a: CompatibleUnion, b: CompatibleUnion): boolean; getType(selector: number): Type; } export declare class CompatibleUnionTreeView>> extends TreeView> { readonly type: CompatibleUnionType; protected tree: Tree; constructor(type: CompatibleUnionType, tree: Tree); get node(): Node; get selector(): number; get data(): unknown; } export declare class CompatibleUnionTreeViewDU>> extends TreeViewDU> { readonly type: CompatibleUnionType; protected _rootNode: Node; constructor(type: CompatibleUnionType, _rootNode: Node); get node(): Node; get cache(): unknown; get selector(): number; get data(): unknown; commit(hcOffset?: number, hcByLevel?: HashComputationLevel[] | null): void; protected clearCache(): void; } export declare function areTypesCompatible(a: Type, b: Type): boolean;