UNPKG

@aeternity/aepp-sdk

Version:

SDK for the æternity blockchain

42 lines (41 loc) 1.5 kB
import { EntryTag } from '../entry/constants.js'; import { Encoded, Encoding } from '../../../utils/encoder.js'; import type { unpackEntry } from '../entry/index.js'; import type { EntUnpacked } from '../entry/schema.generated.js'; type MPTreeBinary = [Buffer, Array<[Buffer, Buffer[]]>]; declare class MPTree<E extends Encoding, T extends EntryTag> { #private; get isComplete(): boolean; /** * Deserialize Merkle Patricia Tree * @param binary - Binary * @param tag - Tag to use to decode value * @param unpEnt - Implementation of unpackEntry use to decode values * @returns Merkle Patricia Tree */ constructor(binary: MPTreeBinary, encoding: E, tag: T, unpEnt: typeof unpackEntry); isEqual(tree: MPTree<E, T>): boolean; /** * Serialize Merkle Patricia Tree * @returns Binary */ serialize(): MPTreeBinary; /** * Retrieve value from Merkle Patricia Tree * @param key - The key of the element to retrieve * @returns Value associated to the specified key */ get(key: Encoded.Generic<E>): (EntUnpacked & { tag: T; }) | undefined; toObject(): Record<Encoded.Generic<E>, EntUnpacked & { tag: T; }>; } export default function genMPTreeField<E extends Encoding, T extends EntryTag>(encoding: E, tag: T): { serialize: (value: MPTree<E, T>) => MPTreeBinary; deserialize: (value: MPTreeBinary, o: { unpackEntry: typeof unpackEntry; }) => MPTree<E, T>; }; export {};