Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
matthme committed Nov 10, 2024
1 parent f9c24f8 commit cb39cae
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
10 changes: 5 additions & 5 deletions dnas/generic_dna/zomes/coordinator/generic_zome/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ pub fn delete_links_from_node(input: CreateOrDeleteLinksInput) -> ExternResult<(
let links_deleted = delete_links_from_node_inner(input)?;

// Emit signals about deleted links to the frontend
emit_signal(Signal::Local(SignalKind::LinksCreated {
emit_signal(Signal::Local(SignalKind::LinksDeleted {
links: links_deleted,
}))?;

Expand Down Expand Up @@ -761,7 +761,7 @@ fn create_link_from_node_by_id(
let ah = create_link(
base.clone(),
path_entry_hash,
LinkTypes::ToAgent,
LinkTypes::ToAnchor,
derive_link_tag(link.tag.clone(), None, link.node_id.clone())?,
)?;
Ok((
Expand Down Expand Up @@ -801,7 +801,7 @@ fn create_link_from_node_by_id(
let ah = create_link(
base.clone(),
path_entry_hash,
LinkTypes::ToAgent,
LinkTypes::ToAnchor,
derive_link_tag(
link.tag.clone(),
Some(backlink_action_hash.clone()),
Expand Down Expand Up @@ -830,7 +830,7 @@ fn create_link_from_node_by_id(
let ah = create_link(
base.clone(),
action_hash,
LinkTypes::ToAgent,
LinkTypes::ToThing,
derive_link_tag(link.tag.clone(), None, link.node_id.clone())?,
)?;
Ok((
Expand Down Expand Up @@ -870,7 +870,7 @@ fn create_link_from_node_by_id(
let ah = create_link(
base.clone(),
action_hash,
LinkTypes::ToAgent,
LinkTypes::ToThing,
derive_link_tag(
link.tag.clone(),
Some(backlink_action_hash.clone()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub fn validate_create_link_to_anchor(
) -> ExternResult<ValidateCallbackResult> {
// Check the entry type for the given action hash
target_address
.into_action_hash()
.into_entry_hash()
.ok_or(wasm_error!(WasmErrorInner::Guest(
"Link target is not an entry hash".to_string()
)))?;
Expand Down
14 changes: 11 additions & 3 deletions lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,11 @@ export class SimpleHolochain {
return nodeStore.subscribe(cb);
}


get myPubkey() {
return this.client.myPubKey
}

/**
* Updates the contents of the node stores. If allowDelete is false (default)
* then existing linked node ids will not get deleted. This is to prevent
Expand Down Expand Up @@ -831,18 +836,21 @@ function areNodeAndTagEqual(
nodeId_b: NodeIdAndTag
): boolean {
if (nodeId_a.node_id.type !== nodeId_b.node_id.type) return false;
const bothUint8Array = !!nodeId_a.tag && !!nodeId_b.tag;
const tagsEqual = bothUint8Array ? areUint8ArrayEqual(nodeId_a.tag, nodeId_b.tag) : !nodeId_a.tag && !nodeId_b.tag;

if (nodeId_a.node_id.type === "Agent" && nodeId_b.node_id.type === "Agent")
return (
encodeHashToBase64(nodeId_a.node_id.id) ===
encodeHashToBase64(nodeId_b.node_id.id) && areUint8ArrayEqual(nodeId_a.tag, nodeId_b.tag)
encodeHashToBase64(nodeId_b.node_id.id) && tagsEqual
);
if (nodeId_a.node_id.type === "Thing" && nodeId_b.node_id.type === "Thing")
return (
encodeHashToBase64(nodeId_a.node_id.id) ===
encodeHashToBase64(nodeId_b.node_id.id) && areUint8ArrayEqual(nodeId_a.tag, nodeId_b.tag)
encodeHashToBase64(nodeId_b.node_id.id) && tagsEqual
);
if (nodeId_a.node_id.type === "Anchor" && nodeId_b.node_id.type === "Anchor")
return nodeId_a.node_id.id === nodeId_b.node_id.id && areUint8ArrayEqual(nodeId_a.tag, nodeId_b.tag);
return nodeId_a.node_id.id === nodeId_b.node_id.id && tagsEqual;
return false;
}

Expand Down

0 comments on commit cb39cae

Please sign in to comment.