- now inputs are published to Aleo PM
- error json message is printed to user
This commit is contained in:
damirka 2021-02-17 21:49:20 +03:00
parent a7c9caf4b3
commit 6caf915701
2 changed files with 27 additions and 13 deletions

View File

@ -119,14 +119,18 @@ impl Command for Publish {
.send();
// Get a response result
let result = match response {
Ok(json_result) => match json_result.json::<ResponseJson>() {
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(_) => {
// tracing::warn!("Received an error from PM {:?}", text.clone());
return Err(anyhow!("Package not published: {}", text));
}
}
},
}
Err(error) => {
tracing::warn!("{:?}", error);
return Err(anyhow!("Connection unavailable"));

View File

@ -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;