@@ -708,14 +708,33 @@ async fn main() -> Result<()> {
708708
709709 // Also handle locally (store WASM if it's an upload)
710710 if update_type == "wasm_upload" && !data. is_empty( ) {
711- let wasm_key = StorageKey :: new( "wasm" , & challenge_id. to_string( ) ) ;
711+ let challenge_id_str = challenge_id. to_string( ) ;
712+ let wasm_key = StorageKey :: new( "wasm" , & challenge_id_str) ;
712713 match storage. put( wasm_key, data, PutOptions :: default ( ) ) . await {
713714 Ok ( metadata) => {
714715 info!(
715716 challenge_id = %challenge_id,
716717 version = metadata. version,
717718 "WASM stored locally in distributed storage"
718719 ) ;
720+
721+ // Sync to ChainState for RPC
722+ let mut cs = chain_state. write( ) ;
723+ let wasm_config = platform_core:: WasmChallengeConfig {
724+ challenge_id,
725+ name: challenge_id_str. clone( ) ,
726+ description: String :: new( ) ,
727+ owner: keypair. hotkey( ) ,
728+ module: platform_core:: WasmModuleMetadata {
729+ module_path: String :: new( ) ,
730+ code_hash: hex:: encode( metadata. value_hash) ,
731+ version: metadata. version. to_string( ) ,
732+ ..Default :: default ( )
733+ } ,
734+ config: platform_core:: ChallengeConfig :: default ( ) ,
735+ is_active: true ,
736+ } ;
737+ cs. register_wasm_challenge( wasm_config) ;
719738 }
720739 Err ( e) => {
721740 error!(
0 commit comments