Files
linea-monorepo/contracts/docs/api/messageService/lib/SparseMerkleTreeVerifier.mdx
kyzooghost ea79b2d2be [Feat] Automate smart contract docgen and PR branch creation into Linea docs repo (#446)
* did poc for autogenerated *.mdx into docs.linea.build

* changed sparseMerkleProof

* first draft of contracts-docgen

* fix typos

* try different github token

* cleanup

* created create-docs-website-pr-branch

* cleanup for doc website repo scripts

* created first docs-repo pr using create-docs-website-pr-branch.sh

* improve comments

* added bash script segment to change filename to lowercase

* fix *.mdx headers to make more docusarus friendly

* update scripts for updated docs pr

* added comments to updateSidebar.js

* fix scripts after local test

* added installation checks

* Update contracts/docs/scripts/create-docs-website-pr-branch.sh

Co-authored-by: The Dark Jester <thedarkjester@users.noreply.github.com>
Signed-off-by: kyzooghost <73516204+kyzooghost@users.noreply.github.com>

---------

Signed-off-by: kyzooghost <73516204+kyzooghost@users.noreply.github.com>
Co-authored-by: The Dark Jester <thedarkjester@users.noreply.github.com>
2024-12-20 20:45:36 +11:00

67 lines
1.5 KiB
Plaintext

# `SparseMerkleTreeVerifier`
### SafeCastOverflowedUintDowncast
```solidity
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value)
```
_Value doesn't fit in a uint of `bits` size.
This is based on OpenZeppelin's SafeCast library._
### LeafIndexOutOfBounds
```solidity
error LeafIndexOutOfBounds(uint32 leafIndex, uint32 maxAllowedIndex)
```
_Custom error for when the leaf index is out of bounds._
### _verifyMerkleProof
```solidity
function _verifyMerkleProof(bytes32 _leafHash, bytes32[] _proof, uint32 _leafIndex, bytes32 _root) internal pure returns (bool proofIsValid)
```
Verify merkle proof
_The depth of the tree is expected to be validated elsewhere beforehand._
#### Parameters
| Name | Type | Description |
| ---- | ---- | ----------- |
| _leafHash | bytes32 | Leaf hash. |
| _proof | bytes32[] | Sparse merkle tree proof. |
| _leafIndex | uint32 | Index of the leaf. |
| _root | bytes32 | Merkle root. |
#### Return Values
| Name | Type | Description |
| ---- | ---- | ----------- |
| proofIsValid | bool | Returns if the proof is valid or not. |
### safeCastToUint32
```solidity
function safeCastToUint32(uint256 _value) internal pure returns (uint32 castUint32)
```
Tries to safely cast to uint32.
_This is based on OpenZeppelin's SafeCast library._
#### Parameters
| Name | Type | Description |
| ---- | ---- | ----------- |
| _value | uint256 | The value being cast to uint32. |
#### Return Values
| Name | Type | Description |
| ---- | ---- | ----------- |
| castUint32 | uint32 | Returns a uint32 safely cast. |