Skip to content

Commit 11f6e6a

Browse files
committed
update
1 parent ba15827 commit 11f6e6a

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

apps/fortuna/src/api/config.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::{api::{ApiState, RestError}, config::Config};
22
use axum::{extract::State, Json};
3+
use anyhow::{anyhow, Error};
34

45
#[derive(serde::Serialize)]
56
pub struct ChainConfigSummary {
@@ -10,12 +11,10 @@ pub struct ChainConfigSummary {
1011
pub fee: u128,
1112
}
1213

13-
pub async fn get_chain_configs(State(_state): State<ApiState>) -> Result<Json<Vec<ChainConfigSummary>>, RestError> {
14+
pub async fn get_chain_configs(State(_state): State<ApiState>) -> Result<Json<Vec<ChainConfigSummary>>, Error> {
1415
// Try to load the config file (assume default path for now)
15-
let config = match Config::load("config.yaml") {
16-
Ok(cfg) => cfg,
17-
Err(_) => return Err(RestError::Unknown),
18-
};
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))?;
1918
let mut configs = Vec::new();
2019
for (name, chain) in config.chains.iter() {
2120
configs.push(ChainConfigSummary {

apps/fortuna/src/command/run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub async fn run_api(
8585

8686
pub async fn run(opts: &RunOptions) -> Result<()> {
8787
// Load environment variables from a .env file if present
88-
let _ = dotenv::dotenv()?;
88+
let _ = dotenv::dotenv().map_err(|e| anyhow!("Failed to load .env file: {}", e))?;
8989
let config = Config::load(&opts.config.config)?;
9090
let secret = config.provider.secret.load()?.ok_or(anyhow!(
9191
"Please specify a provider secret in the config file."

0 commit comments

Comments
 (0)