Skip to content

Commit

Permalink
fix agent key init
Browse files Browse the repository at this point in the history
  • Loading branch information
matthme committed Nov 10, 2024
1 parent fbf9ac3 commit 96e273c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
16 changes: 1 addition & 15 deletions dnas/generic_dna/zomes/coordinator/generic_zome/src/api.rs
Original file line number Diff line number Diff line change
@@ -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::*;

Expand Down Expand Up @@ -904,20 +904,6 @@ fn linkable_hash_from_node_id(node_id: NodeId) -> ExternResult<AnyLinkableHash>
}
}

fn derive_link_tag(
input: Option<Vec<u8>>,
backlink_action_hash: Option<ActionHash>,
target_node_id: NodeId,
) -> ExternResult<LinkTag> {
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<Thing> {
let thing_entry = record
.entry()
Expand Down
19 changes: 17 additions & 2 deletions dnas/generic_dna/zomes/coordinator/generic_zome/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,29 @@ pub const SIMPLE_HOLOCHAIN_ALL_AGENTS: &str = "SIMPLE_HOLOCHAIN_ALL_AGENTS";
#[hdk_extern]
pub fn add_agent_to_anchor(_: ()) -> ExternResult<ActionHash> {
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<Vec<u8>>,
backlink_action_hash: Option<ActionHash>,
target_node_id: NodeId,
) -> ExternResult<LinkTag> {
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<SignedActionHashed>) {
Expand Down

0 comments on commit 96e273c

Please sign in to comment.