Skip to content

Commit

Permalink
(#12) dtp-server websocket events now working with 0.19 localnet
Browse files Browse the repository at this point in the history
  • Loading branch information
mario4tier committed Dec 25, 2022
1 parent 23ca4dc commit 99c522a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/dtp-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 18 additions & 6 deletions crates/dtp-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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");
}
Expand All @@ -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();

Expand Down

0 comments on commit 99c522a

Please sign in to comment.