File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ pragma solidity ^0.8.30;
33
44import {Arrays} from "@openzeppelin-contracts-5.7.0/utils/Arrays.sol " ;
55import {Math} from "@openzeppelin-contracts-5.7.0/utils/math/Math.sol " ;
6+ import {SafeCast} from "@openzeppelin-contracts-5.7.0/utils/math/SafeCast.sol " ;
67
78import {SHA256} from "../libs/SHA256.sol " ;
89
@@ -13,6 +14,8 @@ import {SHA256} from "../libs/SHA256.sol";
1314/// (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.4.0/contracts/utils/structs/MerkleTree.sol).
1415/// @custom:security-contact security@anoma.foundation
1516library MerkleTree {
17+ using SafeCast for uint256 ;
18+
1619 struct Tree {
1720 uint256 _nextLeafIndex;
1821 bytes32 [] _sides;
@@ -158,8 +161,6 @@ library MerkleTree {
158161 /// @param leavesCount The number of leaves.
159162 /// @return treeDepth The minimal required tree depth.
160163 function computeMinimalTreeDepth (uint256 leavesCount ) internal pure returns (uint8 treeDepth ) {
161- // `leavesCount` is a memory array length, so its base-2 logarithm fits in a byte.
162- // forge-lint: disable-next-line(unsafe-typecast)
163- treeDepth = uint8 (Math.log2 ({value: leavesCount, rounding: Math.Rounding.Ceil}));
164+ treeDepth = Math.log2 ({value: leavesCount, rounding: Math.Rounding.Ceil}).toUint8 ();
164165 }
165166}
You can’t perform that action at this time.
0 commit comments