forest/tool/subcommands/
state_migration_cmd.rs

1// Copyright 2019-2025 ChainSafe Systems
2// SPDX-License-Identifier: Apache-2.0, MIT
3
4use crate::networks::{generate_actor_bundle, get_actor_bundles_metadata};
5use std::path::PathBuf;
6
7#[derive(Debug, clap::Subcommand)]
8pub enum StateMigrationCommands {
9    /// Generate a merged actor bundle from the hard-coded sources in forest
10    ActorBundle {
11        #[arg(default_value = "actor_bundles.car.zst")]
12        output: PathBuf,
13    },
14    /// Generate actors metadata from required bundles list
15    GenerateActorsMetadata,
16}
17
18impl StateMigrationCommands {
19    pub async fn run(self) -> anyhow::Result<()> {
20        match self {
21            Self::ActorBundle { output } => {
22                generate_actor_bundle(&output).await?;
23                println!("Wrote the actors bundle to {}", output.display());
24                Ok(())
25            }
26            Self::GenerateActorsMetadata => {
27                let metadata = get_actor_bundles_metadata().await?;
28                let metadata_json = serde_json::to_string_pretty(&metadata)?;
29                println!("{metadata_json}");
30                Ok(())
31            }
32        }
33    }
34}