Skip to content

Commit

Permalink
No need to call deployment.num_combined_variables etc multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
ungaro committed Aug 27, 2024
1 parent 8f250fb commit 48bd831
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions leo/cli/commands/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,22 @@ fn handle_deploy<A: Aleo<Network = N, BaseField = N::Field>, N: Network>(
// Generate the deployment
let deployment = package.deploy::<A>(None)?;

let variables = deployment.num_combined_variables()?;
let constraints = deployment.num_combined_constraints()?;

// Check if the number of variables and constraints are within the limits.
if deployment.num_combined_variables()? > N::MAX_DEPLOYMENT_VARIABLES {
if variables > N::MAX_DEPLOYMENT_VARIABLES {
return Err(CliError::variable_limit_exceeded(name, N::MAX_DEPLOYMENT_VARIABLES, network).into());
}
if deployment.num_combined_constraints()? > N::MAX_DEPLOYMENT_CONSTRAINTS {
if constraints > N::MAX_DEPLOYMENT_CONSTRAINTS {
return Err(CliError::constraint_limit_exceeded(name, N::MAX_DEPLOYMENT_CONSTRAINTS, network).into());
}

// Print deployment summary with comma-formatted variables and constraints counts.
// Print deployment summary
println!(
"📊 Deployment Summary:\n Total Variables: {:>10}\n Total Constraints: {:>10}",
deployment.num_combined_variables()?.to_formatted_string(&Locale::en),
deployment.num_combined_constraints()?.to_formatted_string(&Locale::en)
variables.to_formatted_string(&Locale::en),
constraints.to_formatted_string(&Locale::en)
);

let deployment_id = deployment.to_deployment_id()?;
Expand Down

0 comments on commit 48bd831

Please sign in to comment.