diff --git a/dna/Cargo.lock b/dna/Cargo.lock index 3526369..1d7cc0c 100644 --- a/dna/Cargo.lock +++ b/dna/Cargo.lock @@ -76,15 +76,15 @@ checksum = "41cb0e6161ad61ed084a36ba71fbba9e3ac5aee3606fb607fe08da6acbcf3d8c" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.53", + "syn 1.0.54", ] [[package]] name = "file_storage" version = "0.0.1" -source = "git+https://github.com/holochain-open-dev/file-storage-module?branch=main#32ba8f55de43c0a388e8bcf262c59e148fb52fe3" dependencies = [ "derive_more", + "file_storage 0.0.1 (git+https://github.com/holochain-open-dev/file-storage-module?branch=main)", "hc_utils", "hdk3", "serde", @@ -93,9 +93,9 @@ dependencies = [ [[package]] name = "file_storage" version = "0.0.1" +source = "git+https://github.com/holochain-open-dev/file-storage-module?branch=main#9b71efb07152e7a818dbe37aa6eb0b58e1f8fa0b" dependencies = [ "derive_more", - "file_storage 0.0.1 (git+https://github.com/holochain-open-dev/file-storage-module?branch=main)", "hc_utils", "hdk3", "serde", @@ -104,7 +104,7 @@ dependencies = [ [[package]] name = "fixt" version = "0.0.1" -source = "git+https://github.com/holochain/holochain?rev=68a49be953ecf4ffa228633a197b7ba73350b803#68a49be953ecf4ffa228633a197b7ba73350b803" +source = "git+https://github.com/holochain/holochain?rev=60a906212c17ee067b31511e6b2957746d86297b#60a906212c17ee067b31511e6b2957746d86297b" dependencies = [ "holochain_serialized_bytes", "lazy_static", @@ -137,7 +137,7 @@ checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" [[package]] name = "hc_utils" version = "0.1.0" -source = "git+https://github.com/holochain/hc-utils?rev=7f65e8f941b9c003133b265d06f3334a9cd60d54#7f65e8f941b9c003133b265d06f3334a9cd60d54" +source = "git+https://github.com/holochain/hc-utils?branch=develop#cddc40c4ae4cbabe0c3c0e021dba612065ca75e9" dependencies = [ "hdk3", "holo_hash", @@ -148,7 +148,7 @@ dependencies = [ [[package]] name = "hdk3" version = "0.0.1" -source = "git+https://github.com/holochain/holochain?rev=68a49be953ecf4ffa228633a197b7ba73350b803#68a49be953ecf4ffa228633a197b7ba73350b803" +source = "git+https://github.com/holochain/holochain?rev=60a906212c17ee067b31511e6b2957746d86297b#60a906212c17ee067b31511e6b2957746d86297b" dependencies = [ "hdk3_derive", "holo_hash", @@ -163,13 +163,13 @@ dependencies = [ [[package]] name = "hdk3_derive" version = "0.0.1" -source = "git+https://github.com/holochain/holochain?rev=68a49be953ecf4ffa228633a197b7ba73350b803#68a49be953ecf4ffa228633a197b7ba73350b803" +source = "git+https://github.com/holochain/holochain?rev=60a906212c17ee067b31511e6b2957746d86297b#60a906212c17ee067b31511e6b2957746d86297b" dependencies = [ "holochain_zome_types", "paste", "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.53", + "syn 1.0.54", ] [[package]] @@ -184,7 +184,7 @@ dependencies = [ [[package]] name = "holo_hash" version = "0.0.1" -source = "git+https://github.com/holochain/holochain?rev=68a49be953ecf4ffa228633a197b7ba73350b803#68a49be953ecf4ffa228633a197b7ba73350b803" +source = "git+https://github.com/holochain/holochain?rev=60a906212c17ee067b31511e6b2957746d86297b#60a906212c17ee067b31511e6b2957746d86297b" dependencies = [ "base64", "blake2b_simd", @@ -197,9 +197,9 @@ dependencies = [ [[package]] name = "holochain_serialized_bytes" -version = "0.0.45" +version = "0.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adca869d80860a04757af4fc011d49505594365391a6e3a04105e8f88b9c32e1" +checksum = "4b8fe6bc8c830633862ee0b7903706f6d940f7c794b3f5e768f660a7abbacbc9" dependencies = [ "holochain_serialized_bytes_derive", "rmp-serde", @@ -212,9 +212,9 @@ dependencies = [ [[package]] name = "holochain_serialized_bytes_derive" -version = "0.0.45" +version = "0.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dbbf84d56f0a0cb00e5532fd4d40b1d42ffb403a1a964d8eeedc4d40131e208" +checksum = "a1a4c0ef882177ac63c8912ae9c1eb6285d3b50a56f2bb0cebc41012255b7734" dependencies = [ "quote 0.6.13", "syn 0.15.44", @@ -222,9 +222,9 @@ dependencies = [ [[package]] name = "holochain_wasmer_common" -version = "0.0.50" +version = "0.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfcc07f0ff0aa409a6f7b1fd4766c3c31c6e47a0a7b74563bff5e8791378277" +checksum = "5e064411f7c8cf58e08a451c2df9ab99efb5de839f74a650c1a30abbd607add8" dependencies = [ "holochain_serialized_bytes", "serde", @@ -233,9 +233,9 @@ dependencies = [ [[package]] name = "holochain_wasmer_guest" -version = "0.0.50" +version = "0.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "924a5024a73c73d8835594db1978a4c830ebd51c396920f91a58d7c9ef85641b" +checksum = "6c86bf521e02f8f86ea96177ef316560e66e51a192b83a302e8e4b32a6f47f02" dependencies = [ "holochain_serialized_bytes", "holochain_wasmer_common", @@ -245,11 +245,12 @@ dependencies = [ [[package]] name = "holochain_zome_types" version = "0.0.1" -source = "git+https://github.com/holochain/holochain?rev=68a49be953ecf4ffa228633a197b7ba73350b803#68a49be953ecf4ffa228633a197b7ba73350b803" +source = "git+https://github.com/holochain/holochain?rev=60a906212c17ee067b31511e6b2957746d86297b#60a906212c17ee067b31511e6b2957746d86297b" dependencies = [ "fixt", "holo_hash", "holochain_serialized_bytes", + "paste", "serde", "serde_bytes", "strum", @@ -259,9 +260,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" +checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" dependencies = [ "autocfg", "hashbrown", @@ -281,9 +282,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.80" +version = "0.2.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" +checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" [[package]] name = "lock_api" @@ -500,7 +501,7 @@ checksum = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.53", + "syn 1.0.54", ] [[package]] @@ -517,9 +518,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7acad6f34eb9e8a259d3283d1e8c1d34d7415943d4895f65cc73813c7396fc85" +checksum = "ae524f056d7d770e174287294f562e95044c68e88dec909a00d2094805db9d75" [[package]] name = "strum" @@ -536,14 +537,14 @@ dependencies = [ "heck", "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.53", + "syn 1.0.54", ] [[package]] name = "subtle" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd" +checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" [[package]] name = "syn" @@ -558,9 +559,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.53" +version = "1.0.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8833e20724c24de12bbaba5ad230ea61c3eafb05b881c7c9d3cfe8638b187e68" +checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", @@ -594,7 +595,7 @@ checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", - "syn 1.0.53", + "syn 1.0.54", ] [[package]] diff --git a/dna/Cargo.toml b/dna/Cargo.toml index 2115dc2..c943420 100644 --- a/dna/Cargo.toml +++ b/dna/Cargo.toml @@ -13,6 +13,6 @@ opt-level = "z" [patch.crates-io] -hc_utils = {git = "https://github.com/holochain/hc-utils", rev = "7f65e8f941b9c003133b265d06f3334a9cd60d54", package = "hc_utils"} -hdk3 = {git = "https://github.com/holochain/holochain", rev = "68a49be953ecf4ffa228633a197b7ba73350b803", package = "hdk3"} -holo_hash = {git = "https://github.com/holochain/holochain", rev = "68a49be953ecf4ffa228633a197b7ba73350b803", package = "holo_hash"} +hc_utils = {git = "https://github.com/holochain/hc-utils", branch = "develop", package = "hc_utils"} +hdk3 = {git = "https://github.com/holochain/holochain", rev = "60a906212c17ee067b31511e6b2957746d86297b", package = "hdk3"} +holo_hash = {git = "https://github.com/holochain/holochain", rev = "60a906212c17ee067b31511e6b2957746d86297b", package = "holo_hash"} diff --git a/dna/peershare.dna.gz b/dna/peershare.dna.gz index df33077..7a0551b 100644 Binary files a/dna/peershare.dna.gz and b/dna/peershare.dna.gz differ diff --git a/dna/tests/package-lock.json b/dna/tests/package-lock.json index f13826b..18b9ebc 100644 --- a/dna/tests/package-lock.json +++ b/dna/tests/package-lock.json @@ -37,11 +37,11 @@ } }, "@holochain/tryorama": { - "version": "0.4.0-dev.1", - "resolved": "https://registry.npmjs.org/@holochain/tryorama/-/tryorama-0.4.0-dev.1.tgz", - "integrity": "sha512-/8CMv9eIhjvT9spgO2f192qPRViiKBtg5fL2+/Qe+wK6S6LRYRWuYIA4I66Tv+c8z10C4EwV7g2jBjMmZjOiOw==", + "version": "0.4.0-dev.2", + "resolved": "https://registry.npmjs.org/@holochain/tryorama/-/tryorama-0.4.0-dev.2.tgz", + "integrity": "sha512-LssGnRae7PAOqv/af5Eel/kl0sx41UttfufYe2sV8woTNmUAl5JhMTXXZBFuZdQx4I2z96BpcFhVQd3p4A+z0Q==", "requires": { - "@holochain/conductor-api": "0.0.1-dev.12", + "@holochain/conductor-api": "0.0.1-dev.14", "@holochain/hachiko": "^0.5.2", "@iarna/toml": "^2.2.5", "async-mutex": "^0.1.4", @@ -58,20 +58,6 @@ "uuid": "^3.4.0", "winston": "^3.3.3", "yaml": "^1.10.0" - }, - "dependencies": { - "@holochain/conductor-api": { - "version": "0.0.1-dev.12", - "resolved": "https://registry.npmjs.org/@holochain/conductor-api/-/conductor-api-0.0.1-dev.12.tgz", - "integrity": "sha512-vr06vEFnoYvoJ9zgNaANU/DE04633OK3cXWAdzOGfpZMoeIXXniY/bJx9kgXXJiA+LW5hSCAFDJEBaOV59j2eg==", - "requires": { - "@msgpack/msgpack": "^2.1.0", - "@types/ws": "^7.2.4", - "isomorphic-ws": "^4.0.1", - "nanoid": "^3.1.9", - "ws": "^7.3.0" - } - } } }, "@iarna/toml": { diff --git a/dna/tests/package.json b/dna/tests/package.json index b9d9e4a..5623e12 100644 --- a/dna/tests/package.json +++ b/dna/tests/package.json @@ -5,15 +5,14 @@ "main": "index.js", "scripts": { "test": "npm run test:setup && npm run test:execute", - "test:setup": "CARGO_TARGET_DIR=../target cargo build --release --target wasm32-unknown-unknown && dna-util -c ../peershare.dna.workdir", + "test:setup": "CARGO_TARGET_DIR=../target cargo build --release --target wasm32-unknown-unknown && dna-util -c ../peershare.dna.workdir", "test:execute": "TRYORAMA_LOG_LEVEL=info RUST_LOG=error RUST_BACKTRACE=1 TRYORAMA_HOLOCHAIN_PATH=\"holochain\" ts-node src/index.ts" - }, "author": "", "license": "ISC", "dependencies": { "@holochain/conductor-api": "git+https://github.com/holochain/holochain-conductor-api.git", - "@holochain/tryorama": "^0.4.0-dev.1", + "@holochain/tryorama": "^0.4.0-dev.2", "@types/lodash": "^4.14.158", "@types/node": "^14.14.11", "lodash": "^4.17.19", diff --git a/dna/tests/src/index.ts b/dna/tests/src/index.ts index 2f0ae64..4ae6a34 100644 --- a/dna/tests/src/index.ts +++ b/dna/tests/src/index.ts @@ -103,16 +103,29 @@ orchestrator.registerScenario( t.deepEqual(test1.result, true); _log(test1, "file_tagged"); - ///// Test link to my address is working. - let myfilesResult = await conductor.call( + ///// Test link to my address is working on Tag Zome. + let myfilesResult_fromTagZome = await conductor.call( Tag_ZOME_NAME, "get_my_files", null ); - t.ok(myfilesResult); - t.deepEqual(myfilesResult.list, 1); - _log(myfilesResult, "all my files"); + t.ok(myfilesResult_fromTagZome); + t.deepEqual(myfilesResult_fromTagZome.list, 1); + _log(myfilesResult_fromTagZome, "all my files"); + + ///// Test link to my address is working on Tag Zome. + let myfilesResult_fromPeerShareZome = await conductor.call( + PeerShare_Zome_Name, + "get_my_files", + null + ); + + t.ok(myfilesResult_fromPeerShareZome); + t.deepEqual(myfilesResult_fromPeerShareZome.list, 0); + _log(myfilesResult_fromPeerShareZome, "all my files"); + + } ); diff --git a/dna/zomes/peershare/src/lib.rs b/dna/zomes/peershare/src/lib.rs index 6e8b0d6..580735a 100644 --- a/dna/zomes/peershare/src/lib.rs +++ b/dna/zomes/peershare/src/lib.rs @@ -1,54 +1,27 @@ use hdk3::prelude::*; -mod search; - -pub fn error(reason: &str) -> ExternResult { - Err(HdkError::Wasm(WasmError::Zome(String::from(reason)))) +#[hdk_extern] +pub fn get_agent_pubkey(_: ()) -> ExternResult { + let agent_info = agent_info()?; + Ok(agent_info.agent_latest_pubkey) } -//TODO: Finish this function -// #[hdk_extern] -// pub fn browse_files(input:SearchInput)->SearchResult{ -// let search_result = search::handlers::search_file_by_tags(input.tags, input.from_timestamp, input.filter_boundry_in_min); -// Ok( SearchResult{ -// status:true, -// msg:"".into(), -// result: search_results.0, // search result -// from_timestamp: search_result.1, // the starting point of search, shifted back to this point, for the next round of paging. -// filter_boundry_in_min:input.filter_boundry_in_min // the end point of filtering, by passing via this variable. -// }) -// } - -// let links = get_links(env.clone(), base_address, zome_name, link_tag).await; -// let links = links -// .into_inner() -// .into_iter() -// .map(|h| h.target.try_into().unwrap()) -// .collect::>(); -// #[hdk_extern] -// pub fn get_my_files(_:()) -//pub fn someting() -> FileMetaData {} +#[derive(Serialize, Deserialize, SerializedBytes)] +pub struct MyFilesResult { + pub list: usize, +} -// #[derive(Serialize, Deserialize, SerializedBytes)] -// pub struct FilesResult { -// pub list: usize, -// } -// #[hdk_extern] -// fn get_my_files2(_: ()) -> ExternResult { -// let _linktag = link_tag("all_my_files").unwrap(); -// let links = get_links(my_address(), None)?.into_inner().len(); -// Ok(FilesResult { list: links }) -// } -// #[derive(Serialize, Deserialize, SerializedBytes)] -// struct StringLinkTag(String); -// pub fn link_tag(tag: &str) -> ExternResult { -// let sb: SerializedBytes = StringLinkTag(tag.into()).try_into()?; -// Ok(LinkTag(sb.bytes().clone())) -// } +/// This code is duplicate here and into peershare zome, to replicate the issue, it will be removed later. +pub static ALL_MY_FILES: &str = "all_my_files"; +#[hdk_extern] +fn get_my_files(_: ()) -> ExternResult { + let links = get_links(my_address(), None)?.into_inner(); + Ok(MyFilesResult { list: links.len() }) +} -// fn my_address() -> EntryHash { -// let agent_info = agent_info().unwrap(); -// let agent_address: AnyDhtHash = agent_info.agent_initial_pubkey.into(); -// agent_address.into() -// } +pub fn my_address() -> EntryHash { + let agent_info = agent_info().unwrap(); + let agent_address: AnyDhtHash = agent_info.agent_initial_pubkey.into(); + agent_address.into() +} \ No newline at end of file diff --git a/dna/zomes/tags/src/lib.rs b/dna/zomes/tags/src/lib.rs index e9478d4..6c0bd82 100644 --- a/dna/zomes/tags/src/lib.rs +++ b/dna/zomes/tags/src/lib.rs @@ -18,9 +18,24 @@ pub struct MyFilesResult { pub list: usize, } +// #[hdk_extern] +// fn get_my_files(_: ()) -> ExternResult { +// let _linktag = tag::handlers::link_tag(tag::handlers::ALL_MY_FILES).unwrap(); +// let links = get_links(tag::handlers::my_address(), None)?.into_inner(); +// Ok(MyFilesResult { list: links.len() }) +// } + +/// This code is duplicate here and into peershare zome, to replicate the issue, it will be removed later. +pub static ALL_MY_FILES: &str = "all_my_files"; + #[hdk_extern] fn get_my_files(_: ()) -> ExternResult { - let _linktag = tag::handlers::link_tag(tag::handlers::ALL_MY_FILES).unwrap(); - let links = get_links(tag::handlers::my_address(), None)?.into_inner(); + let links = get_links(my_address(), None)?.into_inner(); Ok(MyFilesResult { list: links.len() }) } + +pub fn my_address() -> EntryHash { + let agent_info = agent_info().unwrap(); + let agent_address: AnyDhtHash = agent_info.agent_initial_pubkey.into(); + agent_address.into() +} \ No newline at end of file