-
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
a92470d
commit 4f7580a
Showing
16 changed files
with
370 additions
and
288 deletions.
There are no files selected for viewing
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,44 @@ | ||
use hc_zome_profiles_integrity::LinkTypes; | ||
use hdk::prelude::*; | ||
|
||
#[hdk_extern] | ||
pub fn link_my_agent_to_profile(profile_hash: ActionHash) -> ExternResult<()> { | ||
let my_pub_key = agent_info()?.agent_latest_pubkey; | ||
create_link_relaxed( | ||
my_pub_key.clone(), | ||
profile_hash.clone(), | ||
LinkTypes::AgentToProfile, | ||
(), | ||
)?; | ||
create_link_relaxed(profile_hash, my_pub_key, LinkTypes::ProfileToAgent, ())?; | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn create_link_relaxed<T, E>( | ||
base_address: impl Into<AnyLinkableHash>, | ||
target_address: impl Into<AnyLinkableHash>, | ||
link_type: T, | ||
tag: impl Into<LinkTag>, | ||
) -> ExternResult<()> | ||
where | ||
ScopedLinkType: TryFrom<T, Error = E>, | ||
WasmError: From<E>, | ||
{ | ||
let ScopedLinkType { | ||
zome_index, | ||
zome_type: link_type, | ||
} = link_type.try_into()?; | ||
HDK.with(|h| { | ||
h.borrow().create_link(CreateLinkInput::new( | ||
base_address.into(), | ||
target_address.into(), | ||
zome_index, | ||
link_type, | ||
tag.into(), | ||
ChainTopOrdering::Relaxed, | ||
)) | ||
})?; | ||
|
||
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
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
Oops, something went wrong.