Skip to content

Commit

Permalink
add endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
JettTech committed Sep 11, 2024
1 parent d926b30 commit db63999
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
26 changes: 26 additions & 0 deletions crates/core_app_cli/src/actions/list_all_happs.rs
Original file line number Diff line number Diff line change
@@ -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<PresentedHappBundle> = 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(())
}
1 change: 1 addition & 0 deletions crates/core_app_cli/src/actions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 8 additions & 4 deletions crates/core_app_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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?
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit db63999

Please sign in to comment.