Skip to content

Commit

Permalink
explorer host flag and new docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
apoorvsadana committed Jan 26, 2024
1 parent 9781391 commit 5c622dd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/cli/explorer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,30 @@ use bollard::models::{HostConfig, PortBinding};
use rand::distributions::Alphanumeric;
use rand::Rng;

use clap::Args;
use std::collections::HashMap;

use crate::utils::docker::{container_exists, kill_container, run_docker_image};

pub async fn explorer() {
#[derive(Args)]
pub struct ExplorerOpts {
#[clap(long, default_value = "localhost")]
pub host: String,
}

pub async fn explorer(opts: &ExplorerOpts) {
let random_string: String = (0..64).map(|_| rand::thread_rng().sample(Alphanumeric).to_string()).collect();
let secret_key_base = format!("SECRET_KEY_BASE={}", random_string);

let host_env = format!("PHX_HOST={}", opts.host);
let env = vec![
"RPC_API_HOST=http://host.docker.internal:9944",
"DB_TYPE=sqlite",
"DISABLE_MAINNET_SYNC=false",
"DISABLE_TESTNET_SYNC=true",
"TESTNET_RPC_API_HOST=http://host.docker.internal:9944",
"DATABASE_PATH=/use/exp.db",
"PHX_HOST=localhost",
host_env.as_str(),
&secret_key_base,
];

Expand Down
5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use clap::{Parser, Subcommand};
use log::LevelFilter;
use madara_cli::cli;
use madara_cli::cli::explorer::ExplorerOpts;

#[derive(Parser)]
#[command(author, version, about, long_about = None)]
Expand All @@ -18,7 +19,7 @@ enum Commands {
/// Runs the App Chain using Madara
Run,
/// Runs the L2 explorer
Explorer,
Explorer(ExplorerOpts),
}

#[tokio::main]
Expand All @@ -36,7 +37,7 @@ async fn main() {
Some(Commands::Init) => cli::init::init().await,
Some(Commands::List) => cli::list::list(),
Some(Commands::Run) => cli::run::run().await,
Some(Commands::Explorer) => cli::explorer::explorer().await,
Some(Commands::Explorer(opts)) => cli::explorer::explorer(opts).await,
None => log::info!("Use --help to see the complete list of available commands"),
}
}

0 comments on commit 5c622dd

Please sign in to comment.