From a166420ea7e048e13a2633c7c23c409e26379430 Mon Sep 17 00:00:00 2001 From: GHkrishna Date: Sun, 31 Mar 2024 15:55:51 +0530 Subject: [PATCH] fix: Did type in message crate Signed-off-by: GHkrishna --- .../src/msg_fields/protocols/connection/invitation/public.rs | 3 ++- aries/messages/src/msg_fields/protocols/connection/mod.rs | 5 +++-- .../src/msg_fields/protocols/did_exchange/request.rs | 3 ++- .../src/msg_fields/protocols/did_exchange/response.rs | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/aries/messages/src/msg_fields/protocols/connection/invitation/public.rs b/aries/messages/src/msg_fields/protocols/connection/invitation/public.rs index 99580db647..74478b8ce5 100644 --- a/aries/messages/src/msg_fields/protocols/connection/invitation/public.rs +++ b/aries/messages/src/msg_fields/protocols/connection/invitation/public.rs @@ -1,3 +1,4 @@ +use did_parser_nom::Did; use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; @@ -7,7 +8,7 @@ use super::InvitationContent; #[builder(build_method(into = InvitationContent))] pub struct PublicInvitationContent { pub label: String, - pub did: String, + pub did: Did, } #[cfg(test)] diff --git a/aries/messages/src/msg_fields/protocols/connection/mod.rs b/aries/messages/src/msg_fields/protocols/connection/mod.rs index a704c876f9..e0a8874848 100644 --- a/aries/messages/src/msg_fields/protocols/connection/mod.rs +++ b/aries/messages/src/msg_fields/protocols/connection/mod.rs @@ -6,6 +6,7 @@ pub mod request; pub mod response; use derive_more::From; +use did_parser_nom::Did; use diddoc_legacy::aries::diddoc::AriesDidDoc; use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; @@ -76,13 +77,13 @@ impl DelayedSerde for Connection { #[derive(Debug, Deserialize, Serialize, Clone, PartialEq)] pub struct ConnectionData { #[serde(rename = "DID")] - pub did: String, + pub did: Did, #[serde(rename = "DIDDoc")] pub did_doc: AriesDidDoc, } impl ConnectionData { - pub fn new(did: String, did_doc: AriesDidDoc) -> Self { + pub fn new(did: Did, did_doc: AriesDidDoc) -> Self { Self { did, did_doc } } } diff --git a/aries/messages/src/msg_fields/protocols/did_exchange/request.rs b/aries/messages/src/msg_fields/protocols/did_exchange/request.rs index 0cc68ffc63..7ab7858b21 100644 --- a/aries/messages/src/msg_fields/protocols/did_exchange/request.rs +++ b/aries/messages/src/msg_fields/protocols/did_exchange/request.rs @@ -1,3 +1,4 @@ +use did_parser_nom::Did; use serde::{Deserialize, Serialize}; use shared::maybe_known::MaybeKnown; use typed_builder::TypedBuilder; @@ -18,7 +19,7 @@ pub struct RequestContent { pub label: String, pub goal_code: Option>, pub goal: Option, - pub did: String, // TODO: Use Did + pub did: Did, #[serde(rename = "did_doc~attach")] pub did_doc: Option, } diff --git a/aries/messages/src/msg_fields/protocols/did_exchange/response.rs b/aries/messages/src/msg_fields/protocols/did_exchange/response.rs index 0779b114ac..464ff6732a 100644 --- a/aries/messages/src/msg_fields/protocols/did_exchange/response.rs +++ b/aries/messages/src/msg_fields/protocols/did_exchange/response.rs @@ -1,3 +1,4 @@ +use did_parser_nom::Did; use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; @@ -10,7 +11,7 @@ pub type Response = MsgParts; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct ResponseContent { - pub did: String, // TODO: Use Did + pub did: Did, #[serde(rename = "did_doc~attach")] pub did_doc: Option, }