@interest-protocol/vortex-sdk 6.0.0 → 6.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interest-protocol/vortex-sdk",
3
- "version": "6.0.0",
3
+ "version": "6.2.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "module": "./dist/index.mjs",
@@ -2,13 +2,22 @@
2
2
 
3
3
  import { ZERO_VALUE, MERKLE_TREE_HEIGHT } from '../constants';
4
4
  import { poseidon2 } from '../crypto';
5
- import { Element, MerkleTree as FixedMerkleTree } from 'fixed-merkle-tree';
5
+ import {
6
+ Element,
7
+ MerkleTree as FixedMerkleTree,
8
+ SerializedTreeState,
9
+ } from 'fixed-merkle-tree';
6
10
 
7
- export const buildMerkleTree = () =>
8
- new FixedMerkleTree(MERKLE_TREE_HEIGHT, [], {
9
- hashFunction: (left: Element, right: Element) =>
10
- poseidon2(BigInt(left), BigInt(right)).toString(),
11
+ export const merkleTreeHashFunction = (left: Element, right: Element) =>
12
+ poseidon2(BigInt(left), BigInt(right)).toString();
13
+
14
+ export const buildMerkleTree = (elements: Element[] = []) =>
15
+ new FixedMerkleTree(MERKLE_TREE_HEIGHT, elements, {
16
+ hashFunction: merkleTreeHashFunction,
11
17
  zeroElement: ZERO_VALUE.toString(),
12
18
  });
13
19
 
20
+ export const deserializeMerkleTree = (data: SerializedTreeState) =>
21
+ FixedMerkleTree.deserialize(data, merkleTreeHashFunction);
22
+
14
23
  export type MerkleTree = FixedMerkleTree;