diff --git a/crates/topos-config/src/edge.rs b/crates/topos-config/src/edge.rs index 791299fb2..3cbd1e4a3 100644 --- a/crates/topos-config/src/edge.rs +++ b/crates/topos-config/src/edge.rs @@ -1,10 +1,16 @@ -use crate::Config; +use crate::{edge::command::CommandConfig, Config}; use figment::{ providers::{Format, Toml}, Figment, }; use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, path::Path}; +use std::{ + collections::HashMap, + path::{Path, PathBuf}, + process::ExitStatus, +}; +use tokio::{spawn, task::JoinHandle}; +use tracing::{error, info}; // TODO: Provides the default arguments here // Serde `flatten` and `default` doesn't work together yet @@ -37,3 +43,24 @@ impl Config for EdgeConfig { "edge".to_string() } } + +pub mod command; + +pub fn generate_edge_config( + edge_path: PathBuf, + config_path: PathBuf, +) -> JoinHandle> { + // Create the Polygon Edge config + info!("Generating the configuration at {config_path:?}"); + info!("Polygon-edge binary located at: {edge_path:?}"); + spawn(async move { + CommandConfig::new(edge_path) + .init(&config_path) + .spawn() + .await + .map_err(|e| { + error!("Failed to generate the edge configuration: {e:?}"); + e + }) + }) +} diff --git a/crates/topos/src/edge/mod.rs b/crates/topos-config/src/edge/command.rs similarity index 100% rename from crates/topos/src/edge/mod.rs rename to crates/topos-config/src/edge/command.rs diff --git a/crates/topos-config/src/lib.rs b/crates/topos-config/src/lib.rs index a83ca8858..59610b749 100644 --- a/crates/topos-config/src/lib.rs +++ b/crates/topos-config/src/lib.rs @@ -1,5 +1,5 @@ pub(crate) mod base; -pub(crate) mod edge; +pub mod edge; pub mod genesis; pub mod node; pub mod sequencer; diff --git a/crates/topos-sequencer-subnet-runtime/tests/subnet_contract.rs b/crates/topos-sequencer-subnet-runtime/tests/subnet_contract.rs index ad20daa73..7ca5e54f9 100644 --- a/crates/topos-sequencer-subnet-runtime/tests/subnet_contract.rs +++ b/crates/topos-sequencer-subnet-runtime/tests/subnet_contract.rs @@ -321,18 +321,18 @@ async fn deploy_test_token( "Deploying new token {} with symbol {}", token_name, token_symbol ); - match ierc20_messaging + + let deploy_query = ierc20_messaging .deploy_token(token_encoded_params) .legacy() - .gas(DEFAULT_GAS) - .send() - .await - .map_err(|e| { - error!("Unable deploy token: {e}"); - e - })? - .await - { + .gas(DEFAULT_GAS); + + let deploy_result = deploy_query.send().await.map_err(|e| { + error!("Unable deploy token: {e}"); + e + })?; + + match deploy_result.await { Ok(r) => { info!("Token deployed: {:?}", r); } diff --git a/crates/topos/src/components/node/mod.rs b/crates/topos/src/components/node/mod.rs index 028e00ca1..4989c597a 100644 --- a/crates/topos/src/components/node/mod.rs +++ b/crates/topos/src/components/node/mod.rs @@ -18,9 +18,8 @@ use tracing::{error, info}; use tracing_opentelemetry::OpenTelemetrySpanExt; use self::commands::{NodeCommand, NodeCommands}; -use crate::edge::BINARY_NAME; use crate::tracing::setup_tracing; -use topos_config::{genesis::Genesis, Config}; +use topos_config::{edge::command::BINARY_NAME, genesis::Genesis, Config}; use topos_config::{node::NodeConfig, node::NodeRole}; use topos_core::api::grpc::tce::v1::console_service_client::ConsoleServiceClient; use topos_wallet::SecretManager; @@ -74,7 +73,7 @@ pub(crate) async fn handle_command( println!("Init the node without polygon-edge process..."); } else { // Generate the Edge configuration - match services::process::generate_edge_config( + match topos_config::edge::generate_edge_config( edge_path.join(BINARY_NAME), node_path.clone(), ) diff --git a/crates/topos/src/components/node/services/process.rs b/crates/topos/src/components/node/services/process.rs index 40bac4b09..59320947b 100644 --- a/crates/topos/src/components/node/services/process.rs +++ b/crates/topos/src/components/node/services/process.rs @@ -1,17 +1,17 @@ -use crate::edge::CommandConfig; use std::collections::HashMap; use std::path::PathBuf; use std::process::ExitStatus; use thiserror::Error; use tokio::{spawn, sync::mpsc, task::JoinHandle}; use tokio_util::sync::CancellationToken; +use topos_config::edge::command::CommandConfig; use topos_config::sequencer::SequencerConfig; use topos_config::tce::broadcast::ReliableBroadcastParams; use topos_config::tce::{AuthKey, StorageConfiguration, TceConfig}; use topos_p2p::Multiaddr; use topos_sequencer::SequencerConfiguration; use topos_wallet::SecretManager; -use tracing::{debug, error, info, warn}; +use tracing::{debug, error, warn}; use topos_config::genesis::Genesis; @@ -25,25 +25,6 @@ pub enum Errors { EdgeTerminated(#[from] std::io::Error), } -pub fn generate_edge_config( - edge_path: PathBuf, - config_path: PathBuf, -) -> JoinHandle> { - // Create the Polygon Edge config - info!("Generating the configuration at {config_path:?}"); - info!("Polygon-edge binary located at: {edge_path:?}"); - spawn(async move { - CommandConfig::new(edge_path) - .init(&config_path) - .spawn() - .await - .map_err(|e| { - error!("Failed to generate the edge configuration: {e:?}"); - Errors::EdgeTerminated(e) - }) - }) -} - pub(crate) fn spawn_sequencer_process( config: SequencerConfig, keys: &SecretManager, diff --git a/crates/topos/src/main.rs b/crates/topos/src/main.rs index d503822d3..503383dcc 100644 --- a/crates/topos/src/main.rs +++ b/crates/topos/src/main.rs @@ -4,8 +4,6 @@ pub(crate) mod components; pub(crate) mod options; mod tracing; -mod edge; - use crate::options::ToposCommand; use tracing_log::LogTracer;