diff --git a/rust/signed_doc/Cargo.toml b/rust/signed_doc/Cargo.toml index 6bd2c874d4..3f5235cd02 100644 --- a/rust/signed_doc/Cargo.toml +++ b/rust/signed_doc/Cargo.toml @@ -12,7 +12,7 @@ workspace = true [dependencies] rbac-registration = { version = "0.0.2", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250128-01" } -catalyst-types = { version = "0.0.1", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250128-01" } +catalyst-types = { version = "0.0.1", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250204-00" } anyhow = "1.0.95" serde = { version = "1.0.217", features = ["derive"] } serde_json = "1.0.134" @@ -20,7 +20,6 @@ coset = "0.3.8" minicbor = { version = "0.25.1", features = ["half"] } brotli = "7.0.0" ed25519-dalek = { version = "2.1.1", features = ["pem", "rand_core"] } -uuid = { version = "1.11.0", features = ["v4", "v7", "serde"] } hex = "0.4.3" strum = { version = "0.26.3", features = ["derive"] } clap = { version = "4.5.23", features = ["derive", "env"] } diff --git a/rust/signed_doc/src/doc_types/mod.rs b/rust/signed_doc/src/doc_types/mod.rs index e07dbb00b2..b971e01414 100644 --- a/rust/signed_doc/src/doc_types/mod.rs +++ b/rust/signed_doc/src/doc_types/mod.rs @@ -3,7 +3,7 @@ mod proposal_document; -use catalyst_types::uuid::UuidV4; +use catalyst_types::uuid::{Uuid, UuidV4}; pub use proposal_document::{ProposalDocument, PROPOSAL_DOCUMENT_UUID_TYPE}; /// Represents different types of documents. @@ -44,50 +44,46 @@ pub enum DocumentType { } /// Proposal template `UuidV4` type. -const PROPOSAL_TEMPLATE_UUID_TYPE: uuid::Uuid = - uuid::Uuid::from_u128(0x0CE8_AB38_9258_4FBC_A62E_7FAA_6E58_318F); +const PROPOSAL_TEMPLATE_UUID_TYPE: Uuid = + Uuid::from_u128(0x0CE8_AB38_9258_4FBC_A62E_7FAA_6E58_318F); /// Comment document `UuidV4` type. -const COMMENT_DOCUMENT_UUID_TYPE: uuid::Uuid = - uuid::Uuid::from_u128(0xB679_DED3_0E7C_41BA_89F8_DA62_A178_98EA); +const COMMENT_DOCUMENT_UUID_TYPE: Uuid = Uuid::from_u128(0xB679_DED3_0E7C_41BA_89F8_DA62_A178_98EA); /// Comment template `UuidV4` type. -const COMMENT_TEMPLATE_UUID_TYPE: uuid::Uuid = - uuid::Uuid::from_u128(0x0B84_24D4_EBFD_46E3_9577_1775_A69D_290C); +const COMMENT_TEMPLATE_UUID_TYPE: Uuid = Uuid::from_u128(0x0B84_24D4_EBFD_46E3_9577_1775_A69D_290C); /// Review document `UuidV4` type. -const REVIEW_DOCUMENT_UUID_TYPE: uuid::Uuid = - uuid::Uuid::from_u128(0xE4CA_F5F0_098B_45FD_94F3_0702_A457_3DB5); +const REVIEW_DOCUMENT_UUID_TYPE: Uuid = Uuid::from_u128(0xE4CA_F5F0_098B_45FD_94F3_0702_A457_3DB5); /// Review template `UuidV4` type. -const REVIEW_TEMPLATE_UUID_TYPE: uuid::Uuid = - uuid::Uuid::from_u128(0xEBE5_D0BF_5D86_4577_AF4D_008F_DDBE_2EDC); +const REVIEW_TEMPLATE_UUID_TYPE: Uuid = Uuid::from_u128(0xEBE5_D0BF_5D86_4577_AF4D_008F_DDBE_2EDC); /// Category parameters document `UuidV4` type. -const CATEGORY_PARAMETERS_DOCUMENT_UUID_TYPE: uuid::Uuid = - uuid::Uuid::from_u128(0x48C2_0109_362A_4D32_9BBA_E0A9_CF8B_45BE); +const CATEGORY_PARAMETERS_DOCUMENT_UUID_TYPE: Uuid = + Uuid::from_u128(0x48C2_0109_362A_4D32_9BBA_E0A9_CF8B_45BE); /// Category parameters template `UuidV4` type. -const CATEGORY_PARAMETERS_TEMPLATE_UUID_TYPE: uuid::Uuid = - uuid::Uuid::from_u128(0x65B1_E8B0_51F1_46A5_9970_72CD_F268_84BE); +const CATEGORY_PARAMETERS_TEMPLATE_UUID_TYPE: Uuid = + Uuid::from_u128(0x65B1_E8B0_51F1_46A5_9970_72CD_F268_84BE); /// Campaign parameters document `UuidV4` type. -const CAMPAIGN_PARAMETERS_DOCUMENT_UUID_TYPE: uuid::Uuid = - uuid::Uuid::from_u128(0x0110_EA96_A555_47CE_8408_36EF_E6ED_6F7C); +const CAMPAIGN_PARAMETERS_DOCUMENT_UUID_TYPE: Uuid = + Uuid::from_u128(0x0110_EA96_A555_47CE_8408_36EF_E6ED_6F7C); /// Campaign parameters template `UuidV4` type. -const CAMPAIGN_PARAMETERS_TEMPLATE_UUID_TYPE: uuid::Uuid = - uuid::Uuid::from_u128(0x7E8F_5FA2_44CE_49C8_BFD5_02AF_42C1_79A3); +const CAMPAIGN_PARAMETERS_TEMPLATE_UUID_TYPE: Uuid = + Uuid::from_u128(0x7E8F_5FA2_44CE_49C8_BFD5_02AF_42C1_79A3); /// Brand parameters document `UuidV4` type. -const BRAND_PARAMETERS_DOCUMENT_UUID_TYPE: uuid::Uuid = - uuid::Uuid::from_u128(0x3E48_08CC_C86E_467B_9702_D60B_AA9D_1FCA); +const BRAND_PARAMETERS_DOCUMENT_UUID_TYPE: Uuid = + Uuid::from_u128(0x3E48_08CC_C86E_467B_9702_D60B_AA9D_1FCA); /// Brand parameters template `UuidV4` type. -const BRAND_PARAMETERS_TEMPLATE_UUID_TYPE: uuid::Uuid = - uuid::Uuid::from_u128(0xFD3C_1735_80B1_4EEA_8D63_5F43_6D97_EA31); +const BRAND_PARAMETERS_TEMPLATE_UUID_TYPE: Uuid = + Uuid::from_u128(0xFD3C_1735_80B1_4EEA_8D63_5F43_6D97_EA31); /// Proposal action document `UuidV4` type. -const PROPOSAL_ACTION_DOCUMENT_UUID_TYPE: uuid::Uuid = - uuid::Uuid::from_u128(0x5E60_E623_AD02_4A1B_A1AC_406D_B978_EE48); +const PROPOSAL_ACTION_DOCUMENT_UUID_TYPE: Uuid = + Uuid::from_u128(0x5E60_E623_AD02_4A1B_A1AC_406D_B978_EE48); /// Public vote transaction v2 `UuidV4` type. -const PUBLIC_VOTE_TX_V2_UUID_TYPE: uuid::Uuid = - uuid::Uuid::from_u128(0x8DE5_586C_E998_4B95_8742_7BE3_C859_2803); +const PUBLIC_VOTE_TX_V2_UUID_TYPE: Uuid = + Uuid::from_u128(0x8DE5_586C_E998_4B95_8742_7BE3_C859_2803); /// Private vote transaction v2 `UuidV4` type. -const PRIVATE_VOTE_TX_V2_UUID_TYPE: uuid::Uuid = - uuid::Uuid::from_u128(0xE78E_E18D_F380_44C1_A852_80AA_6ECB_07FE); +const PRIVATE_VOTE_TX_V2_UUID_TYPE: Uuid = + Uuid::from_u128(0xE78E_E18D_F380_44C1_A852_80AA_6ECB_07FE); /// Immutable ledger block `UuidV4` type. -const IMMUTABLE_LEDGER_BLOCK_UUID_TYPE: uuid::Uuid = - uuid::Uuid::from_u128(0xD9E7_E6CE_2401_4D7D_9492_F4F7_C642_41C3); +const IMMUTABLE_LEDGER_BLOCK_UUID_TYPE: Uuid = + Uuid::from_u128(0xD9E7_E6CE_2401_4D7D_9492_F4F7_C642_41C3); impl TryFrom for DocumentType { type Error = anyhow::Error; diff --git a/rust/signed_doc/src/doc_types/proposal_document.rs b/rust/signed_doc/src/doc_types/proposal_document.rs index 7fffae7f07..4756c956fa 100644 --- a/rust/signed_doc/src/doc_types/proposal_document.rs +++ b/rust/signed_doc/src/doc_types/proposal_document.rs @@ -1,13 +1,13 @@ //! Proposal Document object implementation //! -use catalyst_types::problem_report::ProblemReport; +use catalyst_types::{problem_report::ProblemReport, uuid::Uuid}; use crate::{error::CatalystSignedDocError, CatalystSignedDocument}; /// Proposal document `UuidV4` type. -pub const PROPOSAL_DOCUMENT_UUID_TYPE: uuid::Uuid = - uuid::Uuid::from_u128(0x7808_D2BA_D511_40AF_84E8_C0D1_625F_DFDC); +pub const PROPOSAL_DOCUMENT_UUID_TYPE: Uuid = + Uuid::from_u128(0x7808_D2BA_D511_40AF_84E8_C0D1_625F_DFDC); /// Proposal Document struct pub struct ProposalDocument { diff --git a/rust/signed_doc/src/lib.rs b/rust/signed_doc/src/lib.rs index 2f9ab9e3fb..7c40539296 100644 --- a/rust/signed_doc/src/lib.rs +++ b/rust/signed_doc/src/lib.rs @@ -17,12 +17,12 @@ use std::{ pub use builder::Builder; use catalyst_types::problem_report::ProblemReport; -pub use catalyst_types::uuid::{UuidV4, UuidV7}; +pub use catalyst_types::uuid::{Uuid, UuidV4, UuidV7}; pub use content::Content; use coset::{CborSerializable, Header}; use error::CatalystSignedDocError; pub use metadata::{DocumentRef, ExtraFields, Metadata}; -pub use minicbor::{decode, encode, Decode, Decoder, Encode}; +pub use minicbor::{decode, encode, Decode, Decoder, Encode, Encoder}; pub use rbac_registration::cardano::cip509::SimplePublicKeyType; pub use signature::{IdUri, Signatures}; use utils::context::DecodeSignDocCtx; @@ -106,7 +106,7 @@ impl CatalystSignedDocument { /// Return a Document's signatures #[must_use] - pub fn signatures(&self) -> &Signatures { + pub(crate) fn signatures(&self) -> &Signatures { &self.inner.signatures } @@ -119,12 +119,7 @@ impl CatalystSignedDocument { /// Return a list of Document's author IDs (short form of Catalyst IDs). #[must_use] pub fn authors(&self) -> Vec { - self.inner - .signatures - .kids() - .into_iter() - .map(|k| k.as_short_id()) - .collect() + self.inner.signatures.authors() } /// Verify document signatures. diff --git a/rust/signed_doc/src/signature/mod.rs b/rust/signed_doc/src/signature/mod.rs index 91738ca4af..4ef3f608be 100644 --- a/rust/signed_doc/src/signature/mod.rs +++ b/rust/signed_doc/src/signature/mod.rs @@ -25,7 +25,13 @@ impl Signatures { Self(Vec::new()) } - /// List of signature Key IDs. + /// Return a list of author IDs (short form of Catalyst IDs). + #[must_use] + pub fn authors(&self) -> Vec { + self.kids().into_iter().map(|k| k.as_short_id()).collect() + } + + /// Return a list of Document's Catalyst IDs. #[must_use] pub fn kids(&self) -> Vec { self.0.iter().map(|sig| sig.kid.clone()).collect()