From db639996e2936d5939f5fa6104e5d6609b18e668 Mon Sep 17 00:00:00 2001 From: JettTech Date: Wed, 11 Sep 2024 01:41:56 -0500 Subject: [PATCH] add endpoint --- .../src/actions/list_all_happs.rs | 26 +++++++++++++++++++ crates/core_app_cli/src/actions/mod.rs | 1 + crates/core_app_cli/src/main.rs | 12 ++++++--- 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 crates/core_app_cli/src/actions/list_all_happs.rs diff --git a/crates/core_app_cli/src/actions/list_all_happs.rs b/crates/core_app_cli/src/actions/list_all_happs.rs new file mode 100644 index 0000000..325254e --- /dev/null +++ b/crates/core_app_cli/src/actions/list_all_happs.rs @@ -0,0 +1,26 @@ +use anyhow::Result; +use holochain_types::prelude::{FunctionName, ZomeName}; +use hpos_hc_connect::{ + app_connection::CoreAppRoleName, hha_agent::CoreAppAgent, hha_types::PresentedHappBundle, +}; + +pub async fn get() -> Result<()> { + let mut agent = CoreAppAgent::spawn(None).await?; + + let happs: Vec = agent + .app + .zome_call_typed( + CoreAppRoleName::HHA.into(), + ZomeName::from("hha"), + FunctionName::from("get_happs"), + (), + ) + .await?; + + println!("==================="); + println!("All Holo Happs: "); + println!("{:?}", happs); + println!("==================="); + + Ok(()) +} diff --git a/crates/core_app_cli/src/actions/mod.rs b/crates/core_app_cli/src/actions/mod.rs index 85d858e..eed54d4 100644 --- a/crates/core_app_cli/src/actions/mod.rs +++ b/crates/core_app_cli/src/actions/mod.rs @@ -5,6 +5,7 @@ pub mod get_happ_hosts; pub mod get_happ_pref_hash_for_host; pub mod get_specific_happ_prefs; pub mod ledger; +pub mod list_all_happs; pub mod list_all_my_happs; pub mod list_all_tx; pub mod pay_invoices; diff --git a/crates/core_app_cli/src/main.rs b/crates/core_app_cli/src/main.rs index 3484ccc..4573be2 100644 --- a/crates/core_app_cli/src/main.rs +++ b/crates/core_app_cli/src/main.rs @@ -16,9 +16,12 @@ pub enum Opt { /// Pay your first pending invoice #[structopt(name = "pay")] PayInvoice, + /// List all happs registered in hha + #[structopt(name = "all-happs")] + AllHapps, /// List all happs published by me #[structopt(name = "my-happs")] - Happs, + HappsByMe, /// List all happs by provided publisher #[structopt(name = "publisher-happs")] GetHappsForPublisher { publisher_pubkey: String }, @@ -63,7 +66,8 @@ impl Opt { Opt::Ledger => core_app_cli::ledger::get().await?, Opt::Transactions => core_app_cli::list_all_tx::get().await?, Opt::PayInvoice => core_app_cli::pay_invoices::get().await?, - Opt::Happs => core_app_cli::list_all_my_happs::get().await?, + Opt::AllHapps => core_app_cli::list_all_happs::get().await?, + Opt::HappsByMe => core_app_cli::list_all_my_happs::get().await?, Opt::Hosts { happ_id } => core_app_cli::get_happ_hosts::get(happ_id).await?, Opt::GetPreferenceByHash { pref_hash } => { core_app_cli::get_specific_happ_prefs::get(pref_hash).await? @@ -78,7 +82,7 @@ impl Opt { core_app_cli::enable_happ_for_host::get(happ_id, host_id).await? } Opt::GetHappPrefHashForHost { happ_id, host_id } => { - core_app_cli::get_happ_pref_hash_for_host::get(happ_id, host_id).await? + core_app_cli::get_happ_pref_for_host::get(happ_id, host_id).await? } Opt::SetHappPreferences { happ_id, @@ -89,7 +93,7 @@ impl Opt { max_time_before_invoice_sec, max_time_before_invoice_ms, } => { - core_app_cli::set_host_happ_prefs::get( + core_app_cli::set_happ_prefs::get( happ_id, price_compute, price_bandwidth,