Skip to content

Commit 69d80d3

Browse files
committed
Refactor did-core, update aries-agent and did-exchange implementations
Signed-off-by: Patrik Stas <[email protected]>
1 parent a012338 commit 69d80d3

File tree

144 files changed

+3940
-4687
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+3940
-4687
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
*.code-workspace
99
**/tails.txt
1010
.session.vim
11+
**/rust/aath-backchannel

Cargo.lock

+31-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ members = [
2121
"did_core/did_doc",
2222
"did_core/did_methods/did_peer",
2323
"did_core/did_methods/did_key",
24-
"did_core/did_doc_sov",
2524
"did_core/did_parser",
2625
"did_core/did_parser_nom",
2726
"did_core/did_resolver",

aries/agents/aries-vcx-agent/src/agent/init.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ use std::sync::Arc;
22

33
use aries_vcx::{
44
common::ledger::{
5-
service_didsov::{DidSovServiceType, EndpointDidSov},
5+
service_didsov::EndpointDidSov,
66
transactions::{add_new_did, write_endpoint},
77
},
8+
did_doc::schema::service::typed::ServiceType,
89
global::settings::DEFAULT_LINK_SECRET_ALIAS,
910
};
1011
use aries_vcx_core::{
@@ -110,7 +111,7 @@ impl Agent<IndySdkWallet> {
110111
.await?;
111112
let endpoint = EndpointDidSov::create()
112113
.set_service_endpoint(init_config.service_endpoint.clone())
113-
.set_types(Some(vec![DidSovServiceType::DidCommunication]));
114+
.set_types(Some(vec![ServiceType::DIDCommV1.to_string()]));
114115
write_endpoint(
115116
wallet.as_ref(),
116117
ledger_write.as_ref(),
@@ -134,7 +135,6 @@ impl Agent<IndySdkWallet> {
134135
init_config.service_endpoint.clone(),
135136
));
136137
let did_exchange = Arc::new(ServiceDidExchange::new(
137-
ledger_read.clone(),
138138
wallet.clone(),
139139
did_resolver_registry,
140140
init_config.service_endpoint.clone(),

aries/agents/aries-vcx-agent/src/error/convertors.rs

+16-10
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use std::{convert::From, num::ParseIntError};
22

33
use aries_vcx::{
44
did_doc::error::DidDocumentBuilderError,
5-
did_doc_sov::error::DidDocumentSovError,
65
errors::error::{AriesVcxError, AriesVcxErrorKind},
76
protocols::did_exchange::state_machine::generic::GenericDidExchange,
87
};
98
use aries_vcx_core::errors::error::AriesVcxCoreError;
9+
use did_resolver_sov::did_resolver::did_doc::schema::utils::error::DidDocumentLookupError;
1010

1111
use crate::error::*;
1212

@@ -30,7 +30,6 @@ impl From<serde_json::Error> for AgentError {
3030
}
3131
}
3232

33-
// TODO
3433
impl From<AriesVcxCoreError> for AgentError {
3534
fn from(err: AriesVcxCoreError) -> Self {
3635
let kind = AgentErrorKind::GenericAriesVcxError;
@@ -39,14 +38,6 @@ impl From<AriesVcxCoreError> for AgentError {
3938
}
4039
}
4140

42-
impl From<DidDocumentSovError> for AgentError {
43-
fn from(err: DidDocumentSovError) -> Self {
44-
let kind = AgentErrorKind::GenericAriesVcxError;
45-
let message = format!("DidDocumentSovError; err: {:?}", err.to_string());
46-
AgentError { message, kind }
47-
}
48-
}
49-
5041
impl From<DidDocumentBuilderError> for AgentError {
5142
fn from(err: DidDocumentBuilderError) -> Self {
5243
let kind = AgentErrorKind::GenericAriesVcxError;
@@ -63,6 +54,14 @@ impl From<aries_vcx::did_parser::ParseError> for AgentError {
6354
}
6455
}
6556

57+
impl From<did_peer::error::DidPeerError> for AgentError {
58+
fn from(err: did_peer::error::DidPeerError) -> Self {
59+
let kind = AgentErrorKind::GenericAriesVcxError;
60+
let message = format!("DidPeerError; err: {:?}", err.to_string());
61+
AgentError { message, kind }
62+
}
63+
}
64+
6665
impl From<public_key::PublicKeyError> for AgentError {
6766
fn from(err: public_key::PublicKeyError) -> Self {
6867
let kind = AgentErrorKind::GenericAriesVcxError;
@@ -86,6 +85,13 @@ impl From<(GenericDidExchange, AriesVcxError)> for AgentError {
8685
AgentError { message, kind }
8786
}
8887
}
88+
impl From<DidDocumentLookupError> for AgentError {
89+
fn from(err: DidDocumentLookupError) -> Self {
90+
let kind = AgentErrorKind::GenericAriesVcxError;
91+
let message = format!("DidDocumentLookupError; err: {:?}", err.to_string());
92+
AgentError { message, kind }
93+
}
94+
}
8995

9096
impl From<anoncreds_types::Error> for AgentError {
9197
fn from(err: anoncreds_types::Error) -> Self {

aries/agents/aries-vcx-agent/src/helper.rs

-57
This file was deleted.

aries/agents/aries-vcx-agent/src/http.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub struct VcxHttpClient;
66

77
#[async_trait]
88
impl Transport for VcxHttpClient {
9-
async fn send_message(&self, msg: Vec<u8>, service_endpoint: Url) -> VcxResult<()> {
9+
async fn send_message(&self, msg: Vec<u8>, service_endpoint: &Url) -> VcxResult<()> {
1010
shared::http_client::post_message(msg, service_endpoint).await?;
1111
Ok(())
1212
}

aries/agents/aries-vcx-agent/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ extern crate uuid;
99

1010
mod agent;
1111
mod error;
12-
pub mod helper;
1312
mod http;
1413
mod services;
1514
mod storage;

aries/agents/aries-vcx-agent/src/services/connection.rs

+23-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ use std::sync::{Arc, Mutex};
22

33
use aries_vcx::{
44
handlers::util::AnyInvitation,
5-
messages::msg_fields::protocols::{
6-
connection::{request::Request, response::Response},
7-
notification::ack::Ack,
5+
messages::{
6+
msg_fields::protocols::{
7+
connection::{request::Request, response::Response},
8+
notification::ack::Ack,
9+
},
10+
AriesMessage,
811
},
912
protocols::connection::{
1013
pairwise_info::PairwiseInfo, Connection, GenericConnection, State, ThinState,
@@ -44,6 +47,23 @@ impl<T: BaseWallet> ServiceConnections<T> {
4447
}
4548
}
4649

50+
pub async fn send_message(
51+
&self,
52+
connection_id: &str,
53+
message: &AriesMessage,
54+
) -> AgentResult<()> {
55+
let connection = self.get_by_id(connection_id)?;
56+
let wallet = self.wallet.as_ref();
57+
info!(
58+
"Sending message to connection identified by id {}. Plaintext message payload: {}",
59+
connection_id, message
60+
);
61+
connection
62+
.send_message(wallet, message, &VcxHttpClient)
63+
.await?;
64+
Ok(())
65+
}
66+
4767
pub async fn create_invitation(
4868
&self,
4969
pw_info: Option<PairwiseInfo>,

0 commit comments

Comments
 (0)