From b95931fa02f273abc9d8fdd8134e9d68a3e1ae15 Mon Sep 17 00:00:00 2001
From: librelois <c@elo.tf>
Date: Mon, 31 Aug 2020 22:51:02 +0200
Subject: [PATCH] [deps] upgrade all dubp deps (use dubp-rs-libs)

---
 .gitlab-ci.yml               |   8 +-
 Cargo.toml                   |  32 +++++---
 src/crypto.rs                |  68 +++++++---------
 src/examples.rs              |  19 ++++-
 src/lib.rs                   |  57 +++++++++++---
 src/parsers.rs               | 147 +++++++++++++++--------------------
 src/parsers/wallet_script.rs |  24 ++++++
 src/utils.rs                 |  17 ----
 tests/web.rs                 |  25 ++----
 9 files changed, 208 insertions(+), 189 deletions(-)
 create mode 100644 src/parsers/wallet_script.rs
 delete mode 100644 src/utils.rs

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4e4fa9d..f8c5e32 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -9,9 +9,9 @@ variables:
 
 
 .rust_stable_lin64: &rust_stable_lin64
-  image: registry.duniter.org/docker/duniter-rs-ci:v0.1.0
+  image: registry.duniter.org/docker/rust/rust-x64-stable-ci:latest
   tags:
-    - redshift-rs-stable
+    - redshift
   before_script:
     - export PATH="$HOME/.cargo/bin:$PATH"
     - rustup show
@@ -20,7 +20,7 @@ variables:
 .rust_stable_wasm: &rust_stable_wasm
   image: registry.duniter.org/docker/rust/wasm:v0.0.4
   tags:
-    - redshift-rs-nightly
+    - redshift
   before_script:
     - export PATH="$HOME/.cargo/bin:$PATH"
     - rustc --version && cargo --version
@@ -43,9 +43,9 @@ tests:wasm:stable:
 clippy:
   <<: *rust_stable_lin64
   before_script:
-    - cargo clippy -- -V
   stage: clippy
   script:
+    - cargo clippy -- -V
     - cargo clippy --all -- -D warnings --verbose
 
 publish:npm:
diff --git a/Cargo.toml b/Cargo.toml
index e15bcff..a32f983 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "dup-tools-wasm"
-version = "0.2.1"
-authors = ["librelois <elois@ifee.fr>"]
+version = "0.3.0"
+authors = ["librelois <elois@duniter.org>"]
 description = "Tools for DUP Protocol."
 repository = "https://git.duniter.org/tools/dup-tools-wasm"
 license = "AGPL-3.0"
@@ -14,24 +14,32 @@ crate-type = ["cdylib", "rlib"]
 default = ["console_error_panic_hook"]
 
 [dependencies]
-base58 = "0.1.*"
-cfg-if = "0.1.2"
-dup-crypto = "0.6.0"
-dubp-documents = "0.12.0"
-durs-network-documents = "0.3.1"
+cfg-if = "0.1.10"
+dubp-documents = { version = "0.20.0", features = ["crypto_scrypt"] }
+dubp-documents-parser = { version = "0.5.1", features = ["crypto_scrypt"] }
+#durs-network-documents = "0.3.1"
 serde_derive = "1.0.*"
-wasm-bindgen = "0.2"
+wasm-bindgen = "0.2.67"
 
 # The `console_error_panic_hook` crate provides better debugging of panics by
 # logging them with `console.error`. This is great for development, but requires
 # all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
 # code size when deploying.
-console_error_panic_hook = { version = "0.1.1", optional = true }
+[dependencies.console_error_panic_hook]
+version = "0.1.6"
+optional = true
 
 [dev-dependencies]
-pretty_assertions = "0.5.1"
-wasm-bindgen-test = "0.2"
+pretty_assertions = "0.6.1"
+wasm-bindgen-test = "0.3.17"
 
 [profile.release]
 # Tell `rustc` to optimize for small code size.
