@@ -393,20 +393,20 @@ impl Contract {
393393 Self :: compute_escrow_settlement ( escrow_shares, burn_shares) ;
394394 if to_burn > 0 {
395395 self . withdraw_unchecked ( & env:: current_account_id ( ) , to_burn)
396- . expect ( "Failed to burn escrowed shares" ) ;
396+ . unwrap_or_else ( |e| env :: panic_str ( & e . to_string ( ) ) ) ;
397397 }
398398 if refund_shares > 0 {
399399 #[ allow( clippy:: expect_used, reason = "No side effects" ) ]
400400 self . transfer_unchecked ( & env:: current_account_id ( ) , & owner, refund_shares)
401- . expect ( "Failed to refund remaining escrowed shares" ) ;
401+ . unwrap_or_else ( |e| env :: panic_str ( & e . to_string ( ) ) ) ;
402402 }
403403 self . op_state = OpState :: Idle ;
404404 true
405405 } else {
406406 // Invariant: On payout failure, refund full escrow to owner and leave idle_balance unchanged
407407 #[ allow( clippy:: expect_used, reason = "No side effects" ) ]
408408 self . transfer_unchecked ( & env:: current_account_id ( ) , & owner, escrow_shares)
409- . expect ( "Failed to release escrowed shares" ) ;
409+ . unwrap_or_else ( |e| env :: panic_str ( & e . to_string ( ) ) ) ;
410410 self . op_state = OpState :: Idle ;
411411 false
412412 }
@@ -517,7 +517,7 @@ impl Contract {
517517 let self_id = env:: current_account_id ( ) ;
518518 #[ allow( clippy:: expect_used, reason = "No side effects" ) ]
519519 self . transfer_unchecked ( & self_id, & owner_acc, escrow)
520- . expect ( "Failed to release escrowed shares" ) ;
520+ . unwrap_or_else ( |e| env :: panic_str ( & e . to_string ( ) ) ) ;
521521 }
522522 }
523523 self . op_state = OpState :: Idle ;
@@ -555,7 +555,7 @@ impl Contract {
555555 let self_id = env:: current_account_id ( ) ;
556556 #[ allow( clippy:: expect_used, reason = "No side effects" ) ]
557557 self . transfer_unchecked ( & self_id, & owner_acc, escrow)
558- . expect ( "Failed to release escrowed shares" ) ;
558+ . unwrap_or_else ( |e| env :: panic_str ( & e . to_string ( ) ) ) ;
559559 }
560560 }
561561 self . op_state = OpState :: Idle ;
@@ -579,7 +579,7 @@ impl Contract {
579579 }
580580 PromiseOrValue :: Value ( ( ) )
581581 }
582- // Validate current op is Allocating and return (index, remaining)
582+ /// Validate current op is Allocating and return (index, remaining)
583583 pub ( crate ) fn ctx_allocating ( & self , op_id : u64 ) -> Result < ( u32 , u128 ) , Error > {
584584 match & self . op_state {
585585 OpState :: Allocating {
@@ -591,7 +591,7 @@ impl Contract {
591591 }
592592 }
593593
594- // Validate current op is Withdrawing and return context tuple
594+ /// Validate current op is Withdrawing and return context tuple
595595 pub ( crate ) fn ctx_withdrawing (
596596 & self ,
597597 op_id : u64 ,
@@ -617,7 +617,7 @@ impl Contract {
617617 }
618618 }
619619
620- // Resolve a market for allocation by plan (if present) or supply_queue
620+ /// Resolve a market for allocation by plan (if present) or supply_queue
621621 pub ( crate ) fn resolve_supply_market ( & self , market_index : u32 ) -> Result < AccountId , Error > {
622622 if let Some ( plan) = & self . plan {
623623 if let Some ( ( m, _) ) = plan. get ( market_index as usize ) {
@@ -631,15 +631,15 @@ impl Contract {
631631 . ok_or ( Error :: MissingMarket ( market_index) )
632632 }
633633
634- // Resolve a market for withdraw by withdraw_queue
634+ /// Resolve a market for withdraw by withdraw_queue
635635 pub ( crate ) fn resolve_withdraw_market ( & self , market_index : u32 ) -> Result < AccountId , Error > {
636636 self . withdraw_queue
637637 . get ( market_index)
638638 . cloned ( )
639639 . ok_or ( Error :: MissingMarket ( market_index) )
640640 }
641641
642- // Pure reconciliation for withdraw read outcome to enable unit tests
642+ /// Pure reconciliation for withdraw read outcome to enable unit tests
643643 pub ( crate ) fn reconcile_withdraw_outcome (
644644 & self ,
645645 before_principal : u128 ,
@@ -684,7 +684,7 @@ mod tests {
684684 & vault_id,
685685 & vault_id,
686686 vec ! [ PromiseResult :: Successful (
687- near_sdk:: serde_json:: to_vec( & U128 ( u128 :: MAX ) ) . unwrap ( ) ,
687+ near_sdk:: serde_json:: to_vec( & U128 ( u128 :: MAX ) ) . unwrap_or_else ( |e| near_sdk :: env :: panic_str ( & e . to_string ( ) ) ) ,
688688 ) ] ,
689689 ) ;
690690
@@ -707,7 +707,7 @@ mod tests {
707707 & vault_id,
708708 & vault_id,
709709 vec ! [ PromiseResult :: Successful (
710- near_sdk:: serde_json:: to_vec( & U128 ( u128 :: MAX ) ) . unwrap ( ) ,
710+ near_sdk:: serde_json:: to_vec( & U128 ( u128 :: MAX ) ) . unwrap_or_else ( |e| near_sdk :: env :: panic_str ( & e . to_string ( ) ) ) ,
711711 ) ] ,
712712 ) ;
713713
@@ -735,7 +735,7 @@ mod tests {
735735 & vault_id,
736736 & vault_id,
737737 vec ! [ PromiseResult :: Successful (
738- near_sdk:: serde_json:: to_vec( & U128 ( u128 :: MAX ) ) . unwrap ( ) ,
738+ near_sdk:: serde_json:: to_vec( & U128 ( u128 :: MAX ) ) . unwrap_or_else ( |e| near_sdk :: env :: panic_str ( & e . to_string ( ) ) ) ,
739739 ) ] ,
740740 ) ;
741741
@@ -865,7 +865,7 @@ mod tests {
865865 }
866866 }
867867
868- // Property: Payout failure keeps idle_balance unchanged and does not burn escrow
868+ /// Property: Payout failure keeps idle_balance unchanged and does not burn escrow
869869 #[ rstest(
870870 idle => [ 0u128 , 1 , 100 ] ,
871871 escrow => [ 0u128 , 1 , 50 ] ,
@@ -883,7 +883,7 @@ mod tests {
883883 use near_sdk_contract_tools:: ft:: Nep141Controller as _;
884884
885885 c. deposit_unchecked ( & near_sdk:: env:: current_account_id ( ) , escrow)
886- . expect ( "seed escrow into vault" ) ;
886+ . unwrap_or_else ( |e| near_sdk :: env :: panic_str ( & e . to_string ( ) ) ) ;
887887 }
888888
889889 c. idle_balance = idle;
@@ -914,7 +914,7 @@ mod tests {
914914 ) ;
915915 }
916916
917- // Property: Create-withdraw failure skips to next market and if collected>0 ends in Payout
917+ /// Property: Create-withdraw failure skips to next market and if collected>0 ends in Payout
918918 #[ rstest(
919919 collected => [ 1u128 , 10u128 ] ,
920920 need => [ 1u128 , 5u128 ]
@@ -954,7 +954,7 @@ mod tests {
954954 }
955955 }
956956
957- // Property: Exec-withdraw read failure assumes unchanged principal and does not credit idle
957+ /// Property: Exec-withdraw read failure assumes unchanged principal and does not credit idle
958958 #[ rstest(
959959 before => [ 0u128 , 1u128 , 100u128 ] ,
960960 need => [ 0u128 , 1u128 , 50u128 ] ,
@@ -1011,7 +1011,7 @@ mod tests {
10111011 }
10121012 }
10131013
1014- // Property: Callbacks must match current op_id or index; otherwise stop and go Idle
1014+ /// Property: Callbacks must match current op_id or index; otherwise stop and go Idle
10151015 #[ rstest(
10161016 pass_op => [ false , true ] ,
10171017 pass_index => [ false , true ]
@@ -1068,7 +1068,7 @@ mod tests {
10681068 // Seed escrowed shares into the vault's own account
10691069 let owner = accounts ( 1 ) ;
10701070 c. deposit_unchecked ( & near_sdk:: env:: current_account_id ( ) , 10 )
1071- . expect ( "seed escrow into vault" ) ;
1071+ . unwrap_or_else ( |e| near_sdk :: env :: panic_str ( & e . to_string ( ) ) ) ;
10721072
10731073 // Single-market withdraw queue (not used functionally here, just to satisfy path)
10741074 let market = mk ( 12 ) ;
0 commit comments