This commit is contained in:
evan-schott 2024-06-25 14:17:56 -07:00
parent b3d712bb15
commit 92a0ff4c28
4 changed files with 23 additions and 11 deletions

View File

@ -306,14 +306,14 @@ create_messages!(
msg: "Failed to confirm transaction".to_string(), msg: "Failed to confirm transaction".to_string(),
help: None, help: None,
} }
@backtraced @backtraced
invalid_balance { invalid_balance {
args: (account: impl Display), args: (account: impl Display),
msg: format!("Invalid public balance for account: {account}"), msg: format!("Invalid public balance for account: {account}"),
help: Some("Make sure the account has enough balance to pay for the deployment.".to_string()), help: Some("Make sure the account has enough balance to pay for the deployment.".to_string()),
} }
@backtraced @backtraced
table_render_failed { table_render_failed {
args: (error: impl Display), args: (error: impl Display),

View File

@ -193,7 +193,7 @@ create_messages!(
msg: format!("Invalid field: {field}."), msg: format!("Invalid field: {field}."),
help: Some("Field element must be numerical string with optional \"field\" suffix.".to_string()), help: Some("Field element must be numerical string with optional \"field\" suffix.".to_string()),
} }
@backtraced @backtraced
invalid_bound { invalid_bound {
args: (bound: impl Display), args: (bound: impl Display),

View File

@ -148,7 +148,7 @@ fn handle_deploy<A: Aleo<Network = N, BaseField = N::Field>, N: Network>(
synthesis_cost as f64 / 1_000_000.0, synthesis_cost as f64 / 1_000_000.0,
namespace_cost as f64 / 1_000_000.0, namespace_cost as f64 / 1_000_000.0,
command.fee_options.priority_fee as f64 / 1_000_000.0, command.fee_options.priority_fee as f64 / 1_000_000.0,
); )?;
// Initialize an RNG. // Initialize an RNG.
let rng = &mut rand::thread_rng(); let rng = &mut rand::thread_rng();
@ -240,7 +240,7 @@ fn deploy_cost_breakdown(
["Total", &format!("{:.6}", total_cost)], ["Total", &format!("{:.6}", total_cost)],
]; ];
let mut out = Vec::new(); let mut out = Vec::new();
text_tables::render(&mut out, data).map_err(|err| CliError::table_render_failed(err))?; text_tables::render(&mut out, data).map_err(CliError::table_render_failed)?;
println!("{}", ::std::str::from_utf8(&out).map_err(|err| CliError::table_render_failed(err))?); println!("{}", ::std::str::from_utf8(&out).map_err(CliError::table_render_failed)?);
Ok(()) Ok(())
} }

View File

@ -207,7 +207,7 @@ fn handle_execute<A: Aleo>(
storage_cost as f64 / 1_000_000.0, storage_cost as f64 / 1_000_000.0,
finalize_cost as f64 / 1_000_000.0, finalize_cost as f64 / 1_000_000.0,
command.fee_options.priority_fee as f64 / 1_000_000.0, command.fee_options.priority_fee as f64 / 1_000_000.0,
); )?;
// Check if the public balance is sufficient. // Check if the public balance is sufficient.
if fee_record.is_none() { if fee_record.is_none() {
@ -261,7 +261,13 @@ fn handle_execute<A: Aleo>(
} }
// Execute the request. // Execute the request.
let (response, execution, metrics) = package let (response, execution, metrics) = package
.execute::<A, _>(endpoint.to_string(), &private_key, Identifier::try_from(command.name.clone())?, &parsed_inputs, rng) .execute::<A, _>(
endpoint.to_string(),
&private_key,
Identifier::try_from(command.name.clone())?,
&parsed_inputs,
rng,
)
.map_err(PackageError::execution_error)?; .map_err(PackageError::execution_error)?;
let fee = None; let fee = None;
@ -369,7 +375,13 @@ fn load_program_from_network<N: Network>(
} }
// A helper function to display a cost breakdown of the execution. // A helper function to display a cost breakdown of the execution.
fn execution_cost_breakdown(name: &String, total_cost: f64, storage_cost: f64, finalize_cost: f64, priority_fee: f64) -> Result<()> { fn execution_cost_breakdown(
name: &String,
total_cost: f64,
storage_cost: f64,
finalize_cost: f64,
priority_fee: f64,
) -> Result<()> {
println!("\nBase execution cost for '{}' is {} credits.\n", name.bold(), total_cost); println!("\nBase execution cost for '{}' is {} credits.\n", name.bold(), total_cost);
// Display the cost breakdown in a table. // Display the cost breakdown in a table.
let data = [ let data = [
@ -380,7 +392,7 @@ fn execution_cost_breakdown(name: &String, total_cost: f64, storage_cost: f64, f
["Total", &format!("{:.6}", total_cost)], ["Total", &format!("{:.6}", total_cost)],
]; ];
let mut out = Vec::new(); let mut out = Vec::new();
text_tables::render(&mut out, data).map_err(|err| CliError::table_render_failed(err))?; text_tables::render(&mut out, data).map_err(CliError::table_render_failed)?;
println!("{}", std::str::from_utf8(&out).map_err(|err| CliError::table_render_failed(err))?); println!("{}", std::str::from_utf8(&out).map_err(CliError::table_render_failed)?);
Ok(()) Ok(())
} }