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

Print DNA hash in hc package output #1212

Merged
merged 4 commits into from
Apr 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 9 additions & 3 deletions cli/src/cli/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(())
}
Expand Down
2 changes: 1 addition & 1 deletion core_types/src/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
}
Expand Down
2 changes: 1 addition & 1 deletion doc/holochain_101/src/json_string.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<k
- We don't (yet) have any use-cases showing that JSON is a problem/bottleneck
- Adding more serialization options would exacerbate non-idiomatic conductor
and HDK data structure mapping issues (see above)

Expand Down