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 { ValueOf } from "./abstract.ts"; import { ArrayType } from "./array.ts"; import { BasicType } from "./basic.ts"; import { ByteViews } from "./composite.ts"; import { CompositeType, CompositeView, CompositeViewDU } from "./composite.ts"; export interface ProgressiveListOpts { typeName?: string; cachePermanentRootStruct?: boolean; } export declare class ProgressiveListBasicType> extends ArrayType, ProgressiveListBasicTreeViewDU> { readonly elementType: ElementType; readonly typeName: string; readonly itemsPerChunk: number; readonly depth = 1; readonly chunkDepth = 0; readonly maxChunkCount: number; readonly fixedSize: null; readonly minSize = 0; readonly maxSize = 4294967295; readonly isList = true; readonly isViewMutable = true; readonly limit: number; readonly mixInLengthBlockBytes: Uint8Array; readonly mixInLengthBuffer: Buffer; protected readonly defaultLen = 0; constructor(elementType: ElementType, opts?: ProgressiveListOpts); static named>(elementType: ElementType, opts: Require): ProgressiveListBasicType; getView(tree: Tree): ProgressiveListBasicTreeView; getViewDU(node: Node): ProgressiveListBasicTreeViewDU; commitView(view: ProgressiveListBasicTreeView): Node; commitViewDU(view: ProgressiveListBasicTreeViewDU, hcOffset?: number, hcByLevel?: HashComputationLevel[] | null): Node; cacheOfViewDU(): unknown; createFromProof(proof: Proof, root?: Uint8Array): ProgressiveListBasicTreeView; value_serializedSize(value: ValueOf[]): number; value_serializeToBytes(output: ByteViews, offset: number, value: ValueOf[]): number; value_deserializeFromBytes(data: ByteViews, start: number, end: number): ValueOf[]; tree_serializedSize(node: Node): number; tree_serializeToBytes(output: ByteViews, offset: number, node: Node): number; tree_deserializeFromBytes(data: ByteViews, start: number, end: number): Node; tree_getLength(node: Node): number; tree_setLength(tree: Tree, length: number): void; tree_getChunksNode(node: Node): Node; tree_chunksNodeOffset(): number; tree_setChunksNode(rootNode: Node, chunksNode: Node, newLength: number | null, hcOffset?: number, hcByLevel?: HashComputationLevel[] | null): Node; hashTreeRoot(value: ValueOf[]): Uint8Array; hashTreeRootInto(value: ValueOf[], output: Uint8Array, offset: number, safeCache?: boolean): void; protected getBlocksBytes(value: ValueOf[]): Uint8Array; getPropertyGindex(prop: string | number): Gindex; tree_getLeafGindices(rootGindex: Gindex, rootNode?: Node): Gindex[]; tree_fromProofNode(node: Node): { node: Node; done: boolean; }; } export declare class ProgressiveListCompositeType, CompositeView, CompositeViewDU>> extends ArrayType, ProgressiveListCompositeTreeViewDU> { readonly elementType: ElementType; readonly typeName: string; readonly itemsPerChunk = 1; readonly depth = 1; readonly chunkDepth = 0; readonly maxChunkCount: number; readonly fixedSize: null; readonly minSize: number; readonly maxSize: number; readonly isList = true; readonly isViewMutable = true; readonly limit: number; readonly mixInLengthBlockBytes: Uint8Array; readonly mixInLengthBuffer: Buffer; protected readonly defaultLen = 0; constructor(elementType: ElementType, opts?: ProgressiveListOpts); static named, CompositeView, CompositeViewDU>>(elementType: ElementType, opts: Require): ProgressiveListCompositeType; getView(tree: Tree): ProgressiveListCompositeTreeView; getViewDU(node: Node, cache?: unknown): ProgressiveListCompositeTreeViewDU; commitView(view: ProgressiveListCompositeTreeView): Node; commitViewDU(view: ProgressiveListCompositeTreeViewDU, hcOffset?: number, hcByLevel?: HashComputationLevel[] | null): Node; cacheOfViewDU(): unknown; createFromProof(proof: Proof, root?: Uint8Array): ProgressiveListCompositeTreeView; value_serializedSize(value: ValueOf[]): number; value_serializeToBytes(output: ByteViews, offset: number, value: ValueOf[]): number; value_deserializeFromBytes(data: ByteViews, start: number, end: number, reuseBytes?: boolean): ValueOf[]; tree_serializedSize(node: Node): number; tree_serializeToBytes(output: ByteViews, offset: number, node: Node): number; tree_deserializeFromBytes(data: ByteViews, start: number, end: number): Node; tree_getLength(node: Node): number; tree_setLength(tree: Tree, length: number): void; tree_getChunksNode(node: Node): Node; tree_chunksNodeOffset(): number; tree_setChunksNode(rootNode: Node, chunksNode: Node, newLength: number | null, hcOffset?: number, hcByLevel?: HashComputationLevel[] | null): Node; hashTreeRoot(value: ValueOf[]): Uint8Array; hashTreeRootInto(value: ValueOf[], output: Uint8Array, offset: number, safeCache?: boolean): void; protected getBlocksBytes(value: ValueOf[]): Uint8Array; getPropertyGindex(prop: string | number): Gindex; tree_getLeafGindices(rootGindex: Gindex, rootNode?: Node): Gindex[]; tree_fromProofNode(node: Node): { node: Node; done: boolean; }; } export declare class ProgressiveListBasicTreeView> extends TreeView> { readonly type: ProgressiveListBasicType; protected tree: Tree; constructor(type: ProgressiveListBasicType, tree: Tree); get length(): number; get node(): Node; get(index: number): ValueOf; set(index: number, value: ValueOf): void; getAll(values?: ValueOf[]): ValueOf[]; } export declare class ProgressiveListBasicTreeViewDU> extends TreeViewDU> { readonly type: ProgressiveListBasicType; protected _rootNode: Node; constructor(type: ProgressiveListBasicType, _rootNode: Node); get length(): number; get node(): Node; get cache(): unknown; commit(hcOffset?: number, hcByLevel?: HashComputationLevel[] | null): void; get(index: number): ValueOf; set(index: number, value: ValueOf): void; push(value: ValueOf): void; getAll(values?: ValueOf[]): ValueOf[]; /** * Returns a new ProgressiveListBasicTreeViewDU instance with the values from 0 to `index`. * To achieve it, rebinds the underlying tree zero-ing all nodes right of `chunkIndex`. * Also set all value right of `index` in the same chunk to 0. */ sliceTo(index: number): this; /** * Returns a new ProgressiveListBasicTreeViewDU instance with the values from `index` to the end of list. */ sliceFrom(index: number): this; protected clearCache(): void; } export declare class ProgressiveListCompositeTreeView, CompositeView, CompositeViewDU>> extends TreeView> { readonly type: ProgressiveListCompositeType; protected tree: Tree; constructor(type: ProgressiveListCompositeType, tree: Tree); get length(): number; get node(): Node; get(index: number): CompositeView; set(index: number, view: CompositeView): void; getAllReadonlyValues(values?: ValueOf[]): ValueOf[]; } export declare class ProgressiveListCompositeTreeViewDU, CompositeView, CompositeViewDU>> extends TreeViewDU> { readonly type: ProgressiveListCompositeType; protected _rootNode: Node; private nodes; private caches; private readonly viewsChanged; private nodesPopulated; constructor(type: ProgressiveListCompositeType, _rootNode: Node, cache?: ProgressiveListCompositeTreeViewDUCache); get length(): number; get node(): Node; get cache(): ProgressiveListCompositeTreeViewDUCache; commit(hcOffset?: number, hcByLevel?: HashComputationLevel[] | null): void; get(index: number): CompositeViewDU; /** * Get element at `index`. Returns a view of the Composite element type. * DOES NOT PROPAGATE CHANGES: use only for reads and to skip parent references. */ getReadonly(index: number): CompositeViewDU; set(index: number, view: CompositeViewDU): void; push(view: CompositeViewDU): void; /** * Returns all elements at every index, if an index is modified it will return the modified view. * No need to commit() before calling this function. */ getAllReadonly(views?: CompositeViewDU[]): CompositeViewDU[]; /** * Apply `fn` to each ViewDU in the array. * Similar to getAllReadOnly(), no need to commit() before calling this function. * if an item is modified it will return the modified view. */ forEach(fn: (viewDU: CompositeViewDU, index: number) => void): void; /** * WARNING: Returns all commited changes, if there are any pending changes commit them beforehand * @param values optional output parameter, if is provided it must be an array of the same length as this array */ getAllReadonlyValues(values?: ValueOf[]): ValueOf[]; /** * Apply `fn` to each value in the array. */ forEachValue(fn: (value: ValueOf, index: number) => void): void; /** * Get by range of indexes. Returns an array of views of the Composite element type. * This is similar to getAllReadonly() where we dont have to commit() before calling this function. */ getReadonlyByRange(startIndex: number, count: number): CompositeViewDU[]; /** * Returns a new ProgressiveListCompositeTreeViewDU instance with the values from 0 to `index`. * `index` is inclusive. */ sliceTo(index: number): this; /** * Returns a new ProgressiveListCompositeTreeViewDU instance with the values from `index` to the end of list. */ sliceFrom(index: number): this; protected clearCache(): void; protected populateAllNodes(): void; protected populateAllOldNodes(): void; protected rootNodeToViewDU(rootNode: Node): this; } type ProgressiveListCompositeTreeViewDUCache = { nodes?: Node[]; caches: unknown[]; nodesPopulated?: boolean; }; export {};