-opt-level = "s"
+#opt-level = "s"
+
+[package.metadata.wasm-pack.profile.release]
+wasm-opt = false
+
+[patch.crates-io]
+#dubp-documents = { path = "../../libs/dubp-rs-libs/documents" }
+#dubp-documents-parser = { path = "../../libs/dubp-rs-libs/documents-parser" }
\ No newline at end of file
diff --git a/src/crypto.rs b/src/crypto.rs
index 855d3dd..61c24d5 100644
--- a/src/crypto.rs
+++ b/src/crypto.rs
@@ -1,8 +1,19 @@
-use base58::ToBase58;
-use dup_crypto::bases::*;
-use dup_crypto::hashs::*;
-use dup_crypto::keys::*;
-use wasm_bindgen::prelude::*;
+//  Copyright (C) 2020  Éloïs SANCHEZ.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+use crate::*;
 
 #[wasm_bindgen]
 pub fn verify(datas: &str, pubkey: &str, signature: &str) -> bool {
@@ -15,58 +26,31 @@ pub fn verify(datas: &str, pubkey: &str, signature: &str) -> bool {
         Err(_) => return false,
     };
 
-    pubkey.verify(datas.as_bytes(), &sig)
+    pubkey.verify(datas.as_bytes(), &sig).is_ok()
 }
 
 #[wasm_bindgen]
