Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
hansieodendaal committed Aug 22, 2024
1 parent 73e59ac commit 24af047
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 19 deletions.
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion src/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn create_memory_db_key_manager(wallet_type: Arc<WalletType>) -> Result<MemoryDb
cipher,
KeyManagerDatabase::new(KeyManagerSqliteDatabase::init(connection, db_cipher)),
factory,
wallet_type,
wallet_type.into(),
)?,
)
}
Expand Down
26 changes: 17 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,25 @@ pub async fn tui_main(cli: &Cli) -> Result<(), Box<dyn std::error::Error>> {
},
};

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);
return Ok(());
},
};
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());
Expand Down Expand Up @@ -199,7 +207,7 @@ pub async fn tui_main(cli: &Cli) -> Result<(), Box<dyn std::error::Error>> {
}
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,
Expand Down Expand Up @@ -238,15 +246,15 @@ pub async fn tui_main(cli: &Cli) -> Result<(), Box<dyn std::error::Error>> {
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!();
Expand Down Expand Up @@ -310,7 +318,7 @@ pub async fn tui_main(cli: &Cli) -> Result<(), Box<dyn std::error::Error>> {
};

// 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);
Expand Down Expand Up @@ -378,7 +386,7 @@ pub async fn tui_main(cli: &Cli) -> Result<(), Box<dyn std::error::Error>> {

// 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 {
Expand Down
13 changes: 11 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Network>,
) -> 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())))?;
Expand All @@ -64,11 +70,14 @@ pub(crate) fn out_dir(session_id: &str) -> Result<PathBuf, CommandError> {
}

/// Create the file name with the given stem and optional suffix
pub(crate) fn get_file_name(stem: &str, suffix: Option<String>) -> String {
pub(crate) fn get_file_name(stem: &str, suffix: Option<String>, network: Option<Network>) -> 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
Expand Down

0 comments on commit 24af047

Please sign in to comment.