Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1373 from holochain/release-0.0.14-alpha1
Browse files Browse the repository at this point in the history
Release 0.0.14-alpha1
  • Loading branch information
thedavidmeister committed May 2, 2019
2 parents 35f4c4e + ca901fb commit 7ca721c
Show file tree
Hide file tree
Showing 108 changed files with 2,186 additions and 754 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
**/.git
**/node_modules
**/bin-package
!holonix/**
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

## changelog

Please check one of the following, relating to the [CHANGELOG](https://github.com/holochain/holochain-rust/blob/develop/CHANGELOG.md)
Please check one of the following, relating to the [CHANGELOG-UNRELEASED.md](https://github.com/holochain/holochain-rust/blob/develop/CHANGELOG-UNRELEASED.md)

- [ ] this is a code change that effects some consumer (e.g. zome developers) of holochain core so there is an 'Unreleased' CHANGELOG item, with the format `- summary of change [PR#1234](https://github.com/holochain/holochain-rust/pull/1234)`
- [ ] this is a code change that effects some consumer (e.g. zome developers) of holochain core so it is added to the CHANGELOG-UNRELEASED.md (linked above), with the format `- summary of change [PR#1234](https://github.com/holochain/holochain-rust/pull/1234)`
- [ ] this is not a code change, or doesn't effect anyone outside holochain core development
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,31 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.14-alpha1] - 2019-05-02

### Added

- Adds hdk::commit_entry_result() which features: optional argument to include additional provenances. [#1320](https://github.com/holochain/holochain-rust/pull/1320)
- default.nix file added to facilitate `nix-env` based binary installation [#1356](https://github.com/holochain/holochain-rust/pull/1356)

### Changed
- Changes `LinkAdd` and `RemoveEntry` so that they return a hash instead of a null [#1343](https://github.com/holochain/holochain-rust/pull/1343)
- Merged `default.nix` and `shell.nix` to improve `nix-shell` handling [#1371](https://github.com/holochain/holochain-rust/pull/1371)

### Deprecated

### Removed

### Fixed

### Security

## [0.0.13-alpha1] - 2019-04-29

### Added
- Adds hdk::grant_capability() for zome functions to be able to create [capability grant](doc/architecture/decisions/0017-capabilities.md) [#1285](https://github.com/holochain/holochain-rust/pull/1285)
- `nix-shell` includes latest `hc` and `holochain` binaries [#1306](https://github.com/holochain/holochain-rust/pull/1306)
- Adds `hc-cli-uninstall` and `hc-conductor-rust-uninstall` to drop local development installations of these binaries that would override dist binaries [#1351](https://github.com/holochain/holochain-rust/pull/1351)

### Changed
- changed JSON-RPC Zome call `params` key to `args` for clarity (due to confusion between JSON-RPC `params` and Holochain `params` keys): see [#1203](https://github.com/holochain/holochain-rust/pull/1203) and [#1271](https://github.com/holochain/holochain-rust/pull/1271)
- Remove sleeps during network initialization, block until P2pReady event is received [#1284](https://github.com/holochain/holochain-rust/pull/1284).
Expand Down Expand Up @@ -41,6 +59,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Clarifies the error received when attempting to add a DNA whose expected hash mismatches the actual hash [#1287](https://github.com/holochain/holochain-rust/pull/1287).
- Binary tarballs no longer extract to a subdirectory [#1265](https://github.com/holochain/holochain-rust/pull/1265)
- Linux binary tarballs are now named `generic` rather than `ubuntu` [#1265](https://github.com/holochain/holochain-rust/pull/1265)
- When getting links, the result has changed from `addresses: Vec<Address>` to `links: Vec<LinksResult>`. [#1250](https://github.com/holochain/holochain-rust/pull/1250)

### Deprecated

Expand Down
6 changes: 3 additions & 3 deletions app_spec/test/regressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ scenario.runTape('alice create & publish post -> recommend own post to self', as
agent_address: alice.agentId
})
console.log("linked: ", linked)
t.equal(linked.Ok, null)
t.equal(linked.Ok, "QmQja9SJhYWA5B3myrtnd9bR6dNeaFj6Lr3DRjumfTPWaX")

const recommendedPosts = alice.call('blog', 'my_recommended_posts', {})
console.log("recommendedPosts", recommendedPosts)
Expand All @@ -94,7 +94,7 @@ scenario.runTape('alice create & publish post -> tash recommend to self', async
agent_address: tash.agentId
})
console.log("linked: ", linked)
t.equal(linked.Ok, null)
t.equal(linked.Ok, "QmYZKfRGykurtW96zv9ra8D9cof7Ki4Df8XFSgupWP711Y")

const recommendedPosts = tash.call("blog", "my_recommended_posts", {})
console.log("recommendedPosts", recommendedPosts)
Expand All @@ -118,7 +118,7 @@ scenario.runTape('create & publish post -> recommend to other agent', async (t,
agent_address: tash.agentId
})
console.log("linked: ", linked)
t.equal(linked.Ok, null)
t.equal(linked.Ok, "QmZg7WfQhyUMzfd68VJZg9ah6WhtpLSZQe9BHaz8pmN3Pz")

const recommendedPosts = tash.call('blog', 'my_recommended_posts', {})
console.log("recommendedPosts", recommendedPosts)
Expand Down
47 changes: 45 additions & 2 deletions app_spec/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const scenario1 = new Scenario([instanceAlice], { debugLog:true })
const scenario2 = new Scenario([instanceAlice, instanceBob], { debugLog: true })
const scenario3 = new Scenario([instanceAlice, instanceBob, instanceCarol], { debugLog: true })

const testBridge = Config.bridge('test-bridge', instanceAlice, instanceBob)
const scenarioBridge = new Scenario([instanceAlice, instanceBob], { bridges: [testBridge], debugLog: true })

scenario2.runTape('sign_and_verify_message', async (t, { alice, bob }) => {
const message = "Hello everyone! Time to start the secret meeting";

Expand Down Expand Up @@ -146,6 +149,29 @@ scenario1.runTape('create_post', async (t, { alice }) => {
t.equal(result.Ok, "QmY6MfiuhHnQ1kg7RwNZJNUQhwDxTFL45AAPnpJMNPEoxk")
})

scenario2.runTape('create_post_countersigned', async (t, { alice, bob }) => {

const content = "Holo world"
const in_reply_to = null

const address_params = { content }
const address_result = bob.call("blog", "post_address", address_params)

t.ok(address_result.Ok)
const SignResult = bob.call("converse", "sign_message", { key_id:"", message: address_result.Ok });
t.ok(SignResult.Ok)

const counter_signature = [bob.agentId, SignResult.Ok];

const params = { content, in_reply_to, counter_signature }
const result = alice.call("blog", "create_post_countersigned", params)

t.ok(result.Ok)
t.notOk(result.Err)
t.equal(result.Ok, "QmY6MfiuhHnQ1kg7RwNZJNUQhwDxTFL45AAPnpJMNPEoxk")
})


scenario1.runTape('create_memo', async (t, { alice }) => {

const content = "Reminder: Buy some HOT."
Expand Down Expand Up @@ -266,7 +292,7 @@ scenario2.runTape('delete_entry_post', async (t, { alice, bob }) => {
const deletionParams = { post_address: createResult.Ok }
const deletionResult = await alice.callSync("blog", "delete_entry_post", deletionParams)

t.notOk(deletionResult.Ok)
t.ok(deletionResult.Ok)


//delete should fail
Expand Down Expand Up @@ -436,7 +462,7 @@ scenario2.runTape('remove_update_modifed_entry', async (t, { alice, bob }) => {
//delete
const removeParamsV2 = { post_address: createResult.Ok }
const removeResultV2 = await bob.callSync("blog", "delete_entry_post", removeParamsV2)
t.notOk(removeResultV2.Ok)
t.ok(removeResultV2.Ok)

//get v2 using initial adders
const Postv2Initial = alice.call("blog", "get_initial_post", { post_address: createResult.Ok })
Expand Down Expand Up @@ -635,6 +661,23 @@ scenario2.runTape('scenario test create & publish post -> get from other instanc
t.equal(value.content, initialContent)
})

scenarioBridge.runTape('scenario test create & publish -> getting post via bridge', async (t, {alice, bob}) => {

const initialContent = "Holo world"
const params = { content: initialContent, in_reply_to: null }
const create_result = await bob.callSync("blog", "create_post", params)

t.equal(create_result.Ok, "QmY6MfiuhHnQ1kg7RwNZJNUQhwDxTFL45AAPnpJMNPEoxk")

const post_address = create_result.Ok
const params_get = { post_address }

const result = alice.call("blog", "get_post_bridged", params_get)
console.log("BRIDGE CALL RESULT: " + JSON.stringify(result))
const value = JSON.parse(result.Ok.App[1])
t.equal(value.content, initialContent)
})

scenario2.runTape('request grant', async (t, { alice, bob }) => {

/*
Expand Down
2 changes: 1 addition & 1 deletion app_spec/zomes/blog/code/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "code"
version = "0.0.13-alpha1"
version = "0.0.14-alpha1"
authors = ["Holochain Core Dev Team <devcore@holochain.org>"]

[dependencies]
Expand Down
54 changes: 48 additions & 6 deletions app_spec/zomes/blog/code/src/blog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@ use hdk::{
entry::{cap_entries::CapabilityType, entry_type::EntryType, Entry},
error::HolochainError,
json::JsonString,
signature::Provenance
},
holochain_wasm_utils::api_serialization::{
get_entry::{
EntryHistory, GetEntryOptions, GetEntryResult, GetEntryResultType, StatusRequestKind,
},
commit_entry::CommitEntryOptions,
get_links::{GetLinksOptions, GetLinksResult},
},
AGENT_ADDRESS, AGENT_ID_STR, CAPABILITY_REQ, DNA_ADDRESS, DNA_NAME, PUBLIC_TOKEN,
};

use memo::Memo;
use post::Post;
use std::{collections::BTreeMap, convert::TryFrom};
use std::{collections::BTreeMap, convert::TryFrom, convert::TryInto};

#[derive(Serialize, Deserialize, Debug, DefaultJson, PartialEq)]
struct SumInput {
Expand Down Expand Up @@ -148,6 +150,27 @@ pub fn handle_create_post(content: String, in_reply_to: Option<Address>) -> Zome
Ok(address)
}

pub fn handle_create_post_countersigned(content: String, in_reply_to: Option<Address>,
counter_signature: Provenance) -> ZomeApiResult<Address> {

let entry = post_entry(content);

let options = CommitEntryOptions::new(vec![counter_signature]);

let address = hdk::commit_entry_result(&entry, options).unwrap().address();

hdk::link_entries(&AGENT_ADDRESS, &address, "authored_posts")?;

if let Some(in_reply_to_address) = in_reply_to {
// return with Err if in_reply_to_address points to missing entry
hdk::get_entry_result(&in_reply_to_address, GetEntryOptions::default())?;
hdk::link_entries(&in_reply_to_address, &address, "comments")?;
}

Ok(address)
}


pub fn handle_create_post_with_agent(
agent_id: Address,
content: String,
Expand Down Expand Up @@ -235,12 +258,10 @@ pub fn handle_get_post(post_address: Address) -> ZomeApiResult<Option<Entry>> {
hdk::get_entry(&post_address)
}

pub fn handle_delete_entry_post(post_address: Address) -> ZomeApiResult<()> {
pub fn handle_delete_entry_post(post_address: Address) -> ZomeApiResult<Address> {
hdk::get_entry(&post_address)?;

hdk::remove_entry(&post_address)?;

Ok(())
hdk::remove_entry(&post_address)
}

pub fn handle_get_initial_post(post_address: Address) -> ZomeApiResult<Option<Entry>> {
Expand Down Expand Up @@ -287,7 +308,7 @@ pub fn handle_update_post(post_address: Address, new_content: String) -> ZomeApi
}
}

pub fn handle_recommend_post(post_address: Address, agent_address: Address) -> ZomeApiResult<()> {
pub fn handle_recommend_post(post_address: Address, agent_address: Address) -> ZomeApiResult<Address> {
hdk::debug(format!("my address:\n{:?}", AGENT_ADDRESS.to_string()))?;
hdk::debug(format!("other address:\n{:?}", agent_address.to_string()))?;
hdk::link_entries(&agent_address, &post_address, "recommended_posts")
Expand All @@ -297,6 +318,27 @@ pub fn handle_my_recommended_posts() -> ZomeApiResult<GetLinksResult> {
hdk::get_links(&AGENT_ADDRESS, "recommended_posts")
}

pub fn handle_get_post_bridged(post_address: Address) -> ZomeApiResult<Option<Entry>> {
// Obtains the post via bridge to another instance
let raw_json = hdk::call(
"test-bridge",
"blog",
Address::from(PUBLIC_TOKEN.to_string()),
"get_post",
json!({
"post_address": post_address,
}).into()
)?;

hdk::debug(format!("********DEBUG******** BRIDGING RAW response from test-bridge {:?}", raw_json))?;

let entry : Option<Entry> = raw_json.try_into()?;

hdk::debug(format!("********DEBUG******** BRIDGING ACTUAL response from hosting-bridge {:?}", entry))?;

Ok(entry)
}

#[cfg(test)]
pub mod tests {

Expand Down
20 changes: 16 additions & 4 deletions app_spec/zomes/blog/code/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use hdk::{
error::ZomeApiResult,
holochain_core_types::{
cas::content::Address, entry::Entry, error::HolochainError, json::JsonString,
signature::Provenance
},
holochain_wasm_utils::api_serialization::{
get_entry::{EntryHistory, GetEntryResult},
Expand Down Expand Up @@ -93,6 +94,12 @@ define_zome! {
handler: blog::handle_create_post_with_agent
}

create_post_countersigned: {
inputs: |content: String, in_reply_to: Option<Address>, counter_signature:Provenance|,
outputs: |result: ZomeApiResult<Address>|,
handler: blog::handle_create_post_countersigned
}

request_post_grant: {
inputs: | |,
outputs: |result: ZomeApiResult<Option<Address>>|,
Expand All @@ -103,7 +110,6 @@ define_zome! {
inputs: | |,
outputs: |result: ZomeApiResult<Vec<Address>>|,
handler: blog::handle_get_grants

}

create_memo: {
Expand All @@ -120,7 +126,7 @@ define_zome! {

delete_entry_post: {
inputs: |post_address: Address|,
outputs: |result: ZomeApiResult<()>|,
outputs: |result: ZomeApiResult<Address>|,
handler: blog::handle_delete_entry_post
}

Expand Down Expand Up @@ -190,6 +196,12 @@ define_zome! {
handler: blog::handle_my_post_with_options
}

get_post_bridged: {
inputs: |post_address: Address|,
outputs: |post: ZomeApiResult<Option<Entry>>|,
handler: blog::handle_get_post_bridged
}

my_posts_immediate_timeout: {
inputs: | |,
outputs: |post_hashes: ZomeApiResult<GetLinksResult>|,
Expand All @@ -205,7 +217,7 @@ define_zome! {

recommend_post: {
inputs: |post_address: Address, agent_address: Address|,
outputs: |result: ZomeApiResult<()>|,
outputs: |result: ZomeApiResult<Address>|,
handler: blog::handle_recommend_post
}

Expand All @@ -217,6 +229,6 @@ define_zome! {
]

traits: {
hc_public [show_env, check_sum, check_send, get_sources, post_address, create_post, delete_post, delete_entry_post, update_post, posts_by_agent, get_post, my_posts, memo_address, get_memo, my_memos, create_memo, my_posts_as_committed, my_posts_immediate_timeout, recommend_post, my_recommended_posts,get_initial_post, get_history_post, get_post_with_options, get_post_with_options_latest, authored_posts_with_sources, create_post_with_agent, request_post_grant,get_grants]
hc_public [show_env, check_sum, check_send, get_sources, post_address, create_post, create_post_countersigned, delete_post, delete_entry_post, update_post, posts_by_agent, get_post, my_posts, memo_address, get_memo, my_memos, create_memo, my_posts_as_committed, my_posts_immediate_timeout, recommend_post, my_recommended_posts,get_initial_post, get_history_post, get_post_with_options, get_post_with_options_latest, authored_posts_with_sources, create_post_with_agent, request_post_grant, get_grants, get_post_bridged]
}
}
2 changes: 1 addition & 1 deletion app_spec/zomes/summer/code/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "code"
version = "0.0.13-alpha1"
version = "0.0.14-alpha1"
authors = ["Holochain Core Dev Team <devcore@holochain.org>"]

[dependencies]
Expand Down
2 changes: 0 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# https://www.appveyor.com/docs/enterprise/running-builds-on-aws/

build_cloud: azure
image: hc-azure

Expand Down
Loading

0 comments on commit 7ca721c

Please sign in to comment.