@@ -3,7 +3,7 @@ use std::fmt::Display;
33use crate :: { ext_self, near, Contract , ContractExt , Error , Nep141Controller , OpState } ;
44use near_contract_standards:: fungible_token:: core:: ext_ft_core;
55use near_sdk:: {
6- env, json_types:: U128 , serde_json , AccountId , Gas , NearToken , Promise , PromiseError ,
6+ env, json_types:: U128 , AccountId , NearToken , PromiseError ,
77 PromiseOrValue ,
88} ;
99use near_sdk_contract_tools:: ft:: nep141:: GAS_FOR_FT_TRANSFER_CALL ;
@@ -30,7 +30,7 @@ impl Contract {
3030 attempted : U128 ,
3131 ) -> PromiseOrValue < ( ) > {
3232 // Invariant: Index drift or stale op_id results in a graceful stop
33- let _ = if let Err ( e) = self . ctx_allocating ( op_id) {
33+ let ( ) = if let Err ( e) = self . ctx_allocating ( op_id) {
3434 return self . stop_and_exit ( Some ( & e) ) ;
3535 } ;
3636
@@ -503,7 +503,7 @@ impl Contract {
503503 index,
504504 remaining : U128 ( remaining) ,
505505 collected : U128 ( collected) ,
506- reason : msg. map ( |m| m . to_string ( ) ) ,
506+ reason : msg. map ( std :: string :: ToString :: to_string) ,
507507 }
508508 . emit ( ) ;
509509 }
@@ -540,7 +540,7 @@ impl Contract {
540540 op_id : * op_id,
541541 receiver : receiver. clone ( ) ,
542542 amount : U128 ( * amount) ,
543- reason : msg. map ( |m| m . to_string ( ) ) ,
543+ reason : msg. map ( std :: string :: ToString :: to_string) ,
544544 }
545545 . emit ( ) ;
546546 }
@@ -670,16 +670,16 @@ mod tests {
670670 use std:: u128;
671671
672672 use crate :: test_utils:: * ;
673- use crate :: Contract ;
673+
674674 use near_sdk:: json_types:: U128 ;
675- use near_sdk:: test_utils:: { accounts, VMContextBuilder } ;
676- use near_sdk:: { test_utils :: testing_env_with_promise_results , AccountId , PromiseOrValue } ;
677- use near_sdk:: { test_vm_config , testing_env , PromiseResult , RuntimeFeesConfig } ;
675+ use near_sdk:: test_utils:: accounts;
676+ use near_sdk:: PromiseOrValue ;
677+ use near_sdk:: PromiseResult ;
678678 use rstest:: rstest;
679- use templar_common :: asset :: { BorrowAsset , FungibleAsset } ;
679+
680680 use templar_common:: vault:: Error ;
681- use templar_common:: vault:: { AllocationMode , OpState , VaultConfiguration } ;
682- use test_utils :: vault_configuration ;
681+ use templar_common:: vault:: OpState ;
682+
683683
684684 #[ test]
685685 fn after_supply_1_check_allocating_not_allocating ( ) {
@@ -834,7 +834,7 @@ mod tests {
834834 OpState :: Payout { amount, .. } => {
835835 assert_eq ! ( * amount, 70 , "Payout amount must match collected + credited" ) ;
836836 }
837- other => panic ! ( "Unexpected state after read: {:?}" , other ) ,
837+ other => panic ! ( "Unexpected state after read: {other :?}" ) ,
838838 }
839839 }
840840
@@ -952,9 +952,9 @@ mod tests {
952952
953953 match & c. op_state {
954954 OpState :: Payout { amount, .. } => {
955- assert_eq ! ( * amount, collected, "Payout amount must equal collected" )
955+ assert_eq ! ( * amount, collected, "Payout amount must equal collected" ) ;
956956 }
957- other => panic ! ( "Unexpected state: {:?}" , other ) ,
957+ other => panic ! ( "Unexpected state: {other :?}" ) ,
958958 }
959959 }
960960
@@ -1009,9 +1009,9 @@ mod tests {
10091009
10101010 match & c. op_state {
10111011 OpState :: Payout { amount, .. } => {
1012- assert_eq ! ( * amount, collected, "Payout amount must equal collected" )
1012+ assert_eq ! ( * amount, collected, "Payout amount must equal collected" ) ;
10131013 }
1014- other => panic ! ( "Unexpected state: {:?}" , other ) ,
1014+ other => panic ! ( "Unexpected state: {other :?}" ) ,
10151015 }
10161016 }
10171017
@@ -1046,24 +1046,18 @@ mod tests {
10461046 let call_idx = if pass_index { real_idx } else { real_idx + 1 } ;
10471047
10481048 let r = c. after_exec_withdraw_read ( Ok ( None ) , call_op, call_idx, U128 ( 10 ) , U128 ( 1 ) ) ;
1049- match ( pass_op, pass_index) {
1050- ( true , true ) => {
1051- assert ! (
1052- !matches!( c. op_state, OpState :: Idle ) ,
1053- "Valid callback should not immediately stop"
1054- ) ;
1055- }
1056- _ => {
1057- // Any mismatch should stop and go Idle
1058- match r {
1059- PromiseOrValue :: Value ( ( ) ) => { }
1060- _ => { }
1061- }
1062- assert ! (
1063- matches!( c. op_state, OpState :: Idle ) ,
1064- "Mismatched callback must stop and go Idle"
1065- ) ;
1066- }
1049+ if let ( true , true ) = ( pass_op, pass_index) {
1050+ assert ! (
1051+ !matches!( c. op_state, OpState :: Idle ) ,
1052+ "Valid callback should not immediately stop"
1053+ ) ;
1054+ } else {
1055+ // Any mismatch should stop and go Idle
1056+ if let PromiseOrValue :: Value ( ( ) ) = r { }
1057+ assert ! (
1058+ matches!( c. op_state, OpState :: Idle ) ,
1059+ "Mismatched callback must stop and go Idle"
1060+ ) ;
10671061 }
10681062 }
10691063
0 commit comments