6666 Env : SubtensorExtensionEnv < T :: AccountId > ,
6767 <<T as SysConfig >:: Lookup as StaticLookup >:: Source : From < <T as SysConfig >:: AccountId > ,
6868 {
69- let raw_func_id = env. func_id ( ) ;
70- log:: info!( "chain_ext: dispatch called with raw func_id={raw_func_id}" ) ;
71- let func_id: FunctionId = raw_func_id. try_into ( ) . map_err ( |_| {
72- log:: error!( "chain_ext: invalid func_id={raw_func_id}, not in FunctionId enum" ) ;
69+ let func_id: FunctionId = env. func_id ( ) . try_into ( ) . map_err ( |_| {
7370 DispatchError :: Other (
7471 "Invalid function id - does not correspond to any registered function" ,
7572 )
@@ -601,30 +598,16 @@ where
601598 }
602599 }
603600 FunctionId :: AddStakeRecycleV1 => {
604- log:: info!( "chain_ext: AddStakeRecycleV1 called" ) ;
605-
606601 let weight = Weight :: from_parts ( 454_200_000 , 0 )
607602 . saturating_add ( T :: DbWeight :: get ( ) . reads ( 33 ) )
608603 . saturating_add ( T :: DbWeight :: get ( ) . writes ( 19 ) ) ;
609604
610- if let Err ( e) = env. charge_weight ( weight) {
611- log:: error!( "chain_ext: AddStakeRecycleV1 charge_weight failed: {e:?}" ) ;
612- return Err ( e) ;
613- }
605+ env. charge_weight ( weight) ?;
614606
615- let input: Result < ( T :: AccountId , NetUid , TaoBalance ) , _ > = env. read_as ( ) ;
616- let ( hotkey, netuid, tao_amount) = match input {
617- Ok ( v) => v,
618- Err ( e) => {
619- log:: error!( "chain_ext: AddStakeRecycleV1 read_as failed: {e:?}" ) ;
620- return Err ( e) ;
621- }
622- } ;
607+ let ( hotkey, netuid, tao_amount) : ( T :: AccountId , NetUid , TaoBalance ) =
608+ env. read_as ( ) ?;
623609
624610 let caller = env. caller ( ) ;
625- log:: info!(
626- "chain_ext: AddStakeRecycleV1 caller={caller:?} hotkey={hotkey:?} netuid={netuid:?} tao={tao_amount:?}"
627- ) ;
628611
629612 let alpha = pallet_subtensor:: Pallet :: < T > :: do_add_stake (
630613 RawOrigin :: Signed ( caller. clone ( ) ) . into ( ) ,
@@ -635,9 +618,6 @@ where
635618
636619 match alpha {
637620 Ok ( alpha) => {
638- log:: info!(
639- "chain_ext: AddStakeRecycleV1 do_add_stake ok, alpha={alpha:?}"
640- ) ;
641621 let recycle_result = pallet_subtensor:: Pallet :: < T > :: recycle_alpha (
642622 RawOrigin :: Signed ( caller) . into ( ) ,
643623 hotkey,
@@ -647,22 +627,17 @@ where
647627
648628 match recycle_result {
649629 Ok ( _) => {
650- log:: info!( "chain_ext: AddStakeRecycleV1 recycle ok" ) ;
651630 env. write_output ( & alpha. encode ( ) )
652631 . map_err ( |_| DispatchError :: Other ( "Failed to write output" ) ) ?;
653632 Ok ( RetVal :: Converging ( Output :: Success as u32 ) )
654633 }
655634 Err ( e) => {
656- log:: error!(
657- "chain_ext: AddStakeRecycleV1 recycle failed: {e:?}"
658- ) ;
659635 let error_code = Output :: from ( e) as u32 ;
660636 Ok ( RetVal :: Converging ( error_code) )
661637 }
662638 }
663639 }
664640 Err ( e) => {
665- log:: error!( "chain_ext: AddStakeRecycleV1 do_add_stake failed: {e:?}" ) ;
666641 let error_code = Output :: from ( e) as u32 ;
667642 Ok ( RetVal :: Converging ( error_code) )
668643 }
0 commit comments