Skip to content

Commit

Permalink
upgrade to holochain 0_3
Browse files Browse the repository at this point in the history
  • Loading branch information
LeosPrograms committed Apr 1, 2024
1 parent b36af0e commit f7a4410
Show file tree
Hide file tree
Showing 30 changed files with 961 additions and 1,112 deletions.
1,156 changes: 456 additions & 700 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ members = ["dnas/*/zomes/coordinator/*", "dnas/*/zomes/integrity/*"]
resolver = "2"

[workspace.dependencies]
hdi = "0.3.1"
hdk = "0.2.1"
hdi = "0.4.0-beta-dev.30"
hdk = "0.3.0-beta-dev.34"
serde = "1"

zome_utils = { git = "https://github.com/ddd-mtl/zome-utils", branch = "hdk-3.0" }

[workspace.dependencies.converge]
path = "dnas/converge/zomes/coordinator/converge"

Expand Down
2 changes: 2 additions & 0 deletions dnas/converge/zomes/coordinator/converge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ hdk = { workspace = true }

serde = { workspace = true }

zome_utils.workspace = true

converge_integrity = { workspace = true }
4 changes: 3 additions & 1 deletion dnas/converge/zomes/coordinator/converge/src/all_criteria.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use hdk::prelude::*;
use converge_integrity::*;
use zome_utils::*;

