128128//! T::Currency::withdraw(
129129//! transactor,
130130//! amount,
131- //! WithdrawReason::TransactionPayment,
131+ //! WithdrawReason::TransactionPayment.into() ,
132132//! ExistenceRequirement::KeepAlive,
133133//! )?;
134134//! // ...
@@ -563,11 +563,16 @@ impl<T: Trait> Module<T> {
563563
564564 /// Transfer some liquid free balance from one account to another.
565565 /// This will not emit the `Transferred` event.
566- pub fn make_transfer ( asset_id : & T :: AssetId , from : & T :: AccountId , to : & T :: AccountId , amount : T :: Balance ) -> Result {
566+ pub fn make_transfer (
567+ asset_id : & T :: AssetId ,
568+ from : & T :: AccountId ,
569+ to : & T :: AccountId ,
570+ amount : T :: Balance
571+ ) -> Result {
567572 let new_balance = Self :: free_balance ( asset_id, from)
568573 . checked_sub ( & amount)
569574 . ok_or_else ( || "balance too low to send amount" ) ?;
570- Self :: ensure_can_withdraw ( asset_id, from, amount, WithdrawReason :: Transfer , new_balance) ?;
575+ Self :: ensure_can_withdraw ( asset_id, from, amount, WithdrawReason :: Transfer . into ( ) , new_balance) ?;
571576
572577 if from != to {
573578 <FreeBalance < T > >:: mutate ( asset_id, from, |balance| * balance -= amount) ;
@@ -734,7 +739,7 @@ impl<T: Trait> Module<T> {
734739 asset_id : & T :: AssetId ,
735740 who : & T :: AccountId ,
736741 _amount : T :: Balance ,
737- reason : WithdrawReason ,
742+ reasons : WithdrawReasons ,
738743 new_balance : T :: Balance ,
739744 ) -> Result {
740745 if asset_id != & Self :: staking_asset_id ( ) {
@@ -748,7 +753,7 @@ impl<T: Trait> Module<T> {
748753 let now = <system:: Module < T > >:: block_number ( ) ;
749754 if Self :: locks ( who)
750755 . into_iter ( )
751- . all ( |l| now >= l. until || new_balance >= l. amount || !l. reasons . contains ( reason ) )
756+ . all ( |l| now >= l. until || new_balance >= l. amount || !l. reasons . intersects ( reasons ) )
752757 {
753758 Ok ( ( ) )
754759 } else {
@@ -1098,22 +1103,22 @@ where
10981103 fn ensure_can_withdraw (
10991104 who : & T :: AccountId ,
11001105 amount : Self :: Balance ,
1101- reason : WithdrawReason ,
1106+ reasons : WithdrawReasons ,
11021107 new_balance : Self :: Balance ,
11031108 ) -> Result {
1104- <Module < T > >:: ensure_can_withdraw ( & U :: asset_id ( ) , who, amount, reason , new_balance)
1109+ <Module < T > >:: ensure_can_withdraw ( & U :: asset_id ( ) , who, amount, reasons , new_balance)
11051110 }
11061111
11071112 fn withdraw (
11081113 who : & T :: AccountId ,
11091114 value : Self :: Balance ,
1110- reason : WithdrawReason ,
1115+ reasons : WithdrawReasons ,
11111116 _: ExistenceRequirement , // no existential deposit policy for generic asset
11121117 ) -> result:: Result < Self :: NegativeImbalance , & ' static str > {
11131118 let new_balance = Self :: free_balance ( who)
11141119 . checked_sub ( & value)
11151120 . ok_or_else ( || "account has too few funds" ) ?;
1116- Self :: ensure_can_withdraw ( who, value, reason , new_balance) ?;
1121+ Self :: ensure_can_withdraw ( who, value, reasons , new_balance) ?;
11171122 <Module < T > >:: set_free_balance ( & U :: asset_id ( ) , who, new_balance) ;
11181123 Ok ( NegativeImbalance :: new ( value) )
11191124 }
@@ -1197,7 +1202,7 @@ where
11971202 . checked_sub ( & value)
11981203 . map_or ( false , |new_balance|
11991204 <Module < T > >:: ensure_can_withdraw (
1200- & U :: asset_id ( ) , who, value, WithdrawReason :: Reserve , new_balance
1205+ & U :: asset_id ( ) , who, value, WithdrawReason :: Reserve . into ( ) , new_balance
12011206 ) . is_ok ( )
12021207 )
12031208 }
0 commit comments