Skip to content

Commit 1c82d86

Browse files
committed
refact: config to core
1 parent f08ea7d commit 1c82d86

File tree

6 files changed

+17
-16
lines changed

6 files changed

+17
-16
lines changed

Diff for: cli/src/common.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use alloy::{primitives::ChainId, transports::http::reqwest::Url};
22
use anyhow::Result;
3+
use hdp::config::HdpRunConfig;
34
use hdp::preprocessor::{
45
compile::config::CompilerConfig, module_registry::ModuleRegistry, PreProcessor,
56
};
@@ -24,7 +25,6 @@ use tracing::{debug, info};
2425

2526
use crate::{
2627
commands::{DataLakeCommands, HDPCli, HDPCliCommands},
27-
config::Config,
2828
interactive,
2929
query::{SubmitBatchQuery, Task},
3030
};
@@ -141,7 +141,7 @@ pub async fn module_entry_run(
141141
output_file: Option<PathBuf>,
142142
cairo_pie_file: Option<PathBuf>,
143143
) -> Result<()> {
144-
let config = Config::init(
144+
let config = HdpRunConfig::init(
145145
rpc_url,
146146
chain_id,
147147
dry_run_cairo_file,
@@ -178,7 +178,7 @@ pub async fn datalake_entry_run(
178178
output_file: Option<PathBuf>,
179179
cairo_pie_file: Option<PathBuf>,
180180
) -> Result<()> {
181-
let config = Config::init(rpc_url, chain_id, None, sound_run_cairo_file, None).await;
181+
let config = HdpRunConfig::init(rpc_url, chain_id, None, sound_run_cairo_file, None).await;
182182
let parsed_datalake = match datalake {
183183
DataLakeCommands::BlockSampled {
184184
block_range_start,
@@ -226,7 +226,7 @@ pub async fn datalake_entry_run(
226226
}
227227

228228
pub async fn handle_running_tasks(
229-
config: &Config,
229+
config: &HdpRunConfig,
230230
tasks: Vec<TaskEnvelope>,
231231
pre_processor_output_file: Option<PathBuf>,
232232
output_file: Option<PathBuf>,
@@ -299,7 +299,7 @@ pub async fn entry_run(
299299
fs::read_to_string(request_file).expect("No request file exist in the path");
300300
let parsed: SubmitBatchQuery = serde_json::from_str(&request_context)
301301
.expect("Invalid format of request. Cannot parse it.");
302-
let config = Config::init(
302+
let config = HdpRunConfig::init(
303303
rpc_url,
304304
Some(parsed.destination_chain_id),
305305
dry_run_cairo_file,

Diff for: cli/src/interactive.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use alloy::{primitives::U256, transports::http::reqwest::Url};
22
use anyhow::bail;
3+
use hdp::config::HdpRunConfig;
34
use hdp::preprocessor::module_registry::ModuleRegistry;
45
use hdp::primitives::{
56
aggregate_fn::{integer::Operator, FunctionContext},
@@ -25,7 +26,7 @@ use inquire::{InquireError, Select};
2526
use std::{path::PathBuf, str::FromStr};
2627
use tracing::error;
2728

28-
use crate::{common::handle_running_tasks, config::Config};
29+
use crate::common::handle_running_tasks;
2930

3031
pub async fn run_interactive() -> anyhow::Result<()> {
3132
println!("Welcome to Herodotus Data Processor interactive CLI! 🛰️");
@@ -348,7 +349,7 @@ pub async fn run_interactive() -> anyhow::Result<()> {
348349
},
349350
Err(_) => None,
350351
};
351-
let config = Config::init(rpc_url, chain_id, None, None, None).await;
352+
let config = HdpRunConfig::init(rpc_url, chain_id, None, None, None).await;
352353
let output_file: PathBuf = inquire::Text::new("Enter Output file path: ")
353354
.with_default("output.json")
354355
.prompt()?

Diff for: cli/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
pub mod commands;
22
pub mod common;
3-
pub mod config;
43
pub mod interactive;
54
pub mod query;
65

Diff for: cli/src/config.rs renamed to hdp/src/config.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
use alloy::{primitives::ChainId, transports::http::reqwest::Url};
2-
use hdp::primitives::constant::{
1+
use crate::primitives::constant::{
32
DEFAULT_DRY_CAIRO_RUN_CAIRO_FILE, DEFAULT_SOUND_CAIRO_RUN_CAIRO_FILE,
43
};
5-
use hdp::provider::evm::config::EvmProviderConfig;
4+
use crate::provider::evm::config::EvmProviderConfig;
5+
use alloy::{primitives::ChainId, transports::http::reqwest::Url};
66

77
use std::{env, path::PathBuf};
88
use tokio::sync::OnceCell;
99

10-
pub static CONFIG: OnceCell<Config> = OnceCell::const_new();
10+
pub static CONFIG: OnceCell<HdpRunConfig> = OnceCell::const_new();
1111

12-
/// Configuration for the CLI
12+
/// HdpRunConfig for the CLI
1313
#[derive(Debug)]
14-
pub struct Config {
14+
pub struct HdpRunConfig {
1515
pub evm_provider: EvmProviderConfig,
1616
pub dry_run_program_path: PathBuf,
1717
pub sound_run_program_path: PathBuf,
1818
pub save_fetch_keys_file: Option<PathBuf>,
1919
}
2020

21-
impl Config {
21+
impl HdpRunConfig {
2222
pub async fn init(
2323
cli_rpc_url: Option<Url>,
2424
cli_chain_id: Option<ChainId>,
@@ -59,7 +59,7 @@ impl Config {
5959

6060
CONFIG
6161
.get_or_init(|| async {
62-
Config {
62+
HdpRunConfig {
6363
evm_provider: EvmProviderConfig {
6464
rpc_url,
6565
chain_id,

Diff for: hdp/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pub mod cairo_runner;
2+
pub mod config;
23
pub mod preprocessor;
34
pub mod primitives;
45
pub mod processor;
File renamed without changes.

0 commit comments

Comments
 (0)