@@ -33,6 +33,10 @@ impl<T: Config> MultiCurrencyAccounting for Module<T> {
3333 type PositiveImbalance = PositiveImbalance < T > ;
3434 type NegativeImbalance = NegativeImbalance < T > ;
3535
36+ fn minimum_balance ( currency : Option < T :: AssetId > ) -> Self :: Balance {
37+ <Module < T > >:: asset_meta ( currency. unwrap_or_else ( || Self :: DefaultCurrencyId :: asset_id ( ) ) ) . existential_deposit ( )
38+ }
39+
3640 fn total_balance ( who : & T :: AccountId , currency : Option < T :: AssetId > ) -> Self :: Balance {
3741 <Module < T > >:: total_balance ( currency. unwrap_or_else ( || Self :: DefaultCurrencyId :: asset_id ( ) ) , who)
3842 }
@@ -146,14 +150,30 @@ impl<T: Config> MultiCurrencyAccounting for Module<T> {
146150#[ cfg( test) ]
147151mod tests {
148152 use super :: * ;
149- use crate :: mock:: { new_test_ext_with_balance, new_test_ext_with_default, GenericAsset , Test } ;
153+ use crate :: mock:: {
154+ new_test_ext_with_balance, new_test_ext_with_default, GenericAsset , Test , STAKING_ASSET_ID , TEST1_ASSET_ID ,
155+ TEST2_ASSET_ID ,
156+ } ;
150157 use frame_support:: assert_noop;
151158 use sp_runtime:: traits:: Zero ;
152159
153160 #[ test]
154161 fn multi_accounting_minimum_balance ( ) {
155162 new_test_ext_with_default ( ) . execute_with ( || {
156- assert ! ( <GenericAsset as MultiCurrencyAccounting >:: minimum_balance( ) . is_zero( ) ) ;
163+ assert_eq ! (
164+ <GenericAsset as MultiCurrencyAccounting >:: minimum_balance( Some ( TEST1_ASSET_ID ) ) ,
165+ 3
166+ ) ;
167+ assert_eq ! (
168+ <GenericAsset as MultiCurrencyAccounting >:: minimum_balance( Some ( TEST2_ASSET_ID ) ) ,
169+ 5
170+ ) ;
171+ assert_eq ! (
172+ <GenericAsset as MultiCurrencyAccounting >:: minimum_balance( Some ( STAKING_ASSET_ID ) ) ,
173+ 1
174+ ) ;
175+ // When currency is None, the minimum balance for the default currency will be returned.
176+ assert_eq ! ( <GenericAsset as MultiCurrencyAccounting >:: minimum_balance( None ) , 1 ) ;
157177 } ) ;
158178 }
159179
0 commit comments