import { Gindex, HashComputationLevel, Node, Tree } from "@chainsafe/persistent-merkle-tree"; import { Require } from "../util/types.ts"; import { getContainerTreeViewClass } from "../view/container.ts"; import { ContainerTreeViewType, ContainerTreeViewTypeConstructor, FieldEntry, ValueOfFields } from "../view/container.ts"; import { ContainerTreeViewDUType, ContainerTreeViewDUTypeConstructor, getContainerTreeViewDUClass } from "../viewDU/container.ts"; import { Type } from "./abstract.ts"; import { ByteViews, CompositeType } from "./composite.ts"; type BytesRange = { start: number; end: number; }; export type ContainerOptions> = { typeName?: string; jsonCase?: KeyCase; casingMap?: CasingMap; cachePermanentRootStruct?: boolean; getContainerTreeViewClass?: typeof getContainerTreeViewClass; getContainerTreeViewDUClass?: typeof getContainerTreeViewDUClass; }; export type KeyCase = "eth2" | "snake" | "constant" | "camel" | "header" | "pascal"; type CasingMap> = Partial<{ [K in keyof Fields]: string; }>; /** * Container: ordered heterogeneous collection of values * - Notation: Custom name per instance */ export declare class ContainerType>> extends CompositeType, ContainerTreeViewType, ContainerTreeViewDUType> { readonly fields: Fields; readonly opts?: ContainerOptions | undefined; readonly typeName: string; readonly depth: number; readonly maxChunkCount: number; readonly fixedSize: number | null; readonly minSize: number; readonly maxSize: number; readonly isList = false; readonly isViewMutable = true; readonly fieldsEntries: FieldEntry[]; /** End of fixed section of serialized Container */ readonly fixedEnd: number; protected readonly fieldsGindex: Record; protected readonly jsonKeyToFieldName: Record; protected readonly isFixedLen: boolean[]; protected readonly fieldRangesFixedLen: BytesRange[]; /** Offsets position relative to start of serialized Container. Length may not equal field count. */ protected readonly variableOffsetsPosition: number[]; /** Cached TreeView constuctor with custom prototype for this Type's properties */ protected readonly TreeView: ContainerTreeViewTypeConstructor; protected readonly TreeViewDU: ContainerTreeViewDUTypeConstructor; constructor(fields: Fields, opts?: ContainerOptions | undefined); static named>>(fields: Fields, opts: Require, "typeName">): ContainerType; defaultValue(): ValueOfFields; getView(tree: Tree): ContainerTreeViewType; getViewDU(node: Node, cache?: unknown): ContainerTreeViewDUType; cacheOfViewDU(view: ContainerTreeViewDUType): unknown; commitView(view: ContainerTreeViewType): Node; commitViewDU(view: ContainerTreeViewDUType, hcOffset?: number, hcByLevel?: HashComputationLevel[] | null): Node; value_serializedSize(value: ValueOfFields): number; value_serializeToBytes(output: ByteViews, offset: number, value: ValueOfFields): number; value_deserializeFromBytes(data: ByteViews, start: number, end: number, reuseBytes?: boolean): ValueOfFields; tree_serializedSize(node: Node): number; tree_serializeToBytes(output: ByteViews, offset: number, node: Node): number; tree_deserializeFromBytes(data: ByteViews, start: number, end: number): Node; protected getBlocksBytes(struct: ValueOfFields): Uint8Array; getPropertyGindex(prop: string): Gindex | null; getPropertyType(prop: string): Type; getIndexProperty(index: number): string | null; tree_getLeafGindices(rootGindex: Gindex, rootNode?: Node): Gindex[]; fromJson(json: unknown): ValueOfFields; toJson(value: ValueOfFields): Record; clone(value: ValueOfFields): ValueOfFields; equals(a: ValueOfFields, b: ValueOfFields): boolean; /** * Deserializer helper: Returns the bytes ranges of all fields, both variable and fixed size. * Fields may not be contiguous in the serialized bytes, so the returned ranges are [start, end]. * - For fixed size fields re-uses the pre-computed values this.fieldRangesFixedLen * - For variable size fields does a first pass over the fixed section to read offsets */ getFieldRanges(data: DataView, start: number, end: number): BytesRange[]; } /** * Compute the JSON key for each fieldName. There will exist a single JSON representation for each type. * To transform JSON payloads to a casing that is different from the type's defined use external tooling. */ export declare function precomputeJsonKey>>(fieldName: keyof Fields, casingMap?: CasingMap, jsonCase?: KeyCase): string; /** * Render field typeNames for a detailed typeName of this Container */ export declare function renderContainerTypeName>>(fields: Fields, prefix?: string): string; export {};