Skip to content

Commit c9d8da2

Browse files
authored
Merge branch 'main' into feature-add-agent-pref-endpoint
2 parents 479d496 + a831418 commit c9d8da2

File tree

9 files changed

+327
-10
lines changed

9 files changed

+327
-10
lines changed

crates/core_app_cli/README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# core_app_cli
22

3+
>Note: In holoports, this command can be used with the command: `holo-host <SUBCOMMAND>`
4+
35
```
46
core_app_cli 0.1.1
57
@@ -11,13 +13,19 @@ FLAGS:
1113
-V, --version Prints version information
1214
1315
SUBCOMMANDS:
14-
b Gets your balance, fees, promised and available Fuel
15-
happs List all happs published by me
16-
help Prints this message or the help of the given subcommand(s)
17-
hosts List all hosts for a happ by `happ_id``
18-
pay Pay your first pending invoice
19-
pr Gets profile details
20-
prefs Fetch the happ preferences associated with a `pref_hash`
21-
set-prefs Set new happ preferences
22-
tx Gets the list of all your transactions
16+
all-happs List all happs registered in hha
17+
b Gets your balance, fees, promised and available Fuel
18+
enable-happ Enable hosting for a specific happ
19+
help Prints this message or the help of the given subcommand(s)
20+
host-prefs Fetch the happ preference hash for a specific host for a specific happ
21+
hosts List all hosts for a happ by `happ_id``
22+
jurisdiction List the jurisdiction for the provided agent
23+
my-happs List all happs published by me
24+
pay Pay your first pending invoice
25+
pr Gets profile details
26+
pref-details Fetch the happ preferences associated with a happ preference hash
27+
publisher-happs List all happs by provided publisher
28+
set-prefs Set new happ preferences
29+
tx Gets the list of all your transactions
2330
```
31+

crates/core_app_cli/src/actions/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ pub mod list_all_tx;
1313
pub mod pay_invoices;
1414
pub mod profile;
1515
pub mod set_host_happ_prefs;
16+
pub mod summary;
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
use anyhow::Result;
2+
use holochain_types::dna::AgentPubKey;
3+
use holochain_types::prelude::{FunctionName, ZomeName};
4+
use hpos_hc_connect::app_connection::CoreAppRoleName;
5+
use hpos_hc_connect::hha_agent::CoreAppAgent;
6+
use hpos_hc_connect::holofuel_types::MigrationCloseStateV1Handler;
7+
8+
pub async fn get_my_summary() -> Result<()> {
9+
let mut agent = CoreAppAgent::spawn(None).await?;
10+
11+
let summary: MigrationCloseStateV1Handler = agent
12+
.app
13+
.zome_call_typed(
14+
CoreAppRoleName::Holofuel.into(),
15+
ZomeName::from("transactor"),
16+
FunctionName::from("get_my_summary"),
17+
(),
18+
)
19+
.await?;
20+
21+
display(summary);
22+
Ok(())
23+
}
24+
25+
pub async fn get_agent_summary(pub_key: AgentPubKey) -> Result<()> {
26+
let mut agent = CoreAppAgent::spawn(None).await?;
27+
28+
let summary: MigrationCloseStateV1Handler = agent
29+
.app
30+
.zome_call_typed(
31+
CoreAppRoleName::Holofuel.into(),
32+
ZomeName::from("transactor"),
33+
FunctionName::from("get_agent_summary"),
34+
pub_key,
35+
)
36+
.await?;
37+
display(summary);
38+
Ok(())
39+
}
40+
41+
fn display(summary: MigrationCloseStateV1Handler) {
42+
println!("===================");
43+
println!("Your Summary: ");
44+
println!("multi_sig_authorizer: {:?}", summary.multi_sig_authorizer);
45+
println!("reserve_setting: {:?}", summary.reserve_setting);
46+
println!("reserve_sale_price: {:?}", summary.reserve_sale_price);
47+
println!("tx_parked_links: {:?}", summary.tx_parked_links);
48+
println!("cs_txs: {:?}", summary.cs_txs);
49+
println!(
50+
"incomplete_invoice_txs: {:?}",
51+
summary.incomplete_invoice_txs
52+
);
53+
println!(
54+
"incomplete_promise_txs: {:?}",
55+
summary.incomplete_promise_txs
56+
);
57+
println!("Number of cs tx: {:?}", summary.cs_txs.len());
58+
println!(
59+
"Number of incomplete invoice: {:?}",
60+
summary.incomplete_invoice_txs.len()
61+
);
62+
println!(
63+
"Number of incomplete promises: {:?}",
64+
summary.incomplete_promise_txs.len()
65+
);
66+
println!("Number of declined: {:?}", summary.number_of_declined);
67+
println!("opening_balance: {:?}", summary.opening_balance);
68+
println!("closing_balance: {:?}", summary.closing_balance);
69+
println!("===================");
70+
}

crates/core_app_cli/src/main.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use anyhow::Result;
2+
use holochain_types::dna::AgentPubKeyB64;
23
use structopt::StructOpt;
34

45
#[derive(Debug, StructOpt)]
@@ -71,6 +72,12 @@ pub enum Opt {
7172
#[structopt(name = "max-time-ms")]
7273
max_time_before_invoice_ms: String,
7374
},
75+
/// Get My Summary
76+
#[structopt(name = "gms")]
77+
GetMySummary,
78+
/// Get Summary by providing an agent public key
79+
#[structopt(name = "gas")]
80+
GetAgentSummary { pub_key: String },
7481
}
7582
impl Opt {
7683
/// Run this command
@@ -135,6 +142,12 @@ impl Opt {
135142
)
136143
.await?
137144
}
145+
Opt::GetMySummary => core_app_cli::summary::get_my_summary().await?,
146+
Opt::GetAgentSummary { pub_key } => {
147+
let pub_key = AgentPubKeyB64::from_b64_str(&pub_key)
148+
.expect("Failed to serialize string into AgentPubKey");
149+
core_app_cli::summary::get_agent_summary(pub_key.into()).await?
150+
}
138151
}
139152
Ok(())
140153
}

