Skip to content

Commit 00a586a

Browse files
committed
use zdk and GetStrategy
1 parent b1d6f36 commit 00a586a

File tree

18 files changed

+78
-80
lines changed

18 files changed

+78
-80
lines changed

Cargo.toml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,20 @@ ill_formed_attribute_input = "allow"
3131
[workspace.dependencies]
3232
serde = { version = "=1.0.219", default-features = false }
3333
holochain_serialized_bytes = "=0.0.56"
34-
hdi = { version = "=0.7.0-dev.18", default-features = false }
35-
hdk = { version = "=0.6.0-dev.21", default-features = false }
34+
hdi = { version = "=0.7.0-rc.0", default-features = false }
35+
hdk = { version = "=0.6.0-rc.0", default-features = false }
3636

37-
zome_utils = { git = "https://github.com/ddd-mtl/zome-utils", branch = "hdk-6.0" }
38-
zome_signals = { git = "https://github.com/ddd-mtl/zome-signals", branch = "hdk-6.0" }
39-
path_explorer_types = {git = "https://github.com/lightningrodlabs/path-explorer", package = "path_explorer_types", branch = "hdk-6.0" }
37+
zome_utils = { git = "https://github.com/ddd-mtl/zdk", branch = "main-0.6" }
38+
zome_path = { git = "https://github.com/ddd-mtl/zdk", branch = "main-0.6" }
39+
zome_signals = { git = "https://github.com/ddd-mtl/zdk", branch = "main-0.6" }
40+
zome_core = { git = "https://github.com/ddd-mtl/zdk", branch = "main-0.6" }
41+
hc_zome_profiles_integrity = { git = "https://github.com/holochain-open-dev/profiles", branch = "main-0.6" }
42+
hc_zome_profiles_coordinator = {git = "https://github.com/ddd-mtl/zdk", branch = "main-0.6", package="profiles_alt_coordinator" }
4043

4144
delivery = {git = "https://github.com/ddd-mtl/delivery-zome", branch = "hdk-6.0" }
4245
zome_delivery_integrity = {git = "https://github.com/ddd-mtl/delivery-zome", branch = "hdk-6.0" }
4346
zome_delivery_types = {git = "https://github.com/ddd-mtl/delivery-zome", package = "zome_delivery_types", branch = "hdk-6.0" }
4447
zome_delivery_api = {git = "https://github.com/ddd-mtl/delivery-zome", package = "zome_delivery_api", branch = "hdk-6.0" }
45-
path_explorer = {git = "https://github.com/lightningrodlabs/path-explorer", package = "path_explorer", branch = "hdk-6.0" }
46-
47-
hc_zome_profiles_coordinator = {git = "https://github.com/ddd-mtl/profiles_alt_zome", branch = "hdk-6.0", package="profiles_alt_coordinator" }
48-
hc_zome_profiles_integrity = {git = "https://github.com/ddd-mtl/profiles_alt_zome", branch = "hdk-6.0" }
4948

5049

5150
[profile.dev]

dna/zomes/files/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ workspace = true
1414
serde.workspace = true
1515
hdk.workspace = true
1616
zome_utils.workspace = true
17+
zome_path.workspace = true
18+
zome_core.workspace = true
1719

1820
zome_delivery_types.workspace = true
1921
zome_delivery_api.workspace = true

dna/zomes/files/src/attach_to_hrl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::attach_to_hrl::holo_hash::DnaHash;
22
use hdk::prelude::*;
33
use zome_files_integrity::*;
44
use zome_utils::*;
5+
use zome_path::*;
56

