From 96e273c6da2319d5660a27e06d045119ed1f8b1d Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 10 Nov 2024 21:01:59 +0100 Subject: [PATCH] fix agent key init --- .../zomes/coordinator/generic_zome/src/api.rs | 16 +--------------- .../zomes/coordinator/generic_zome/src/lib.rs | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/dnas/generic_dna/zomes/coordinator/generic_zome/src/api.rs b/dnas/generic_dna/zomes/coordinator/generic_zome/src/api.rs index 3a1c450..8315ebf 100644 --- a/dnas/generic_dna/zomes/coordinator/generic_zome/src/api.rs +++ b/dnas/generic_dna/zomes/coordinator/generic_zome/src/api.rs @@ -1,4 +1,4 @@ -use crate::{NodeLink, Signal, SignalKind, Thing}; +use crate::{derive_link_tag, NodeLink, Signal, SignalKind, Thing}; use generic_zome_integrity::*; use hdk::prelude::*; @@ -904,20 +904,6 @@ fn linkable_hash_from_node_id(node_id: NodeId) -> ExternResult } } -fn derive_link_tag( - input: Option>, - backlink_action_hash: Option, - target_node_id: NodeId, -) -> ExternResult { - let link_tag_content = LinkTagContent { - tag: input, - backlink_action_hash, - target_node_id, - }; - let serialized_content = serialize_link_tag(link_tag_content)?; - Ok(LinkTag::from(serialized_content)) -} - fn thing_record_to_thing(record: Record) -> ExternResult { let thing_entry = record .entry() diff --git a/dnas/generic_dna/zomes/coordinator/generic_zome/src/lib.rs b/dnas/generic_dna/zomes/coordinator/generic_zome/src/lib.rs index 873a550..8ad17b5 100644 --- a/dnas/generic_dna/zomes/coordinator/generic_zome/src/lib.rs +++ b/dnas/generic_dna/zomes/coordinator/generic_zome/src/lib.rs @@ -106,14 +106,29 @@ pub const SIMPLE_HOLOCHAIN_ALL_AGENTS: &str = "SIMPLE_HOLOCHAIN_ALL_AGENTS"; #[hdk_extern] pub fn add_agent_to_anchor(_: ()) -> ExternResult { let path = Path::from(SIMPLE_HOLOCHAIN_ALL_AGENTS); + let my_agent_pubkey = agent_info()?.agent_initial_pubkey; create_link( path.path_entry_hash()?, - agent_info()?.agent_initial_pubkey, + my_agent_pubkey.clone(), LinkTypes::ToAgent, - (), + derive_link_tag(None, None, NodeId::Agent(my_agent_pubkey))?, ) } +pub fn derive_link_tag( + input: Option>, + backlink_action_hash: Option, + target_node_id: NodeId, +) -> ExternResult { + let link_tag_content = LinkTagContent { + tag: input, + backlink_action_hash, + target_node_id, + }; + let serialized_content = serialize_link_tag(link_tag_content)?; + Ok(LinkTag::from(serialized_content)) +} + // /// Whenever an action is committed, we emit a signal to the UI elements to reactively update them // #[hdk_extern(infallible)] // pub fn post_commit(committed_actions: Vec) {