Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadkaouk committed Dec 13, 2024
1 parent 81a63b1 commit 13318f9
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/lazy-migrations/005-foreign-assets-migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ async function main() {
await api.query.moonbeamLazyMigrations.foreignAssetMigrationStatusValue();

if (!status.isMigrating) {
throw new Error("Migration did not start");
console.error("Migration did not start correctly");
return;
}

remainingBalances = status.asMigrating?.remainingBalances.toNumber();
Expand Down Expand Up @@ -114,6 +115,18 @@ async function main() {
}
console.log("Completed approvals migration for asset", assetId);

await waitForAllMonitoredExtrinsics();
const status: PalletMoonbeamLazyMigrationsForeignAssetForeignAssetMigrationStatus =
await api.query.moonbeamLazyMigrations.foreignAssetMigrationStatusValue();
if (
(status.asMigrating?.remainingBalances.toNumber() || 0) > 0 ||
(status.asMigrating?.remainingApprovals.toNumber() || 0) > 0
) {
// If there are still balances or approvals to migrate, we should not finish the migration
console.log("Migration is still in progress, not finishing yet");
return;
}

// Step 4: Finish migration
const txFinish = api.tx.moonbeamLazyMigrations.finishForeignAssetsMigration();
await txFinish.signAndSend(
Expand Down

0 comments on commit 13318f9

Please sign in to comment.