Skip to content

Commit

Permalink
Merge pull request #12 from karnotxyz/anvil_run_docs
Browse files Browse the repository at this point in the history
anvil run message
  • Loading branch information
apoorvsadana authored Jan 12, 2024
2 parents 606379b + 73f0731 commit 87027e1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/da/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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> {
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 87027e1

Please sign in to comment.