Commit ece0a503 authored by Éloïs's avatar Éloïs

[deps] upgrade durs dependencies

parent 9d80da45
......@@ -15,9 +15,9 @@ default = ["console_error_panic_hook"]
[dependencies]
cfg-if = "0.1.2"
dup-crypto = "0.5.0"
dubp-documents = "0.11.0"
durs-network-documents = "0.3.0"
dup-crypto = "0.6.0"
dubp-documents = "0.12.0"
durs-network-documents = "0.3.1"
serde_derive = "1.0.*"
wasm-bindgen = "0.2"
......
use crate::*;
use dubp_documents::v10::certification::*;
use dubp_documents::v10::identity::*;
use dubp_documents::v10::membership::*;
use dubp_documents::v10::revocation::*;
use dubp_documents::v10::transaction::*;
use dubp_documents::v10::V10Document;
use dubp_documents::documents::certification::*;
use dubp_documents::documents::identity::*;
use dubp_documents::documents::membership::*;
use dubp_documents::documents::revocation::*;
use dubp_documents::documents::transaction::*;
use dubp_documents::documents::*;
use dubp_documents::Document;
use dubp_documents::*;
use dup_crypto::keys::text_signable::TextSignable;
......@@ -35,45 +35,41 @@ pub fn parse_doc_and_verify(source: &str, doc_type: DocumentType) -> DocCheckRes
if let Ok(document) = parse_doc(source, doc_type) {
let valid_sig = match document {
Document_::DUBPDocument(blockchain_document) => match blockchain_document {
DUBPDocument::V10(blockchain_document_v10) => match blockchain_document_v10.deref()
{
V10Document::Transaction(doc) => {
if let VerificationResult::Valid() = doc.verify_signatures() {
true
} else {
false
}
DUBPDocument::Transaction(doc) => {
if let VerificationResult::Valid() = doc.verify_signatures() {
true
} else {
false
}
V10Document::Identity(doc) => {
if let VerificationResult::Valid() = doc.verify_signatures() {
true
} else {
false
}
}
DUBPDocument::Identity(doc) => {
if let VerificationResult::Valid() = doc.verify_signatures() {
true
} else {
false
}
V10Document::Membership(doc) => {
if let VerificationResult::Valid() = doc.verify_signatures() {
true
} else {
false
}
}
DUBPDocument::Membership(doc) => {
if let VerificationResult::Valid() = doc.verify_signatures() {
true
} else {
false
}
V10Document::Certification(doc) => {
if let VerificationResult::Valid() = doc.verify_signatures() {
true
} else {
false
}
}
DUBPDocument::Certification(doc) => {
if let VerificationResult::Valid() = doc.verify_signatures() {
true
} else {
false
}
V10Document::Revocation(doc) => {
if let VerificationResult::Valid() = doc.verify_signatures() {
true
} else {
false
}
}
DUBPDocument::Revocation(doc) => {
if let VerificationResult::Valid() = doc.verify_signatures() {
true
} else {
false
}
_ => unimplemented!(),
},
}
_ => unimplemented!(),
},
Document_::NetworkDocument(network_document) => match network_document {
......@@ -104,21 +100,14 @@ pub fn parse_doc_into_json(doc: &str, doc_type: DocumentType) -> String {
match parse_doc(doc, doc_type) {
Ok(document) => match document {
Document_::DUBPDocument(blockchain_document) => match blockchain_document {
DUBPDocument::V10(doc_v10_box) => {
let doc_v10 = doc_v10_box.deref();
if let V10Document::Transaction(ref tx_v10_box) = doc_v10 {
let mut tx_v10 = tx_v10_box.deref().clone();
tx_v10.compute_hash();
V10Document::to_json_string_pretty(&V10Document::Transaction(Box::new(
tx_v10,
)))
DUBPDocument::Transaction(ref tx_box) => {
let mut tx = tx_box.deref().clone();
tx.compute_hash();
DUBPDocument::to_json_string_pretty(&DUBPDocument::Transaction(Box::new(tx)))
.unwrap_or_else(|_| "Fail to jsonifie document.".to_owned())
} else {
V10Document::to_json_string_pretty(&doc_v10)
.unwrap_or_else(|_| "Fail to jsonifie document.".to_owned())
}
}
_ => unimplemented!(),
_ => DUBPDocument::to_json_string_pretty(&blockchain_document)
.unwrap_or_else(|_| "Fail to jsonifie document.".to_owned()),
},
Document_::NetworkDocument(network_document) => match network_document {
NetworkDocument::Peer(peer_box) => match peer_box.deref() {
......@@ -153,21 +142,21 @@ fn parse_doc(doc: &str, doc_type: DocumentType) -> Result<Document_, TextDocumen
Err(_) => Err(TextDocumentParseError::UnknownType),
},
},
DocumentType::TxV10 => Ok(Document_::DUBPDocument(DUBPDocument::V10(Box::new(
V10Document::Transaction(Box::new(TransactionDocumentParser::parse(doc)?)),
)))),
DocumentType::IdentityV10 => Ok(Document_::DUBPDocument(DUBPDocument::V10(Box::new(
V10Document::Identity(IdentityDocumentParser::parse(doc)?),
)))),
DocumentType::MembershipV10 => Ok(Document_::DUBPDocument(DUBPDocument::V10(Box::new(
V10Document::Membership(MembershipDocumentParser::parse(doc)?),
)))),
DocumentType::CertificationV10 => Ok(Document_::DUBPDocument(DUBPDocument::V10(Box::new(
V10Document::Certification(Box::new(CertificationDocumentParser::parse(doc)?)),
)))),
DocumentType::RevocationV10 => Ok(Document_::DUBPDocument(DUBPDocument::V10(Box::new(
V10Document::Revocation(Box::new(RevocationDocumentParser::parse(doc)?)),
)))),
DocumentType::TxV10 => Ok(Document_::DUBPDocument(DUBPDocument::Transaction(
Box::new(TransactionDocumentParser::parse(doc)?),
))),
DocumentType::IdentityV10 => Ok(Document_::DUBPDocument(DUBPDocument::Identity(
IdentityDocumentParser::parse(doc)?,
))),
DocumentType::MembershipV10 => Ok(Document_::DUBPDocument(DUBPDocument::Membership(
MembershipDocumentParser::parse(doc)?,
))),
DocumentType::CertificationV10 => Ok(Document_::DUBPDocument(DUBPDocument::Certification(
Box::new(CertificationDocumentParser::parse(doc)?),
))),
DocumentType::RevocationV10 => Ok(Document_::DUBPDocument(DUBPDocument::Revocation(
Box::new(RevocationDocumentParser::parse(doc)?),
))),
DocumentType::PeerV11 => Ok(Document_::NetworkDocument(NetworkDocument::Peer(Box::new(
PeerCard::V11(PeerCardV11::parse(doc)?),
)))),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment