diff --git a/leo/commands/package/publish.rs b/leo/commands/package/publish.rs index 7b1fceb3a6..97bce33719 100644 --- a/leo/commands/package/publish.rs +++ b/leo/commands/package/publish.rs @@ -119,14 +119,17 @@ impl Command for Publish { .send(); // Get a response result - let result = match response { - Ok(json_result) => match json_result.json::() { - Ok(json) => json, - Err(error) => { - tracing::warn!("{:?}", error); - return Err(anyhow!("Package not published")); + let result: ResponseJson = match response { + Ok(json_result) => { + let text = json_result.text()?; + + match serde_json::from_str(&text) { + Ok(json) => json, + Err(_) => { + return Err(anyhow!("Package not published: {}", text)); + } } - }, + } Err(error) => { tracing::warn!("{:?}", error); return Err(anyhow!("Connection unavailable")); diff --git a/package/src/root/zip.rs b/package/src/root/zip.rs index 76f82c1aee..ee09917dd0 100644 --- a/package/src/root/zip.rs +++ b/package/src/root/zip.rs @@ -19,7 +19,7 @@ use crate::{ errors::ZipFileError, imports::IMPORTS_DIRECTORY_NAME, - inputs::{INPUTS_DIRECTORY_NAME, INPUT_FILE_EXTENSION}, + inputs::{INPUTS_DIRECTORY_NAME, INPUT_FILE_EXTENSION, STATE_FILE_EXTENSION}, outputs::{ CHECKSUM_FILE_EXTENSION, CIRCUIT_FILE_EXTENSION, @@ -151,9 +151,8 @@ impl ZipFile { /// Check if the file path should be included in the package zip file. fn is_included(path: &Path) -> bool { - // excluded directories: `input`, `output`, `imports` - if path.ends_with(INPUTS_DIRECTORY_NAME.trim_end_matches('/')) - | path.ends_with(OUTPUTS_DIRECTORY_NAME.trim_end_matches('/')) + // excluded directories: `output`, `imports` + if path.ends_with(OUTPUTS_DIRECTORY_NAME.trim_end_matches('/')) | path.ends_with(IMPORTS_DIRECTORY_NAME.trim_end_matches('/')) { return false; @@ -161,8 +160,7 @@ fn is_included(path: &Path) -> bool { // excluded extensions: `.in`, `.bytes`, `lpk`, `lvk`, `.proof`, `.sum`, `.zip`, `.bytes` if let Some(true) = path.extension().map(|ext| { - ext.eq(INPUT_FILE_EXTENSION.trim_start_matches('.')) - | ext.eq(ZIP_FILE_EXTENSION.trim_start_matches('.')) + ext.eq(ZIP_FILE_EXTENSION.trim_start_matches('.')) | ext.eq(PROVING_KEY_FILE_EXTENSION.trim_start_matches('.')) | ext.eq(VERIFICATION_KEY_FILE_EXTENSION.trim_start_matches('.')) | ext.eq(PROOF_FILE_EXTENSION.trim_start_matches('.')) @@ -173,6 +171,18 @@ fn is_included(path: &Path) -> bool { return false; } + // Allow `inputs` folder + if path.ends_with(INPUTS_DIRECTORY_NAME.trim_end_matches('/')) { + return true; + } + + // Allow `.state` and `.in` files + if let Some(true) = path.extension().map(|ext| { + ext.eq(INPUT_FILE_EXTENSION.trim_start_matches('.')) | ext.eq(STATE_FILE_EXTENSION.trim_start_matches('.')) + }) { + return true; + } + // Allow the README.md and Leo.toml files in the root directory if (path.ends_with(README_FILENAME) | path.ends_with(MANIFEST_FILENAME)) & (path.parent() == Some(Path::new(""))) { return true;