Skip to content

change: simplify didcore components, did-exchange protocol #1075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 15, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
*.code-workspace
**/tails.txt
.session.vim
**/rust/aath-backchannel
49 changes: 31 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ members = [
"did_core/did_doc",
"did_core/did_methods/did_peer",
"did_core/did_methods/did_key",
"did_core/did_doc_sov",
"did_core/did_parser",
"did_core/did_parser_nom",
"did_core/did_resolver",
Expand Down
6 changes: 3 additions & 3 deletions aries/agents/aries-vcx-agent/src/agent/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ use std::sync::Arc;

use aries_vcx::{
common::ledger::{
service_didsov::{DidSovServiceType, EndpointDidSov},
service_didsov::EndpointDidSov,
transactions::{add_new_did, write_endpoint},
},
did_doc::schema::service::typed::ServiceType,
global::settings::DEFAULT_LINK_SECRET_ALIAS,
};
use aries_vcx_core::{
Expand Down Expand Up @@ -110,7 +111,7 @@ impl Agent<IndySdkWallet> {
.await?;
let endpoint = EndpointDidSov::create()
.set_service_endpoint(init_config.service_endpoint.clone())
.set_types(Some(vec![DidSovServiceType::DidCommunication]));
.set_types(Some(vec![ServiceType::DIDCommV1.to_string()]));
write_endpoint(
wallet.as_ref(),
ledger_write.as_ref(),
Expand All @@ -134,7 +135,6 @@ impl Agent<IndySdkWallet> {
init_config.service_endpoint.clone(),
));
let did_exchange = Arc::new(ServiceDidExchange::new(
ledger_read.clone(),
wallet.clone(),
did_resolver_registry,
init_config.service_endpoint.clone(),
Expand Down
26 changes: 16 additions & 10 deletions aries/agents/aries-vcx-agent/src/error/convertors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use std::{convert::From, num::ParseIntError};

use aries_vcx::{
did_doc::error::DidDocumentBuilderError,
did_doc_sov::error::DidDocumentSovError,
errors::error::{AriesVcxError, AriesVcxErrorKind},
protocols::did_exchange::state_machine::generic::GenericDidExchange,
};
use aries_vcx_core::errors::error::AriesVcxCoreError;
use did_resolver_sov::did_resolver::did_doc::schema::utils::error::DidDocumentLookupError;

use crate::error::*;

Expand All @@ -30,7 +30,6 @@ impl From<serde_json::Error> for AgentError {
}
}

// TODO
impl From<AriesVcxCoreError> for AgentError {
fn from(err: AriesVcxCoreError) -> Self {
let kind = AgentErrorKind::GenericAriesVcxError;
Expand All @@ -39,14 +38,6 @@ impl From<AriesVcxCoreError> for AgentError {
}
}

impl From<DidDocumentSovError> for AgentError {
fn from(err: DidDocumentSovError) -> Self {
let kind = AgentErrorKind::GenericAriesVcxError;
let message = format!("DidDocumentSovError; err: {:?}", err.to_string());
AgentError { message, kind }
}
}

impl From<DidDocumentBuilderError> for AgentError {
fn from(err: DidDocumentBuilderError) -> Self {
let kind = AgentErrorKind::GenericAriesVcxError;
Expand All @@ -63,6 +54,14 @@ impl From<aries_vcx::did_parser::ParseError> for AgentError {
}
}

impl From<did_peer::error::DidPeerError> for AgentError {
fn from(err: did_peer::error::DidPeerError) -> Self {
let kind = AgentErrorKind::GenericAriesVcxError;
let message = format!("DidPeerError; err: {:?}", err.to_string());
AgentError { message, kind }
}
}

impl From<public_key::PublicKeyError> for AgentError {
fn from(err: public_key::PublicKeyError) -> Self {
let kind = AgentErrorKind::GenericAriesVcxError;
Expand All @@ -86,6 +85,13 @@ impl From<(GenericDidExchange, AriesVcxError)> for AgentError {
AgentError { message, kind }
}
}
impl From<DidDocumentLookupError> for AgentError {
fn from(err: DidDocumentLookupError) -> Self {
let kind = AgentErrorKind::GenericAriesVcxError;
let message = format!("DidDocumentLookupError; err: {:?}", err.to_string());
AgentError { message, kind }
}
}

impl From<anoncreds_types::Error> for AgentError {
fn from(err: anoncreds_types::Error) -> Self {
Expand Down
57 changes: 0 additions & 57 deletions aries/agents/aries-vcx-agent/src/helper.rs

This file was deleted.

2 changes: 1 addition & 1 deletion aries/agents/aries-vcx-agent/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub struct VcxHttpClient;

#[async_trait]
impl Transport for VcxHttpClient {
async fn send_message(&self, msg: Vec<u8>, service_endpoint: Url) -> VcxResult<()> {
async fn send_message(&self, msg: Vec<u8>, service_endpoint: &Url) -> VcxResult<()> {
shared::http_client::post_message(msg, service_endpoint).await?;
Ok(())
}
Expand Down
1 change: 0 additions & 1 deletion aries/agents/aries-vcx-agent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ extern crate uuid;

mod agent;
mod error;
pub mod helper;
mod http;
mod services;
mod storage;
Expand Down
26 changes: 23 additions & 3 deletions aries/agents/aries-vcx-agent/src/services/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ use std::sync::{Arc, Mutex};

use aries_vcx::{
handlers::util::AnyInvitation,
messages::msg_fields::protocols::{
connection::{request::Request, response::Response},
notification::ack::Ack,
messages::{
msg_fields::protocols::{
connection::{request::Request, response::Response},
notification::ack::Ack,
},
AriesMessage,
},
protocols::connection::{
pairwise_info::PairwiseInfo, Connection, GenericConnection, State, ThinState,
Expand Down Expand Up @@ -44,6 +47,23 @@ impl<T: BaseWallet> ServiceConnections<T> {
}
}

pub async fn send_message(
&self,
connection_id: &str,
message: &AriesMessage,
) -> AgentResult<()> {
let connection = self.get_by_id(connection_id)?;
let wallet = self.wallet.as_ref();
info!(
"Sending message to connection identified by id {}. Plaintext message payload: {}",
connection_id, message
);
connection
.send_message(wallet, message, &VcxHttpClient)
.await?;
Ok(())
}

pub async fn create_invitation(
&self,
pw_info: Option<PairwiseInfo>,
Expand Down
Loading