Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ledger: default folder in home directory #1138

Merged
merged 5 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ masp_proofs = { git = "https://github.com/anoma/masp", rev = "bee40fc465f6afbd10
bimap = {version = "0.6.2", features = ["serde"]}
rust_decimal = "1.26.1"
rust_decimal_macros = "1.26.1"
directories = "4.0.1"

[dev-dependencies]
namada = {path = "../shared", default-features = false, features = ["testing", "wasm-runtime"]}
Expand Down
2 changes: 1 addition & 1 deletion apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,7 @@ pub mod args {
"base-dir",
DefaultFn(|| match env::var("NAMADA_BASE_DIR") {
Ok(dir) => dir.into(),
Err(_) => config::DEFAULT_BASE_DIR.into(),
Err(_) => config::get_default_namada_folder(),
}),
);
// const BLOCK_HEIGHT_OPT: ArgOpt<BlockHeight> = arg_opt("height");
Expand Down
9 changes: 9 additions & 0 deletions apps/src/lib/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::path::{Path, PathBuf};
use std::str::FromStr;

use directories::BaseDirs;
use namada::types::chain::ChainId;
use namada::types::time::Rfc3339String;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -348,6 +349,14 @@ impl Config {
}
}

pub fn get_default_namada_folder() -> PathBuf {
if let Some(base_dirs) = BaseDirs::new() {
base_dirs.home_dir().join(DEFAULT_BASE_DIR)
tzemanovic marked this conversation as resolved.
Show resolved Hide resolved
} else {
DEFAULT_BASE_DIR.into()
}
}

pub const VALUE_AFTER_TABLE_ERROR_MSG: &str = r#"
Error while serializing to toml. It means that some nested structure is followed
by simple fields.
Expand Down