2025-07-25 11:45:15 +00:00
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^ 0 . 8 . 27 ;
import { MerkleUtils } from " ../../src/libraries/MerkleUtils.sol " ;
import { BeefyClient } from " snowbridge/src/BeefyClient.sol " ;
library ValidatorsUtils {
function _buildValidatorSet (
uint128 id ,
bytes32 [ ] memory validators
) internal pure returns ( BeefyClient . ValidatorSet memory ) {
2025-07-28 16:34:28 +00:00
// Calculate the merkle root from the validators array. We specify to not sort the pair before hashing to be compatible with Beefy Merkle Tree implementation.
bytes32 merkleRoot = MerkleUtils . calculateMerkleRoot ( validators , false ) ;
2025-07-25 11:45:15 +00:00
// Create and return the validator set with the calculated merkle root
return
BeefyClient . ValidatorSet ( { id : id , length : uint128 ( validators . length ) , root : merkleRoot } ) ;
}
}