Skip to content

Commit

Permalink
slight renaming and adding zome functions to get all original develop…
Browse files Browse the repository at this point in the history
…er collectives and original tools
  • Loading branch information
matthme committed Apr 22, 2024
1 parent 23cbde6 commit 899451f
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
use hdk::prelude::*;
use library_integrity::*;
#[hdk_extern]
pub fn get_all_developer_collectives(_: ()) -> ExternResult<Vec<Link>> {
pub fn get_all_developer_collective_links(_: ()) -> ExternResult<Vec<Link>> {
let path = Path::from("all_developer_collectives");
get_links(
GetLinksInputBuilder::try_new(path.path_entry_hash()?, LinkTypes::AllDeveloperCollectives)?
.build(),
)
}

#[hdk_extern]
pub fn get_all_original_developer_collectives(_: ()) -> ExternResult<Vec<Record>> {
let path = Path::from("all_developer_collectives");
let links = get_links(
GetLinksInputBuilder::try_new(path.path_entry_hash()?, LinkTypes::AllDeveloperCollectives)?
.build(),
)?;
let get_input: Vec<GetInput> = links
.into_iter()
.map(|link| {
Ok(GetInput::new(
link.target
.into_action_hash()
.ok_or(wasm_error!(WasmErrorInner::Guest(
"No action hash associated with link".to_string()
)))?
.into(),
GetOptions::default(),
))
})
.collect::<ExternResult<Vec<GetInput>>>()?;
let records = HDK.with(|hdk| hdk.borrow().get(get_input))?;
Ok(records.into_iter().flatten().collect())
}
30 changes: 29 additions & 1 deletion dnas/tools/zomes/coordinator/library/src/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ pub fn get_oldest_delete_for_tool(
Ok(deletes.first().cloned())
}
#[hdk_extern]
pub fn get_tools_for_developer_collective(
pub fn get_tool_links_for_developer_collective(
developer_collective_hash: ActionHash,
) -> ExternResult<Vec<Link>> {
get_links(
Expand All @@ -215,6 +215,34 @@ pub fn get_tools_for_developer_collective(
)
}
#[hdk_extern]
pub fn get_original_tools_for_developer_collective(
developer_collective_hash: ActionHash,
) -> ExternResult<Vec<Record>> {
let links = get_links(
GetLinksInputBuilder::try_new(
developer_collective_hash,
LinkTypes::DeveloperCollectiveToTools,
)?
.build(),
)?;
let get_input: Vec<GetInput> = links
.into_iter()
.map(|link| {
Ok(GetInput::new(
link.target
.into_action_hash()
.ok_or(wasm_error!(WasmErrorInner::Guest(
"No action hash associated with link".to_string()
)))?
.into(),
GetOptions::default(),
))
})
.collect::<ExternResult<Vec<GetInput>>>()?;
let records = HDK.with(|hdk| hdk.borrow().get(get_input))?;
Ok(records.into_iter().flatten().collect())
}
#[hdk_extern]
pub fn get_deleted_tools_for_developer_collective(
developer_collective_hash: ActionHash,
) -> ExternResult<Vec<(SignedActionHashed, Vec<SignedActionHashed>)>> {
Expand Down

0 comments on commit 899451f

Please sign in to comment.