Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(nargo)!: restrict CliError visibility to crate #911

Merged
merged 3 commits into from
Feb 24, 2023
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
2 changes: 1 addition & 1 deletion crates/nargo/src/cli/check_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub(crate) fn run(args: CheckCommand, config: NargoConfig) -> Result<(), CliErro
Ok(())
}
// This is exposed so that we can run the examples and verify that they pass
pub fn check_from_path<P: AsRef<Path>>(p: P, allow_warnings: bool) -> Result<(), CliError> {
fn check_from_path<P: AsRef<Path>>(p: P, allow_warnings: bool) -> Result<(), CliError> {
let backend = crate::backends::ConcreteBackend;

let mut driver = Resolver::resolve_root_config(p.as_ref(), backend.np_language())?;
Expand Down
2 changes: 1 addition & 1 deletion crates/nargo/src/cli/compile_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn compile_and_preprocess_circuit<P: AsRef<Path>>(
Ok(circuit_path)
}

pub fn compile_circuit<P: AsRef<Path>>(
pub(crate) fn compile_circuit<P: AsRef<Path>>(
program_dir: P,
show_ssa: bool,
allow_warnings: bool,
Expand Down
4 changes: 2 additions & 2 deletions crates/nargo/src/cli/fs/inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use super::write_to_file;
/// let (input_map, return_value): (InputMap, Option<InputValue>) =
/// read_inputs_from_file(path, "Verifier", Format::Toml, &abi)?;
/// ```
pub fn read_inputs_from_file<P: AsRef<Path>>(
pub(crate) fn read_inputs_from_file<P: AsRef<Path>>(
path: P,
file_name: &str,
format: Format,
Expand All @@ -42,7 +42,7 @@ pub fn read_inputs_from_file<P: AsRef<Path>>(
Ok((input_map, return_value))
}

pub fn write_inputs_to_file<P: AsRef<Path>>(
pub(crate) fn write_inputs_to_file<P: AsRef<Path>>(
input_map: &InputMap,
return_value: &Option<InputValue>,
path: P,
Expand Down
2 changes: 1 addition & 1 deletion crates/nargo/src/cli/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub(crate) fn write_to_file(bytes: &[u8], path: &Path) -> String {
}
}

pub fn load_hex_data<P: AsRef<Path>>(path: P) -> Result<Vec<u8>, CliError> {
pub(crate) fn load_hex_data<P: AsRef<Path>>(path: P) -> Result<Vec<u8>, CliError> {
let hex_data: Vec<_> =
std::fs::read(&path).map_err(|_| CliError::PathNotValid(path.as_ref().to_path_buf()))?;

Expand Down
2 changes: 1 addition & 1 deletion crates/nargo/src/cli/gates_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub(crate) fn run(args: GatesCommand, config: NargoConfig) -> Result<(), CliErro
count_gates_with_path(config.program_dir, args.show_ssa, args.allow_warnings)
}

pub fn count_gates_with_path<P: AsRef<Path>>(
fn count_gates_with_path<P: AsRef<Path>>(
program_dir: P,
show_ssa: bool,
allow_warnings: bool,
Expand Down
1 change: 0 additions & 1 deletion crates/nargo/src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub use check_cmd::check_from_path;
use clap::{Args, Parser, Subcommand};
use const_format::formatcp;
use noirc_abi::InputMap;
Expand Down
2 changes: 1 addition & 1 deletion crates/nargo/src/cli/prove_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub(crate) fn run(args: ProveCommand, config: NargoConfig) -> Result<(), CliErro
Ok(())
}

pub fn prove_with_path<P: AsRef<Path>>(
pub(crate) fn prove_with_path<P: AsRef<Path>>(
proof_name: Option<String>,
program_dir: P,
proof_dir: P,
Expand Down
6 changes: 1 addition & 5 deletions crates/nargo/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
use thiserror::Error;

#[derive(Debug, Error)]
pub enum CliError {
pub(crate) enum CliError {
#[error("{0}")]
Generic(String),
#[error("Error: destination {} already exists", .0.display())]
Expand All @@ -19,10 +19,6 @@ pub enum CliError {
" Error: cannot find {0}.toml file.\n Expected location: {1:?} \n Please generate this file at the expected location."
)]
MissingTomlFile(String, PathBuf),
#[error("Error: cannot find proving key located at {}\nEither run `nargo compile` to generate the missing proving key or check that the correct file name has been provided", .0.display())]
MissingProvingKey(PathBuf),
#[error("Error: cannot find verification key located at {}\nEither run `nargo compile` to generate the missing verification key or check that the correct file name has been provided", .0.display())]
MissingVerificationkey(PathBuf),
#[error("Error: the circuit you are trying to prove differs from the build artifact at {}\nYou must call `nargo compile` to generate the correct proving and verification keys for this circuit", .0.display())]
MismatchedAcir(PathBuf),
#[error("Failed to verify proof {}", .0.display())]
Expand Down
2 changes: 1 addition & 1 deletion crates/nargo/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct CachedDep {
/// or it uses the repo on the cache.
/// Downloading will be recursive, so if a package contains packages
/// We need to download those too
pub struct Resolver<'a> {
pub(crate) struct Resolver<'a> {
cached_packages: HashMap<PathBuf, (CrateId, CachedDep)>,
driver: &'a mut Driver,
}
Expand Down
2 changes: 1 addition & 1 deletion crates/nargo/src/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub enum Dependency {
/// Parses a Nargo.toml file from it's path
/// The path to the toml file must be present.
/// Calling this function without this guarantee is an ICE.
pub fn parse<P: AsRef<Path>>(path_to_toml: P) -> Result<Config, CliError> {
pub(crate) fn parse<P: AsRef<Path>>(path_to_toml: P) -> Result<Config, CliError> {
let toml_as_string =
std::fs::read_to_string(&path_to_toml).expect("ice: path given for toml file is invalid");

Expand Down