crates/holofuel_cli/src/actions/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ pub mod ledger;
44
pub mod pending;
55
pub mod profile;
66
pub mod reserve;
7+
pub mod summary;
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
use anyhow::Result;
2+
use holochain_types::dna::AgentPubKey;
3+
use holochain_types::prelude::{FunctionName, ZomeName};
4+
use hpos_hc_connect::app_connection::CoreAppRoleName;
5+
use hpos_hc_connect::hf_agent::HfAgent;
6+
use hpos_hc_connect::holofuel_types::MigrationCloseStateV1Handler;
7+
8+
pub async fn get_my_summary() -> Result<()> {
9+
let mut agent = HfAgent::spawn(None).await?;
10+
11+
let summary: MigrationCloseStateV1Handler = agent
12+
.app
13+
.zome_call_typed(
14+
CoreAppRoleName::Holofuel.into(),
15+
ZomeName::from("transactor"),
16+
FunctionName::from("get_my_summary"),
17+
(),
18+
)
19+
.await?;
20+
21+
display(summary);
22+
Ok(())
23+
}
24+
25+
pub async fn get_agent_summary(pub_key: AgentPubKey) -> Result<()> {
26+
let mut agent = HfAgent::spawn(None).await?;
27+
28+
let summary: MigrationCloseStateV1Handler = agent
29+
.app
30+
.zome_call_typed(
31+
CoreAppRoleName::Holofuel.into(),
32+
ZomeName::from("transactor"),
33+
FunctionName::from("get_agent_summary"),
34+
pub_key,
35+
)
36+
.await?;
37+
display(summary);
38+
Ok(())
39+
}
40+
41+
fn display(summary: MigrationCloseStateV1Handler) {
42+
println!("===================");
43+
println!("Your Summary: ");
44+
println!("multi_sig_authorizer: {:?}", summary.multi_sig_authorizer);
45+
println!("reserve_setting: {:?}", summary.reserve_setting);
46+
println!("reserve_sale_price: {:?}", summary.reserve_sale_price);
47+
println!("tx_parked_links: {:?}", summary.tx_parked_links);
48+
println!("cs_txs: {:?}", summary.cs_txs);
49+
println!(
50+
"incomplete_invoice_txs: {:?}",
51+
summary.incomplete_invoice_txs
52+
);
53+
println!(
54+
"incomplete_promise_txs: {:?}",
55+
summary.incomplete_promise_txs
56+
);
57+
println!("Number of cs tx: {:?}", summary.cs_txs.len());
58+
println!(
59+
"Number of incomplete invoice: {:?}",
60+
summary.incomplete_invoice_txs.len()
61+
);
62+
println!(
63+
"Number of incomplete promises: {:?}",
64+
summary.incomplete_promise_txs.len()
65+
);
66+
println!("Number of declined: {:?}", summary.number_of_declined);
67+
println!("opening_balance: {:?}", summary.opening_balance);
68+
println!("closing_balance: {:?}", summary.closing_balance);
69+
println!("===================");
70+
}

crates/holofuel_cli/src/main.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use anyhow::Result;
2+
use holochain_types::dna::AgentPubKeyB64;
23
use structopt::StructOpt;
34

45
#[derive(Debug, StructOpt)]
@@ -24,7 +25,14 @@ pub enum Opt {
2425
/// Get this reserve accounts sales price
2526
#[structopt(name = "rsp")]
2627
ReserveSalePrice,
28+
/// Get My Summary
29+
#[structopt(name = "gms")]
30+
GetMySummary,
31+
/// Get Summary by providing an agent public key
32+
#[structopt(name = "gas")]
33+
GetAgentSummary { pub_key: String },
2734
}
35+
2836
impl Opt {
2937
/// Run this command
3038
pub async fn run(self) -> Result<()> {
@@ -36,6 +44,12 @@ impl Opt {
3644
Opt::Profile => hf::actions::profile::get().await?,
3745
Opt::ReserveSetting => hf::actions::reserve::get_setting().await?,
3846
Opt::ReserveSalePrice => hf::actions::reserve::get_sale_price().await?,
47+
Opt::GetMySummary => hf::actions::summary::get_my_summary().await?,
48+
Opt::GetAgentSummary { pub_key } => {
49+
let pub_key = AgentPubKeyB64::from_b64_str(&pub_key)
50+
.expect("Failed to serialize string into AgentPubKey");
51+
hf::actions::summary::get_agent_summary(pub_key.into()).await?
52+
}
3953
}
4054
Ok(())
4155
}

crates/hpos_connect_hc/src/hf_agent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl HfAgent {
2323
let app_file = HappsFile::load_happ_file_from_env(config)?;
2424
let holofuel = app_file
2525
.holofuel()
26-
.ok_or(anyhow!("There's no core-app defined in a happs file"))?;
26+
.ok_or(anyhow!("There's no holofuel app defined in a happs file"))?;
2727

2828
// connect to lair
2929
let passphrase = sodoken::BufRead::from(default_password()?.as_bytes().to_vec());

0 commit comments

Comments
 (0)