@@ -547,15 +547,93 @@ impl RpcHandler {
547547
548548 fn chain_get_state ( & self , id : Value ) -> JsonRpcResponse {
549549 let chain = self . chain_state . read ( ) ;
550+
551+ // Serialize challenge_configs
552+ let challenge_configs: serde_json:: Map < String , Value > = chain
553+ . challenge_configs
554+ . iter ( )
555+ . map ( |( id, config) | {
556+ (
557+ id. to_string ( ) ,
558+ json ! ( {
559+ "challenge_id" : id. to_string( ) ,
560+ "name" : config. name,
561+ "docker_image" : config. docker_image,
562+ "mechanism_id" : config. mechanism_id,
563+ "emission_weight" : config. emission_weight,
564+ "timeout_secs" : config. timeout_secs,
565+ "cpu_cores" : config. cpu_cores,
566+ "memory_mb" : config. memory_mb,
567+ "gpu_required" : config. gpu_required,
568+ } ) ,
569+ )
570+ } )
571+ . collect ( ) ;
572+
573+ // Serialize mechanism_configs
574+ let mechanism_configs: serde_json:: Map < String , Value > = chain
575+ . mechanism_configs
576+ . iter ( )
577+ . map ( |( id, config) | {
578+ (
579+ id. to_string ( ) ,
580+ json ! ( {
581+ "mechanism_id" : config. mechanism_id,
582+ "base_burn_rate" : config. base_burn_rate,
583+ "equal_distribution" : config. equal_distribution,
584+ "min_weight_threshold" : config. min_weight_threshold,
585+ "max_weight_cap" : config. max_weight_cap,
586+ "is_active" : config. active,
587+ } ) ,
588+ )
589+ } )
590+ . collect ( ) ;
591+
592+ // Serialize challenge_weights
593+ let challenge_weights: serde_json:: Map < String , Value > = chain
594+ . challenge_weights
595+ . iter ( )
596+ . map ( |( id, alloc) | {
597+ (
598+ id. to_string ( ) ,
599+ json ! ( {
600+ "challenge_id" : id. to_string( ) ,
601+ "mechanism_id" : alloc. mechanism_id,
602+ "weight_ratio" : alloc. weight_ratio,
603+ "active" : alloc. active,
604+ } ) ,
605+ )
606+ } )
607+ . collect ( ) ;
608+
609+ // Serialize validators
610+ let validators: serde_json:: Map < String , Value > = chain
611+ . validators
612+ . iter ( )
613+ . map ( |( hotkey, info) | {
614+ (
615+ hotkey. to_hex ( ) ,
616+ json ! ( {
617+ "hotkey" : hotkey. to_hex( ) ,
618+ "stake" : info. stake. 0 ,
619+ "stake_tao" : info. stake. as_tao( ) ,
620+ } ) ,
621+ )
622+ } )
623+ . collect ( ) ;
624+
550625 JsonRpcResponse :: result (
551626 id,
552627 json ! ( {
553628 "blockHeight" : chain. block_height,
554629 "epoch" : chain. epoch,
555630 "stateHash" : format!( "0x{}" , hex:: encode( & chain. state_hash) ) ,
556631 "sudoKey" : chain. sudo_key. to_hex( ) ,
557- "validators" : chain . validators. len ( ) ,
632+ "validators" : validators,
558633 "challenges" : chain. challenges. len( ) ,
634+ "challenge_configs" : challenge_configs,
635+ "mechanism_configs" : mechanism_configs,
636+ "challenge_weights" : challenge_weights,
559637 "pendingJobs" : chain. pending_jobs. len( ) ,
560638 "config" : {
561639 "subnetId" : chain. config. subnet_id,
0 commit comments