pub async fn run(
    shell: &Shell,
    params: FinalizeChainMigrationFromGatewayArgs,
) -> anyhow::Result<()> {
    if !params.no_cross_check {
        let state = get_gateway_migration_state(
            params.l1_rpc_url.clone(),
            params.l1_bridgehub_addr,
            params.l2_chain_id,
            params
                .l2_rpc_url
                .clone()
                .context("L2 RPC URL must be provided for cross checking")?,
            params.gateway_rpc_url.clone(),
            MigrationDirection::FromGateway,
        )
        .await?;

        match state {
            GatewayMigrationProgressState::PendingManualFinalization => {
                logger::info("The chain migration to Gateway has been finalized on the Gateway side. Finalizing the migration...");
            }
            _ => {
                anyhow::bail!(message_for_gateway_migration_progress_state(
                    state,
                    MigrationDirection::FromGateway,
                ));
            }
        }
    }

    let migraiton_tx = get_migration_transaction(
        &params.gateway_rpc_url,
        L2_BRIDGEHUB_ADDRESS,
        params.l2_chain_id,
    )
    .await?
    .context("Failed to find the transaction where the migration from GW to L1 happened")?;

    let gateway_zk_client = get_zk_client(&params.gateway_rpc_url, params.l2_chain_id)?;

    let withdrawal_params = gateway_zk_client
        .get_finalize_withdrawal_params(migraiton_tx, 0)
        .await?;

    finish_migrate_chain_from_gateway(
        shell,
        Default::default(),
        &get_default_foundry_path(shell)?,
        Wallet::new(
            params
                .private_key
                .parse()
                .context("Failed to parse private key")?,
        ),
        params.l1_bridgehub_addr,
        params.l2_chain_id,
        params.gateway_chain_id,
        withdrawal_params,
        params.l1_rpc_url,
    )
    .await?;

    Ok(())
}
Produces the calldata necessary to perform (or continue) a migration to Gateway.
zkstack_cli/crates/zkstack/src/commands/chain/gateway/finalize_chain_migration_from_gw.rs