Use network when invoking snarkos CLI

This commit is contained in:
Pranav Gaddamadugu 2024-06-05 07:57:08 -07:00
parent 4ee4ba7746
commit c721fa25b0
3 changed files with 14 additions and 0 deletions

View File

@ -97,6 +97,8 @@ impl Command for Deploy {
self.compiler_options.endpoint.clone(),
"--priority-fee".to_string(),
self.fee_options.priority_fee.to_string(),
"--network".to_string(),
network.id().to_string(),
"--path".to_string(),
path.to_str().unwrap().parse().unwrap(),
"--broadcast".to_string(),

View File

@ -105,6 +105,8 @@ fn handle_execute<N: Network>(command: Execute, context: Context) -> Result<<Exe
command.compiler_options.endpoint.clone(),
"--priority-fee".to_string(),
command.fee_options.priority_fee.to_string(),
"--network".to_string(),
N::ID.to_string(),
"--broadcast".to_string(),
format!("{}/{}/transaction/broadcast", command.compiler_options.endpoint, command.compiler_options.network)
.to_string(),

View File

@ -16,6 +16,7 @@
use leo_errors::{CliError, LeoError};
use serde::{Deserialize, Serialize};
use snarkvm::prelude::{MainnetV0, Network, TestnetV0};
use std::fmt;
// Retrievable networks for an external program
@ -27,6 +28,15 @@ pub enum NetworkName {
MainnetV0,
}
impl NetworkName {
pub fn id(&self) -> u16 {
match self {
NetworkName::TestnetV0 => TestnetV0::ID,
NetworkName::MainnetV0 => MainnetV0::ID,
}
}
}
impl TryFrom<&str> for NetworkName {
type Error = LeoError;