use std::env::current_dir;
use std::fs::create_dir_all;
#[allow(unused_imports)]
use nextgraph::local_broker::{
app_request, app_request_stream, init_local_broker, session_start, session_stop, user_connect,
user_disconnect, wallet_close, wallet_create_v0, wallet_get, wallet_get_file, wallet_import,
wallet_open_with_pazzle, wallet_open_with_pazzle_words, wallet_read_file, wallet_was_opened,
LocalBrokerConfig, SessionConfig,
};
#[async_std::main]
async fn main() -> std::io::Result<()> {
let mut current_path = current_dir()?;
current_path.push(".ng");
current_path.push("example");
create_dir_all(current_path.clone())?;
init_local_broker(Box::new(move || {
LocalBrokerConfig::BasePath(current_path.clone())
}))
.await;
let wallet_name = "9ivXl3TpgcQlDKTmR9NOipjhPWxQw6Yg5jkWBTlJuXw".to_string();
let wallet = wallet_get(&wallet_name).await?;
let opened_wallet = wallet_open_with_pazzle(
&wallet,
vec![110, 139, 115, 94, 9, 40, 74, 25, 52],
[2, 3, 2, 3],
)?;
let user_id = opened_wallet.personal_identity();
let _client = wallet_was_opened(opened_wallet).await?;
let _session = session_start(SessionConfig::new_save(&user_id, &wallet_name)).await?;
let status = user_connect(&user_id).await?;
println!("Connection was : {:?}", status[0]);
user_disconnect(&user_id).await?;
session_stop(&user_id).await?;
wallet_close(&wallet_name).await?;
Ok(())
}