Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
85a966a
feat: initial
apskhem Sep 24, 2025
72c71d2
Merge branch 'main' into feat/chain-rule-validator
apskhem Sep 24, 2025
de8e87a
Merge branch 'main' into feat/chain-rule-validator
apskhem Sep 25, 2025
ba55514
feat: initial integrity validation
apskhem Sep 25, 2025
591956e
feat: document validation
apskhem Sep 25, 2025
7e4429c
feat: updated provider
apskhem Sep 26, 2025
39db568
feat: validation message
apskhem Oct 8, 2025
c272b6c
feat: complete chain validation
apskhem Oct 8, 2025
79d58fc
feat: complete chain validation
apskhem Oct 8, 2025
e837de8
feat: remaining case
apskhem Oct 8, 2025
419b441
feat: initial test
apskhem Oct 9, 2025
8b82eb8
feat: listing tests
apskhem Oct 9, 2025
37866a2
feat: basic rules
apskhem Oct 9, 2025
dbdc3c8
feat: tmp valid test
apskhem Oct 10, 2025
3c519bb
feat: valid test pass
apskhem Oct 10, 2025
feaf113
feat: invalid cases finalized
apskhem Oct 10, 2025
98417f4
Merge branch 'main' into feat/chain-rule-validator
apskhem Oct 10, 2025
b1a8297
feat: chain rule
apskhem Oct 10, 2025
0a6ef20
chore: fmtfix
apskhem Oct 11, 2025
f002713
fix: spellcheck
apskhem Oct 13, 2025
ab79aa4
fix: comments
apskhem Oct 14, 2025
a175690
chore: lintfix
apskhem Oct 14, 2025
cc92267
chore: lintfix
apskhem Oct 14, 2025
66239ad
feat: height validation
apskhem Oct 14, 2025
517763c
fix: deferred report
apskhem Oct 14, 2025
f13f49a
fix: cspell
apskhem Oct 14, 2025
2f67223
chore: minor comment
apskhem Oct 14, 2025
397f8bb
feat: minor validation
apskhem Oct 14, 2025
3cfcff0
chore: minor
apskhem Oct 14, 2025
42a9bfc
Merge branch 'main' into feat/chain-rule-validator
apskhem Oct 14, 2025
6b574bb
Update rust/signed_doc/src/validator/rules/chain/mod.rs
apskhem Oct 16, 2025
67d95e3
fix: comments
apskhem Oct 16, 2025
0e3fea1
Merge branch 'main' into feat/chain-rule-validator
apskhem Oct 16, 2025
a0298ac
fix: chain link validation
apskhem Oct 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions rust/catalyst-signed-doc-spec/src/metadata/chain.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//! `signed_doc.json` "chain" field JSON definition

use crate::is_required::IsRequired;

/// `signed_doc.json` "chain" field JSON object
#[derive(serde::Deserialize)]
pub struct Chain {
pub required: IsRequired,
}
2 changes: 2 additions & 0 deletions rust/catalyst-signed-doc-spec/src/metadata/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! `metadata` field definition

pub mod chain;
pub mod doc_ref;
pub mod parameters;
pub mod reply;
Expand All @@ -14,4 +15,5 @@ pub struct Metadata {
pub doc_ref: doc_ref::Ref,
pub reply: reply::Reply,
pub parameters: parameters::Parameters,
pub chain: chain::Chain,
}
26 changes: 26 additions & 0 deletions rust/signed_doc/src/metadata/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,32 @@ pub struct Chain {
document_ref: Option<DocumentRef>,
}

impl Chain {
/// Creates a new `Chain`.
#[must_use]
pub fn new(
height: i32,
document_ref: Option<DocumentRef>,
) -> Self {
Self {
height,
document_ref,
}
}

/// Gets `height`.
#[must_use]
pub fn height(&self) -> i32 {
self.height
}

/// Gets `document_ref`.
#[must_use]
pub fn document_ref(&self) -> Option<&DocumentRef> {
self.document_ref.as_ref()
}
}

impl Display for Chain {
fn fmt(
&self,
Expand Down
20 changes: 20 additions & 0 deletions rust/signed_doc/src/metadata/document_refs/doc_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use cbork_utils::{array::Array, decode_context::DecodeCtx};
use minicbor::{Decode, Encode};

use super::doc_locator::DocLocator;
use crate::CatalystSignedDocument;

/// Number of item that should be in each document reference instance.
const DOC_REF_ARR_ITEM: u64 = 3;
Expand Down Expand Up @@ -38,6 +39,13 @@ impl DocumentRef {
}
}

/// Create a new instance of another document reference without including
/// `doc_locator`.
#[must_use]
pub fn from_without_locator(other: &Self) -> Self {
Self::new(*other.id(), *other.ver(), DocLocator::default())
}

/// Get Document Id.
#[must_use]
pub fn id(&self) -> &UuidV7 {
Expand All @@ -57,6 +65,18 @@ impl DocumentRef {
}
}

impl TryFrom<&CatalystSignedDocument> for DocumentRef {
type Error = anyhow::Error;

fn try_from(value: &CatalystSignedDocument) -> Result<Self, Self::Error> {
Ok(Self::new(
value.doc_id()?,
value.doc_ver()?,
DocLocator::default(),
))
}
}

impl Display for DocumentRef {
fn fmt(
&self,
Expand Down
18 changes: 18 additions & 0 deletions rust/signed_doc/src/providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ pub trait CatalystSignedDocumentProvider: Send + Sync {
doc_ref: &DocumentRef,
) -> impl Future<Output = anyhow::Result<Option<CatalystSignedDocument>>> + Send;

/// Try to get all versions of the `CatalystSignedDocument` from the given `id`.
fn try_get_all(
&self,
id: UuidV7,
) -> impl Future<Output = anyhow::Result<Vec<CatalystSignedDocument>>> + Send;

/// Try to get the last known version of the `CatalystSignedDocument`, same
/// `id` and the highest known `ver`.
fn try_get_last_doc(
Expand Down Expand Up @@ -111,6 +117,18 @@ pub mod tests {
Ok(self.signed_doc.get(doc_ref).cloned())
}

async fn try_get_all(
&self,
id: catalyst_types::uuid::UuidV7,
) -> anyhow::Result<Vec<CatalystSignedDocument>> {
Ok(self
.signed_doc
.iter()
.filter(|(doc_ref, _)| doc_ref.id() == &id)
.map(|(_, doc)| doc.clone())
.collect())
}

async fn try_get_last_doc(
&self,
id: catalyst_types::uuid::UuidV7,
Expand Down
Loading
Loading