diff --git a/CHANGELOG.md b/CHANGELOG.md index dd5bc019f2..6c797d0746 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Adds pickle db for cas and eav [#1178](https://github.com/holochain/holochain-rust/pull/1178) - Adds a `--quiet` option to `hc keygen` for machine-readable output, intended for use in scripts. [#1197](https://github.com/holochain/holochain-rust/pull/1197) - Adds logging output for every failed WASM execution showing the call that caused this error. [#1200](https://github.com/holochain/holochain-rust/pull/1200) This helps with debugging "Arguement Deserialization failed" errors. +- Adds DNA hash to `hc package` output [#1212](https://github.com/holochain/holochain-rust/pull/1212) ### Changed diff --git a/cli/src/cli/package.rs b/cli/src/cli/package.rs index 04bdccc678..4089f44006 100644 --- a/cli/src/cli/package.rs +++ b/cli/src/cli/package.rs @@ -2,9 +2,11 @@ use crate::{config_files::Build, error::DefaultResult, util}; use base64; use colored::*; use holochain_core::nucleus::ribosome::{run_dna, WasmCallData}; +use holochain_core_types::{cas::content::AddressableContent, dna::Dna, json::JsonString}; use ignore::WalkBuilder; use serde_json::{self, Map, Value}; use std::{ + convert::TryFrom, fs::{self, File}, io::{Read, Write}, path::PathBuf, @@ -60,18 +62,22 @@ impl Packager { } fn run(&self, output: &PathBuf) -> DefaultResult<()> { - let dir_obj_bundle = self.bundle_recurse(&std::env::current_dir()?)?; + let dir_obj_bundle = Value::from(self.bundle_recurse(&std::env::current_dir()?)?); + + let dna_json = JsonString::from_json(&dir_obj_bundle.to_string()); + let dna = Dna::try_from(dna_json)?; let out_file = File::create(&output)?; - serde_json::to_writer_pretty(&out_file, &Value::from(dir_obj_bundle))?; + serde_json::to_writer_pretty(&out_file, &(dir_obj_bundle))?; // CLI feedback println!( - "{} dna package file at {:?}", + "{} DNA package file at {:?}", "Created".green().bold(), output ); + println!("DNA hash: {}", dna.address()); Ok(()) } diff --git a/core_types/src/error/mod.rs b/core_types/src/error/mod.rs index 0a79b3692e..ca3e5074f4 100644 --- a/core_types/src/error/mod.rs +++ b/core_types/src/error/mod.rs @@ -136,7 +136,7 @@ impl fmt::Display for HolochainError { InitializationFailed(err_msg) => write!(f, "{}", err_msg), DnaHashMismatch(hash1, hash2) => write!( f, - "DNA hash does not match expected hash!\n{} != {}", + "DNA hash does not match expected hash! {} != {}", hash1, hash2 ), } diff --git a/doc/holochain_101/src/json_string.md b/doc/holochain_101/src/json_string.md index 6e7841c944..7301be3d5f 100644 --- a/doc/holochain_101/src/json_string.md +++ b/doc/holochain_101/src/json_string.md @@ -244,7 +244,7 @@ Yes, `serde` supports many serialization options but: - Serde is already quite heavy in compilation/WASM files so we don't want to bloat that more with edge-case serialization needs - every new format is a new crate -- We don't (yet) have any use-cases showing that JSON is a problem/bottlenec