fuel_chain_config/
genesis.rs

1use fuel_core_interfaces::{
2    common::prelude::{
3        Hasher,
4        MerkleRoot,
5    },
6    model::Genesis,
7};
8
9pub trait GenesisCommitment {
10    /// Calculates the merkle root of the state of the entity.
11    fn root(&mut self) -> anyhow::Result<MerkleRoot>;
12}
13
14impl GenesisCommitment for Genesis {
15    fn root(&mut self) -> anyhow::Result<MerkleRoot> {
16        let genesis_hash = *Hasher::default()
17            .chain(self.chain_config_hash)
18            .chain(self.coins_root)
19            .chain(self.contracts_root)
20            .chain(self.messages_root)
21            .finalize();
22
23        Ok(genesis_hash)
24    }
25}