Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 12 additions & 5 deletions docs/src/architecture/08_concepts/signed_doc/meta.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions rust/signed_doc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
28 changes: 14 additions & 14 deletions rust/signed_doc/src/metadata/extra_fields.rs
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -47,16 +47,16 @@ pub struct ExtraFields {
collabs: Vec<String>,
/// Unique identifier for the brand that is running the voting.
#[serde(skip_serializing_if = "Option::is_none")]
brand_id: Option<UuidV4>,
brand_id: Option<DocumentRef>,
/// Unique identifier for the campaign of voting.
#[serde(skip_serializing_if = "Option::is_none")]
campaign_id: Option<UuidV4>,
campaign_id: Option<DocumentRef>,
/// Unique identifier for the election.
#[serde(skip_serializing_if = "Option::is_none")]
election_id: Option<UuidV4>,
/// Unique identifier for the voting category as a collection of proposals.
#[serde(skip_serializing_if = "Option::is_none")]
category_id: Option<UuidV4>,
category_id: Option<DocumentRef>,
}

impl ExtraFields {
Expand Down Expand Up @@ -92,13 +92,13 @@ impl ExtraFields {

/// Return `brand_id` field.
#[must_use]
pub fn brand_id(&self) -> Option<UuidV4> {
pub fn brand_id(&self) -> Option<DocumentRef> {
self.brand_id
}

/// Return `campaign_id` field.
#[must_use]
pub fn campaign_id(&self) -> Option<UuidV4> {
pub fn campaign_id(&self) -> Option<DocumentRef> {
self.campaign_id
}

Expand All @@ -110,7 +110,7 @@ impl ExtraFields {

/// Return `category_id` field.
#[must_use]
pub fn category_id(&self) -> Option<UuidV4> {
pub fn category_id(&self) -> Option<DocumentRef> {
self.category_id
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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)
}
Expand Down Expand Up @@ -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);
},
Expand All @@ -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);
},
Expand Down Expand Up @@ -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);
},
Expand Down
Loading