-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds zome_call_typed method to app_ws (#184)
- Loading branch information
Showing
44 changed files
with
861 additions
and
911 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
use anyhow::Result; | ||
use holochain_types::{ | ||
dna::AgentPubKey, | ||
prelude::{FunctionName, ZomeName}, | ||
}; | ||
use hpos_hc_connect::{app_connection::CoreAppRoleName, hha_agent::HHAAgent, holo_config::Config}; | ||
use serde::{Deserialize, Serialize}; | ||
use std::process::{Command, Output}; | ||
|
||
#[derive(Debug, Deserialize)] | ||
#[allow(dead_code)] | ||
struct HostingCriteria { | ||
id: String, | ||
jurisdiction: String, | ||
kyc: String, | ||
} | ||
|
||
pub async fn get_jurisdiction() -> Result<String> { | ||
let output: Output = Command::new("hpos-holochain-client") | ||
.args(["--url=http://localhost/holochain-api/", "hosting-criteria"]) | ||
.output()?; | ||
|
||
let output_str = String::from_utf8_lossy(&output.stdout).to_string(); | ||
|
||
let hosting_criteria: HostingCriteria = serde_json::from_str(&output_str)?; | ||
|
||
Ok(hosting_criteria.jurisdiction) | ||
} | ||
|
||
pub async fn update_jurisdiction_if_changed( | ||
config: &Config, | ||
hbs_jurisdiction: String, | ||
) -> Result<()> { | ||
let mut agent = HHAAgent::spawn(Some(config)).await?; | ||
|
||
let host_pubkey = agent.pubkey().await?; | ||
|
||
let hha_jurisdiction: Option<String> = agent | ||
.app | ||
.zome_call_typed( | ||
CoreAppRoleName::HHA.into(), | ||
ZomeName::from("hha"), | ||
FunctionName::from("get_host_jurisdiction"), | ||
host_pubkey.clone(), | ||
) | ||
.await?; | ||
|
||
if hha_jurisdiction.is_none() || hha_jurisdiction.as_ref() != Some(&hbs_jurisdiction) { | ||
#[derive(Debug, Serialize)] | ||
pub struct SetHostJurisdictionInput { | ||
pub pubkey: AgentPubKey, | ||
pub jurisdiction: String, | ||
} | ||
|
||
let _: () = agent | ||
.app | ||
.zome_call_typed( | ||
CoreAppRoleName::HHA.into(), | ||
ZomeName::from("hha"), | ||
FunctionName::from("set_host_jurisdiction"), | ||
SetHostJurisdictionInput { | ||
pubkey: host_pubkey, | ||
jurisdiction: hbs_jurisdiction, | ||
}, | ||
) | ||
.await?; | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 10 additions & 11 deletions
21
crates/core_app_cli/src/actions/get_specific_happ_prefs.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.