From 73f07317b0048668187f0c9131b06f8456560561 Mon Sep 17 00:00:00 2001 From: apoorvsadana <95699312+apoorvsadana@users.noreply.github.com> Date: Fri, 12 Jan 2024 15:34:36 +0530 Subject: [PATCH] anvil run message --- src/da/ethereum.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/da/ethereum.rs b/src/da/ethereum.rs index cd80001..9332ae0 100644 --- a/src/da/ethereum.rs +++ b/src/da/ethereum.rs @@ -13,6 +13,7 @@ use ethers::signers::{LocalWallet, Signer, WalletError}; use serde::{Deserialize, Serialize}; use std::fs; +use crate::cli::prompt::get_boolean_input; use std::str::FromStr; use std::sync::Arc; use std::time::Duration; @@ -36,8 +37,12 @@ pub enum EthereumError { FailedToCreateWallet(WalletError), #[error("Failed to setup Starknet on Anvil")] FailedToSetupStarknet, + #[error("Anvil node not running")] + AnvilNodeNotRunning, } +const ANVIL_DOCS: &str = "https://github.com/foundry-rs/foundry/tree/master/crates/anvil"; + #[async_trait] impl DaClient for EthereumClient { fn setup_and_generate_keypair(&self, config: &AppChainConfig) -> Result<(), DaError> { @@ -66,6 +71,14 @@ impl DaClient for EthereumClient { } async fn setup(&self, config: &AppChainConfig) -> EyreResult<()> { + match get_boolean_input( + format!("Are you running an Anvil node locally? The CLI tool has been tested on Anvil version 0.2.0 (c312c0d). Docs: {}", ANVIL_DOCS).as_str(), + Some(true), + )? { + true => Ok(()), + false => Err(DaError::EthereumError(EthereumError::AnvilNodeNotRunning)), + }?; + let ethereum_config_path = self.get_da_config_path(config)?; let ethereum_config: EthereumConfig = serde_json::from_str( fs::read_to_string(ethereum_config_path).map_err(DaError::FailedToReadDaConfigFile)?.as_str(),