@@ -134,7 +134,13 @@ pub mod module {
134134 ) -> DispatchResult {
135135 let from = ensure_signed ( origin) ?;
136136 let to = T :: Lookup :: lookup ( dest) ?;
137- <Self as MultiCurrency < T :: AccountId > >:: transfer ( currency_id, & from, & to, amount)
137+ <Self as MultiCurrency < T :: AccountId > >:: transfer (
138+ currency_id,
139+ & from,
140+ & to,
141+ amount,
142+ ExistenceRequirement :: AllowDeath ,
143+ )
138144 }
139145
140146 /// Transfer some native currency to another account.
@@ -150,7 +156,7 @@ pub mod module {
150156 ) -> DispatchResult {
151157 let from = ensure_signed ( origin) ?;
152158 let to = T :: Lookup :: lookup ( dest) ?;
153- T :: NativeCurrency :: transfer ( & from, & to, amount)
159+ T :: NativeCurrency :: transfer ( & from, & to, amount, ExistenceRequirement :: AllowDeath )
154160 }
155161
156162 /// update amount of account `who` under `currency_id`.
@@ -220,14 +226,15 @@ impl<T: Config> MultiCurrency<T::AccountId> for Pallet<T> {
220226 from : & T :: AccountId ,
221227 to : & T :: AccountId ,
222228 amount : Self :: Balance ,
229+ existence_requirement : ExistenceRequirement ,
223230 ) -> DispatchResult {
224231 if amount. is_zero ( ) || from == to {
225232 return Ok ( ( ) ) ;
226233 }
227234 if currency_id == T :: GetNativeCurrencyId :: get ( ) {
228- T :: NativeCurrency :: transfer ( from, to, amount)
235+ T :: NativeCurrency :: transfer ( from, to, amount, existence_requirement )
229236 } else {
230- T :: MultiCurrency :: transfer ( currency_id, from, to, amount)
237+ T :: MultiCurrency :: transfer ( currency_id, from, to, amount, existence_requirement )
231238 }
232239 }
233240
@@ -242,14 +249,19 @@ impl<T: Config> MultiCurrency<T::AccountId> for Pallet<T> {
242249 }
243250 }
244251
245- fn withdraw ( currency_id : Self :: CurrencyId , who : & T :: AccountId , amount : Self :: Balance ) -> DispatchResult {
252+ fn withdraw (
253+ currency_id : Self :: CurrencyId ,
254+ who : & T :: AccountId ,
255+ amount : Self :: Balance ,
256+ existence_requirement : ExistenceRequirement ,
257+ ) -> DispatchResult {
246258 if amount. is_zero ( ) {
247259 return Ok ( ( ) ) ;
248260 }
249261 if currency_id == T :: GetNativeCurrencyId :: get ( ) {
250- T :: NativeCurrency :: withdraw ( who, amount)
262+ T :: NativeCurrency :: withdraw ( who, amount, existence_requirement )
251263 } else {
252- T :: MultiCurrency :: withdraw ( currency_id, who, amount)
264+ T :: MultiCurrency :: withdraw ( currency_id, who, amount, existence_requirement )
253265 }
254266 }
255267
@@ -475,16 +487,31 @@ where
475487 <Pallet < T > >:: ensure_can_withdraw ( GetCurrencyId :: get ( ) , who, amount)
476488 }
477489
478- fn transfer ( from : & T :: AccountId , to : & T :: AccountId , amount : Self :: Balance ) -> DispatchResult {
479- <Pallet < T > as MultiCurrency < T :: AccountId > >:: transfer ( GetCurrencyId :: get ( ) , from, to, amount)
490+ fn transfer (
491+ from : & T :: AccountId ,
492+ to : & T :: AccountId ,
493+ amount : Self :: Balance ,
494+ existence_requirement : ExistenceRequirement ,
495+ ) -> DispatchResult {
496+ <Pallet < T > as MultiCurrency < T :: AccountId > >:: transfer (
497+ GetCurrencyId :: get ( ) ,
498+ from,
499+ to,
500+ amount,
501+ existence_requirement,
502+ )
480503 }
481504
482505 fn deposit ( who : & T :: AccountId , amount : Self :: Balance ) -> DispatchResult {
483506 <Pallet < T > >:: deposit ( GetCurrencyId :: get ( ) , who, amount)
484507 }
485508
486- fn withdraw ( who : & T :: AccountId , amount : Self :: Balance ) -> DispatchResult {
487- <Pallet < T > >:: withdraw ( GetCurrencyId :: get ( ) , who, amount)
509+ fn withdraw (
510+ who : & T :: AccountId ,
511+ amount : Self :: Balance ,
512+ existence_requirement : ExistenceRequirement ,
513+ ) -> DispatchResult {
514+ <Pallet < T > >:: withdraw ( GetCurrencyId :: get ( ) , who, amount, existence_requirement)
488515 }
489516
490517 fn can_slash ( who : & T :: AccountId , amount : Self :: Balance ) -> bool {
@@ -653,8 +680,13 @@ where
653680 Currency :: ensure_can_withdraw ( who, amount, WithdrawReasons :: all ( ) , new_balance)
654681 }
655682
656- fn transfer ( from : & AccountId , to : & AccountId , amount : Self :: Balance ) -> DispatchResult {
657- Currency :: transfer ( from, to, amount, ExistenceRequirement :: AllowDeath )
683+ fn transfer (
684+ from : & AccountId ,
685+ to : & AccountId ,
686+ amount : Self :: Balance ,
687+ existence_requirement : ExistenceRequirement ,
688+ ) -> DispatchResult {
689+ Currency :: transfer ( from, to, amount, existence_requirement)
658690 }
659691
660692 fn deposit ( who : & AccountId , amount : Self :: Balance ) -> DispatchResult {
@@ -666,8 +698,8 @@ where
666698 Ok ( ( ) )
667699 }
668700
669- fn withdraw ( who : & AccountId , amount : Self :: Balance ) -> DispatchResult {
670- Currency :: withdraw ( who, amount, WithdrawReasons :: all ( ) , ExistenceRequirement :: AllowDeath ) . map ( |_| ( ) )
701+ fn withdraw ( who : & AccountId , amount : Self :: Balance , existence_requirement : ExistenceRequirement ) -> DispatchResult {
702+ Currency :: withdraw ( who, amount, WithdrawReasons :: all ( ) , existence_requirement ) . map ( |_| ( ) )
671703 }
672704
673705 fn can_slash ( who : & AccountId , amount : Self :: Balance ) -> bool {
@@ -707,7 +739,7 @@ where
707739 if by_amount. is_positive ( ) {
708740 Self :: deposit ( who, by_balance)
709741 } else {
710- Self :: withdraw ( who, by_balance)
742+ Self :: withdraw ( who, by_balance, ExistenceRequirement :: AllowDeath )
711743 }
712744 }
713745}
@@ -817,7 +849,12 @@ impl<T: Config> TransferAll<T::AccountId> for Pallet<T> {
817849 T :: MultiCurrency :: transfer_all ( source, dest) ?;
818850
819851 // transfer all free to dest
820- T :: NativeCurrency :: transfer ( source, dest, T :: NativeCurrency :: free_balance ( source) )
852+ T :: NativeCurrency :: transfer (
853+ source,
854+ dest,
855+ T :: NativeCurrency :: free_balance ( source) ,
856+ ExistenceRequirement :: AllowDeath ,
857+ )
821858 } )
822859 }
823860}
0 commit comments