mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-10-26 15:13:13 +03:00
style
This commit is contained in:
parent
57599607d0
commit
4d04b603ba
@ -215,4 +215,11 @@ create_messages!(
|
||||
msg: format!("Failed to read private key from environment.\nIO Error: {error}"),
|
||||
help: Some("Pass in private key using `--private-key <PRIVATE-KEY>` or create a .env file with your private key information. See examples for formatting information.".to_string()),
|
||||
}
|
||||
|
||||
@backtraced
|
||||
recursive_deploy_with_record {
|
||||
args: (),
|
||||
msg: "Cannot combine recursive deploy with private fee.".to_string(),
|
||||
help: None,
|
||||
}
|
||||
);
|
||||
|
@ -370,4 +370,17 @@ create_messages!(
|
||||
help: None,
|
||||
}
|
||||
|
||||
@backtraced
|
||||
missing_on_chain_program_name {
|
||||
args: (),
|
||||
msg: "The name of the program to execute on-chain is missing.".to_string(),
|
||||
help: Some("Either set `--local` to execute the local program on chain, or set `--program <PROGRAM>`.".to_string()),
|
||||
}
|
||||
|
||||
@backtraced
|
||||
conflicting_on_chain_program_name {
|
||||
args: (first: impl Display, second: impl Display),
|
||||
msg: format!("Conflicting program names given to execute on chain: `{first}` and `{second}`."),
|
||||
help: Some("Either set `--local` to execute the local program on chain, or set `--program <PROGRAM>`.".to_string()),
|
||||
}
|
||||
);
|
||||
|
@ -26,16 +26,16 @@ pub struct Deploy {
|
||||
pub endpoint: String,
|
||||
#[clap(flatten)]
|
||||
pub(crate) fee_options: FeeOptions,
|
||||
#[clap(long, help = "Disables building of the project before deployment", default_value = "false")]
|
||||
#[clap(long, help = "Disables building of the project before deployment.", default_value = "false")]
|
||||
pub(crate) no_build: bool,
|
||||
#[clap(long, help = "Disables recursive deployment of dependencies", default_value = "false")]
|
||||
pub(crate) non_recursive: bool,
|
||||
#[clap(long, help = "Enables recursive deployment of dependencies.", default_value = "false")]
|
||||
pub(crate) recursive: bool,
|
||||
#[clap(
|
||||
long,
|
||||
help = "Custom wait gap between consecutive deployments. This is to help prevent a program from trying to be included in an earlier block than its dependency program.",
|
||||
help = "Time in seconds to wait between consecutive deployments. This is to help prevent a program from trying to be included in an earlier block than its dependency program.",
|
||||
default_value = "12"
|
||||
)]
|
||||
pub(crate) wait_gap: u64,
|
||||
pub(crate) wait: u64,
|
||||
}
|
||||
|
||||
impl Command for Deploy {
|
||||
@ -67,7 +67,11 @@ impl Command for Deploy {
|
||||
let mut all_paths: Vec<(String, PathBuf)> = Vec::new();
|
||||
|
||||
// Extract post-ordered list of local dependencies' paths from `leo.lock`.
|
||||
if !self.non_recursive {
|
||||
if self.recursive {
|
||||
// Cannot combine with private fee.
|
||||
if self.fee_options.record.is_some() {
|
||||
return Err(CliError::recursive_deploy_with_record().into());
|
||||
}
|
||||
all_paths = context.local_dependency_paths()?;
|
||||
}
|
||||
|
||||
@ -105,7 +109,7 @@ impl Command for Deploy {
|
||||
// Sleep for `wait_gap` seconds.
|
||||
// This helps avoid parents from being serialized before children.
|
||||
if index < all_paths.len() - 1 {
|
||||
std::thread::sleep(std::time::Duration::from_secs(self.wait_gap));
|
||||
std::thread::sleep(std::time::Duration::from_secs(self.wait));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,10 +29,12 @@ pub struct Execute {
|
||||
name: String,
|
||||
#[clap(name = "INPUTS", help = "The inputs to the program.")]
|
||||
inputs: Vec<String>,
|
||||
#[clap(long, help = "Execute the transition on chain", default_value = "false")]
|
||||
#[clap(short, long, help = "Execute the transition on-chain.", default_value = "false")]
|
||||
broadcast: bool,
|
||||
#[clap(short, long, help = "Execute a different program from the one in the current working directory.")]
|
||||
external: Option<String>,
|
||||
#[clap(short, long, help = "Execute the local program on-chain.", default_value = "false")]
|
||||
local: bool,
|
||||
#[clap(short, long, help = "The program to execute on-chain.")]
|
||||
program: Option<String>,
|
||||
#[clap(flatten)]
|
||||
fee_options: FeeOptions,
|
||||
#[clap(flatten)]
|
||||
@ -51,7 +53,7 @@ impl Command for Execute {
|
||||
|
||||
fn prelude(&self, context: Context) -> Result<Self::Input> {
|
||||
// No need to build if we are executing an external program.
|
||||
if self.external.is_some() {
|
||||
if self.program.is_some() {
|
||||
return Ok(());
|
||||
}
|
||||
(Build { options: self.compiler_options.clone() }).execute(context)
|
||||
@ -60,10 +62,20 @@ impl Command for Execute {
|
||||
fn apply(self, context: Context, _input: Self::Input) -> Result<Self::Output> {
|
||||
// If the `broadcast` flag is set, then broadcast the transaction.
|
||||
if self.broadcast {
|
||||
// Get the program name. Override local project if external name provided.
|
||||
let program_name = match self.external {
|
||||
Some(name) => name,
|
||||
None => context.open_manifest()?.program_id().to_string(),
|
||||
// Get the program name.
|
||||
let program_name = match (self.program, self.local) {
|
||||
(Some(name), true) => {
|
||||
let local = context.open_manifest()?.program_id().to_string();
|
||||
// Throw error if local name doesn't match the specified name.
|
||||
if name == local {
|
||||
local
|
||||
} else {
|
||||
return Err(PackageError::conflicting_on_chain_program_name(local, name).into());
|
||||
}
|
||||
}
|
||||
(Some(name), false) => name,
|
||||
(None, true) => context.open_manifest()?.program_id().to_string(),
|
||||
(None, false) => return Err(PackageError::missing_on_chain_program_name().into()),
|
||||
};
|
||||
|
||||
// Get the private key.
|
||||
|
@ -162,7 +162,7 @@ pub struct BuildOptions {
|
||||
/// Used by Execute and Deploy commands.
|
||||
#[derive(Parser, Clone, Debug, Default)]
|
||||
pub struct FeeOptions {
|
||||
#[clap(long, help = "Priority fee in microcredits. Defaults to 1000000.", default_value = "1000000")]
|
||||
#[clap(long, help = "Priority fee in microcredits. Defaults to 0.", default_value = "0")]
|
||||
pub(crate) priority_fee: String,
|
||||
#[clap(long, help = "Network to broadcast to. Defaults to testnet3.", default_value = "testnet3")]
|
||||
pub(crate) network: String,
|
||||
|
Loading…
Reference in New Issue
Block a user