diff --git a/Cargo.lock b/Cargo.lock index 113796a..6fd3d30 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2340,6 +2340,7 @@ dependencies = [ "clap 3.2.23", "colored", "dtp-sdk", + "futures", "sui-sdk", "telemetry-subscribers 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio", diff --git a/crates/dtp-server/Cargo.toml b/crates/dtp-server/Cargo.toml index 423f25c..daa4928 100644 --- a/crates/dtp-server/Cargo.toml +++ b/crates/dtp-server/Cargo.toml @@ -12,6 +12,7 @@ anyhow.workspace = true sui-sdk.workspace = true clap.workspace = true colored.workspace = true +futures = "0.3.23" telemetry-subscribers.workspace = true # tracing.workspace = true diff --git a/crates/dtp-server/src/main.rs b/crates/dtp-server/src/main.rs index 8cd873d..ce8b3f1 100644 --- a/crates/dtp-server/src/main.rs +++ b/crates/dtp-server/src/main.rs @@ -5,7 +5,11 @@ use clap::*; use colored::Colorize; use std::path::PathBuf; -use telemetry_subscribers; +use telemetry_subscribers::TelemetryConfig; + +use futures::StreamExt; +use sui_sdk::rpc_types::SuiEventFilter; +use sui_sdk::SuiClient; #[allow(clippy::large_enum_variant)] #[derive(Parser)] @@ -28,8 +32,18 @@ impl Command { pub async fn execute(self) -> Result<(), anyhow::Error> { match self { Command::Localnet { path } => { - if let Some(x) = path { - println!("{}", x.into_os_string().into_string().unwrap()); + if let Some(_x) = path { + let sui = + SuiClient::new("http://0.0.0.0:9000", Some("ws://0.0.0.0:9000"), None) + .await?; + let mut subscribe_all = sui + .event_api() + .subscribe_event(SuiEventFilter::All(vec![])) + .await?; + loop { + println!("{:?}", subscribe_all.next().await); + } + //println!("{}", x.into_os_string().into_string().unwrap()); } else { println!("Path not provided"); } @@ -46,9 +60,7 @@ async fn main() { // TODO Socket for external dtp CLI binary (this is the server not the CLI!) // TODO Look into https://crates.io/crates/sentry-tracing for bail/panic logging. - let _guard = telemetry_subscribers::TelemetryConfig::new("dtp-server") - .with_env() - .init(); + let _guard = TelemetryConfig::new("dtp-server").with_env().init(); let cmd: Command = Command::parse();