1- use crate :: { api:: { ApiState , RestError } , config:: Config } ;
1+ use crate :: {
2+ api:: { ApiState , RestError } ,
3+ config:: Config ,
4+ } ;
25use axum:: { extract:: State , Json } ;
3- use anyhow:: { anyhow, Error } ;
46
57#[ derive( serde:: Serialize ) ]
68pub 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