From 24af047d35fdd793b3d9e7db2c0dcbe2ef3a6134 Mon Sep 17 00:00:00 2001 From: Hansie Odendaal Date: Tue, 13 Aug 2024 04:51:28 +0200 Subject: [PATCH] update dependencies --- Cargo.toml | 14 +++++++------- src/ledger.rs | 2 +- src/main.rs | 26 +++++++++++++++++--------- src/utils.rs | 13 +++++++++++-- 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 089df65..3e30065 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,14 +4,14 @@ version = "0.2.0" edition = "2021" [dependencies] -minotari_ledger_wallet_comms = { git = "https://github.com/tari-project/tari", rev = "a67b79dded03acd4c9b0393e5e1bfc143a4aa3d1" } -tari_common = { git = "https://github.com/tari-project/tari", rev = "a67b79dded03acd4c9b0393e5e1bfc143a4aa3d1" } -tari_common_sqlite = { git = "https://github.com/tari-project/tari", rev = "a67b79dded03acd4c9b0393e5e1bfc143a4aa3d1" } -tari_common_types = { git = "https://github.com/tari-project/tari", rev = "a67b79dded03acd4c9b0393e5e1bfc143a4aa3d1" } -tari_core = { git = "https://github.com/tari-project/tari", rev = "a67b79dded03acd4c9b0393e5e1bfc143a4aa3d1", features = ["default", "ledger"] } +minotari_ledger_wallet_comms = { git = "https://github.com/tari-project/tari", rev = "a510455aa55646d65eda9e2afa794bd2125f17fb" } +tari_common = { git = "https://github.com/tari-project/tari", rev = "a510455aa55646d65eda9e2afa794bd2125f17fb" } +tari_common_sqlite = { git = "https://github.com/tari-project/tari", rev = "a510455aa55646d65eda9e2afa794bd2125f17fb" } +tari_common_types = { git = "https://github.com/tari-project/tari", rev = "a510455aa55646d65eda9e2afa794bd2125f17fb" } +tari_core = { git = "https://github.com/tari-project/tari", rev = "a510455aa55646d65eda9e2afa794bd2125f17fb", features = ["default", "ledger"] } tari_crypto = { version = "0.20" } -tari_key_manager = { git = "https://github.com/tari-project/tari", rev = "a67b79dded03acd4c9b0393e5e1bfc143a4aa3d1" } -tari_script = { git = "https://github.com/tari-project/tari", rev = "a67b79dded03acd4c9b0393e5e1bfc143a4aa3d1" } +tari_key_manager = { git = "https://github.com/tari-project/tari", rev = "a510455aa55646d65eda9e2afa794bd2125f17fb" } +tari_script = { git = "https://github.com/tari-project/tari", rev = "a510455aa55646d65eda9e2afa794bd2125f17fb" } tari_utilities = { version = "0.7" } blake2 = { version = "0.10" } diff --git a/src/ledger.rs b/src/ledger.rs index b2081be..3bfba8d 100644 --- a/src/ledger.rs +++ b/src/ledger.rs @@ -68,7 +68,7 @@ fn create_memory_db_key_manager(wallet_type: Arc) -> Result Result<(), Box> { }, }; - let (session_id, out_dir) = match create_pre_mine_output_dir(Some(&args.alias)) { + let (session_id, out_dir) = match create_pre_mine_output_dir(Some(&args.alias), Some(cli.network)) { Ok(values) => values, Err(e) => { eprintln!("\nError: {}\n", e); @@ -142,9 +142,17 @@ pub async fn tui_main(cli: &Cli) -> Result<(), Box> { }, }; let leader_out_file = if args.fail_safe_wallet { - out_dir.join(get_file_name(STEP_1_FAIL_SAFE_LEADER, Some(args.alias.clone()))) + out_dir.join(get_file_name( + STEP_1_FAIL_SAFE_LEADER, + Some(args.alias.clone()), + Some(cli.network), + )) } else { - out_dir.join(get_file_name(STEP_1_LEADER, Some(args.alias.clone()))) + out_dir.join(get_file_name( + STEP_1_LEADER, + Some(args.alias.clone()), + Some(cli.network), + )) }; let mut outputs_for_leader = Vec::with_capacity(pre_mine_items.len()); @@ -199,7 +207,7 @@ pub async fn tui_main(cli: &Cli) -> Result<(), Box> { } write_to_json_file(&leader_out_file, true, outputs_for_leader)?; - let session_out_file = out_dir.join(get_file_name(STEP_1_SELF, None)); + let session_out_file = out_dir.join(get_file_name(STEP_1_SELF, None, Some(cli.network))); let outputs_for_self = Step1ForSelf { account: args.account, network: cli.network, @@ -238,15 +246,15 @@ pub async fn tui_main(cli: &Cli) -> Result<(), Box> { println!("Your session's output directory is: '{}'", out_dir.display()); println!( "Session info saved to: '{}'", - get_file_name(STEP_1_SELF, None) + get_file_name(STEP_1_SELF, None, Some(cli.network)) ); println!("Pre-mine schedule saved to: '{}'", csv_file_name); println!( "Please send '{}' to leader for step 2", if args.fail_safe_wallet { - get_file_name(STEP_1_FAIL_SAFE_LEADER, Some(args.alias.clone())) + get_file_name(STEP_1_FAIL_SAFE_LEADER, Some(args.alias.clone()), Some(cli.network)) } else { - get_file_name(STEP_1_LEADER, Some(args.alias.clone())) + get_file_name(STEP_1_LEADER, Some(args.alias.clone()), Some(cli.network)) } ); println!(); @@ -310,7 +318,7 @@ pub async fn tui_main(cli: &Cli) -> Result<(), Box> { }; // Create the genesis file - let (session_id, out_dir) = match create_pre_mine_output_dir(Some("leader")) { + let (session_id, out_dir) = match create_pre_mine_output_dir(Some("leader"), Some(cli.network)) { Ok(values) => values, Err(e) => { eprintln!("\nError: {}\n", e); @@ -378,7 +386,7 @@ pub async fn tui_main(cli: &Cli) -> Result<(), Box> { // Read own info let out_dir = out_dir(&args.session_id)?; - let file = out_dir.join(get_file_name(STEP_1_SELF, None)); + let file = out_dir.join(get_file_name(STEP_1_SELF, None, Some(cli.network))); let own_info = match json_from_file_single_object::<_, Step1ForSelf>(file, None) { Ok(info) => { if cli.network != info.network { diff --git a/src/utils.rs b/src/utils.rs index f9f77f5..b98dec5 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -42,13 +42,19 @@ pub(crate) fn set_console_title(title: &str) { } /// Create a unique session-based output directory -pub(crate) fn create_pre_mine_output_dir(alias: Option<&str>) -> Result<(String, PathBuf), CommandError> { +pub(crate) fn create_pre_mine_output_dir( + alias: Option<&str>, + network: Option, +) -> Result<(String, PathBuf), CommandError> { let mut session_id = PrivateKey::random(&mut OsRng).to_base58(); session_id.truncate(10); if let Some(alias) = alias { session_id.push('_'); session_id.push_str(alias); } + if let Some(network) = network { + session_id.push_str(&format!("_{}", network)); + } let out_dir = out_dir(&session_id)?; fs::create_dir_all(out_dir.clone()) .map_err(|e| CommandError::JsonFile(format!("{} ({})", e, out_dir.display())))?; @@ -64,11 +70,14 @@ pub(crate) fn out_dir(session_id: &str) -> Result { } /// Create the file name with the given stem and optional suffix -pub(crate) fn get_file_name(stem: &str, suffix: Option) -> String { +pub(crate) fn get_file_name(stem: &str, suffix: Option, network: Option) -> String { let mut file_name = stem.to_string(); if let Some(suffix) = suffix { file_name.push_str(&suffix); } + if let Some(network) = network { + file_name.push_str(&format!("_{}", network)); + } file_name.push('.'); file_name.push_str(FILE_EXTENSION); file_name