mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-27 12:17:35 +03:00
remove unused logic
This commit is contained in:
parent
9ccae18622
commit
f4a32331b7
@ -88,13 +88,13 @@ impl Command for Build {
|
||||
fn apply(self, context: Context, _: Self::Input) -> Result<Self::Output> {
|
||||
let path = context.dir()?;
|
||||
let manifest = context.manifest().map_err(|_| CliError::manifest_file_not_found())?;
|
||||
let package_name = manifest.get_package_name();
|
||||
let imports_map = manifest.get_imports_map().unwrap_or_default();
|
||||
|
||||
// Error out if there are dependencies but no lock file found.
|
||||
if !imports_map.is_empty() && !context.lock_file_exists()? {
|
||||
return Err(CliError::dependencies_are_not_installed().into());
|
||||
}
|
||||
let package_name = manifest.program_id().name().to_string();
|
||||
// let imports_map = manifest.get_imports_map().unwrap_or_default();
|
||||
//
|
||||
// // Error out if there are dependencies but no lock file found.
|
||||
// if !imports_map.is_empty() && !context.lock_file_exists()? {
|
||||
// return Err(CliError::dependencies_are_not_installed().into());
|
||||
// }
|
||||
|
||||
// Sanitize the package path to the root directory.
|
||||
let mut package_path = path.clone();
|
||||
|
@ -39,7 +39,7 @@ impl Command for Clean {
|
||||
|
||||
fn apply(self, context: Context, _: Self::Input) -> Result<Self::Output> {
|
||||
let path = context.dir()?;
|
||||
let package_name = context.manifest()?.get_package_name();
|
||||
let package_name = context.manifest()?.program_id().name().to_string();
|
||||
|
||||
// Removes the aleo file from the output directory.
|
||||
|
||||
|
@ -21,15 +21,15 @@ pub use build::Build;
|
||||
pub mod clean;
|
||||
pub use clean::Clean;
|
||||
|
||||
pub mod run;
|
||||
pub use run::Run;
|
||||
|
||||
// pub mod init;
|
||||
// pub use init::Init;
|
||||
|
||||
// pub mod new;
|
||||
// pub use new::New;
|
||||
|
||||
// pub mod run;
|
||||
// pub use run::Run;
|
||||
|
||||
use crate::context::*;
|
||||
use leo_errors::Result;
|
||||
|
||||
|
@ -14,18 +14,17 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use super::{build::BuildOptions, prove::Prove};
|
||||
use super::build::BuildOptions;
|
||||
use crate::{commands::Command, context::Context};
|
||||
use leo_errors::{Result, SnarkVMError};
|
||||
use leo_errors::Result;
|
||||
|
||||
use snarkvm_algorithms::{snark::groth16::Groth16, traits::SNARK};
|
||||
use snarkvm_curves::bls12_377::{Bls12_377, Fr};
|
||||
use structopt::StructOpt;
|
||||
// use aleo::commands::CLI as AleoCLI;
|
||||
|
||||
use clap::StructOpt;
|
||||
use tracing::span::Span;
|
||||
|
||||
/// Build, Prove and Run Leo program with inputs
|
||||
#[derive(StructOpt, Debug)]
|
||||
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
|
||||
pub struct Run {
|
||||
#[structopt(long = "skip-key-check", help = "Skip key verification on Setup stage")]
|
||||
pub(crate) skip_key_check: bool,
|
||||
@ -35,35 +34,25 @@ pub struct Run {
|
||||
}
|
||||
|
||||
impl Command for Run {
|
||||
type Input = <Prove as Command>::Output;
|
||||
type Input = ();
|
||||
type Output = ();
|
||||
|
||||
fn log_span(&self) -> Span {
|
||||
tracing::span!(tracing::Level::INFO, "Verifying")
|
||||
tracing::span!(tracing::Level::INFO, "Executing")
|
||||
}
|
||||
|
||||
fn prelude(&self, context: Context) -> Result<Self::Input> {
|
||||
(Prove {
|
||||
skip_key_check: self.skip_key_check,
|
||||
compiler_options: self.compiler_options.clone(),
|
||||
})
|
||||
.execute(context)
|
||||
fn prelude(&self, _context: Context) -> Result<Self::Input> {
|
||||
Ok(()) // todo: call aleo build here?
|
||||
}
|
||||
|
||||
fn apply(self, _context: Context, input: Self::Input) -> Result<Self::Output> {
|
||||
let (proof, prepared_verifying_key) = input;
|
||||
|
||||
fn apply(self, _context: Context, _input: Self::Input) -> Result<Self::Output> {
|
||||
tracing::info!("Starting...");
|
||||
|
||||
// Run the verifier
|
||||
let is_success = Groth16::<Bls12_377, Vec<Fr>>::verify_prepared(&prepared_verifying_key, &vec![], &proof)
|
||||
.map_err(|_| SnarkVMError::default())?;
|
||||
// Execute the aleo program.
|
||||
// let cli = AleoCLI::parse_from(&["aleo", "run", "main"]);
|
||||
|
||||
// Log the verifier output
|
||||
match is_success {
|
||||
true => tracing::info!("Proof is valid"),
|
||||
false => tracing::error!("Proof is invalid"),
|
||||
};
|
||||
// tracing::info!("Result: {}", res);
|
||||
|
||||
Ok(())
|
||||
}
|
@ -16,9 +16,11 @@
|
||||
|
||||
use crate::{api::Api, config};
|
||||
use leo_errors::{CliError, Result};
|
||||
use leo_package::root::{LockFile, Manifest};
|
||||
|
||||
use std::{convert::TryFrom, env::current_dir, path::PathBuf};
|
||||
use snarkvm::file::Manifest;
|
||||
use snarkvm::prelude::Testnet3;
|
||||
|
||||
use std::{env::current_dir, path::PathBuf};
|
||||
|
||||
pub const PACKAGE_MANAGER_URL: &str = "https://api.aleo.pm/";
|
||||
|
||||
@ -42,18 +44,8 @@ impl Context {
|
||||
}
|
||||
|
||||
/// Get package manifest for current context.
|
||||
pub fn manifest(&self) -> Result<Manifest> {
|
||||
Ok(Manifest::try_from(self.dir()?.as_path())?)
|
||||
}
|
||||
|
||||
/// Get lock file for current context.
|
||||
pub fn lock_file(&self) -> Result<LockFile> {
|
||||
Ok(LockFile::try_from(self.dir()?.as_path())?)
|
||||
}
|
||||
|
||||
/// Check if lock file exists.
|
||||
pub fn lock_file_exists(&self) -> Result<bool> {
|
||||
Ok(LockFile::exists_at(&self.dir()?))
|
||||
pub fn manifest(&self) -> Result<Manifest<Testnet3>> {
|
||||
Ok(Manifest::<Testnet3>::open(self.dir()?.as_path())?)
|
||||
}
|
||||
}
|
||||
|
||||
|
27
leo/main.rs
27
leo/main.rs
@ -79,11 +79,11 @@ enum Commands {
|
||||
#[structopt(flatten)]
|
||||
command: Clean,
|
||||
},
|
||||
// #[structopt(about = "Run a program with input variables")]
|
||||
// Run {
|
||||
// #[structopt(flatten)]
|
||||
// command: Run,
|
||||
// },
|
||||
#[structopt(about = "Run a program with input variables")]
|
||||
Run {
|
||||
#[structopt(flatten)]
|
||||
command: Run,
|
||||
},
|
||||
}
|
||||
|
||||
fn set_panic_hook() {
|
||||
@ -150,22 +150,7 @@ pub fn run_with_args(cli: CLI) -> Result<()> {
|
||||
// CommandOpts::New { command } => command.try_execute(context),
|
||||
Commands::Build { command } => command.try_execute(context),
|
||||
Commands::Clean { command } => command.try_execute(context),
|
||||
// CommandOpts::Setup { command } => command.try_execute(context),
|
||||
// CommandOpts::Prove { command } => command.try_execute(context),
|
||||
// CommandOpts::Test { command } => command.try_execute(context),
|
||||
// CommandOpts::Run { command } => command.try_execute(context),
|
||||
// CommandOpts::Watch { command } => command.try_execute(context),
|
||||
// CommandOpts::Update { command } => command.try_execute(context),
|
||||
//
|
||||
// // CommandOpts::Add { command } => command.try_execute(context),
|
||||
// CommandOpts::Fetch { command } => command.try_execute(context),
|
||||
// CommandOpts::Clone { command } => command.try_execute(context),
|
||||
// CommandOpts::Login { command } => command.try_execute(context),
|
||||
// CommandOpts::Logout { command } => command.try_execute(context),
|
||||
// CommandOpts::Publish { command } => command.try_execute(context),
|
||||
// // CommandOpts::Remove { command } => command.try_execute(context),
|
||||
// CommandOpts::Lint { command } => command.try_execute(context),
|
||||
// CommandOpts::Deploy { command } => command.try_execute(context),
|
||||
Commands::Run { command } => command.try_execute(context),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,18 +0,0 @@
|
||||
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||
// This file is part of the Leo library.
|
||||
|
||||
// The Leo library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// The Leo library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
pub mod directory;
|
||||
pub use directory::*;
|
@ -19,9 +19,3 @@ pub use directory::*;
|
||||
|
||||
pub mod input;
|
||||
pub use input::*;
|
||||
|
||||
pub mod pairs;
|
||||
pub use pairs::*;
|
||||
|
||||
pub mod state;
|
||||
pub use state::*;
|
||||
|
@ -16,32 +16,32 @@
|
||||
|
||||
#![doc = include_str!("../README.md")]
|
||||
|
||||
pub mod imports;
|
||||
// pub mod imports;
|
||||
pub mod inputs;
|
||||
pub mod outputs;
|
||||
pub mod package;
|
||||
pub mod root;
|
||||
pub mod source;
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use leo_errors::Result;
|
||||
|
||||
pub struct LeoPackage;
|
||||
|
||||
impl LeoPackage {
|
||||
/// Initializes a Leo package at the given path.
|
||||
pub fn initialize(package_name: &str, path: &Path, author: Option<String>) -> Result<()> {
|
||||
package::Package::initialize(package_name, path, author)
|
||||
}
|
||||
|
||||
/// Returns `true` if the given Leo package name is valid.
|
||||
pub fn is_package_name_valid(package_name: &str) -> bool {
|
||||
package::Package::is_package_name_valid(package_name)
|
||||
}
|
||||
|
||||
/// Removes an imported Leo package
|
||||
pub fn remove_imported_package(package_name: &str, path: &Path) -> Result<()> {
|
||||
package::Package::remove_imported_package(package_name, path)
|
||||
}
|
||||
}
|
||||
// use std::path::Path;
|
||||
//
|
||||
// use leo_errors::Result;
|
||||
//
|
||||
// pub struct LeoPackage;
|
||||
//
|
||||
// impl LeoPackage {
|
||||
// /// Initializes a Leo package at the given path.
|
||||
// pub fn initialize(package_name: &str, path: &Path, author: Option<String>) -> Result<()> {
|
||||
// package::Package::initialize(package_name, path, author)
|
||||
// }
|
||||
//
|
||||
// /// Returns `true` if the given Leo package name is valid.
|
||||
// pub fn is_package_name_valid(package_name: &str) -> bool {
|
||||
// package::Package::is_package_name_valid(package_name)
|
||||
// }
|
||||
//
|
||||
// /// Removes an imported Leo package
|
||||
// pub fn remove_imported_package(package_name: &str, path: &Path) -> Result<()> {
|
||||
// package::Package::remove_imported_package(package_name, path)
|
||||
// }
|
||||
// }
|
||||
|
@ -26,13 +26,4 @@ pub use self::checksum::*;
|
||||
pub mod directory;
|
||||
pub use directory::*;
|
||||
|
||||
pub mod proof;
|
||||
pub use self::proof::*;
|
||||
|
||||
pub mod proving_key;
|
||||
pub use self::proving_key::*;
|
||||
|
||||
pub mod verification_key;
|
||||
pub use self::verification_key::*;
|
||||
|
||||
pub static MAIN_ALEO_FILE_NAME: &str = "main.aleo";
|
||||
|
@ -15,9 +15,8 @@
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{
|
||||
imports::ImportsDirectory,
|
||||
inputs::{InputFile, InputsDirectory, StateFile},
|
||||
root::{Gitignore, Manifest, README},
|
||||
inputs::{InputFile, InputsDirectory},
|
||||
root::{Gitignore, README},
|
||||
source::{MainFile, SourceDirectory},
|
||||
};
|
||||
|
||||
@ -117,12 +116,6 @@ impl Package {
|
||||
let mut result = true;
|
||||
let mut existing_files = vec![];
|
||||
|
||||
// Check if the manifest file already exists.
|
||||
if Manifest::exists_at(path) {
|
||||
existing_files.push(Manifest::filename());
|
||||
result = false;
|
||||
}
|
||||
|
||||
// Check if the input file already exists.
|
||||
let input_file = InputFile::new(package_name);
|
||||
if input_file.exists_at(path) {
|
||||
@ -130,13 +123,6 @@ impl Package {
|
||||
result = false;
|
||||
}
|
||||
|
||||
// Check if the state file already exists.
|
||||
let state_file = StateFile::new(package_name);
|
||||
if state_file.exists_at(path) {
|
||||
existing_files.push(state_file.filename());
|
||||
result = false;
|
||||
}
|
||||
|
||||
// Check if the main file already exists.
|
||||
if MainFile::exists_at(path) {
|
||||
existing_files.push(MainFile::filename());
|
||||
@ -157,23 +143,12 @@ impl Package {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the manifest file exists.
|
||||
if !Manifest::exists_at(path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the input file exists.
|
||||
let input_file = InputFile::new(package_name);
|
||||
if !input_file.exists_at(path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the state file exists.
|
||||
let state_file = StateFile::new(package_name);
|
||||
if !state_file.exists_at(path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the main file exists.
|
||||
if !MainFile::exists_at(path) {
|
||||
return false;
|
||||
@ -183,7 +158,7 @@ impl Package {
|
||||
}
|
||||
|
||||
/// Creates a package at the given path
|
||||
pub fn initialize(package_name: &str, path: &Path, author: Option<String>) -> Result<()> {
|
||||
pub fn initialize(package_name: &str, path: &Path, _author: Option<String>) -> Result<()> {
|
||||
// First, verify that this directory is not already initialized as a Leo package.
|
||||
{
|
||||
if !Self::can_initialize(package_name, path) {
|
||||
@ -192,9 +167,6 @@ impl Package {
|
||||
}
|
||||
// Next, initialize this directory as a Leo package.
|
||||
{
|
||||
// Create the manifest file.
|
||||
Manifest::new(package_name, author)?.write_to(path)?;
|
||||
|
||||
// Verify that the .gitignore file does not exist.
|
||||
if !Gitignore::exists_at(path) {
|
||||
// Create the .gitignore file.
|
||||
@ -216,9 +188,6 @@ impl Package {
|
||||
// Create the input file in the inputs directory.
|
||||
InputFile::new(package_name).write_to(path)?;
|
||||
|
||||
// Create the state file in the inputs directory.
|
||||
StateFile::new(package_name).write_to(path)?;
|
||||
|
||||
// Create the main file in the source directory.
|
||||
MainFile::new(package_name).write_to(path)?;
|
||||
}
|
||||
@ -231,11 +200,11 @@ impl Package {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Removes the package at the given path
|
||||
pub fn remove_imported_package(package_name: &str, path: &Path) -> Result<()> {
|
||||
ImportsDirectory::remove_import(path, package_name)
|
||||
}
|
||||
//
|
||||
// /// Removes the package at the given path
|
||||
// pub fn remove_imported_package(package_name: &str, path: &Path) -> Result<()> {
|
||||
// ImportsDirectory::remove_import(path, package_name)
|
||||
// }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -17,11 +17,5 @@
|
||||
pub mod gitignore;
|
||||
pub use self::gitignore::*;
|
||||
|
||||
pub mod lock_file;
|
||||
pub use self::lock_file::*;
|
||||
|
||||
pub mod manifest;
|
||||
pub use self::manifest::*;
|
||||
|
||||
pub mod readme;
|
||||
pub use self::readme::*;
|
||||
|
Loading…
Reference in New Issue
Block a user