From 97813918e1bd7a8bfab2792a47329107c34503c6 Mon Sep 17 00:00:00 2001 From: apoorvsadana <95699312+apoorvsadana@users.noreply.github.com> Date: Fri, 26 Jan 2024 23:27:17 +0530 Subject: [PATCH 1/2] update explorer version --- src/cli/explorer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/explorer.rs b/src/cli/explorer.rs index 07b50fd..3021190 100644 --- a/src/cli/explorer.rs +++ b/src/cli/explorer.rs @@ -37,7 +37,7 @@ pub async fn explorer() { } run_docker_image( - "ghcr.io/lambdaclass/stark_compass_explorer:v0.2.34.2", + "ghcr.io/lambdaclass/stark_compass_explorer:v0.2.34.3-1", CONTAINER_NAME, Some(env), Some(host_config), From 5c622dd1cc5185c573392f1426ad465cde043d4c Mon Sep 17 00:00:00 2001 From: apoorvsadana <95699312+apoorvsadana@users.noreply.github.com> Date: Sat, 27 Jan 2024 00:03:10 +0530 Subject: [PATCH 2/2] explorer host flag and new docker image --- src/cli/explorer.rs | 12 ++++++++++-- src/main.rs | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/cli/explorer.rs b/src/cli/explorer.rs index 3021190..c0bdd99 100644 --- a/src/cli/explorer.rs +++ b/src/cli/explorer.rs @@ -2,14 +2,22 @@ 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", @@ -17,7 +25,7 @@ pub async fn explorer() { "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, ]; diff --git a/src/main.rs b/src/main.rs index 001f17e..0412702 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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)] @@ -18,7 +19,7 @@ enum Commands { /// Runs the App Chain using Madara Run, /// Runs the L2 explorer - Explorer, + Explorer(ExplorerOpts), } #[tokio::main] @@ -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"), } }