mirror of
https://github.com/privacy-scaling-explorations/zk-kit.git
synced 2026-04-22 03:00:15 -04:00
update @zk-kit/incremental-merkle-tree.sol readme
This commit is contained in:
@@ -74,6 +74,7 @@ contract Example {
|
||||
|
||||
event TreeCreated(bytes32 id, uint8 depth);
|
||||
event LeafInserted(bytes32 indexed treeId, uint256 leaf, uint256 root);
|
||||
event LeadUpdated(bytes32 indexed treeId, uint256 leaf, uint256 root);
|
||||
event LeafRemoved(bytes32 indexed treeId, uint256 leaf, uint256 root);
|
||||
|
||||
mapping(bytes32 => IncrementalTreeData) public trees;
|
||||
@@ -94,6 +95,19 @@ contract Example {
|
||||
emit LeafInserted(_treeId, _leaf, trees[_treeId].root);
|
||||
}
|
||||
|
||||
function updateLeaf(
|
||||
bytes32 _treeId,
|
||||
uint256 _leaf,
|
||||
uint256[] calldata _proofSiblings,
|
||||
uint8[] calldata _proofPathIndices
|
||||
) external {
|
||||
require(trees[_treeId].depth != 0, "Example: tree does not exist");
|
||||
|
||||
trees[_treeId].update(_leaf, _proofSiblings, _proofPathIndices);
|
||||
|
||||
emit LeafUpdated(_treeId, _leaf, trees[_treeId].root);
|
||||
}
|
||||
|
||||
function removeLeaf(
|
||||
bytes32 _treeId,
|
||||
uint256 _leaf,
|
||||
|
||||
@@ -37,6 +37,7 @@ contract IncrementalBinaryTreeTest {
|
||||
uint8[] calldata _proofPathIndices
|
||||
) external {
|
||||
require(trees[_treeId].depth != 0, "BinaryTreeTest: tree does not exist");
|
||||
|
||||
trees[_treeId].update(_leaf, _proofSiblings, _proofPathIndices);
|
||||
|
||||
emit LeafUpdated(_treeId, _leaf, trees[_treeId].root);
|
||||
|
||||
Reference in New Issue
Block a user