@@ -80,22 +80,28 @@ use crate::{
8080 pallet:: { Accounts , Config , HoldReason } ,
8181 BalanceOf ,
8282} ;
83- use alloc :: collections :: BTreeMap ;
83+
8484use frame_support:: {
8585 migrations:: { MigrationId , SteppedMigration , SteppedMigrationError } ,
8686 pallet_prelude:: PhantomData ,
8787 traits:: {
88- fungible:: { Inspect , InspectHold , MutateHold } ,
88+ fungible:: { Inspect , MutateHold } ,
8989 tokens:: { Fortitude , Preservation } ,
9090 Currency , Get , ReservableCurrency ,
9191 } ,
9292 weights:: WeightMeter ,
9393} ;
94- use sp_runtime:: { traits:: Zero , TryRuntimeError } ;
94+ use sp_runtime:: traits:: Zero ;
9595use std:: cmp:: min;
9696
9797#[ cfg( feature = "try-runtime" ) ]
9898use alloc:: vec:: Vec ;
99+ #[ cfg( any( test, feature = "try-runtime" ) ) ]
100+ use alloc:: collections:: BTreeMap ;
101+ #[ cfg( any( test, feature = "try-runtime" ) ) ]
102+ use sp_runtime:: TryRuntimeError ;
103+ #[ cfg( any( test, feature = "try-runtime" ) ) ]
104+ use frame_support:: traits:: fungible:: InspectHold ;
99105
100106// Module containing the OLD (v0) storage items that used Currency trait.
101107pub mod v0 {
@@ -150,12 +156,6 @@ where
150156 return Err ( SteppedMigrationError :: InsufficientWeight { required : min_required } ) ;
151157 }
152158
153- loop {
154- // Process one account per step
155- if meter. try_consume ( min_required) . is_err ( ) {
156- break ;
157- }
158-
159159 // Get the iterator for the OLD accounts to migrate
160160 let mut iter = if let Some ( Some ( last_key) ) = cursor {
161161 v0:: OldAccounts :: < T > :: iter_from ( v0:: OldAccounts :: < T > :: hashed_key_for ( last_key) )
@@ -172,7 +172,8 @@ where
172172 println ! ( "Migration completed - no more accounts to migrate" ) ;
173173 return Ok ( None ) ;
174174 }
175- }
175+
176+ meter. consume ( min_required) ;
176177
177178 Ok ( cursor)
178179 }
@@ -254,7 +255,12 @@ where
254255
255256 Ok ( ( ) )
256257 }
258+ }
257259
260+ impl < T : Config , OldCurrency > MigrateCurrencyToFungibles < T , OldCurrency >
261+ where
262+ OldCurrency : Currency < T :: AccountId , Balance = BalanceOf < T > > + ReservableCurrency < T :: AccountId > ,
263+ {
258264 fn migrate_account (
259265 account : T :: AccountId ,
260266 index : T :: AccountIndex ,
0 commit comments