@feelyourprotocol/mpt 8141.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/README.md +448 -0
  2. package/dist/cjs/constructors.d.ts +12 -0
  3. package/dist/cjs/constructors.d.ts.map +1 -0
  4. package/dist/cjs/constructors.js +57 -0
  5. package/dist/cjs/constructors.js.map +1 -0
  6. package/dist/cjs/db/checkpointDB.d.ts +87 -0
  7. package/dist/cjs/db/checkpointDB.d.ts.map +1 -0
  8. package/dist/cjs/db/checkpointDB.js +258 -0
  9. package/dist/cjs/db/checkpointDB.js.map +1 -0
  10. package/dist/cjs/db/index.d.ts +2 -0
  11. package/dist/cjs/db/index.d.ts.map +1 -0
  12. package/dist/cjs/db/index.js +18 -0
  13. package/dist/cjs/db/index.js.map +1 -0
  14. package/dist/cjs/index.d.ts +8 -0
  15. package/dist/cjs/index.d.ts.map +1 -0
  16. package/dist/cjs/index.js +24 -0
  17. package/dist/cjs/index.js.map +1 -0
  18. package/dist/cjs/mpt.d.ts +261 -0
  19. package/dist/cjs/mpt.d.ts.map +1 -0
  20. package/dist/cjs/mpt.js +900 -0
  21. package/dist/cjs/mpt.js.map +1 -0
  22. package/dist/cjs/node/branch.d.ts +14 -0
  23. package/dist/cjs/node/branch.d.ts.map +1 -0
  24. package/dist/cjs/node/branch.js +52 -0
  25. package/dist/cjs/node/branch.js.map +1 -0
  26. package/dist/cjs/node/extension.d.ts +7 -0
  27. package/dist/cjs/node/extension.d.ts.map +1 -0
  28. package/dist/cjs/node/extension.js +14 -0
  29. package/dist/cjs/node/extension.js.map +1 -0
  30. package/dist/cjs/node/extensionOrLeafNodeBase.d.ts +15 -0
  31. package/dist/cjs/node/extensionOrLeafNodeBase.d.ts.map +1 -0
  32. package/dist/cjs/node/extensionOrLeafNodeBase.js +42 -0
  33. package/dist/cjs/node/extensionOrLeafNodeBase.js.map +1 -0
  34. package/dist/cjs/node/index.d.ts +5 -0
  35. package/dist/cjs/node/index.d.ts.map +1 -0
  36. package/dist/cjs/node/index.js +21 -0
  37. package/dist/cjs/node/index.js.map +1 -0
  38. package/dist/cjs/node/leaf.d.ts +7 -0
  39. package/dist/cjs/node/leaf.d.ts.map +1 -0
  40. package/dist/cjs/node/leaf.js +14 -0
  41. package/dist/cjs/node/leaf.js.map +1 -0
  42. package/dist/cjs/node/util.d.ts +8 -0
  43. package/dist/cjs/node/util.d.ts.map +1 -0
  44. package/dist/cjs/node/util.js +38 -0
  45. package/dist/cjs/node/util.js.map +1 -0
  46. package/dist/cjs/package.json +3 -0
  47. package/dist/cjs/proof/index.d.ts +3 -0
  48. package/dist/cjs/proof/index.d.ts.map +1 -0
  49. package/dist/cjs/proof/index.js +19 -0
  50. package/dist/cjs/proof/index.js.map +1 -0
  51. package/dist/cjs/proof/proof.d.ts +41 -0
  52. package/dist/cjs/proof/proof.d.ts.map +1 -0
  53. package/dist/cjs/proof/proof.js +119 -0
  54. package/dist/cjs/proof/proof.js.map +1 -0
  55. package/dist/cjs/proof/range.d.ts +35 -0
  56. package/dist/cjs/proof/range.d.ts.map +1 -0
  57. package/dist/cjs/proof/range.js +456 -0
  58. package/dist/cjs/proof/range.js.map +1 -0
  59. package/dist/cjs/types.d.ts +110 -0
  60. package/dist/cjs/types.d.ts.map +1 -0
  61. package/dist/cjs/types.js +6 -0
  62. package/dist/cjs/types.js.map +1 -0
  63. package/dist/cjs/util/asyncWalk.d.ts +20 -0
  64. package/dist/cjs/util/asyncWalk.d.ts.map +1 -0
  65. package/dist/cjs/util/asyncWalk.js +50 -0
  66. package/dist/cjs/util/asyncWalk.js.map +1 -0
  67. package/dist/cjs/util/encoding.d.ts +31 -0
  68. package/dist/cjs/util/encoding.d.ts.map +1 -0
  69. package/dist/cjs/util/encoding.js +200 -0
  70. package/dist/cjs/util/encoding.js.map +1 -0
  71. package/dist/cjs/util/genesisState.d.ts +6 -0
  72. package/dist/cjs/util/genesisState.d.ts.map +1 -0
  73. package/dist/cjs/util/genesisState.js +45 -0
  74. package/dist/cjs/util/genesisState.js.map +1 -0
  75. package/dist/cjs/util/hex.d.ts +20 -0
  76. package/dist/cjs/util/hex.d.ts.map +1 -0
  77. package/dist/cjs/util/hex.js +48 -0
  78. package/dist/cjs/util/hex.js.map +1 -0
  79. package/dist/cjs/util/index.d.ts +4 -0
  80. package/dist/cjs/util/index.d.ts.map +1 -0
  81. package/dist/cjs/util/index.js +20 -0
  82. package/dist/cjs/util/index.js.map +1 -0
  83. package/dist/cjs/util/nibbles.d.ts +30 -0
  84. package/dist/cjs/util/nibbles.d.ts.map +1 -0
  85. package/dist/cjs/util/nibbles.js +79 -0
  86. package/dist/cjs/util/nibbles.js.map +1 -0
  87. package/dist/cjs/util/walkController.d.ts +72 -0
  88. package/dist/cjs/util/walkController.d.ts.map +1 -0
  89. package/dist/cjs/util/walkController.js +138 -0
  90. package/dist/cjs/util/walkController.js.map +1 -0
  91. package/dist/esm/constructors.d.ts +12 -0
  92. package/dist/esm/constructors.d.ts.map +1 -0
  93. package/dist/esm/constructors.js +53 -0
  94. package/dist/esm/constructors.js.map +1 -0
  95. package/dist/esm/db/checkpointDB.d.ts +87 -0
  96. package/dist/esm/db/checkpointDB.d.ts.map +1 -0
  97. package/dist/esm/db/checkpointDB.js +254 -0
  98. package/dist/esm/db/checkpointDB.js.map +1 -0
  99. package/dist/esm/db/index.d.ts +2 -0
  100. package/dist/esm/db/index.d.ts.map +1 -0
  101. package/dist/esm/db/index.js +2 -0
  102. package/dist/esm/db/index.js.map +1 -0
  103. package/dist/esm/index.d.ts +8 -0
  104. package/dist/esm/index.d.ts.map +1 -0
  105. package/dist/esm/index.js +8 -0
  106. package/dist/esm/index.js.map +1 -0
  107. package/dist/esm/mpt.d.ts +261 -0
  108. package/dist/esm/mpt.d.ts.map +1 -0
  109. package/dist/esm/mpt.js +897 -0
  110. package/dist/esm/mpt.js.map +1 -0
  111. package/dist/esm/node/branch.d.ts +14 -0
  112. package/dist/esm/node/branch.d.ts.map +1 -0
  113. package/dist/esm/node/branch.js +48 -0
  114. package/dist/esm/node/branch.js.map +1 -0
  115. package/dist/esm/node/extension.d.ts +7 -0
  116. package/dist/esm/node/extension.d.ts.map +1 -0
  117. package/dist/esm/node/extension.js +10 -0
  118. package/dist/esm/node/extension.js.map +1 -0
  119. package/dist/esm/node/extensionOrLeafNodeBase.d.ts +15 -0
  120. package/dist/esm/node/extensionOrLeafNodeBase.d.ts.map +1 -0
  121. package/dist/esm/node/extensionOrLeafNodeBase.js +38 -0
  122. package/dist/esm/node/extensionOrLeafNodeBase.js.map +1 -0
  123. package/dist/esm/node/index.d.ts +5 -0
  124. package/dist/esm/node/index.d.ts.map +1 -0
  125. package/dist/esm/node/index.js +5 -0
  126. package/dist/esm/node/index.js.map +1 -0
  127. package/dist/esm/node/leaf.d.ts +7 -0
  128. package/dist/esm/node/leaf.d.ts.map +1 -0
  129. package/dist/esm/node/leaf.js +10 -0
  130. package/dist/esm/node/leaf.js.map +1 -0
  131. package/dist/esm/node/util.d.ts +8 -0
  132. package/dist/esm/node/util.d.ts.map +1 -0
  133. package/dist/esm/node/util.js +33 -0
  134. package/dist/esm/node/util.js.map +1 -0
  135. package/dist/esm/package.json +3 -0
  136. package/dist/esm/proof/index.d.ts +3 -0
  137. package/dist/esm/proof/index.d.ts.map +1 -0
  138. package/dist/esm/proof/index.js +3 -0
  139. package/dist/esm/proof/index.js.map +1 -0
  140. package/dist/esm/proof/proof.d.ts +41 -0
  141. package/dist/esm/proof/proof.d.ts.map +1 -0
  142. package/dist/esm/proof/proof.js +113 -0
  143. package/dist/esm/proof/proof.js.map +1 -0
  144. package/dist/esm/proof/range.d.ts +35 -0
  145. package/dist/esm/proof/range.d.ts.map +1 -0
  146. package/dist/esm/proof/range.js +453 -0
  147. package/dist/esm/proof/range.js.map +1 -0
  148. package/dist/esm/types.d.ts +110 -0
  149. package/dist/esm/types.d.ts.map +1 -0
  150. package/dist/esm/types.js +3 -0
  151. package/dist/esm/types.js.map +1 -0
  152. package/dist/esm/util/asyncWalk.d.ts +20 -0
  153. package/dist/esm/util/asyncWalk.d.ts.map +1 -0
  154. package/dist/esm/util/asyncWalk.js +47 -0
  155. package/dist/esm/util/asyncWalk.js.map +1 -0
  156. package/dist/esm/util/encoding.d.ts +31 -0
  157. package/dist/esm/util/encoding.d.ts.map +1 -0
  158. package/dist/esm/util/encoding.js +188 -0
  159. package/dist/esm/util/encoding.js.map +1 -0
  160. package/dist/esm/util/genesisState.d.ts +6 -0
  161. package/dist/esm/util/genesisState.d.ts.map +1 -0
  162. package/dist/esm/util/genesisState.js +42 -0
  163. package/dist/esm/util/genesisState.js.map +1 -0
  164. package/dist/esm/util/hex.d.ts +20 -0
  165. package/dist/esm/util/hex.d.ts.map +1 -0
  166. package/dist/esm/util/hex.js +43 -0
  167. package/dist/esm/util/hex.js.map +1 -0
  168. package/dist/esm/util/index.d.ts +4 -0
  169. package/dist/esm/util/index.d.ts.map +1 -0
  170. package/dist/esm/util/index.js +4 -0
  171. package/dist/esm/util/index.js.map +1 -0
  172. package/dist/esm/util/nibbles.d.ts +30 -0
  173. package/dist/esm/util/nibbles.d.ts.map +1 -0
  174. package/dist/esm/util/nibbles.js +73 -0
  175. package/dist/esm/util/nibbles.js.map +1 -0
  176. package/dist/esm/util/walkController.d.ts +72 -0
  177. package/dist/esm/util/walkController.d.ts.map +1 -0
  178. package/dist/esm/util/walkController.js +134 -0
  179. package/dist/esm/util/walkController.js.map +1 -0
  180. package/dist/tsconfig.prod.cjs.tsbuildinfo +1 -0
  181. package/dist/tsconfig.prod.esm.tsbuildinfo +1 -0
  182. package/package.json +85 -0
  183. package/src/constructors.ts +71 -0
  184. package/src/db/checkpointDB.ts +298 -0
  185. package/src/db/index.ts +1 -0
  186. package/src/index.ts +7 -0
  187. package/src/mpt.ts +1090 -0
  188. package/src/node/branch.ts +60 -0
  189. package/src/node/extension.ts +13 -0
  190. package/src/node/extensionOrLeafNodeBase.ts +54 -0
  191. package/src/node/index.ts +4 -0
  192. package/src/node/leaf.ts +13 -0
  193. package/src/node/util.ts +35 -0
  194. package/src/proof/index.ts +2 -0
  195. package/src/proof/proof.ts +135 -0
  196. package/src/proof/range.ts +542 -0
  197. package/src/types.ts +151 -0
  198. package/src/util/asyncWalk.ts +60 -0
  199. package/src/util/encoding.ts +209 -0
  200. package/src/util/genesisState.ts +52 -0
  201. package/src/util/hex.ts +47 -0
  202. package/src/util/index.ts +3 -0
  203. package/src/util/nibbles.ts +80 -0
  204. package/src/util/walkController.ts +172 -0
