-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2fa5558
commit 7601f09
Showing
59 changed files
with
3,318 additions
and
2,471 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use hc_zome_profiles_integrity::LinkTypes; | ||
use hdk::prelude::*; | ||
|
||
use crate::search::get_agent_profile; | ||
|
||
#[hdk_extern] | ||
pub fn link_agent_with_my_profile(agent_pub_key: AgentPubKey) -> ExternResult<()> { | ||
let my_profile_links = get_agent_profile(agent_info()?.agent_latest_pubkey)?; | ||
|
||
if my_profile_links.len() != 1 { | ||
return Err(wasm_error!(WasmErrorInner::Guest(format!( | ||
"Can't fetch my profile" | ||
)))); | ||
} | ||
|
||
let profile_link = my_profile_links[0].clone(); | ||
let Some(profile_hash) = profile_link.target.into_action_hash() else { | ||
return Err(wasm_error!(WasmErrorInner::Guest(format!( | ||
"Profile link does not have an ActionHash as its target" | ||
)))); | ||
}; | ||
|
||
create_link(agent_pub_key, profile_hash, LinkTypes::AgentToProfile, ())?; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use hdk::prelude::*; | ||
|
||
use hc_zome_profiles_integrity::*; | ||
|
||
#[hdk_extern] | ||
pub fn create_profile_claim(profile_claim: ProfileClaim) -> ExternResult<()> { | ||
create_relaxed(EntryTypes::ProfileClaim(profile_claim))?; | ||
|
||
Ok(()) | ||
} | ||
pub fn create_relaxed(entry_type: EntryTypes) -> ExternResult<()> { | ||
HDK.with(|h| { | ||
let index = ScopedEntryDefIndex::try_from(&entry_type)?; | ||
let vis = EntryVisibility::from(&entry_type); | ||
let entry = Entry::try_from(entry_type)?; | ||
|
||
h.borrow().create(CreateInput::new( | ||
index, | ||
vis, | ||
entry, | ||
// This is used to test many conductors thrashing creates between | ||
// each other so we want to avoid retries that make the test take | ||
// a long time. | ||
ChainTopOrdering::Relaxed, | ||
)) | ||
})?; | ||
|
||
Ok(()) | ||
} | ||
|
||
#[hdk_extern] | ||
pub fn query_my_profile_claims() -> ExternResult<Vec<Record>> { | ||
let filter = ChainQueryFilter::new() | ||
.entry_type(UnitEntryTypes::ProfileClaim.try_into()?) | ||
.include_entries(true) | ||
.action_type(ActionType::Create); | ||
let records = query(filter)?; | ||
|
||
Ok(records) | ||
} |
Oops, something went wrong.