Skip to content

Commit 7f1bbd3

Browse files
committed
wip
1 parent 365a330 commit 7f1bbd3

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

rust/signed_doc/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ mod tests {
223223
"section": section,
224224
"collabs": collabs,
225225
"campaign_id": {"id": uuid_v7.to_string()},
226-
"election_id": {"id": uuid_v7.to_string()},
226+
"election_id": uuid_v4.to_string(),
227227
"brand_id": {"id": uuid_v7.to_string()},
228228
"category_id": {"id": uuid_v7.to_string()},
229229
}))

rust/signed_doc/src/metadata/extra_fields.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
//! Catalyst Signed Document Extra Fields.
22
33
use anyhow::anyhow;
4+
use catalyst_types::uuid::UuidV4;
45
use coset::{cbor::Value, Label, ProtectedHeader};
56

6-
use super::{cose_protected_header_find, DocumentRef};
7+
use super::{cose_protected_header_find, decode_cbor_uuid, encode_cbor_uuid, DocumentRef};
78

89
/// `ref` field COSE key value
910
const REF_KEY: &str = "ref";
@@ -52,7 +53,7 @@ pub struct ExtraFields {
5253
campaign_id: Option<DocumentRef>,
5354
/// Unique identifier for the election.
5455
#[serde(skip_serializing_if = "Option::is_none")]
55-
election_id: Option<DocumentRef>,
56+
election_id: Option<UuidV4>,
5657
/// Unique identifier for the voting category as a collection of proposals.
5758
#[serde(skip_serializing_if = "Option::is_none")]
5859
category_id: Option<DocumentRef>,
@@ -103,7 +104,7 @@ impl ExtraFields {
103104

104105
/// Return `election_id` field.
105106
#[must_use]
106-
pub fn election_id(&self) -> Option<DocumentRef> {
107+
pub fn election_id(&self) -> Option<UuidV4> {
107108
self.election_id
108109
}
109110

@@ -148,7 +149,7 @@ impl ExtraFields {
148149

149150
if let Some(election_id) = &self.election_id {
150151
builder =
151-
builder.text_value(ELECTION_ID_KEY.to_string(), Value::try_from(*election_id)?);
152+
builder.text_value(ELECTION_ID_KEY.to_string(), encode_cbor_uuid(election_id)?);
152153
}
153154

154155
if let Some(category_id) = &self.category_id {
@@ -288,7 +289,7 @@ impl TryFrom<&ProtectedHeader> for ExtraFields {
288289
if let Some(cbor_doc_election_id) = cose_protected_header_find(protected, |key| {
289290
key == &Label::Text(ELECTION_ID_KEY.to_string())
290291
}) {
291-
match DocumentRef::try_from(cbor_doc_election_id) {
292+
match decode_cbor_uuid(cbor_doc_election_id.clone()) {
292293
Ok(election_id) => {
293294
extra.election_id = Some(election_id);
294295
},

0 commit comments

Comments
 (0)