-pub fn generate_ed25519_keypair(salt: &str, password: &str) -> String {
+pub fn generate_ed25519_pubkey(salt: String, password: String) -> String {
     let keypair = ed25519::KeyPairFromSaltedPasswordGenerator::with_default_parameters()
-        .generate(salt.as_bytes(), password.as_bytes());
+        .generate(ed25519::SaltedPassword::new(salt, password));
 
-    format!("{}:{}", keypair.pubkey, keypair.privkey)
+    format!("{}", keypair.public_key())
 }
 
 #[wasm_bindgen]
-pub fn generate_ed25519_pubkey(salt: &str, password: &str) -> String {
-    let keypair = ed25519::KeyPairFromSaltedPasswordGenerator::with_default_parameters()
-        .generate(salt.as_bytes(), password.as_bytes());
-
-    format!("{}", keypair.pubkey)
-}
-
-#[wasm_bindgen]
-pub fn generate_seed_from_salted_password(salt: &str, password: &str, base: usize) -> String {
-    if base != 16 && base != 58 {
-        return "Error : invalid param base : accepted values are : 16, 58.".to_owned();
-    }
-
+pub fn generate_seed_from_salted_password(salt: String, password: String) -> String {
     let seed = ed25519::KeyPairFromSaltedPasswordGenerator::with_default_parameters()
         .generate_seed(salt.as_bytes(), password.as_bytes());
 
-    match base {
-        16 => Hash(seed).to_hex(),
-        58 => seed.to_base58(),
-        _ => unreachable!(),
-    }
-}
-
-#[wasm_bindgen]
-pub fn generate_ed25519_keypair_from_seed(seed: &str, base: usize) -> String {
-    match parse_seed(seed, base) {
-        Ok(seed) => {
-            let keypair = ed25519::KeyPairFromSeedGenerator::generate(&seed);
-            format!("{}:{}", keypair.pubkey, keypair.privkey)
-        }
-        Err(error_message) => error_message,
-    }
+    seed.to_base58()
 }
 
 #[wasm_bindgen]
 pub fn generate_ed25519_pubkey_from_seed(seed: &str, base: usize) -> String {
     match parse_seed(seed, base) {
-        Ok(seed) => {
-            let keypair = ed25519::KeyPairFromSeedGenerator::generate(&seed);
-            format!("{}", keypair.pubkey)
+        Ok(seed_bytes) => {
+            let keypair = ed25519::KeyPairFromSeed32Generator::generate(Seed32::new(seed_bytes));
+            format!("{}", keypair.public_key())
         }
         Err(error_message) => error_message,
     }
@@ -79,7 +63,7 @@ fn parse_seed(seed: &str, base: usize) -> Result<[u8; 32], String> {
             Err(err) => Err(format!("{}", err)),
         },
         58 => match b58::str_base58_to_32bytes(seed) {
-            Ok(seed) => Ok(seed),
+            Ok((seed, _leading_1)) => Ok(seed),
             Err(err) => Err(format!("{}", err)),
         },
         _ => Err("Error : invalid param base : accepted values are : 16, 58.".to_owned()),
diff --git a/src/examples.rs b/src/examples.rs
index dd77e2d..2e0c21e 100644
--- a/src/examples.rs
+++ b/src/examples.rs
@@ -1,3 +1,18 @@
+//  Copyright (C) 2020  Éloïs SANCHEZ.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
 use crate::*;
 
 #[wasm_bindgen]
@@ -55,12 +70,12 @@ IdtyUniqueID: tic
 IdtyTimestamp: 0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855
 IdtySignature: 1eubHHbuNfilHMM0G2bI30iZzebQ2cQ1PC7uPAw08FGMMmQCRerlF/3pc4sAcsnexsxBseA/3lY03KlONqJBAg==
 XXOgI++6qpY9O31ml/FcfbXCE6aixIrgkT5jL7kBle3YOMr+8wrp7Rt+z9hDVjrNfYX2gpeJsuMNfG4T/fzVDQ==".to_owned(),
-        DocumentType::PeerV11 => "11:g1:0:7iMV3b6j2hSj5WtrfchfvxivS9swN3opDgxudeHq64fb:50-000005B1CEB4EC5245EF7E33101A330A1C9A358EC45A25FC13F78BB58C9E7370
+        /*DocumentType::PeerV11 => "11:g1:0:7iMV3b6j2hSj5WtrfchfvxivS9swN3opDgxudeHq64fb:50-000005B1CEB4EC5245EF7E33101A330A1C9A358EC45A25FC13F78BB58C9E7370
 WS2P V2 S 7 g1.durs.ifee.fr 443 ws2p
 WS2P V2 S 7 84.16.72.210 443 ws2p
 EQ2D5almq2RNUi3XZNtTpjo9nWtJF0PzsCW7ROAzCQKiEtpI7/fW8Z23GJ2a/SIxfYSzlq/cZqksE4EoVe1rAw==".to_owned(),
         DocumentType::HeadV3 => "3:g1:0:0:0:0:0:7iMV3b6j2hSj5WtrfchfvxivS9swN3opDgxudeHq64fb:50-000005B1CEB4EC5245EF7E33101A330A1C9A358EC45A25FC13F78BB58C9E7370:durs:0.1.0-a0.1
 vwlxpkCbv83qYSiClYA/GD35hs0AsZBnqv7uoE8hqlarT2c6jVRKhjp8JBqmRI7Se4IDwC2owk0mF4CglvyACQ==
-2".to_owned(),
+2".to_owned(),*/
     }
 }
diff --git a/src/lib.rs b/src/lib.rs
index e88b75c..376bfde 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,17 +1,37 @@
-extern crate cfg_if;
-extern crate dubp_documents;
-extern crate dup_crypto;
-extern crate durs_network_documents;
-extern crate serde_derive;
-extern crate wasm_bindgen;
+//  Copyright (C) 2020  Éloïs SANCHEZ.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 pub mod crypto;
 pub mod examples;
 pub mod parsers;
-mod utils;
 
-use cfg_if::cfg_if;
-use wasm_bindgen::prelude::*;
+// Crate imports
+pub(crate) use cfg_if::cfg_if;
+pub(crate) use dubp_documents::certification::*;
+pub(crate) use dubp_documents::dubp_common::crypto::bases::b58::ToBase58;
+pub(crate) use dubp_documents::dubp_common::crypto::bases::*;
+pub(crate) use dubp_documents::dubp_common::crypto::keys::*;
+pub(crate) use dubp_documents::identity::*;
+pub(crate) use dubp_documents::membership::*;
+pub(crate) use dubp_documents::prelude::*;
+pub(crate) use dubp_documents::revocation::*;
+pub(crate) use dubp_documents::transaction::*;
+pub(crate) use dubp_documents_parser::prelude::*;
+pub(crate) use dubp_documents_parser::{PestError, RawTextParseError};
+pub(crate) use std::ops::Deref;
+pub(crate) use wasm_bindgen::prelude::*;
 
 cfg_if! {
     // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
@@ -22,6 +42,21 @@ cfg_if! {
         static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
     }
 }
+cfg_if! {
+    // When the `console_error_panic_hook` feature is enabled, we can call the
+    // `set_panic_hook` function at least once during initialization, and then
+    // we will get better error messages if our code ever panics.
+    //
+    // For more details see
+    // https://github.com/rustwasm/console_error_panic_hook#readme
+    if #[cfg(feature = "console_error_panic_hook")] {
+        extern crate console_error_panic_hook;
+        pub use self::console_error_panic_hook::set_once as set_panic_hook;
+    } else {
+        #[inline]
+        pub fn set_panic_hook() {}
+    }
+}
 
 #[wasm_bindgen]
 #[derive(Debug, Copy, Clone)]
@@ -32,6 +67,6 @@ pub enum DocumentType {
     MembershipV10,
     CertificationV10,
     RevocationV10,
-    PeerV11,
-    HeadV3,
+    //PeerV11,
+    //HeadV3,
 }
diff --git a/src/parsers.rs b/src/parsers.rs
index c503d32..3bef0d7 100644
--- a/src/parsers.rs
+++ b/src/parsers.rs
@@ -1,19 +1,25 @@
+//  Copyright (C) 2020  Éloïs SANCHEZ.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+pub mod wallet_script;
+
 use crate::*;
-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;
-use durs_network_documents::network_head::NetworkHead;
-use durs_network_documents::network_head_v3::NetworkHeadV3;
-use durs_network_documents::network_peer::*;
-use durs_network_documents::*;
-use std::ops::Deref;
-use wasm_bindgen::prelude::*;
+//use durs_network_documents::network_head::NetworkHead;
+//use durs_network_documents::network_head_v3::NetworkHeadV3;
+//use durs_network_documents::network_peer::*;
+//use durs_network_documents::*;
 
 #[wasm_bindgen]
 #[derive(Debug, Copy, Clone, Eq, PartialEq)]
@@ -26,53 +32,22 @@ pub enum DocCheckResult {
 
 #[derive(Debug, Clone)]
 pub enum Document_ {
-    DUBPDocument(DUBPDocument),
-    NetworkDocument(NetworkDocument),
+    DubpDocument(DubpDocument),
+    //NetworkDocument(NetworkDocument),
 }
 
 #[wasm_bindgen]
 pub fn parse_doc_and_verify(source: &str, doc_type: DocumentType) -> DocCheckResult {
     if let Ok(document) = parse_doc(source, doc_type) {
         let valid_sig = match document {
-            Document_::DUBPDocument(blockchain_document) => match blockchain_document {
-                DUBPDocument::Transaction(doc) => {
-                    if let VerificationResult::Valid() = doc.verify_signatures() {
-                        true
-                    } else {
-                        false
-                    }
-                }
-                DUBPDocument::Identity(doc) => {
-                    if let VerificationResult::Valid() = doc.verify_signatures() {
-                        true
-                    } else {
-                        false
-                    }
-                }
-                DUBPDocument::Membership(doc) => {
-                    if let VerificationResult::Valid() = doc.verify_signatures() {
-                        true
-                    } else {
-                        false
-                    }
-                }
-                DUBPDocument::Certification(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!(),
+            Document_::DubpDocument(blockchain_document) => match blockchain_document {
+                DubpDocument::Transaction(doc) => doc.verify_signatures().is_ok(),
+                DubpDocument::Identity(doc) => doc.verify_signatures().is_ok(),
+                DubpDocument::Membership(doc) => doc.verify_signatures().is_ok(),
+                DubpDocument::Certification(doc) => doc.verify_signatures().is_ok(),
+                DubpDocument::Revocation(doc) => doc.verify_signatures().is_ok(),
             },
-            Document_::NetworkDocument(network_document) => match network_document {
+            /*Document_::NetworkDocument(network_document) => match network_document {
                 NetworkDocument::Peer(peer_box) => match peer_box.deref() {
                     PeerCard::V11(peer_v11) => peer_v11.verify().is_ok(),
                     _ => unimplemented!(),
@@ -81,7 +56,7 @@ pub fn parse_doc_and_verify(source: &str, doc_type: DocumentType) -> DocCheckRes
                     NetworkHead::V3(head_v3_box) => head_v3_box.deref().verify().is_ok(),
                     _ => unimplemented!(),
                 },
-            },
+            },*/
         };
         if valid_sig {
             DocCheckResult::ValidSig
@@ -99,17 +74,17 @@ pub fn parse_doc_and_verify(source: &str, doc_type: DocumentType) -> DocCheckRes
 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::Transaction(ref tx_box) => {
-                    let mut tx = tx_box.deref().clone();
+            Document_::DubpDocument(blockchain_document) => match blockchain_document {
+                DubpDocument::Transaction(ref tx_box) => {
+                    let tx = tx_box.deref().clone();
                     tx.compute_hash();
-                    DUBPDocument::to_json_string_pretty(&DUBPDocument::Transaction(Box::new(tx)))
+                    DubpDocument::to_json_string_pretty(&DubpDocument::Transaction(Box::new(tx)))
                         .unwrap_or_else(|_| "Fail to jsonifie document.".to_owned())
                 }
-                _ => DUBPDocument::to_json_string_pretty(&blockchain_document)
+                _ => DubpDocument::to_json_string_pretty(&blockchain_document)
                     .unwrap_or_else(|_| "Fail to jsonifie document.".to_owned()),
             },
-            Document_::NetworkDocument(network_document) => match network_document {
+            /*Document_::NetworkDocument(network_document) => match network_document {
                 NetworkDocument::Peer(peer_box) => match peer_box.deref() {
                     PeerCard::V11(peer_v11) => PeerCardV11::to_json_string_pretty(&peer_v11)
                         .unwrap_or_else(|_| "Fail to jsonifie document.".to_owned()),
@@ -120,48 +95,52 @@ pub fn parse_doc_into_json(doc: &str, doc_type: DocumentType) -> String {
                         .unwrap_or_else(|_| "Fail to jsonifie document.".to_owned()),
                     _ => unimplemented!(),
                 },
-            },
+            },*/
         },
         Err(parse_error) => match parse_error {
-            TextDocumentParseError::UnknownType => {
+            RawTextParseError::UnknownType => {
                 "Invalid document. Specify the expected document type for more information."
                     .to_owned()
             }
-            TextDocumentParseError::PestError(pest_error) => pest_error,
+            RawTextParseError::PestError(PestError(pest_error)) => pest_error,
             _ => format!("{:?}", parse_error),
         },
     }
 }
 
-fn parse_doc(doc: &str, doc_type: DocumentType) -> Result<Document_, TextDocumentParseError> {
+fn parse_doc(doc: &str, doc_type: DocumentType) -> Result<Document_, RawTextParseError> {
     match doc_type {
-        DocumentType::Any => match NetworkDocument::parse(doc) {
+        DocumentType::Any => /*match NetworkDocument::parse(doc) {
             Ok(network_document) => Ok(Document_::NetworkDocument(network_document)),
-            Err(_) => match DUBPDocument::parse(doc) {
-                Ok(blockchain_document) => Ok(Document_::DUBPDocument(blockchain_document)),
-                Err(_) => Err(TextDocumentParseError::UnknownType),
-            },
-        },
-        DocumentType::TxV10 => Ok(Document_::DUBPDocument(DUBPDocument::Transaction(
-            Box::new(TransactionDocumentParser::parse(doc)?),
+            Err(_) => match DubpDocument::parse(doc) {
+                Ok(blockchain_document) => Ok(Document_::DubpDocument(blockchain_document)),
+                Err(_) => Err(RawTextParseError::UnknownType),
+            },*/
+            match DubpDocument::parse_from_raw_text(doc) {
+                Ok(blockchain_document) => Ok(Document_::DubpDocument(blockchain_document)),
+                Err(_) => Err(RawTextParseError::UnknownType),
+            }
+        //},
+        DocumentType::TxV10 => Ok(Document_::DubpDocument(DubpDocument::Transaction(
+            Box::new(TransactionDocument::parse_from_raw_text(doc)?),
         ))),
-        DocumentType::IdentityV10 => Ok(Document_::DUBPDocument(DUBPDocument::Identity(
-            IdentityDocumentParser::parse(doc)?,
+        DocumentType::IdentityV10 => Ok(Document_::DubpDocument(DubpDocument::Identity(
+            IdentityDocument::parse_from_raw_text(doc)?,
         ))),
-        DocumentType::MembershipV10 => Ok(Document_::DUBPDocument(DUBPDocument::Membership(
-            MembershipDocumentParser::parse(doc)?,
+        DocumentType::MembershipV10 => Ok(Document_::DubpDocument(DubpDocument::Membership(
+            MembershipDocument::parse_from_raw_text(doc)?,
         ))),
-        DocumentType::CertificationV10 => Ok(Document_::DUBPDocument(DUBPDocument::Certification(
-            Box::new(CertificationDocumentParser::parse(doc)?),
+        DocumentType::CertificationV10 => Ok(Document_::DubpDocument(DubpDocument::Certification(
+            Box::new(CertificationDocument::parse_from_raw_text(doc)?),
         ))),
-        DocumentType::RevocationV10 => Ok(Document_::DUBPDocument(DUBPDocument::Revocation(
-            Box::new(RevocationDocumentParser::parse(doc)?),
+        DocumentType::RevocationV10 => Ok(Document_::DubpDocument(DubpDocument::Revocation(
+            Box::new(RevocationDocument::parse_from_raw_text(doc)?),
         ))),
-        DocumentType::PeerV11 => Ok(Document_::NetworkDocument(NetworkDocument::Peer(Box::new(
+        /*DocumentType::PeerV11 => Ok(Document_::NetworkDocument(NetworkDocument::Peer(Box::new(
             PeerCard::V11(PeerCardV11::parse(doc)?),
         )))),
         DocumentType::HeadV3 => Ok(Document_::NetworkDocument(NetworkDocument::Head(
             NetworkHead::V3(Box::new(NetworkHeadV3::parse(doc)?)),
-        ))),
+        ))),*/
     }
 }
diff --git a/src/parsers/wallet_script.rs b/src/parsers/wallet_script.rs
new file mode 100644
index 0000000..564960d
--- /dev/null
+++ b/src/parsers/wallet_script.rs
@@ -0,0 +1,24 @@
+//  Copyright (C) 2020  Éloïs SANCHEZ.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+use crate::*;
+
+#[wasm_bindgen]
+pub fn parse_wallet_script(script_str: &str) -> String {
+    match dubp_documents_parser::wallet_script_from_str(script_str) {
+        Ok(script) => format!("{:#?}", script),
+        Err(e) => format!("{:#?}", e),
+    }
+}
diff --git a/src/utils.rs b/src/utils.rs
deleted file mode 100644
index 2ffc954..0000000
--- a/src/utils.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-use cfg_if::cfg_if;
-
-cfg_if! {
-    // When the `console_error_panic_hook` feature is enabled, we can call the
-    // `set_panic_hook` function at least once during initialization, and then
-    // we will get better error messages if our code ever panics.
-    //
-    // For more details see
-    // https://github.com/rustwasm/console_error_panic_hook#readme
-    if #[cfg(feature = "console_error_panic_hook")] {
-        extern crate console_error_panic_hook;
-        pub use self::console_error_panic_hook::set_once as set_panic_hook;
-    } else {
-        #[inline]
-        pub fn set_panic_hook() {}
-    }
-}
diff --git a/tests/web.rs b/tests/web.rs
index dfaa369..c174a84 100644
--- a/tests/web.rs
+++ b/tests/web.rs
@@ -18,8 +18,8 @@ wasm_bindgen_test_configure!(run_in_browser);
 #[wasm_bindgen_test]
 fn test_generate_ed25519_keypair() {
     let pubkey = generate_ed25519_pubkey(
-        "JhxtHB7UcsDbA9wMSyMKXUzBZUQvqVyB32KwzS9SWoLkjrUhHV",
-        "JhxtHB7UcsDbA9wMSyMKXUzBZUQvqVyB32KwzS9SWoLkjrUhHV_",
+        "JhxtHB7UcsDbA9wMSyMKXUzBZUQvqVyB32KwzS9SWoLkjrUhHV".to_owned(),
+        "JhxtHB7UcsDbA9wMSyMKXUzBZUQvqVyB32KwzS9SWoLkjrUhHV_".to_owned(),
     );
 
     assert_eq!(
@@ -30,22 +30,13 @@ fn test_generate_ed25519_keypair() {
 
 #[wasm_bindgen_test]
 fn test_generate_ed25519_keypair_from_seed() {
-    let seed_b16 = generate_seed_from_salted_password(
-        "JhxtHB7UcsDbA9wMSyMKXUzBZUQvqVyB32KwzS9SWoLkjrUhHV",
-        "JhxtHB7UcsDbA9wMSyMKXUzBZUQvqVyB32KwzS9SWoLkjrUhHV_",
-        16,
-    );
-
     let seed_b58 = generate_seed_from_salted_password(
-        "JhxtHB7UcsDbA9wMSyMKXUzBZUQvqVyB32KwzS9SWoLkjrUhHV",
-        "JhxtHB7UcsDbA9wMSyMKXUzBZUQvqVyB32KwzS9SWoLkjrUhHV_",
-        58,
+        "JhxtHB7UcsDbA9wMSyMKXUzBZUQvqVyB32KwzS9SWoLkjrUhHV".to_owned(),
+        "JhxtHB7UcsDbA9wMSyMKXUzBZUQvqVyB32KwzS9SWoLkjrUhHV_".to_owned(),
     );
 
-    let pubkey_from_seed_b16 = generate_ed25519_pubkey_from_seed(&seed_b16, 16);
     let pubkey_from_seed_b58 = generate_ed25519_pubkey_from_seed(&seed_b58, 58);
 
-    assert_eq!(pubkey_from_seed_b16, pubkey_from_seed_b58);
     assert_eq!(
         pubkey_from_seed_b58.as_str(),
         "7iMV3b6j2hSj5WtrfchfvxivS9swN3opDgxudeHq64fb"
@@ -122,7 +113,7 @@ fn test_parse_and_verify_example_tx_v10() {
     );
 }
 
-#[wasm_bindgen_test]
+/*#[wasm_bindgen_test]
 fn test_parse_and_verify_example_peer_v11() {
     let doc = example_doc(DocumentType::PeerV11);
 
@@ -134,9 +125,9 @@ fn test_parse_and_verify_example_peer_v11() {
         parse_doc_and_verify(&doc, DocumentType::Any),
         DocCheckResult::ValidSig,
     );
-}
+}*/
 
-#[wasm_bindgen_test]
+/*#[wasm_bindgen_test]
 fn test_parse_and_verify_example_head_v3() {
     let doc = example_doc(DocumentType::HeadV3);
 
@@ -148,7 +139,7 @@ fn test_parse_and_verify_example_head_v3() {
         parse_doc_and_verify(&doc, DocumentType::Any),
         DocCheckResult::ValidSig,
     );
-}
+}*/
 
 #[wasm_bindgen_test]
 fn test_verify_sig() {
-- 
GitLab