Skip to content

Commit

Permalink
feat: create infra utils crate
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware committed Nov 19, 2024
1 parent 5abee58 commit 278821c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 10 additions & 0 deletions crates/infra_utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "infra_utils"
version.workspace = true
edition.workspace = true
repository.workspace = true
license-file.workspace = true
description = "Infrastructure utility functions for the sequencer node."

[lints]
workspace = true
1 change: 1 addition & 0 deletions crates/infra_utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod path;
1 change: 1 addition & 0 deletions crates/infra_utils/src/path.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// TODO(Arni): Move the function get_absolute_path to this file.
3 changes: 2 additions & 1 deletion crates/starknet_sequencer_node/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down

0 comments on commit 278821c

Please sign in to comment.