From c70b26e80e168e5636b35b2fcc755ef124023201 Mon Sep 17 00:00:00 2001
From: Hugo Trentesaux <hugo@trentesaux.fr>
Date: Fri, 16 Feb 2024 16:58:05 +0100
Subject: [PATCH] remove unnecessary complexity

---
 Cargo.lock            |  2 --
 Cargo.toml            | 13 +++++--------
 src/commands/vault.rs | 10 ++--------
 3 files changed, 7 insertions(+), 18 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index f4b5060..1e61c32 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2087,11 +2087,9 @@ dependencies = [
  "graphql_client",
  "hex",
  "inquire",
- "itertools 0.12.1",
  "log",
  "nacl",
  "parity-scale-codec",
- "rand_chacha",
  "reqwest",
  "rpassword",
  "scrypt",
diff --git a/Cargo.toml b/Cargo.toml
index d840777..bd3166d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -41,16 +41,13 @@ confy = "^0.5.1"
 bs58 = "^0.5.0"
 inquire = "^0.6.2"
 directories = "^5.0.1"
-itertools = "^0.12.1"
 
 # crypto
-scrypt = { version = "^0.11", default-features = false } # for old-style key generation
-nacl = { version = "^0.5.3" } # for old-style key generation
-age = { default-features = false, version = "^0.10.0", features = [
-    "armor",
-] } # this is beta crate for password -encrypted files
-rand_chacha = "^0.3.1" # used to generate random seed
-bip39 = "^2.0.0" # to convert seed to mnemonic
+scrypt = { version = "^0.11", default-features = false }                      # for old-style key generation
+nacl = { version = "^0.5.3" }                                                 # for old-style key generation
+# this is beta crate for password-encrypted files
+age = { default-features = false, version = "^0.10.0", features = ["armor"] }
+bip39 = { version = "^2.0.0", features = ["rand"] } # mnemonic
 
 # allows to build gcli for different runtimes and with different predefined networks 
 [features]
diff --git a/src/commands/vault.rs b/src/commands/vault.rs
index 6355110..d8e0bc0 100644
--- a/src/commands/vault.rs
+++ b/src/commands/vault.rs
@@ -1,7 +1,5 @@
 use crate::*;
 use age::secrecy::Secret;
-use itertools::Itertools;
-use rand_chacha::rand_core::SeedableRng;
 use std::io::{Read, Write};
 
 /// define universal dividends subcommands
@@ -60,12 +58,8 @@ pub fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliError>
 			println!("{}", data.project_dir.data_dir().to_str().unwrap());
 		}
 		Subcommand::Generate => {
-			// ChaCha20Rng is ok for cryptography
-			let rng = rand_chacha::ChaCha20Rng::from_entropy();
-			let seed = rng.get_seed();
-			let mnemonic = bip39::Mnemonic::from_entropy(&seed);
-			let phrase = mnemonic.unwrap().word_iter().join(" ");
-			println!("{phrase}");
+			let mnemonic = bip39::Mnemonic::generate(12).unwrap(); // TODO allow word count
+			println!("{mnemonic}");
 		}
 		Subcommand::Import => {
 			// --- currently only support mnemonic secret
-- 
GitLab