@@ -0,0 +1,2 @@
1
+ export * from "./checkpointDB.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/db/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
@@ -0,0 +1,8 @@
1
+ export * from './constructors.ts';
2
+ export * from './db/index.ts';
3
+ export * from './mpt.ts';
4
+ export * from './node/index.ts';
5
+ export * from './proof/index.ts';
6
+ export * from './types.ts';
7
+ export * from './util/index.ts';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA"}
@@ -0,0 +1,8 @@
1
+ export * from "./constructors.js";
2
+ export * from "./db/index.js";
3
+ export * from "./mpt.js";
4
+ export * from "./node/index.js";
5
+ export * from "./proof/index.js";
6
+ export * from "./types.js";
7
+ export * from "./util/index.js";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA"}
@@ -0,0 +1,261 @@
1
+ import { Lock, ValueEncoding } from '@feelyourprotocol/util';
2
+ import { CheckpointDB } from './db/checkpointDB.ts';
3
+ import type { BatchDBOp, DB } from '@feelyourprotocol/util';
4
+ import type { Debugger } from 'debug';
5
+ import type { BranchMPTNodeBranchValue, FoundNodeFunction, MPTNode, MPTOpts, MPTOptsWithDefaults, Nibbles, NodeReferenceOrRawMPTNode, Path, TrieShallowCopyOpts } from './types.ts';
6
+ import type { OnFound } from './util/asyncWalk.ts';
7
+ /**
8
+ * The basic trie interface, use with `import { MerklePatriciaTrie } from '@feelyourprotocol/mpt'`.
9
+ *
10
+ * A MerklePatriciaTrie object can be created with the constructor method:
11
+ *
12
+ * - {@link createMPT}
13
+ *
14
+ * A sparse MerklePatriciaTrie object can be created from a merkle proof:
15
+ *
16
+ * - {@link createMPTFromProof}
17
+ */
18
+ /**
19
+ * Merkle Patricia Trie - a space-optimized trie where each node with only one child
20
+ * is merged with its parent. Used for Ethereum state and storage.
21
+ *
22
+ * Node types:
23
+ * - Branch: 16-way branch + optional value (for keys ending at this node)
24
+ * - Extension: short path (nibbles) → child node
25
+ * - Leaf: remaining path (nibbles) → value
26
+ */
27
+ export declare class MerklePatriciaTrie {
28
+ /** Options with defaults applied */
29
+ protected readonly _opts: MPTOptsWithDefaults;
30
+ /** The root for an empty trie */
31
+ EMPTY_TRIE_ROOT: Uint8Array;
32
+ /** The backend DB */
33
+ protected _db: CheckpointDB;
34
+ protected _hashLen: number;
35
+ protected _lock: Lock;
36
+ protected _root: Uint8Array;
37
+ /** Debug logging */
38
+ protected DEBUG: boolean;
39
+ protected _debug: Debugger;
40
+ protected debug: (...args: any) => void;
41
+ /**
42
+ * Creates a new trie.
43
+ * @param opts Options for instantiating the trie
44
+ *
45
+ * Note: in most cases, {@link createMPT} constructor should be used. It uses the same API but provides sensible defaults
46
+ */
47
+ constructor(opts?: MPTOpts);
48
+ database(db?: DB<string, string | Uint8Array>, valueEncoding?: ValueEncoding): CheckpointDB;
49
+ /**
50
+ * Gets and/or Sets the current root of the `trie`
51
+ */
52
+ root(value?: Uint8Array | null): Uint8Array;
53
+ /**
54
+ * Checks if a given root exists.
55
+ */
56
+ checkRoot(root: Uint8Array): Promise<boolean>;
57
+ /**
58
+ * Gets a value given a `key`
59
+ * @param key - the key to search for
60
+ * @param throwIfMissing - if true, throws if any nodes are missing. Used for verifying proofs. (default: false)
61
+ * @returns A Promise that resolves to `Uint8Array` if a value was found or `null` if no value was found.
62
+ */
63
+ get(key: Uint8Array, throwIfMissing?: boolean): Promise<Uint8Array | null>;
64
+ /**
65
+ * Stores a given `value` at the given `key` or do a delete if `value` is empty
66
+ * (delete operations are only executed on DB with `deleteFromDB` set to `true`)
67
+ * @param key
68
+ * @param value
69
+ * @returns A Promise that resolves once value is stored.
70
+ */
71
+ put(key: Uint8Array, value: Uint8Array | null, skipKeyTransform?: boolean): Promise<void>;
72
+ /**
73
+ * Deletes a value given a `key` from the trie
74
+ * (delete operations are only executed on DB with `deleteFromDB` set to `true`)
75
+ * @param key
76
+ * @returns A Promise that resolves once value is deleted.
77
+ */
78
+ del(key: Uint8Array, skipKeyTransform?: boolean): Promise<void>;
79
+ /**
80
+ * Finds the path from root to the node for the given key.
81
+ * Walks the trie, matching nibbles at each level. Returns the target node (if found)
82
+ * and the stack of nodes along the path (needed for updates/deletes).
83
+ *
84
+ * @param key - the search key (bytes)
85
+ * @param throwIfMissing - if true, throws when nodes are missing (e.g. proof verification)
86
+ * @param partialPath - optional pre-loaded stack for resuming from a mid-path node
87
+ */
88
+ findPath(key: Uint8Array, throwIfMissing?: boolean, partialPath?: {
89
+ stack: MPTNode[];
90
+ }): Promise<Path>;
91
+ /**
92
+ * Walks a trie until finished.
93
+ * @param root
94
+ * @param onFound - callback to call when a node is found. This schedules new tasks. If no tasks are available, the Promise resolves.
95
+ * @returns Resolves when finished walking trie.
96
+ */
97
+ walkTrie(root: Uint8Array, onFound: FoundNodeFunction): Promise<void>;
98
+ walkTrieIterable: (nodeHash: Uint8Array<ArrayBufferLike>, currentKey?: number[] | undefined, onFound?: OnFound | undefined, filter?: import("./util/asyncWalk.ts").NodeFilter | undefined, visited?: Set<string> | undefined) => AsyncIterable<{
99
+ node: MPTNode;
100
+ currentKey: number[];
101
+ }>;
102
+ /**
103
+ * Executes a callback for each node in the trie.
104
+ * @param onFound - callback to call when a node is found.
105
+ * @returns Resolves when finished walking trie.
106
+ */
107
+ walkAllNodes(onFound: OnFound): Promise<void>;
108
+ /**
109
+ * Executes a callback for each value node in the trie.
110
+ * @param onFound - callback to call when a node is found.
111
+ * @returns Resolves when finished walking trie.
112
+ */
113
+ walkAllValueNodes(onFound: OnFound): Promise<void>;
114
+ /**
115
+ * Creates the initial leaf node when inserting into an empty trie.
116
+ * @private
117
+ */
118
+ protected _createInitialNode(key: Uint8Array, value: Uint8Array): Promise<void>;
119
+ /**
120
+ * Retrieves a node from db by hash.
121
+ */
122
+ lookupNode(node: Uint8Array | Uint8Array[]): Promise<MPTNode>;
123
+ /**
124
+ * True when we're updating an existing leaf value (key already exists, no structural change).
125
+ * @private
126
+ */
127
+ protected _isMatchingLeafUpdate(lastNode: MPTNode, stack: MPTNode[], fullKeyNibbles: Nibbles, keyRemainder: Nibbles): boolean;
128
+ /**
129
+ * Applies a value update given the path from findPath. Modifies the stack in-place
130
+ * to represent the new structure, then calls saveStack to persist.
131
+ *
132
+ * Three cases:
133
+ * 1. Match leaf: key exists, just update value (no structure change)
134
+ * 2. Branch: add new leaf to branch, or set branch value
135
+ * 3. Extension/Leaf with diverging path: create new branch at divergence, re-hang old + new leaf
136
+ *
137
+ * @private
138
+ */
139
+ protected _updateNode(keyBytes: Uint8Array, value: Uint8Array, keyRemainder: Nibbles, stack: MPTNode[]): Promise<void>;
140
+ /**
141
+ * Removes a key from the trie. Handles two main cases:
142
+ * - Deleting from a leaf: remove leaf, possibly collapse parent branch
143
+ * - Deleting from a branch value: clear value, possibly collapse if branch has single child
144
+ *
145
+ * When a branch ends up with only one child after deletion, we collapse it into
146
+ * an extension (or merge with parent extension) to keep the trie minimal.
147
+ *
148
+ * @private
149
+ */
150
+ protected _deleteNode(keyBytes: Uint8Array, stack: MPTNode[]): Promise<void>;
151
+ /**
152
+ * Persists the modified node stack to the DB. Processes nodes from leaf toward root,
153
+ * wiring each node's references (extension value, branch slot) to its child's hash.
154
+ *
155
+ * @param key - nibble path that corresponds to the stack
156
+ * @param stack - nodes from findPath/update, bottom (leaf) to top (root)
157
+ * @param opStack - put/del operations accumulated by _formatNode
158
+ */
159
+ saveStack(pathNibbles: Nibbles, stack: MPTNode[], opStack: BatchDBOp[]): Promise<void>;
160
+ /**
161
+ * Serializes a node and either stores it (put) or schedules removal (del).
162
+ * Nodes ≥32 bytes (or top-level) are hashed and stored; smaller nodes are inlined as raw.
163
+ *
164
+ * @param node - the node to persist
165
+ * @param topLevel - if true, always store (root must be in DB)
166
+ * @param opStack - accumulates put/del operations for batch commit
167
+ * @param remove - if true, schedule del (used when pruning)
168
+ * @returns hash (for references) or raw encoding (for inline)
169
+ */
170
+ _formatNode(node: MPTNode, topLevel: boolean, opStack: BatchDBOp[], remove?: boolean): Uint8Array | NodeReferenceOrRawMPTNode | BranchMPTNodeBranchValue[];
171
+ /**
172
+ * The given hash of operations (key additions or deletions) are executed on the trie
173
+ * (delete operations are only executed on DB with `deleteFromDB` set to `true`)
174
+ * @example
175
+ * const ops = [
176
+ * { type: 'del', key: Uint8Array.from('father') }
177
+ * , { type: 'put', key: Uint8Array.from('name'), value: Uint8Array.from('Yuri Irsenovich Kim') } // cspell:disable-line
178
+ * , { type: 'put', key: Uint8Array.from('dob'), value: Uint8Array.from('16 February 1941') }
179
+ * , { type: 'put', key: Uint8Array.from('spouse'), value: Uint8Array.from('Kim Young-sook') } // cspell:disable-line
180
+ * , { type: 'put', key: Uint8Array.from('occupation'), value: Uint8Array.from('Clown') }
181
+ * ]
182
+ * await trie.batch(ops)
183
+ * @param ops
184
+ */
185
+ batch(ops: BatchDBOp[], skipKeyTransform?: boolean): Promise<void>;
186
+ /**
187
+ * Verifies that every key in the DB is reachable from the root. Used to ensure
188
+ * pruning is correct – unreachable keys indicate a bug or corrupt state.
189
+ */
190
+ verifyPrunedIntegrity(): Promise<boolean>;
191
+ /**
192
+ * Returns a copy of the underlying trie.
193
+ *
194
+ * Note on db: the copy will create a reference to the
195
+ * same underlying database.
196
+ *
197
+ * Note on cache: for memory reasons a copy will by default
198
+ * not recreate a new LRU cache but initialize with cache
199
+ * being deactivated. This behavior can be overwritten by
200
+ * explicitly setting `cacheSize` as an option on the method.
201
+ *
202
+ * @param includeCheckpoints - If true and during a checkpoint, the copy will contain the checkpointing metadata and will use the same scratch as underlying db.
203
+ */
204
+ shallowCopy(includeCheckpoints?: boolean, opts?: TrieShallowCopyOpts): MerklePatriciaTrie;
205
+ /**
206
+ * Persists the root hash in the underlying database
207
+ */
208
+ persistRoot(): Promise<void>;
209
+ /**
210
+ * Finds all nodes that are stored directly in the db
211
+ * (some nodes are stored raw inside other nodes)
212
+ * called by {@link ScratchReadStream}
213
+ * @private
214
+ */
215
+ protected _findDbNodes(onFound: FoundNodeFunction): Promise<void>;
216
+ /** Applies keyPrefix to a hash when multiple tries share a DB. */
217
+ protected _getDbKey(hash: Uint8Array): Uint8Array;
218
+ /** Builds del ops for nodes that will be replaced (pruning). */
219
+ protected _createPruneDeleteOps(stack: MPTNode[]): BatchDBOp[];
220
+ /** Applies key hashing (keccak) when useKeyHashing is enabled (Ethereum-style). */
221
+ protected appliedKey(key: Uint8Array): Uint8Array<ArrayBufferLike>;
222
+ protected hash(inputBytes: Uint8Array): Uint8Array;
223
+ /**
224
+ * Is the trie during a checkpoint phase?
225
+ */
226
+ hasCheckpoints(): boolean;
227
+ /**
228
+ * Creates a checkpoint that can later be reverted to or committed.
229
+ * After this is called, all changes can be reverted until `commit` is called.
230
+ */
231
+ checkpoint(): void;
232
+ /**
233
+ * Commits a checkpoint to disk, if current checkpoint is not nested.
234
+ * If nested, only sets the parent checkpoint as current checkpoint.
235
+ * @throws If not during a checkpoint phase
236
+ */
237
+ commit(): Promise<void>;
238
+ /**
239
+ * Reverts the trie to the state it was at when `checkpoint` was first called.
240
+ * If during a nested checkpoint, sets root to most recent checkpoint, and sets
241
+ * parent checkpoint as current.
242
+ */
243
+ revert(): Promise<void>;
244
+ /**
245
+ * Flushes all checkpoints, restoring the initial checkpoint state.
246
+ */
247
+ flushCheckpoints(): void;
248
+ /**
249
+ * Returns a list of values stored in the trie
250
+ * @param startKey first unhashed key in the range to be returned (defaults to 0). Note, all keys must be of the same length or undefined behavior will result
251
+ * @param limit - the number of keys to be returned (undefined means all keys)
252
+ * @returns an object with two properties (a map of all key/value pairs in the trie - or in the specified range) and then a `nextKey` reference if a range is specified
253
+ */
254
+ getValueMap(startKey?: bigint, limit?: number): Promise<{
255
+ values: {
256
+ [key: string]: string;
257
+ };
258
+ nextKey: null | string;
259
+ }>;
260
+ }
261
+ //# sourceMappingURL=mpt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpt.d.ts","sourceRoot":"","sources":["../../src/mpt.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,IAAI,EAGJ,aAAa,EAQd,MAAM,kBAAkB,CAAA;AAIzB,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAcnD,OAAO,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACrC,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,OAAO,EACP,OAAO,EACP,mBAAmB,EACnB,OAAO,EACP,yBAAyB,EACzB,IAAI,EACJ,mBAAmB,EACpB,MAAM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