From d1b38f41e09e918c292c48b898681fb6f6f1de30 Mon Sep 17 00:00:00 2001 From: Tuyen Nguyen Date: Mon, 9 Sep 2024 11:10:24 +0700 Subject: [PATCH] fix: move ZERO_SNAPSHOT to ssz --- packages/persistent-merkle-tree/src/snapshot.ts | 6 ------ packages/ssz/src/util/types.ts | 8 ++++++++ packages/ssz/src/viewDU/partialListComposite.ts | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/persistent-merkle-tree/src/snapshot.ts b/packages/persistent-merkle-tree/src/snapshot.ts index 38b2d877..bc076d0e 100644 --- a/packages/persistent-merkle-tree/src/snapshot.ts +++ b/packages/persistent-merkle-tree/src/snapshot.ts @@ -8,12 +8,6 @@ type Snapshot = { count: number; }; -export const ZERO_SNAPSHOT = { - finalized: [], - root: zeroNode(0).root, - count: 0, -}; - /** * Given a tree, return a snapshot of the tree with the root, finalized nodes, and count. * Tree could be full tree, or partial tree. See https://github.com/ChainSafe/ssz/issues/293 diff --git a/packages/ssz/src/util/types.ts b/packages/ssz/src/util/types.ts index a456ed58..6cf476e1 100644 --- a/packages/ssz/src/util/types.ts +++ b/packages/ssz/src/util/types.ts @@ -1,3 +1,5 @@ +import {zeroNode} from "@chainsafe/persistent-merkle-tree"; + export type Require = T & Required>; export type Snapshot = { @@ -5,3 +7,9 @@ export type Snapshot = { root: Uint8Array; count: number; }; + +export const ZERO_SNAPSHOT = { + finalized: [], + root: zeroNode(0).root, + count: 0, +}; diff --git a/packages/ssz/src/viewDU/partialListComposite.ts b/packages/ssz/src/viewDU/partialListComposite.ts index a957e02b..c2aa5faa 100644 --- a/packages/ssz/src/viewDU/partialListComposite.ts +++ b/packages/ssz/src/viewDU/partialListComposite.ts @@ -1,10 +1,10 @@ -import {Node, zeroNode, subtreeFillToContents, getNodesAtDepth, ZERO_SNAPSHOT} from "@chainsafe/persistent-merkle-tree"; +import {Node, zeroNode, subtreeFillToContents, getNodesAtDepth} from "@chainsafe/persistent-merkle-tree"; import {ValueOf} from "../type/abstract"; import {CompositeType, CompositeView, CompositeViewDU} from "../type/composite"; import {ArrayCompositeTreeViewDUCache} from "./arrayComposite"; import {ListCompositeTreeViewDU} from "./listComposite"; import {PartialListCompositeType} from "../type/partialListComposite"; -import {Snapshot} from "../util/types"; +import {Snapshot, ZERO_SNAPSHOT} from "../util/types"; /** * Similar to ListCompositeTreeViewDU but this is created from a snapshot so some methods are not supported