tezos-smart-rollup-installer 0.2.0

Installer client for Tezos Smart Rollups.
Documentation
// SPDX-FileCopyrightText: 2023 TriliTech <contact@trili.tech>
//
// SPDX-License-Identifier: MIT

mod commands;
mod installer;
mod output;
mod preimages;

use clap::Parser;
use commands::Cli;
use commands::Commands;
use std::path::Path;
use tezos_smart_rollup_installer::config::{create_installer_config, ConfigurationError};
use thiserror::Error;

fn main() -> Result<(), ClientError> {
    match Cli::parse().command {
        Commands::GetRevealInstaller {
            upgrade_to,
            output,
            preimages_dir,
            setup_file,
        } => {
            let upgrade_to = Path::new(&upgrade_to);
            let output = Path::new(&output);
            let preimages_dir = Path::new(&preimages_dir);

            let root_hash = preimages::content_to_preimages(upgrade_to, preimages_dir)?;

            let config = create_installer_config(root_hash, setup_file)?;
            let kernel = installer::with_config_program(config);

            output::save_kernel(output, &kernel).map_err(ClientError::SaveInstaller)?;
        }
    }

    Ok(())
}

#[derive(Debug, Error)]
enum ClientError {
    #[error("Error preimaging kernel: {0}")]
    KernelPreimageError(#[from] preimages::Error),
    #[error("Error configuring kernel: {0}")]
    ConfigError(#[from] ConfigurationError),
    #[error("Unable to save installer kernel: {0}")]
    SaveInstaller(std::io::Error),
}