From 096174684c53d49c957f827ae8c0188ef654f980 Mon Sep 17 00:00:00 2001 From: Arni Hod Date: Thu, 14 Nov 2024 16:27:27 +0200 Subject: [PATCH] feat: create infra utils crate --- Cargo.lock | 4 ++++ Cargo.toml | 2 ++ crates/infra_utils/Cargo.toml | 10 ++++++++++ crates/infra_utils/src/lib.rs | 1 + crates/infra_utils/src/path.rs | 1 + crates/starknet_sequencer_node/src/utils.rs | 3 ++- 6 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 crates/infra_utils/Cargo.toml create mode 100644 crates/infra_utils/src/lib.rs create mode 100644 crates/infra_utils/src/path.rs diff --git a/Cargo.lock b/Cargo.lock index d5b009a0f1..594ba06c01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5160,6 +5160,10 @@ version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" +[[package]] +name = "infra_utils" +version = "0.0.0" + [[package]] name = "inout" version = "0.1.3" diff --git a/Cargo.toml b/Cargo.toml index 0854e5740f..3a6def375f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ members = [ "crates/blockifier", "crates/blockifier_reexecution", "crates/committer_cli", + "crates/infra_utils", "crates/mempool_test_utils", "crates/native_blockifier", "crates/papyrus_base_layer", @@ -131,6 +132,7 @@ http-body = "0.4.5" human_bytes = "0.4.3" hyper = "0.14" indexmap = "2.1.0" +infra_utils = { path = "crates/infra_utils", version = "0.0.0" } insta = "1.29.0" integer-encoding = "3.0.4" itertools = "0.12.1" diff --git a/crates/infra_utils/Cargo.toml b/crates/infra_utils/Cargo.toml new file mode 100644 index 0000000000..69c33687b6 --- /dev/null +++ b/crates/infra_utils/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "infra_utils" +version.workspace = true +edition.workspace = true +repository.workspace = true +license-file.workspace = true +description = "Infrastructure utility." + +[lints] +workspace = true diff --git a/crates/infra_utils/src/lib.rs b/crates/infra_utils/src/lib.rs new file mode 100644 index 0000000000..4da9789237 --- /dev/null +++ b/crates/infra_utils/src/lib.rs @@ -0,0 +1 @@ +pub mod path; diff --git a/crates/infra_utils/src/path.rs b/crates/infra_utils/src/path.rs new file mode 100644 index 0000000000..7605971f8a --- /dev/null +++ b/crates/infra_utils/src/path.rs @@ -0,0 +1 @@ +// TODO(Arni): Move the function get_absolute_path to this file. diff --git a/crates/starknet_sequencer_node/src/utils.rs b/crates/starknet_sequencer_node/src/utils.rs index cb587a0b5e..0b84c07c85 100644 --- a/crates/starknet_sequencer_node/src/utils.rs +++ b/crates/starknet_sequencer_node/src/utils.rs @@ -22,7 +22,8 @@ pub fn create_node_modules( /// Returns the absolute path from the project root. pub fn get_absolute_path(relative_path: &str) -> PathBuf { let base_dir = env::var("CARGO_MANIFEST_DIR") - // Attempt to get the `CARGO_MANIFEST_DIR` environment variable and convert it to `PathBuf`. Ascend two directories ("../..") to get to the project root. + // Attempt to get the `CARGO_MANIFEST_DIR` environment variable and convert it to `PathBuf`. + // Ascend two directories ("../..") to get to the project root. .map(|dir| PathBuf::from(dir).join("../..")) // If `CARGO_MANIFEST_DIR` isn't set, fall back to the current working directory .unwrap_or_else(|_| env::current_dir().expect("Failed to get current directory"));