diff --git a/src/v0.8/interfaces/module/IDatasetsProof.sol b/src/v0.8/interfaces/module/IDatasetsProof.sol index ee6b37fe..3d1b1ff5 100644 --- a/src/v0.8/interfaces/module/IDatasetsProof.sol +++ b/src/v0.8/interfaces/module/IDatasetsProof.sol @@ -99,6 +99,15 @@ interface IDatasetsProof { uint64 _datasetId ) external view returns (uint64); + /// @notice Retrieves the Merkle root hash of the dataset for the specified dataset ID and data type. + /// @param _datasetId The ID of the dataset for which to retrieve the Merkle root hash. + /// @param _dataType The type of data for which to retrieve the Merkle root hash. + /// @return rootHash The Merkle root hash of the dataset. + function getDatasetProofRootHash( + uint64 _datasetId, + DatasetType.DataType _dataType + ) external view returns (bytes32 rootHash); + ///@notice Check if a dataset has a car id function isDatasetContainsCar( uint64 _datasetId, diff --git a/src/v0.8/module/dataset/DatasetsProof.sol b/src/v0.8/module/dataset/DatasetsProof.sol index d5de7c4b..cd787217 100644 --- a/src/v0.8/module/dataset/DatasetsProof.sol +++ b/src/v0.8/module/dataset/DatasetsProof.sol @@ -577,6 +577,20 @@ contract DatasetsProof is return datasetProof.completedHeight; } + /// @notice Retrieves the Merkle root hash of the dataset for the specified dataset ID and data type. + /// @param _datasetId The ID of the dataset for which to retrieve the Merkle root hash. + /// @param _dataType The type of data for which to retrieve the Merkle root hash. + /// @return rootHash The Merkle root hash of the dataset. + function getDatasetProofRootHash( + uint64 _datasetId, + DatasetType.DataType _dataType + ) external view onlyNotZero(_datasetId) returns (bytes32 rootHash) { + DatasetType.DatasetProof storage datasetProof = datasetProofs[ + _datasetId + ]; + rootHash = datasetProof.getDatasetRootHash(_dataType); + } + ///@notice Check if a dataset proof all completed function isDatasetProofallCompleted( uint64 _datasetId, diff --git a/src/v0.8/module/dataset/library/proof/DatasetProofLIB.sol b/src/v0.8/module/dataset/library/proof/DatasetProofLIB.sol index acf97d83..7efa97a7 100644 --- a/src/v0.8/module/dataset/library/proof/DatasetProofLIB.sol +++ b/src/v0.8/module/dataset/library/proof/DatasetProofLIB.sol @@ -163,6 +163,23 @@ library DatasetProofLIB { return self.proofSubmitter; } + /// @notice Retrieves the root hash of the dataset proof for the specified data type. + /// @param self The storage reference to the dataset proof. + /// @param _dataType The type of data for which to retrieve the root hash. + /// @return The root hash of the dataset proof. + function getDatasetRootHash( + DatasetType.DatasetProof storage self, + DatasetType.DataType _dataType + ) internal view returns (bytes32) { + DatasetType.Proof storage proof; + if (_dataType == DatasetType.DataType.Source) { + proof = self.sourceProof; + } else { + proof = self.mappingFilesProof; + } + return proof.rootHash; + } + /// @notice Check if a dataset has submitter /// @param self The dataset from which to retrieve the source dataset proof. /// @param submitter The address being compared.