Skip to content

Commit 0eae35a

Browse files
committed
push
1 parent 11f6e6a commit 0eae35a

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

apps/fortuna/src/api.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,18 @@ use {
2222
tokio::sync::RwLock,
2323
url::Url,
2424
};
25-
pub use {chain_ids::*, config::*, explorer::*, index::*, live::*, metrics::*, ready::*, revelation::*};
25+
pub use {
26+
chain_ids::*, config::*, explorer::*, index::*, live::*, metrics::*, ready::*, revelation::*,
27+
};
2628

2729
mod chain_ids;
30+
mod config;
2831
mod explorer;
2932
mod index;
3033
mod live;
3134
mod metrics;
3235
mod ready;
3336
mod revelation;
34-
mod config;
3537

3638
pub type ChainId = String;
3739
pub type NetworkId = u64;

apps/fortuna/src/api/config.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
use crate::{api::{ApiState, RestError}, config::Config};
1+
use crate::{
2+
api::{ApiState, RestError},
3+
config::Config,
4+
};
25
use axum::{extract::State, Json};
3-
use anyhow::{anyhow, Error};
46

57
#[derive(serde::Serialize)]
68
pub struct ChainConfigSummary {
@@ -11,10 +13,17 @@ pub struct ChainConfigSummary {
1113
pub fee: u128,
1214
}
1315

14-
pub async fn get_chain_configs(State(_state): State<ApiState>) -> Result<Json<Vec<ChainConfigSummary>>, Error> {
15-
// Try to load the config file (assume default path for now)
16-
let yaml_content = std::fs::read_to_string("../config.yaml").map_err(|e| anyhow!("Failed to read config file: {}", e))?;
17-
let config: Config = serde_yaml::from_str(&yaml_content).map_err(|e| anyhow!("Failed to parse config file: {}", e))?;
16+
pub async fn get_chain_configs(
17+
State(_state): State<ApiState>,
18+
) -> anyhow::Result<Json<Vec<ChainConfigSummary>>, RestError> {
19+
let yaml_content = std::fs::read_to_string("config.yaml").map_err(|e| {
20+
tracing::error!("Failed to read config file: {}", e);
21+
RestError::Unknown
22+
})?;
23+
let config: Config = serde_yaml::from_str(&yaml_content).map_err(|e| {
24+
tracing::error!("Failed to parse config file: {}", e);
25+
RestError::Unknown
26+
})?;
1827
let mut configs = Vec::new();
1928
for (name, chain) in config.chains.iter() {
2029
configs.push(ChainConfigSummary {
@@ -26,4 +35,4 @@ pub async fn get_chain_configs(State(_state): State<ApiState>) -> Result<Json<Ve
2635
});
2736
}
2837
Ok(Json(configs))
29-
}
38+
}

0 commit comments

Comments
 (0)