Skip to content

Commit

Permalink
feat(CIL): add directories crate and data
Browse files Browse the repository at this point in the history
This allows for logging transaction data including budgets/costs for later inspection.
  • Loading branch information
willemneal committed Nov 7, 2023
1 parent e0e104e commit f528cc0
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 2 deletions.
30 changes: 29 additions & 1 deletion 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ tracing-subscriber = "0.3.16"
tracing-appender = "0.2.2"
which = "4.4.0"
wasmparser = "0.90.0"
directories = "5.0.1"


# [patch."https://github.com/stellar/rs-soroban-env"]
Expand Down
3 changes: 2 additions & 1 deletion cmd/soroban-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ csv = "1.1.6"
ed25519-dalek = "2.0.0"
jsonrpsee-http-client = "0.20.1"
jsonrpsee-core = "0.20.1"
hyper = "0.14.27"
hyper = "0.14.27"
hyper-tls = "0.5"
http = "0.2.9"
regex = "1.6.0"
Expand All @@ -92,6 +92,7 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] }
cargo_metadata = "0.15.4"
pathdiff = "0.2.1"
dotenvy = "0.15.7"
directories = { workspace = true }
# For hyper-tls
[target.'cfg(unix)'.dependencies]
openssl = { version = "0.10.55", features = ["vendored"] }
Expand Down
21 changes: 21 additions & 0 deletions cmd/soroban-cli/src/commands/config/data.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use chrono::prelude::*;
use directories::ProjectDirs;

#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("Failed to find project directories")]
FiledToFindProjectDirs,
#[error(transparent)]
Io(#[from] std::io::Error),
}

pub fn project_dir() -> Result<directories::ProjectDirs, Error> {
ProjectDirs::from("com", "stellar", "soroban-cli").ok_or(Error::FiledToFindProjectDirs)
}

pub fn write(prefix: &str, suffix: &str, data: impl AsRef<[u8]>) -> Result<(), Error> {
let timestamp = Utc::now().format("%Y%m%d_%H%M%S");
let name = format!("{prefix}_{timestamp}{suffix}");
let file = project_dir()?.data_local_dir().join(name);
Ok(std::fs::write(file, data)?)
}
1 change: 1 addition & 0 deletions cmd/soroban-cli/src/commands/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::Pwd;

use self::{network::Network, secret::Secret};

pub mod data;
pub mod identity;
pub mod locator;
pub mod network;
Expand Down

0 comments on commit f528cc0

Please sign in to comment.