67
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
78
pub struct AttachInput {

dna/zomes/files/src/get_file_info.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,18 @@ use zome_delivery_types::*;
66

77
/// Return manifest
88
#[hdk_extern]
9-
pub fn get_file_info(eh: EntryHash) -> ExternResult<ParcelManifest> {
9+
pub fn get_file_info_local(eh: EntryHash) -> ExternResult<ParcelManifest> {
1010
std::panic::set_hook(Box::new(zome_panic_hook));
11-
let manifest: ParcelManifest = get_typed_from_eh(eh)?;
11+
let manifest: ParcelManifest = get_typed_from_eh(eh, GetStrategy::Local)?;
1212
ensure_parcel_is_file(&manifest.description)?;
1313
Ok(manifest)
1414
}
15+
16+
/// Return manifest
17+
#[hdk_extern]
18+
pub fn get_file_info_network(eh: EntryHash) -> ExternResult<ParcelManifest> {
19+
std::panic::set_hook(Box::new(zome_panic_hook));
20+
let manifest: ParcelManifest = get_typed_from_eh(eh, GetStrategy::Network)?;
21+
ensure_parcel_is_file(&manifest.description)?;
22+
Ok(manifest)
23+
}

dna/zomes/files/src/lib.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,4 @@ mod send_file;
1414
mod utils;
1515
mod write_file_chunk;
1616

17-
///-------------------------------------------------------------------------------------------------
18-
use hdk::prelude::*;
19-
20-
#[hdk_extern]
21-
fn get_zome_info(_: ()) -> ExternResult<ZomeInfo> {
22-
return zome_info();
23-
}
24-
25-
#[hdk_extern]
26-
fn get_dna_info(_: ()) -> ExternResult<DnaInfo> {
27-
return dna_info();
28-
}
29-
30-
#[hdk_extern]
31-
fn get_record_author(dh: AnyDhtHash) -> ExternResult<AgentPubKey> {
32-
return zome_utils::get_author(dh);
33-
}
17+
extern crate zome_core;

dna/zomes/files/src/send_file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn send_file(input: SendFileInput) -> ExternResult<ActionHash> {
2424
debug!(" zome_name: {:?}", zome_info()?.name);
2525

2626
///Make sure manifest exists and is of File type.
27-
let manifest: ParcelManifest = get_typed_from_eh(input.manifest_eh.clone())?;
27+
let manifest: ParcelManifest = get_typed_from_eh(input.manifest_eh.clone(), GetStrategy::Network)?;
2828
ensure_parcel_is_file(&manifest.description)?;
2929

3030
/// Form Parcel Reference

dna/zomes/tagging/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ serde.workspace = true
1515
holochain_serialized_bytes.workspace = true
1616
hdk.workspace = true
1717
zome_utils.workspace = true
18+
zome_path.workspace = true
1819
zome_signals.workspace = true
19-
#path_explorer_types.workspace = true
20+
zome_core.workspace = true
2021

2122
zome_tagging_integrity = {path = "../tagging_integrity" }
2223

dna/zomes/tagging/src/lib.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ mod public;
55
pub use private::*;
66
pub use public::*;
77

8+
extern crate zome_core;
9+
810
//--------------------------------------------------------------------------------------------------
911

1012
use hdk::prelude::*;
@@ -33,14 +35,3 @@ pub struct UntagInput {
3335
// }
3436
//}
3537

36-
///-------------------------------------------------------------------------------------------------
37-
38-
#[hdk_extern]
39-
fn get_zome_info(_: ()) -> ExternResult<ZomeInfo> {
40-
return zome_info();
41-
}
42-
43-
#[hdk_extern]
44-
fn get_dna_info(_: ()) -> ExternResult<DnaInfo> {
45-
return dna_info();
46-
}

dna/zomes/tagging/src/private.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use hdk::prelude::*;
33
use zome_signals::*;
44
use zome_tagging_integrity::*;
55
use zome_utils::*;
6+
use zome_path::*;
67

78
///
89
#[hdk_extern]
@@ -153,7 +154,7 @@ fn untag_private_entry(input: UntagInput) -> ExternResult<()> {
153154
let tag_eh = hash_entry(PrivateTag { value: input.tag })?;
154155
/// Get Tag link
155156
let link_tuples =
156-
get_typed_from_links::<PrivateTag>(link_input(input.target.clone(), TaggingLinkTypes::PrivateTags.try_into_filter().unwrap(), None))?;
157+
get_typed_from_links::<PrivateTag>(link_input(input.target.clone(), TaggingLinkTypes::PrivateTags.try_into_filter().unwrap(), None), GetStrategy::Network)?;
157158
let link_tuple: Vec<(PrivateTag, Link)> = link_tuples
158159
.into_iter()
159160
.filter(|(tag_entry, _link)| {
@@ -191,7 +192,7 @@ pub fn find_private_tags_for_entry(eh: EntryHash) -> ExternResult<Vec<(EntryHash
191192
/// Make sure entry exist and is private
192193
let _record = query_private_entry(eh.clone())?;
193194
/// Grab private tags
194-
let link_tuples = get_typed_from_links::<PrivateTag>(LinkQuery::new(eh, TaggingLinkTypes::PrivateTags.try_into_filter().unwrap()))?;
195+
let link_tuples = get_typed_from_links::<PrivateTag>(LinkQuery::new(eh, TaggingLinkTypes::PrivateTags.try_into_filter().unwrap()), GetStrategy::Network)?;
195196
let res = link_tuples
196197
.clone()
197198
.into_iter()

dna/zomes/tagging/src/public.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use hdk::prelude::*;
33
use zome_signals::*;
44
use zome_tagging_integrity::*;
55
use zome_utils::*;
6+
use zome_path::*;
67

78
fn root_path() -> ExternResult<TypedPath> {
89
let tp = Path::from(format!("{}", PUBLIC_TAG_ROOT)).typed(TaggingLinkTypes::PublicPath)?;
@@ -11,10 +12,10 @@ fn root_path() -> ExternResult<TypedPath> {
1112

1213
///
1314
#[hdk_extern]
14-
fn probe_public_tags(_: ()) -> ExternResult<Vec<(EntryHash, String)>> {
15+
fn probe_public_tags(strategy: GetStrategy) -> ExternResult<Vec<(EntryHash, String)>> {
1516
std::panic::set_hook(Box::new(zome_panic_hook));
1617
let root_tp = root_path()?;
17-
let links = tp_children(&root_tp)?;
18+
let links = tp_children(&root_tp, strategy)?;
1819
let children = links_to_paths(&root_tp, links.clone())?;
1920
debug!("children_links: {:?}", links);
2021
debug!("children: {:?}", children);
@@ -39,7 +40,7 @@ fn probe_public_tags(_: ()) -> ExternResult<Vec<(EntryHash, String)>> {
3940
fn publish_public_tag(tag_value: String) -> ExternResult<EntryHash> {
4041
std::panic::set_hook(Box::new(zome_panic_hook));
4142
/// Make sure Tag does not already exists
42-
for (eh, tag) in probe_public_tags(())? {
43+
for (eh, tag) in probe_public_tags(GetStrategy::Network)? {
4344
if tag == tag_value {
4445
return Ok(eh);
4546
}
@@ -62,8 +63,8 @@ fn publish_public_tag(tag_value: String) -> ExternResult<EntryHash> {
6263

6364
///
6465
pub fn fetch_public_entry(eh: EntryHash) -> ExternResult<Entry> {
65-
let entry = get_entry_from_eh(eh.clone())?;
66-
let entry_type = get_entry_type(&entry)?;
66+
let entry = get_entry_from_eh(eh.clone(), GetStrategy::Network)?;
67+
let entry_type = get_entry_type(&entry, GetStrategy::Network)?;
6768
if !entry_type.visibility().is_public() {
6869
return error("Entry is Private");
6970
}
@@ -82,7 +83,7 @@ fn tag_public_entry(input: TaggingInput) -> ExternResult<Vec<ActionHash>> {
8283
/// Make sure entry exist and is public
8384
let _entry = fetch_public_entry(input.target.clone())?;
8485
/// Grab existing public tags
85-
let public_tuples = probe_public_tags(())?;
86+
let public_tuples = probe_public_tags(GetStrategy::Network)?;
8687
let public_tags: Vec<String> = public_tuples.iter().map(|(_, tag)| tag.to_owned()).collect();
8788
/// Link to/from each tag (create PublicTag entry if necessary)
8889
let mut link_ahs = Vec::new();

0 commit comments

Comments
 (0)