|
| 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 | +} |
0 commit comments