diff --git a/integration_tests/src/lib.rs b/integration_tests/src/lib.rs index dc7188b..31cd177 100644 --- a/integration_tests/src/lib.rs +++ b/integration_tests/src/lib.rs @@ -56,7 +56,7 @@ fn make_private_account_input_from_str(account_id: &str) -> String { pub async fn pre_test( home_dir: PathBuf, ) -> Result<(ServerHandle, JoinHandle>, TempDir)> { - wallet::execute_setup("test_pass".to_owned()).await?; + wallet::cli::execute_setup("test_pass".to_owned()).await?; let home_dir_sequencer = home_dir.join("sequencer"); diff --git a/wallet/src/cli/mod.rs b/wallet/src/cli/mod.rs index 3d63d5c..c1def06 100644 --- a/wallet/src/cli/mod.rs +++ b/wallet/src/cli/mod.rs @@ -189,3 +189,12 @@ pub async fn execute_continuous_run() -> Result<()> { latest_block_num = seq_client.get_last_block().await?.last_block; } } + +pub async fn execute_setup(password: String) -> Result<()> { + let config = fetch_config().await?; + let wallet_core = WalletCore::start_from_config_new_storage(config.clone(), password).await?; + + wallet_core.store_persistent_data().await?; + + Ok(()) +} diff --git a/wallet/src/cli/programs/pinata.rs b/wallet/src/cli/programs/pinata.rs index b920f3f..c0e2223 100644 --- a/wallet/src/cli/programs/pinata.rs +++ b/wallet/src/cli/programs/pinata.rs @@ -123,10 +123,6 @@ impl WalletSubcommand for PinataProgramSubcommandPublic { println!("Transaction data is {transfer_tx:?}"); - let path = wallet_core.store_persistent_data().await?; - - println!("Stored persistent accounts at {path:#?}"); - Ok(SubcommandReturnValue::Empty) } } diff --git a/wallet/src/helperfunctions.rs b/wallet/src/helperfunctions.rs index 174105f..19d2d56 100644 --- a/wallet/src/helperfunctions.rs +++ b/wallet/src/helperfunctions.rs @@ -5,7 +5,9 @@ use base64::{Engine, engine::general_purpose::STANDARD as BASE64}; use common::{ block::HashableBlockData, sequencer_client::SequencerClient, transaction::NSSATransaction, }; -use key_protocol::{key_management::key_tree::traits::KeyNode, key_protocol_core::NSSAUserData}; +use key_protocol::{ + key_management::key_tree::traits::KeyNode as _, key_protocol_core::NSSAUserData, +}; use nssa::{Account, privacy_preserving_transaction::message::EncryptedAccountData}; use nssa_core::account::Nonce; use rand::{RngCore, rngs::OsRng}; diff --git a/wallet/src/lib.rs b/wallet/src/lib.rs index 23e13d0..f79d947 100644 --- a/wallet/src/lib.rs +++ b/wallet/src/lib.rs @@ -19,8 +19,7 @@ use tokio::io::AsyncWriteExt; use crate::{ config::PersistentStorage, helperfunctions::{ - fetch_config, fetch_persistent_storage, get_home, produce_data_for_storage, - produce_random_nonces, + fetch_persistent_storage, get_home, produce_data_for_storage, produce_random_nonces, }, poller::TxPoller, }; @@ -295,12 +294,3 @@ impl WalletCore { )) } } - -pub async fn execute_setup(password: String) -> Result<()> { - let config = fetch_config().await?; - let wallet_core = WalletCore::start_from_config_new_storage(config.clone(), password).await?; - - wallet_core.store_persistent_data().await?; - - Ok(()) -} diff --git a/wallet/src/main.rs b/wallet/src/main.rs index 71d7620..a8a4fbe 100644 --- a/wallet/src/main.rs +++ b/wallet/src/main.rs @@ -1,10 +1,7 @@ use anyhow::Result; use clap::{CommandFactory as _, Parser as _}; use tokio::runtime::Builder; -use wallet::{ - cli::{Args, OverCommand, execute_continuous_run, execute_subcommand}, - execute_setup, -}; +use wallet::cli::{Args, OverCommand, execute_continuous_run, execute_setup, execute_subcommand}; pub const NUM_THREADS: usize = 2; @@ -26,17 +23,16 @@ fn main() -> Result<()> { env_logger::init(); runtime.block_on(async move { - if let Some(overcommand) = args.command { - match overcommand { + if let Some(over_command) = args.command { + match over_command { OverCommand::Command(command) => { - // TODO: Do something with the output let _output = execute_subcommand(command).await?; Ok(()) } - OverCommand::Setup { password } => Ok(execute_setup(password).await?), + OverCommand::Setup { password } => execute_setup(password).await, } } else if args.continuous_run { - Ok(execute_continuous_run().await?) + execute_continuous_run().await } else { let help = Args::command().render_long_help(); println!("{help}");