#[hdk_extern]
pub fn get_all_criteria(_: ()) -> ExternResult<Vec<Record>> {
let path = Path::from("all_criteria");
let links = get_links(path.path_entry_hash()?, LinkTypes::AllCriteria, None)?;
let links = get_links(link_input(path.path_entry_hash()?, LinkTypes::AllCriteria, None))?;
let get_input: Vec<GetInput> = links
.into_iter()
.map(|link| GetInput::new(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use hdk::prelude::*;
use converge_integrity::*;
use zome_utils::*;

#[hdk_extern]
pub fn get_all_deliberations(_: ()) -> ExternResult<Vec<Record>> {
let path = Path::from("all_deliberations");
let links = get_links(path.path_entry_hash()?, LinkTypes::AllDeliberations, None)?;
let links = get_links(link_input(path.path_entry_hash()?, LinkTypes::AllDeliberations, None))?;
let get_input: Vec<GetInput> = links
.into_iter()
.map(|link| GetInput::new(
Expand All @@ -23,7 +25,7 @@ pub fn get_all_deliberations(_: ()) -> ExternResult<Vec<Record>> {
#[hdk_extern]
pub fn search_all_deliberations(query: String) -> ExternResult<Vec<ActionHash>> {
let path = Path::from("all_deliberations");
let links = get_links(path.path_entry_hash()?, LinkTypes::AllDeliberations, None)?;
let links = get_links(link_input(path.path_entry_hash()?, LinkTypes::AllDeliberations, None))?;
let get_input: Vec<GetInput> = links
.into_iter()
.map(|link| GetInput::new(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use hdk::prelude::*;
use converge_integrity::*;
use zome_utils::*;

#[hdk_extern]
pub fn get_all_proposals(_: ()) -> ExternResult<Vec<Record>> {
let path = Path::from("all_proposals");
let links = get_links(path.path_entry_hash()?, LinkTypes::AllProposals, None)?;
let links = get_links(link_input(path.path_entry_hash()?, LinkTypes::AllProposals, None))?;
let get_input: Vec<GetInput> = links
.into_iter()
.map(|link| GetInput::new(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use hdk::prelude::*;
use converge_integrity::*;
use zome_utils::*;

#[derive(Serialize, Deserialize, Debug)]
pub struct CreateCriterionCommentInput {
pub criterion_comment: CriterionComment,
Expand Down Expand Up @@ -30,11 +32,11 @@ pub fn create_criterion_comment(
pub fn get_criterion_comment(
original_criterion_comment_hash: ActionHash,
) -> ExternResult<Option<Record>> {
let links = get_links(
let links = get_links(link_input(
original_criterion_comment_hash.clone(),
LinkTypes::CriterionCommentUpdates,
None,
)?;
))?;
let latest_link = links
.into_iter()
.max_by(|link_a, link_b| link_a.timestamp.cmp(&link_b.timestamp));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use hdk::prelude::*;
use converge_integrity::*;
use zome_utils::*;

use std::collections::HashSet;
#[derive(Serialize, Deserialize, Debug)]
pub struct AddCriterionForCriterionInput {
Expand All @@ -22,7 +24,7 @@ pub fn add_criterion_for_criterion(
pub fn get_criteria_for_criterion(
criterion_hash: ActionHash,
) -> ExternResult<Vec<Record>> {
let links = get_links(criterion_hash, LinkTypes::CriterionToCriteria, None)?;
let links = get_links(link_input(criterion_hash, LinkTypes::CriterionToCriteria, None))?;
let mut seen_targets = HashSet::new();
let get_input: Vec<GetInput> = links
.into_iter()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use hdk::prelude::*;
use converge_integrity::*;
use zome_utils::*;

#[derive(Serialize, Deserialize, Debug)]
pub struct AddCriterionCommentForCriterionInput {
pub base_criterion_hash: ActionHash,
Expand All @@ -21,11 +23,11 @@ pub fn add_criterion_comment_for_criterion(
pub fn get_criterion_comments_for_criterion(
criterion_hash: ActionHash,
) -> ExternResult<Vec<Record>> {
let links = get_links(
let links = get_links(link_input(
criterion_hash,
LinkTypes::CriterionToCriterionComments,
None,
)?;
))?;
let get_input: Vec<GetInput> = links
.into_iter()
.map(|link| GetInput::new(
Expand Down Expand Up @@ -54,11 +56,11 @@ pub struct RemoveCriterionCommentForCriterionInput {
pub fn remove_criterion_comment_for_criterion(
input: RemoveCriterionCommentForCriterionInput,
) -> ExternResult<()> {
let links = get_links(
let links = get_links(link_input(
input.base_criterion_hash.clone(),
LinkTypes::CriterionToCriterionComments,
None,
)?;
))?;
for link in links {
if ActionHash::try_from(link.target.clone())
.map_err(|_| {
Expand Down
6 changes: 4 additions & 2 deletions dnas/converge/zomes/coordinator/converge/src/deliberation.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use hdk::prelude::*;
use converge_integrity::*;
use zome_utils::*;

#[hdk_extern]
pub fn create_deliberation(deliberation: Deliberation) -> ExternResult<Record> {
debug!("create_deliberation: {:?}", deliberation);
Expand All @@ -25,11 +27,11 @@ pub fn create_deliberation(deliberation: Deliberation) -> ExternResult<Record> {
pub fn get_deliberation(
original_deliberation_hash: ActionHash,
) -> ExternResult<Option<Record>> {
let links = get_links(
let links = get_links(link_input(
original_deliberation_hash.clone(),
LinkTypes::DeliberationUpdates,
None,
)?;
))?;
let latest_link = links
.into_iter()
.max_by(|link_a, link_b| link_a.timestamp.cmp(&link_b.timestamp));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use hdk::prelude::*;
use converge_integrity::*;
use zome_utils::*;

#[derive(Serialize, Deserialize, Debug)]
pub struct AddCriterionForDeliberationInput {
pub base_deliberation_hash: ActionHash,
Expand Down Expand Up @@ -27,7 +29,7 @@ pub fn add_criterion_for_deliberation(
pub fn get_criteria_for_deliberation(
deliberation_hash: ActionHash,
) -> ExternResult<Vec<Record>> {
let links = get_links(deliberation_hash, LinkTypes::DeliberationToCriteria, None)?;
let links = get_links(link_input(deliberation_hash, LinkTypes::DeliberationToCriteria, None))?;
let get_input: Vec<GetInput> = links
.into_iter()
.map(|link| GetInput::new(
Expand All @@ -51,7 +53,7 @@ pub fn get_criteria_for_deliberation(
pub fn get_deliberations_for_criterion(
criterion_hash: ActionHash,
) -> ExternResult<Vec<Record>> {
let links = get_links(criterion_hash, LinkTypes::CriterionToDeliberations, None)?;
let links = get_links(link_input(criterion_hash, LinkTypes::CriterionToDeliberations, None))?;
let get_input: Vec<GetInput> = links
.into_iter()
.map(|link| GetInput::new(
Expand Down Expand Up @@ -80,11 +82,11 @@ pub struct RemoveCriterionForDeliberationInput {
pub fn remove_criterion_for_deliberation(
input: RemoveCriterionForDeliberationInput,
) -> ExternResult<()> {
let links = get_links(
let links = get_links(link_input(
input.base_deliberation_hash.clone(),
LinkTypes::DeliberationToCriteria,
None,
)?;
))?;
for link in links {
if ActionHash::try_from(link.target.clone())
.map_err(|_| {
Expand All @@ -96,11 +98,11 @@ pub fn remove_criterion_for_deliberation(
delete_link(link.create_link_hash)?;
}
}
let links = get_links(
let links = get_links(link_input(
input.target_criterion_hash.clone(),
LinkTypes::CriterionToDeliberations,
None,
)?;
))?;
for link in links {
if ActionHash::try_from(link.target.clone())
.map_err(|_| {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use hdk::prelude::*;
use converge_integrity::*;
use zome_utils::*;

#[derive(Serialize, Deserialize, Debug)]
pub struct AddProposalForDeliberationInput {
pub base_deliberation_hash: ActionHash,
Expand Down Expand Up @@ -27,7 +29,7 @@ pub fn add_proposal_for_deliberation(
pub fn get_proposals_for_deliberation(
deliberation_hash: ActionHash,
) -> ExternResult<Vec<Record>> {
let links = get_links(deliberation_hash, LinkTypes::DeliberationToProposals, None)?;
let links = get_links(link_input(deliberation_hash, LinkTypes::DeliberationToProposals, None))?;
let get_input: Vec<GetInput> = links
.into_iter()
.map(|link| GetInput::new(
Expand All @@ -51,7 +53,7 @@ pub fn get_proposals_for_deliberation(
pub fn get_deliberations_for_proposal(
proposal_hash: ActionHash,
) -> ExternResult<Vec<Record>> {
let links = get_links(proposal_hash, LinkTypes::ProposalToDeliberations, None)?;
let links = get_links(link_input(proposal_hash, LinkTypes::ProposalToDeliberations, None))?;
let get_input: Vec<GetInput> = links
.into_iter()
.map(|link| GetInput::new(
Expand Down Expand Up @@ -80,11 +82,11 @@ pub struct RemoveProposalForDeliberationInput {
pub fn remove_proposal_for_deliberation(
input: RemoveProposalForDeliberationInput,
) -> ExternResult<()> {
let links = get_links(
let links = get_links(link_input(
input.base_deliberation_hash.clone(),
LinkTypes::DeliberationToProposals,
None,
)?;
))?;
for link in links {
if ActionHash::try_from(link.target.clone())
.map_err(|_| {
Expand All @@ -96,11 +98,11 @@ pub fn remove_proposal_for_deliberation(
delete_link(link.create_link_hash)?;
}
}
let links = get_links(
let links = get_links(link_input(
input.target_proposal_hash.clone(),
LinkTypes::ProposalToDeliberations,
None,
)?;
))?;
for link in links {
if ActionHash::try_from(link.target.clone())
.map_err(|_| {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use hdk::prelude::*;
use converge_integrity::*;
use zome_utils::*;

#[derive(Serialize, Deserialize, Debug)]
pub struct AddDeliberationForDeliberatorInput {
pub base_deliberator: AgentPubKey,
Expand Down Expand Up @@ -27,7 +29,7 @@ pub fn add_deliberation_for_deliberator(
pub fn get_deliberations_for_deliberator(
deliberator: AgentPubKey,
) -> ExternResult<Vec<Record>> {
let links = get_links(deliberator, LinkTypes::DeliberatorToDeliberations, None)?;
let links = get_links(link_input(deliberator, LinkTypes::DeliberatorToDeliberations, None))?;
let get_input: Vec<GetInput> = links
.into_iter()
.map(|link| GetInput::new(
Expand All @@ -51,11 +53,11 @@ pub fn get_deliberations_for_deliberator(
pub fn get_deliberators_for_deliberation(
deliberation_hash: ActionHash,
) -> ExternResult<Vec<AgentPubKey>> {
let links = get_links(
let links = get_links(link_input(
deliberation_hash,
LinkTypes::DeliberationToDeliberators,
None,
)?;
))?;
let agents: Vec<AgentPubKey> = links
.into_iter()
.map(|link| AgentPubKey::from(
Expand All @@ -77,11 +79,11 @@ pub struct RemoveDeliberationForDeliberatorInput {
pub fn remove_deliberation_for_deliberator(
input: RemoveDeliberationForDeliberatorInput,
) -> ExternResult<()> {
let links = get_links(
let links = get_links(link_input(
input.base_deliberator.clone(),
LinkTypes::DeliberatorToDeliberations,
None,
)?;
))?;
for link in links {
if ActionHash::try_from(link.target.clone())
.map_err(|_| {
Expand All @@ -93,11 +95,11 @@ pub fn remove_deliberation_for_deliberator(
delete_link(link.create_link_hash)?;
}
}
let links = get_links(
let links = get_links(link_input(
input.target_deliberation_hash.clone(),
LinkTypes::DeliberationToDeliberators,
None,
)?;
))?;
for link in links {
if AgentPubKey::from(
EntryHash::try_from(link.target.clone())
Expand Down
15 changes: 9 additions & 6 deletions dnas/converge/zomes/coordinator/converge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,15 @@ pub fn new_activity_sender(data: ActivityPayload) -> ExternResult<InitCallbackRe
debug!("all_agents: {:?}", all_agents);
for agent in all_agents {
if agent != agent_info()?.agent_latest_pubkey.into() {
let zome_call_response = call_remote(
agent.clone(),
"converge",
FunctionName(String::from("new_activity_receiver")),
None,
data.clone(),
// let zome_call_response = call_remote(
// agent.clone(),
// "converge",
// FunctionName(String::from("new_activity_receiver")),
// None,
// data.clone(),
// )?;
let zome_call_response = send_remote_signal(
ExternIO::encode(data.clone()).unwrap(), vec![agent.clone()]
)?;
debug!("zome_call_response: {:?}", zome_call_response);
}
Expand Down
Loading

0 comments on commit f7a4410

Please sign in to comment.