Skip to content

Commit 9c40793

Browse files
committed
wip
1 parent 1f02d57 commit 9c40793

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

rust/signed_doc/src/doc_types/proposal_document.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ pub struct ProposalDocument {
1818
}
1919

2020
impl ProposalDocument {
21-
/// Try to build `ProposalDocument` from `CatalystSignedDoc` collecting report
21+
/// Try to build `ProposalDocument` from `CatalystSignedDoc` doing all necessary
22+
/// stateless verifications,
2223
#[allow(dead_code)]
2324
pub(crate) fn from_signed_doc(
2425
doc: &CatalystSignedDocument, error_report: &ProblemReport,
@@ -46,6 +47,13 @@ impl ProposalDocument {
4647
let content = doc.doc_content().decoded_bytes().to_vec();
4748
Ok(Self { content })
4849
}
50+
51+
/// A comprehensive validation of the `ProposalDocument` content.
52+
#[allow(clippy::unused_self)]
53+
pub(crate) fn validate_with_report<F>(&self, _doc_getter: F, _error_report: &ProblemReport)
54+
where F: FnMut() -> Option<CatalystSignedDocument> {
55+
// TODO: implement the rest of the validation
56+
}
4957
}
5058

5159
impl TryFrom<CatalystSignedDocument> for ProposalDocument {

rust/signed_doc/src/validator/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::{
1515
///
1616
/// Returns a report of validation failures and the source error.
1717
pub fn validate<F>(
18-
doc: &CatalystSignedDocument, _doc_getter: F,
18+
doc: &CatalystSignedDocument, doc_getter: F,
1919
) -> Result<(), CatalystSignedDocError>
2020
where F: FnMut() -> Option<CatalystSignedDocument> {
2121
let error_report = ProblemReport::new("Catalyst Signed Document Validation");
@@ -39,7 +39,9 @@ where F: FnMut() -> Option<CatalystSignedDocument> {
3939
#[allow(clippy::match_same_arms)]
4040
match doc_type {
4141
DocumentType::ProposalDocument => {
42-
drop(ProposalDocument::from_signed_doc(doc, &error_report));
42+
if let Ok(proposal_doc) = ProposalDocument::from_signed_doc(doc, &error_report) {
43+
proposal_doc.validate_with_report(doc_getter, &error_report);
44+
}
4345
},
4446
DocumentType::ProposalTemplate => {},
4547
DocumentType::CommentDocument => {},

0 commit comments

Comments
 (0)