From f60c7cec81aeb786507ad49f14de97677207397d Mon Sep 17 00:00:00 2001 From: SHAcollision Date: Tue, 21 Jan 2025 19:23:41 -0400 Subject: [PATCH] chore: move create use example to specs crate --- examples/new_homeserver_user.rs | 52 --------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 examples/new_homeserver_user.rs diff --git a/examples/new_homeserver_user.rs b/examples/new_homeserver_user.rs deleted file mode 100644 index 52405561..00000000 --- a/examples/new_homeserver_user.rs +++ /dev/null @@ -1,52 +0,0 @@ -use anyhow::Result; -use log::info; -use pubky::Client; -use pubky_app_specs::{traits::HasPath, PubkyAppUser, PubkyAppUserLink, PROTOCOL}; -use pubky_common::crypto::{Keypair, PublicKey}; -use pubky_nexus::{setup, Config}; - -#[tokio::main] -async fn main() -> Result<()> { - let config = Config::from_env(); - setup(&config).await; - - // Initialize the Client based on configuration - let client = match config.testnet { - true => Client::testnet()?, - false => Client::new()?, - }; - - // Generate a random keypair - let keypair = Keypair::random(); - let pk = keypair.public_key().to_z32(); - info!("The pubky id is: {}", pk); - - // Convert the homeserver from the config into a PublicKey - let homeserver = PublicKey::try_from(config.homeserver.as_str())?; - - // Perform signup - client.signup(&keypair, &homeserver).await?; - - // Create a new profile - let user = PubkyAppUser::new( - "Satoshi Nakamoto".to_string(), - Some("This is an example bio".to_string()), - Some("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdjiO4O+w8ABL0CPPcYQa4AAAAASUVORK5CYII=".to_string()), - Some(vec![PubkyAppUserLink { - title: "My Website".to_string(), - url: "https://example.com".to_string(), - }]), - Some("Running Bitcoin".to_string()), - ); - - // Put some content into the Pubky homeserver - let url = format!( - "{protocol}{pk}{path}", - protocol = PROTOCOL, - pk = pk, - path = user.create_path() - ); - client.put(url.as_str()).json(&user).send().await?; - - Ok(()) -}