@@ -274,7 +274,7 @@ pub async fn migrate_token_balances_from_gateway(
274274
275275 // Send all initiate migration transactions
276276 let mut pending_txs = FuturesUnordered :: new ( ) ;
277- for asset_id in asset_ids {
277+ for asset_id in asset_ids. iter ( ) . copied ( ) {
278278 println ! (
279279 "Migrating token balance for assetId: 0x{}" ,
280280 hex:: encode( asset_id)
@@ -379,18 +379,23 @@ pub async fn migrate_token_balances_from_gateway(
379379 forge = fill_forge_private_key ( forge, Some ( & wallet) , WalletOwner :: Deployer ) ?;
380380 forge. run ( shell) ?;
381381
382- // Wait for migration to be finalized
382+ // Wait for all tokens to be migrated
383383 let tracker = Contract :: new (
384384 L2_ASSET_TRACKER_ADDRESS ,
385385 parse_abi ( & [ "function tokenMigratedThisChain(bytes32) view returns (bool)" ] ) ?,
386386 Arc :: new ( Provider :: < Http > :: try_from ( l2_rpc_url. as_str ( ) ) ?) ,
387387 ) ;
388- while !tracker
389- . method :: < _ , bool > ( "tokenMigratedThisChain" , base_token_asset_id) ?
390- . call ( )
391- . await ?
392- {
393- std:: thread:: sleep ( std:: time:: Duration :: from_secs ( 1 ) ) ;
388+ for asset_id in asset_ids. iter ( ) . copied ( ) {
389+ loop {
390+ let asset_is_migrated = tracker
391+ . method :: < _ , bool > ( "tokenMigratedThisChain" , asset_id) ?
392+ . call ( )
393+ . await ?;
394+ if asset_is_migrated {
395+ break ;
396+ }
397+ tokio:: time:: sleep ( std:: time:: Duration :: from_millis ( LOOK_WAITING_TIME_MS ) ) . await ;
398+ }
394399 }
395400
396401 println ! ( "Token migration finished" ) ;
0 commit comments