Skip to content

Commit

Permalink
chore(nargo)!: restrict CliError visibility to crate (#911)
Browse files Browse the repository at this point in the history
* chore: restrict CliError visibility to crate

* chore!: remove check_from_path from crate's  interface.

* chore: clippy
  • Loading branch information
TomAFrench authored Feb 24, 2023
1 parent 9b58da4 commit ed0e1ab
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 15 deletions.
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

0 comments on commit ed0e1ab

Please sign in to comment.