diff --git a/docs/src/architecture/08_concepts/signed_doc/cddl/additional_meta.cddl b/docs/src/architecture/08_concepts/signed_doc/cddl/additional_meta.cddl index 71a7ce9adc..6c1bdd4b74 100644 --- a/docs/src/architecture/08_concepts/signed_doc/cddl/additional_meta.cddl +++ b/docs/src/architecture/08_concepts/signed_doc/cddl/additional_meta.cddl @@ -5,10 +5,10 @@ additional_fields = { ? "reply" => ref_type, ? "section" => text, ? "collabs" => [+any], - ? "brand_id" => UUID, ; UUID v4 - ? "campaign_id" => UUID, ; UUID v4 + ? "brand_id" => ref_type, + ? "campaign_id" => ref_type, ? "election_id" => UUID, ; UUID v4 - ? "category_id" => UUID, ; UUID v4 + ? "category_id" => ref_type, } ref_type = UUID / [UUID, UUID] ; UUIDs v7 diff --git a/docs/src/architecture/08_concepts/signed_doc/meta.md b/docs/src/architecture/08_concepts/signed_doc/meta.md index 8088cd2b0b..539f53a79a 100644 --- a/docs/src/architecture/08_concepts/signed_doc/meta.md +++ b/docs/src/architecture/08_concepts/signed_doc/meta.md @@ -88,13 +88,17 @@ This list can impact actions that can be performed by the `Proposal Action Docum ## `brand_id` -Unique identifier [UUID] v4, which represents a "brand" who is running the voting, -e.g. Catalyst, Midnight. +This is a reply to another document. +The format is the same as the [CBOR] Array form of [`ref`](#ref-document-reference). + +`brand_id` represents a "brand" who is running the voting, e.g. Catalyst, Midnight. ## `campaign_id` -Unique identifier [UUID] v4, which defines a "campaign" of voting, -e.g. "treasury campaign". +This is a reply to another document. +The format is the same as the [CBOR] Array form of [`ref`](#ref-document-reference). + +`campaign_id` defines a "campaign" of voting, e.g. "treasury campaign". ## `election_id` @@ -103,7 +107,10 @@ e.g. "Catalyst Fund 1", "Catalyst Fund 2". ## `category_id` -Unique identifier [UUID] v4 which defines a voting category as a collection of proposals, +This is a reply to another document. +The format is the same as the [CBOR] Array form of [`ref`](#ref-document-reference). + +`campaign_id` defines a voting category as a collection of proposals, e.g. "Development & Infrastructure", "Products & Integrations". [UUID]: https://www.rfc-editor.org/rfc/rfc9562.html diff --git a/rust/signed_doc/src/lib.rs b/rust/signed_doc/src/lib.rs index 24cc5d10dc..e65f5e8675 100644 --- a/rust/signed_doc/src/lib.rs +++ b/rust/signed_doc/src/lib.rs @@ -268,10 +268,10 @@ mod tests { "template": {"id": uuid_v7.to_string()}, "section": section, "collabs": collabs, - "campaign_id": uuid_v4.to_string(), + "campaign_id": {"id": uuid_v7.to_string()}, "election_id": uuid_v4.to_string(), - "brand_id": uuid_v4.to_string(), - "category_id": uuid_v4.to_string(), + "brand_id": {"id": uuid_v7.to_string()}, + "category_id": {"id": uuid_v7.to_string()}, })) .unwrap(); let content = vec![1, 2, 4, 5, 6, 7, 8, 9]; diff --git a/rust/signed_doc/src/metadata/extra_fields.rs b/rust/signed_doc/src/metadata/extra_fields.rs index 6aa4a87533..0cfe905bfd 100644 --- a/rust/signed_doc/src/metadata/extra_fields.rs +++ b/rust/signed_doc/src/metadata/extra_fields.rs @@ -1,10 +1,10 @@ //! Catalyst Signed Document Extra Fields. use anyhow::bail; -use catalyst_types::problem_report::ProblemReport; +use catalyst_types::{problem_report::ProblemReport, uuid::UuidV4}; use coset::{cbor::Value, Label, ProtectedHeader}; -use super::{cose_protected_header_find, decode_cbor_uuid, encode_cbor_uuid, DocumentRef, UuidV4}; +use super::{cose_protected_header_find, decode_cbor_uuid, encode_cbor_uuid, DocumentRef}; /// `ref` field COSE key value const REF_KEY: &str = "ref"; @@ -47,16 +47,16 @@ pub struct ExtraFields { collabs: Vec, /// Unique identifier for the brand that is running the voting. #[serde(skip_serializing_if = "Option::is_none")] - brand_id: Option, + brand_id: Option, /// Unique identifier for the campaign of voting. #[serde(skip_serializing_if = "Option::is_none")] - campaign_id: Option, + campaign_id: Option, /// Unique identifier for the election. #[serde(skip_serializing_if = "Option::is_none")] election_id: Option, /// Unique identifier for the voting category as a collection of proposals. #[serde(skip_serializing_if = "Option::is_none")] - category_id: Option, + category_id: Option, } impl ExtraFields { @@ -92,13 +92,13 @@ impl ExtraFields { /// Return `brand_id` field. #[must_use] - pub fn brand_id(&self) -> Option { + pub fn brand_id(&self) -> Option { self.brand_id } /// Return `campaign_id` field. #[must_use] - pub fn campaign_id(&self) -> Option { + pub fn campaign_id(&self) -> Option { self.campaign_id } @@ -110,7 +110,7 @@ impl ExtraFields { /// Return `category_id` field. #[must_use] - pub fn category_id(&self) -> Option { + pub fn category_id(&self) -> Option { self.category_id } @@ -139,12 +139,12 @@ impl ExtraFields { ); } if let Some(brand_id) = &self.brand_id { - builder = builder.text_value(BRAND_ID_KEY.to_string(), encode_cbor_uuid(brand_id)?); + builder = builder.text_value(BRAND_ID_KEY.to_string(), Value::try_from(*brand_id)?); } if let Some(campaign_id) = &self.campaign_id { builder = - builder.text_value(CAMPAIGN_ID_KEY.to_string(), encode_cbor_uuid(campaign_id)?); + builder.text_value(CAMPAIGN_ID_KEY.to_string(), Value::try_from(*campaign_id)?); } if let Some(election_id) = &self.election_id { @@ -154,7 +154,7 @@ impl ExtraFields { if let Some(category_id) = &self.category_id { builder = - builder.text_value(CATEGORY_ID_KEY.to_string(), encode_cbor_uuid(*category_id)?); + builder.text_value(CATEGORY_ID_KEY.to_string(), Value::try_from(*category_id)?); } Ok(builder) } @@ -278,7 +278,7 @@ impl ExtraFields { if let Some(cbor_doc_brand_id) = cose_protected_header_find(protected, |key| { key == &Label::Text(BRAND_ID_KEY.to_string()) }) { - match decode_cbor_uuid(cbor_doc_brand_id.clone()) { + match DocumentRef::try_from(cbor_doc_brand_id) { Ok(brand_id) => { extra.brand_id = Some(brand_id); }, @@ -296,7 +296,7 @@ impl ExtraFields { if let Some(cbor_doc_campaign_id) = cose_protected_header_find(protected, |key| { key == &Label::Text(CAMPAIGN_ID_KEY.to_string()) }) { - match decode_cbor_uuid(cbor_doc_campaign_id.clone()) { + match DocumentRef::try_from(cbor_doc_campaign_id) { Ok(campaign_id) => { extra.campaign_id = Some(campaign_id); }, @@ -332,7 +332,7 @@ impl ExtraFields { if let Some(cbor_doc_category_id) = cose_protected_header_find(protected, |key| { key == &Label::Text(CATEGORY_ID_KEY.to_string()) }) { - match decode_cbor_uuid(cbor_doc_category_id.clone()) { + match DocumentRef::try_from(cbor_doc_category_id) { Ok(category_id) => { extra.category_id = Some(category_id); },