import { Gindex, HashComputationLevel, Node, Tree } from "@chainsafe/persistent-merkle-tree"; import { Require } from "../util/types.ts"; import { ByteViews, JsonPath, JsonPathProp, Type } from "./abstract.ts"; import { CompositeType } from "./composite.ts"; export type NonOptionalType> = T extends OptionalType ? U : T; export type NonOptionalFields>> = { [K in keyof Fields]: NonOptionalType; }; export type OptionalOpts = { typeName?: string; }; type ValueOfType> = ElementType extends Type ? T | null : never; /** * Optional: optional type containing either None or a type * - Notation: Optional[type], e.g. optional[uint64] * - merklizes as list of length 0 or 1, essentially acts like * - like Union[none,type] or * - list [], [type] */ export declare class OptionalType> extends CompositeType, ValueOfType, ValueOfType> { readonly elementType: ElementType; readonly typeName: string; readonly depth: number; readonly maxChunkCount: number; readonly fixedSize: null; readonly minSize: number; readonly maxSize: number; readonly isList = true; readonly isViewMutable = true; readonly mixInLengthBlockBytes: Uint8Array; readonly mixInLengthBuffer: Buffer; constructor(elementType: ElementType, opts?: OptionalOpts); static named>(elementType: ElementType, opts: Require): OptionalType; defaultValue(): ValueOfType; getView(tree: Tree): ValueOfType; getViewDU(node: Node): ValueOfType; commitView(view: ValueOfType): Node; commitViewDU(view: ValueOfType, hcOffset?: number, hcByLevel?: HashComputationLevel[] | null): Node; cacheOfViewDU(): unknown; value_serializedSize(value: ValueOfType): number; value_serializeToBytes(output: ByteViews, offset: number, value: ValueOfType): number; value_deserializeFromBytes(data: ByteViews, start: number, end: number, reuseBytes?: boolean): ValueOfType; 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: ValueOfType): Uint8Array; hashTreeRootInto(value: ValueOfType, output: Uint8Array, offset: number): void; protected getBlocksBytes(value: ValueOfType): Uint8Array; getPropertyGindex(prop: JsonPathProp): Gindex | null; getPropertyType(prop: JsonPathProp): Type; getIndexProperty(index: number): JsonPathProp | null; tree_createProofGindexes(node: Node, jsonPaths: JsonPath[]): Gindex[]; tree_getLeafGindices(rootGindex: bigint, rootNode?: Node): Gindex[]; fromJson(json: unknown): ValueOfType; toJson(value: ValueOfType): unknown | Record; clone(value: ValueOfType): ValueOfType; equals(a: ValueOfType, b: ValueOfType): boolean; } export declare function isOptionalType(type: Type): type is OptionalType>; export declare function toNonOptionalType>(type: T): NonOptionalType; export {};