Skip to content

Commit

Permalink
merge updates to hc3
Browse files Browse the repository at this point in the history
  • Loading branch information
zippy committed Apr 11, 2024
2 parents 4b2e424 + 7b4d773 commit 5e652d9
Show file tree
Hide file tree
Showing 86 changed files with 7,682 additions and 6,247 deletions.
4,925 changes: 2,973 additions & 1,952 deletions Cargo.lock

Large diffs are not rendered by default.

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

[workspace.dependencies]
hdi = "=0.2.3"
hdk = "=0.1.3"
hdi = "0.4.0-beta-dev.33"
hdk = "0.3.0-beta-dev.37"
serde = "1"

[workspace.dependencies.emergence]
Expand Down
7 changes: 4 additions & 3 deletions dnas/emergence/zomes/coordinator/emergence/src/all_maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ pub struct MapInfo{
#[hdk_extern]
pub fn get_all_maps(_: ()) -> ExternResult<Vec<MapInfo>> {
let path = Path::from("all_maps");
let links = get_links(path.path_entry_hash()?, LinkTypes::AllMaps, None)?;
let input: GetLinksInput = GetLinksInputBuilder::try_new(path.path_entry_hash()?, LinkTypes::AllMaps)?.build();
let links = get_links(input)?;

let mut records: Vec<Record> = Vec::new();
let mut hashes: HashMap<ActionHash,ActionHash>= HashMap::new();
for link in links {
if let Some(record) = get_map(ActionHash::from(link.target.clone()))? {
hashes.insert(record.action_address().clone(), ActionHash::from(link.target));
if let Some(record) = get_map(ActionHash::try_from(link.target.clone()).map_err(|err| wasm_error!(err))?)? {
hashes.insert(record.action_address().clone(), ActionHash::try_from(link.target).map_err(|err| wasm_error!(err))?);
records.push(record);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ pub struct ProxyAgentInfo{
#[hdk_extern]
pub fn get_all_proxy_agents(_: ()) -> ExternResult<Vec<ProxyAgentInfo>> {
let path = Path::from("all_proxy_agents");
let links = get_links(path.path_entry_hash()?, LinkTypes::AllProxyAgents, None)?;
let input: GetLinksInput = GetLinksInputBuilder::try_new(path.path_entry_hash()?, LinkTypes::AllProxyAgents)?.build();
let links = get_links(input)?;
let mut records: Vec<Record> = Vec::new();
let mut hashes: HashMap<ActionHash,ActionHash>= HashMap::new();
for link in links {
if let Some(record) = get_proxy_agent(ActionHash::from(link.target.clone()))? {
hashes.insert(record.action_address().clone(), ActionHash::from(link.target));
if let Some(record) = get_proxy_agent(ActionHash::try_from(link.target.clone()).map_err(|err| wasm_error!(err))?)? {
hashes.insert(record.action_address().clone(), ActionHash::try_from(link.target).map_err(|err| wasm_error!(err))?);
records.push(record);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ pub struct SessionInfo {
#[hdk_extern]
pub fn get_all_sessions(_: ()) -> ExternResult<Vec<SessionInfo>> {
let path = Path::from("all_sessions");
let links = get_links(path.path_entry_hash()?, LinkTypes::AllSessions, None)?;
let input: GetLinksInput = GetLinksInputBuilder::try_new(path.path_entry_hash()?, LinkTypes::AllSessions)?.build();
let links = get_links(input)?;

let mut records: Vec<Record> = Vec::new();
let mut hashes: HashMap<ActionHash,ActionHash>= HashMap::new();
for link in links {
if let Some(record) = get_session(ActionHash::from(link.target.clone()))? {
hashes.insert(record.action_address().clone(), ActionHash::from(link.target));
if let Some(record) = get_session(ActionHash::try_from(link.target.clone()).map_err(|err| wasm_error!(err))?)? {
hashes.insert(record.action_address().clone(), ActionHash::try_from(link.target).map_err(|err| wasm_error!(err))?);
records.push(record);
}
}
Expand Down
7 changes: 4 additions & 3 deletions dnas/emergence/zomes/coordinator/emergence/src/all_spaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ pub struct SpaceInfo{
#[hdk_extern]
pub fn get_all_spaces(_: ()) -> ExternResult<Vec<SpaceInfo>> {
let path = Path::from("all_spaces");
let links = get_links(path.path_entry_hash()?, LinkTypes::AllSpaces, None)?;
let input: GetLinksInput = GetLinksInputBuilder::try_new(path.path_entry_hash()?, LinkTypes::AllSpaces)?.build();
let links = get_links(input)?;

let mut records: Vec<Record> = Vec::new();
let mut hashes: HashMap<ActionHash,ActionHash>= HashMap::new();
for link in links {
if let Some(record) = get_space(ActionHash::from(link.target.clone()))? {
hashes.insert(record.action_address().clone(), ActionHash::from(link.target));
if let Some(record) = get_space(ActionHash::try_from(link.target.clone()).map_err(|err| wasm_error!(err))?)? {
hashes.insert(record.action_address().clone(), ActionHash::try_from(link.target).map_err(|err| wasm_error!(err))?);
records.push(record);
}
}
Expand Down
5 changes: 3 additions & 2 deletions dnas/emergence/zomes/coordinator/emergence/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ pub fn create_map(map: Map) -> ExternResult<Record> {
}
#[hdk_extern]
pub fn get_map(original_map_hash: ActionHash) -> ExternResult<Option<Record>> {
let links = get_links(original_map_hash.clone(), LinkTypes::MapUpdates, None)?;
let input: GetLinksInput = GetLinksInputBuilder::try_new(original_map_hash.clone(), LinkTypes::MapUpdates)?.build();
let links = get_links(input)?;
let latest_link = links
.into_iter()
.max_by(|link_a, link_b| link_a.timestamp.cmp(&link_b.timestamp));
let latest_map_hash = match latest_link {
Some(link) => ActionHash::from(link.target.clone()),
Some(link) => ActionHash::try_from(link.target.clone()).map_err(|err| wasm_error!(err))?,
None => original_map_hash.clone(),
};
get(latest_map_hash, GetOptions::default())
Expand Down
5 changes: 3 additions & 2 deletions dnas/emergence/zomes/coordinator/emergence/src/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ pub fn create_note(note: Note) -> ExternResult<Record> {
}
#[hdk_extern]
pub fn get_note(original_note_hash: ActionHash) -> ExternResult<Option<Record>> {
let links = get_links(original_note_hash.clone(), LinkTypes::NoteUpdates, None)?;
let input: GetLinksInput = GetLinksInputBuilder::try_new(original_note_hash.clone(), LinkTypes::NoteUpdates)?.build();
let links = get_links(input)?;
let latest_link = links
.into_iter()
.max_by(|link_a, link_b| link_a.timestamp.cmp(&link_b.timestamp));
let latest_note_hash = match latest_link {
Some(link) => ActionHash::from(link.target.clone()),
Some(link) => ActionHash::try_from(link.target.clone()).map_err(|err| wasm_error!(err))?,
None => original_note_hash.clone(),
};
get(latest_note_hash, GetOptions::default())
Expand Down
5 changes: 3 additions & 2 deletions dnas/emergence/zomes/coordinator/emergence/src/proxy_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ pub fn create_proxy_agent(proxy_agent: ProxyAgent) -> ExternResult<Record> {
}
#[hdk_extern]
pub fn get_proxy_agent(original_proxy_agent_hash: ActionHash) -> ExternResult<Option<Record>> {
let links = get_links(original_proxy_agent_hash.clone(), LinkTypes::ProxyAgentUpdates, None)?;
let input: GetLinksInput = GetLinksInputBuilder::try_new(original_proxy_agent_hash.clone(), LinkTypes::ProxyAgentUpdates)?.build();
let links = get_links(input)?;
let latest_link = links
.into_iter()
.max_by(|link_a, link_b| link_a.timestamp.cmp(&link_b.timestamp));
let latest_proxy_agent_hash = match latest_link {
Some(link) => ActionHash::from(link.target.clone()),
Some(link) => ActionHash::try_from(link.target.clone()).map_err(|err| wasm_error!(err))?,
None => original_proxy_agent_hash.clone(),
};
get(latest_proxy_agent_hash, GetOptions::default())
Expand Down
14 changes: 9 additions & 5 deletions dnas/emergence/zomes/coordinator/emergence/src/relation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ pub struct GetFeedInput {
#[hdk_extern]
pub fn get_feed(input: GetFeedInput) -> ExternResult<Vec<RelationInfo>> {
let path = Path::from("feed");
let links = get_links(path.path_entry_hash()?, LinkTypes::Relations, None)?;
let get_links_input: GetLinksInput = GetLinksInputBuilder::try_new(path.path_entry_hash()?, LinkTypes::Relations)?.build();
let links = get_links(get_links_input)?;
let mut relations: Vec<RelationInfo> = Vec::new();
for link in links {
let relation = Relation
Expand Down Expand Up @@ -123,13 +124,14 @@ pub struct TagUse {
#[hdk_extern]
pub fn get_tags(_input: ()) -> ExternResult<Vec<TagUse>> {
let path = Path::from("tags");
let links = get_links(path.path_entry_hash()?, LinkTypes::Relations, None)?;
let input: GetLinksInput = GetLinksInputBuilder::try_new(path.path_entry_hash()?, LinkTypes::Relations)?.build();
let links = get_links(input)?;
let mut tags: HashMap<String,Vec<SessionAgent>> = HashMap::new();
for link in links {
let content = convert_relation_tag(link.tag)?;
let tag = content.data;
let sa = SessionAgent{
session: link.target.try_into()?,
session: ActionHash::try_from(link.target).map_err(|err| wasm_error!(err))?,
agent: link.author
};
if let Some(session_agent) = tags.get_mut(&tag) {
Expand All @@ -153,7 +155,8 @@ pub struct RelationInfo {
#[hdk_extern]
pub fn get_relations(input: AnyLinkableHash) -> ExternResult<Vec<RelationInfo>> {
let hash = AnyLinkableHash::from(input);
let links = get_links(hash.clone(), LinkTypes::Relations, None)?;
let input: GetLinksInput = GetLinksInputBuilder::try_new(hash.clone(), LinkTypes::Relations)?.build();
let links = get_links(input)?;

let mut relations: Vec<RelationInfo> = Vec::new();
for link in links {
Expand All @@ -176,7 +179,8 @@ pub fn get_relations(input: AnyLinkableHash) -> ExternResult<Vec<RelationInfo>>
#[hdk_extern]
pub fn get_relations_agent(input: AgentPubKey) -> ExternResult<Vec<Relation>> {
let hash = AnyLinkableHash::from(input);
let links = get_links(hash.clone(), LinkTypes::Relations, None)?;
let input: GetLinksInput = GetLinksInputBuilder::try_new(hash.clone(), LinkTypes::Relations)?.build();
let links = get_links(input)?;

let mut relations: Vec<Relation> = Vec::new();
for link in links {
Expand Down
11 changes: 5 additions & 6 deletions dnas/emergence/zomes/coordinator/emergence/src/session.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use hdk::prelude::*;
use emergence_integrity::*;

#[hdk_extern]
pub fn create_session(session: Session) -> ExternResult<Record> {
let session_hash = create_entry(&EntryTypes::Session(session.clone()))?;
Expand All @@ -20,16 +21,14 @@ pub fn create_session(session: Session) -> ExternResult<Record> {
}
#[hdk_extern]
pub fn get_session(original_session_hash: ActionHash) -> ExternResult<Option<Record>> {
let links = get_links(
original_session_hash.clone(),
LinkTypes::SessionUpdates,
None,
)?;
let input: GetLinksInput = GetLinksInputBuilder::try_new(original_session_hash.clone(), LinkTypes::SessionUpdates)?.build();

let links = get_links(input)?;
let latest_link = links
.into_iter()
.max_by(|link_a, link_b| link_a.timestamp.cmp(&link_b.timestamp));
let latest_session_hash = match latest_link {
Some(link) => ActionHash::from(link.target.clone()),
Some(link) => ActionHash::try_from(link.target.clone()).map_err(|err| wasm_error!(err))?,
None => original_session_hash.clone(),
};
get(latest_session_hash, GetOptions::default())
Expand Down
5 changes: 3 additions & 2 deletions dnas/emergence/zomes/coordinator/emergence/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ pub fn set_settings(input: Settings) -> ExternResult<ActionHash> {
// let me = agent_info()?.agent_latest_pubkey;
//let agents = agents.into_iter().filter(|a| a != &me).collect();
debug!("agents: {:?}", agents);
remote_signal(EmergenceMessage::UpdateSettings(input), agents)?;
send_remote_signal(EmergenceMessage::UpdateSettings(input), agents)?;
}
Ok(action_hash)
}

#[hdk_extern]
pub fn get_settings(_: ()) -> ExternResult<Settings> {
let path = Path::from("all_settings");
let mut links = get_links(path.path_entry_hash()?, LinkTypes::Settings, None)?;
let input: GetLinksInput = GetLinksInputBuilder::try_new(path.path_entry_hash()?, LinkTypes::Settings)?.build();
let mut links = get_links(input)?;
if links.len() == 0 {
return Ok(Settings {
game_active: false,
Expand Down
5 changes: 3 additions & 2 deletions dnas/emergence/zomes/coordinator/emergence/src/space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ pub fn create_space(space: Space) -> ExternResult<Record> {
}
#[hdk_extern]
pub fn get_space(original_space_hash: ActionHash) -> ExternResult<Option<Record>> {
let links = get_links(original_space_hash.clone(), LinkTypes::SpaceUpdates, None)?;
let input: GetLinksInput = GetLinksInputBuilder::try_new(original_space_hash.clone(), LinkTypes::SpaceUpdates)?.build();
let links = get_links(input)?;
let latest_link = links
.into_iter()
.max_by(|link_a, link_b| link_a.timestamp.cmp(&link_b.timestamp));
let latest_space_hash = match latest_link {
Some(link) => ActionHash::from(link.target.clone()),
Some(link) => ActionHash::try_from(link.target.clone()).map_err(|err| wasm_error!(err))?,
None => original_space_hash.clone(),
};
get(latest_space_hash, GetOptions::default())
Expand Down
6 changes: 4 additions & 2 deletions dnas/emergence/zomes/coordinator/emergence/src/time_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ pub fn create_time_window(input: TimeWindow) -> ExternResult<ActionHash> {
#[hdk_extern]
pub fn delete_time_window(input: TimeWindow) -> ExternResult<()> {
let path = Path::from("all_time_windows");
let links = get_links(path.path_entry_hash()?, LinkTypes::TimeWindows, None)?;
let get_links_input: GetLinksInput = GetLinksInputBuilder::try_new(path.path_entry_hash()?, LinkTypes::TimeWindows)?.build();
let links = get_links(get_links_input)?;
for link in links {
let w = convert_time_window_tag(link.tag)?;
if w == input {
Expand All @@ -32,7 +33,8 @@ pub fn delete_time_window(input: TimeWindow) -> ExternResult<()> {
#[hdk_extern]
pub fn get_time_windows(_: ()) -> ExternResult<Vec<TimeWindow>> {
let path = Path::from("all_time_windows");
let links = get_links(path.path_entry_hash()?, LinkTypes::TimeWindows, None)?;
let input: GetLinksInput = GetLinksInputBuilder::try_new(path.path_entry_hash()?, LinkTypes::TimeWindows)?.build();
let links = get_links(input)?;

let mut time_windows: Vec<TimeWindow> = Vec::new();
for link in links {
Expand Down
7 changes: 3 additions & 4 deletions dnas/emergence/zomes/coordinator/file_storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ hdk = { workspace = true }
serde = { workspace = true }

file_storage_integrity = { workspace = true }
hc_zome_file_storage_coordinator = "0.1.0"
hc_zome_file_storage_coordinator = { git = "https://github.com/holochain-open-dev/file-storage", branch = "for-hdk-0.3.0-beta-dev" }


[dev-dependencies]
fixt = "0.1.0"
futures = { version = "0.3.1", default-features = false }
#futures = { version = "0.3.1", default-features = false }
hdk = { workspace = true, features = ["encoding", "test_utils"] }
holochain = { worskpace = true, default-features = false, features = [
"test_utils",
] }
tokio = { version = "1.3", features = ["full"] }
#tokio = { version = "1.3", features = ["full"] }

7 changes: 3 additions & 4 deletions dnas/emergence/zomes/coordinator/profiles/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ hdk = { workspace = true }
serde = { workspace = true }

profiles_integrity = { workspace = true }
hc_zome_profiles_coordinator = "0.1.2"
hc_zome_profiles_coordinator = { git = "https://github.com/holochain-open-dev/profiles", branch = "for-hdk-v0.3.0-beta-dev.33" }


[dev-dependencies]
fixt = "0.1.0"
futures = { version = "0.3.1", default-features = false }
#futures = { version = "0.3.1", default-features = false }
hdk = { workspace = true, features = ["encoding", "test_utils"] }
tokio = { version = "1.3", features = ["full"] }
#tokio = { version = "1.3", features = ["full"] }

2 changes: 1 addition & 1 deletion dnas/emergence/zomes/integrity/emergence/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub mod relation;
pub use relation::*;
#[derive(Serialize, Deserialize)]
#[serde(tag = "type")]
#[hdk_entry_defs]
#[hdk_entry_types]
#[unit_enum(UnitEntryTypes)]
pub enum EntryTypes {
Session(Session),
Expand Down
6 changes: 3 additions & 3 deletions dnas/emergence/zomes/integrity/emergence/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn validate_create_link_map_updates(
target_address: AnyLinkableHash,
_tag: LinkTag,
) -> ExternResult<ValidateCallbackResult> {
let action_hash = ActionHash::from(base_address);
let action_hash = ActionHash::try_from(base_address).map_err(|err| wasm_error!(err))?;
let record = must_get_valid_record(action_hash)?;
let _map: crate::Map = record
.entry()
Expand All @@ -44,7 +44,7 @@ pub fn validate_create_link_map_updates(
WasmErrorInner::Guest(String::from("Linked action must reference an entry"))
),
)?;
let action_hash = ActionHash::from(target_address);
let action_hash = ActionHash::try_from(target_address).map_err(|err| wasm_error!(err))?;
let record = must_get_valid_record(action_hash)?;
let _map: crate::Map = record
.entry()
Expand Down Expand Up @@ -77,7 +77,7 @@ pub fn validate_create_link_all_maps(
_tag: LinkTag,
) -> ExternResult<ValidateCallbackResult> {
// Check the entry type for the given action hash
let action_hash = ActionHash::from(target_address);
let action_hash = ActionHash::try_from(target_address).map_err(|err| wasm_error!(err))?;
let record = must_get_valid_record(action_hash)?;
let _space: crate::Map = record
.entry()
Expand Down
6 changes: 3 additions & 3 deletions dnas/emergence/zomes/integrity/emergence/src/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn validate_create_link_note_updates(
target_address: AnyLinkableHash,
_tag: LinkTag,
) -> ExternResult<ValidateCallbackResult> {
let action_hash = ActionHash::from(base_address);
let action_hash = ActionHash::try_from(base_address).map_err(|err| wasm_error!(err))?;
let record = must_get_valid_record(action_hash)?;
let _note: crate::Note = record
.entry()
Expand All @@ -46,7 +46,7 @@ pub fn validate_create_link_note_updates(
WasmErrorInner::Guest(String::from("Linked action must reference an entry"))
),
)?;
let action_hash = ActionHash::from(target_address);
let action_hash = ActionHash::try_from(target_address).map_err(|err| wasm_error!(err))?;
let record = must_get_valid_record(action_hash)?;
let _note: crate::Note = record
.entry()
Expand Down Expand Up @@ -79,7 +79,7 @@ pub fn validate_create_link_all_notes(
_tag: LinkTag,
) -> ExternResult<ValidateCallbackResult> {
// Check the entry type for the given action hash
let action_hash = ActionHash::from(target_address);
let action_hash = ActionHash::try_from(target_address).map_err(|err| wasm_error!(err))?;
let record = must_get_valid_record(action_hash)?;
let _note: crate::Note = record
.entry()
Expand Down
6 changes: 3 additions & 3 deletions dnas/emergence/zomes/integrity/emergence/src/proxy_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn validate_create_link_proxy_agent_updates(
target_address: AnyLinkableHash,
_tag: LinkTag,
) -> ExternResult<ValidateCallbackResult> {
let action_hash = ActionHash::from(base_address);
let action_hash = ActionHash::try_from(base_address).map_err(|err| wasm_error!(err))?;
let record = must_get_valid_record(action_hash)?;
let _proxy_agent: crate::ProxyAgent = record
.entry()
Expand All @@ -45,7 +45,7 @@ pub fn validate_create_link_proxy_agent_updates(
WasmErrorInner::Guest(String::from("Linked action must reference an entry"))
),
)?;
let action_hash = ActionHash::from(target_address);
let action_hash = ActionHash::try_from(target_address).map_err(|err| wasm_error!(err))?;
let record = must_get_valid_record(action_hash)?;
let _proxy_agent: crate::ProxyAgent = record
.entry()
Expand Down Expand Up @@ -78,7 +78,7 @@ pub fn validate_create_link_all_proxy_agents(
_tag: LinkTag,
) -> ExternResult<ValidateCallbackResult> {
// Check the entry type for the given action hash
let action_hash = ActionHash::from(target_address);
let action_hash = ActionHash::try_from(target_address).map_err(|err| wasm_error!(err))?;
let record = must_get_valid_record(action_hash)?;
let _space: crate::ProxyAgent = record
.entry()
Expand Down
Loading

0 comments on commit 5e652d9

Please sign in to comment.