update @zk-kit/incremental-merkle-tree.sol readme

This commit is contained in:
Jack Gilcrest
2022-07-10 00:20:20 -04:00
parent 43f19247b1
commit 299c522ba9
2 changed files with 15 additions and 0 deletions

View File

@@ -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,

View File

@@ -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);