import { Gindex, Node, Tree } from "@chainsafe/persistent-merkle-tree"; import { Require } from "../util/types.ts"; import { BitArray } from "../value/bitArray.ts"; import { ContainerTreeViewType, ContainerTreeViewTypeConstructor, FieldEntry, ValueOfFields, getProfileTreeViewClass } from "../view/profile.ts"; import { ContainerTreeViewDUType, ContainerTreeViewDUTypeConstructor, getProfileTreeViewDUClass } from "../viewDU/profile.ts"; import { Type } from "./abstract.ts"; import { ByteViews, CompositeType } from "./composite.ts"; import { NonOptionalFields } from "./optional.ts"; type BytesRange = { start: number; end: number; }; export type ProfileOptions> = { typeName?: string; jsonCase?: KeyCase; casingMap?: CasingMap; cachePermanentRootStruct?: boolean; getProfileTreeViewClass?: typeof getProfileTreeViewClass; getProfileTreeViewDUClass?: typeof getProfileTreeViewDUClass; }; export type KeyCase = "eth2" | "snake" | "constant" | "camel" | "header" | "pascal"; type CasingMap> = Partial<{ [K in keyof Fields]: string; }>; /** * Profile: ordered heterogeneous collection of values that inherits merkleization from a base stable container * - EIP: https://eips.ethereum.org/EIPS/eip-7495 * - No reordering of fields for merkleization */ export declare class ProfileType>> extends CompositeType, ContainerTreeViewType, ContainerTreeViewDUType> { readonly fields: Fields; readonly opts?: ProfileOptions | 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 activeFields: BitArray; readonly fieldsEntries: FieldEntry>[]; /** End of fixed section of serialized Container */ protected readonly fieldsGindex: Record; protected readonly jsonKeyToFieldName: Record; /** Cached TreeView constuctor with custom prototype for this Type's properties */ protected readonly TreeView: ContainerTreeViewTypeConstructor; protected readonly TreeViewDU: ContainerTreeViewDUTypeConstructor; private optionalFieldsCount; private tempRoot; constructor(fields: Fields, activeFields: BitArray, opts?: ProfileOptions | undefined); static named>>(fields: Fields, activeFields: BitArray, opts: Require, "typeName">): ProfileType; defaultValue(): ValueOfFields; getView(tree: Tree): ContainerTreeViewType; getViewDU(node: Node, cache?: unknown): ContainerTreeViewDUType; cacheOfViewDU(view: ContainerTreeViewDUType): unknown; commitView(view: ContainerTreeViewType): Node; commitViewDU(view: ContainerTreeViewDUType): 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; hashTreeRootInto(value: ValueOfFields, output: Uint8Array, offset: number, safeCache?: boolean): void; protected getBlocksBytes(struct: ValueOfFields): Uint8Array; /** INTERNAL METHOD: For view's API, create proof from a tree */ 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 * - offsets are relative to the start of serialized active fields, after the Bitvector[N] */ getFieldRanges(data: ByteViews, start: number, end: number): { optionalFields: BitArray; fieldRanges: 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 {};