clap-utils: Add more compute unit helpers (#440)
* clap-utils: Refactor compute_unit_price into compute_budget * clap-utils: Validate compute unit price as a u64 * clap-utils: Add compute unit limit arg * clap-v3-utils: Add compute unit price and limit helpers * Add deprecation on `pub use` even though it isn't triggered
This commit is contained in:
parent
10d06773cd
commit
8246590f47
|
@ -0,0 +1,34 @@
|
|||
use {
|
||||
crate::{input_validators::is_parsable, ArgConstant},
|
||||
clap::Arg,
|
||||
};
|
||||
|
||||
pub const COMPUTE_UNIT_PRICE_ARG: ArgConstant<'static> = ArgConstant {
|
||||
name: "compute_unit_price",
|
||||
long: "--with-compute-unit-price",
|
||||
help: "Set compute unit price for transaction, in increments of 0.000001 lamports per compute unit.",
|
||||
};
|
||||
|
||||
pub const COMPUTE_UNIT_LIMIT_ARG: ArgConstant<'static> = ArgConstant {
|
||||
name: "compute_unit_limit",
|
||||
long: "--with-compute-unit-limit",
|
||||
help: "Set compute unit limit for transaction.",
|
||||
};
|
||||
|
||||
pub fn compute_unit_price_arg<'a, 'b>() -> Arg<'a, 'b> {
|
||||
Arg::with_name(COMPUTE_UNIT_PRICE_ARG.name)
|
||||
.long(COMPUTE_UNIT_PRICE_ARG.long)
|
||||
.takes_value(true)
|
||||
.value_name("COMPUTE-UNIT-PRICE")
|
||||
.validator(is_parsable::<u64>)
|
||||
.help(COMPUTE_UNIT_PRICE_ARG.help)
|
||||
}
|
||||
|
||||
pub fn compute_unit_limit_arg<'a, 'b>() -> Arg<'a, 'b> {
|
||||
Arg::with_name(COMPUTE_UNIT_LIMIT_ARG.name)
|
||||
.long(COMPUTE_UNIT_LIMIT_ARG.long)
|
||||
.takes_value(true)
|
||||
.value_name("COMPUTE-UNIT-LIMIT")
|
||||
.validator(is_parsable::<u32>)
|
||||
.help(COMPUTE_UNIT_LIMIT_ARG.help)
|
||||
}
|
|
@ -1,15 +1,2 @@
|
|||
use {crate::ArgConstant, clap::Arg};
|
||||
|
||||
pub const COMPUTE_UNIT_PRICE_ARG: ArgConstant<'static> = ArgConstant {
|
||||
name: "compute_unit_price",
|
||||
long: "--with-compute-unit-price",
|
||||
help: "Set compute unit price for transaction, in increments of 0.000001 lamports per compute unit.",
|
||||
};
|
||||
|
||||
pub fn compute_unit_price_arg<'a, 'b>() -> Arg<'a, 'b> {
|
||||
Arg::with_name(COMPUTE_UNIT_PRICE_ARG.name)
|
||||
.long(COMPUTE_UNIT_PRICE_ARG.long)
|
||||
.takes_value(true)
|
||||
.value_name("COMPUTE-UNIT-PRICE")
|
||||
.help(COMPUTE_UNIT_PRICE_ARG.help)
|
||||
}
|
||||
#[deprecated(since = "2.0.0", note = "Please use `compute_budget` instead")]
|
||||
pub use crate::compute_budget::{compute_unit_price_arg, COMPUTE_UNIT_PRICE_ARG};
|
||||
|
|
|
@ -27,6 +27,7 @@ pub fn hidden_unless_forced() -> bool {
|
|||
std::env::var("SOLANA_NO_HIDDEN_CLI_ARGS").is_err()
|
||||
}
|
||||
|
||||
pub mod compute_budget;
|
||||
pub mod compute_unit_price;
|
||||
pub mod fee_payer;
|
||||
pub mod input_parsers;
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
use {
|
||||
crate::ArgConstant,
|
||||
clap::{value_parser, Arg},
|
||||
};
|
||||
|
||||
pub const COMPUTE_UNIT_PRICE_ARG: ArgConstant<'static> = ArgConstant {
|
||||
name: "compute_unit_price",
|
||||
long: "--with-compute-unit-price",
|
||||
help: "Set compute unit price for transaction, in increments of 0.000001 lamports per compute unit.",
|
||||
};
|
||||
|
||||
pub const COMPUTE_UNIT_LIMIT_ARG: ArgConstant<'static> = ArgConstant {
|
||||
name: "compute_unit_limit",
|
||||
long: "--with-compute-unit-limit",
|
||||
help: "Set compute unit limit for transaction.",
|
||||
};
|
||||
|
||||
pub fn compute_unit_price_arg<'a>() -> Arg<'a> {
|
||||
Arg::with_name(COMPUTE_UNIT_PRICE_ARG.name)
|
||||
.long(COMPUTE_UNIT_PRICE_ARG.long)
|
||||
.takes_value(true)
|
||||
.value_name("COMPUTE-UNIT-PRICE")
|
||||
.value_parser(value_parser!(u64))
|
||||
.help(COMPUTE_UNIT_PRICE_ARG.help)
|
||||
}
|
||||
|
||||
pub fn compute_unit_limit_arg<'a>() -> Arg<'a> {
|
||||
Arg::with_name(COMPUTE_UNIT_LIMIT_ARG.name)
|
||||
.long(COMPUTE_UNIT_LIMIT_ARG.long)
|
||||
.takes_value(true)
|
||||
.value_name("COMPUTE-UNIT-LIMIT")
|
||||
.value_parser(value_parser!(u32))
|
||||
.help(COMPUTE_UNIT_LIMIT_ARG.help)
|
||||
}
|
|
@ -23,6 +23,7 @@ impl std::fmt::Debug for DisplayError {
|
|||
}
|
||||
}
|
||||
|
||||
pub mod compute_budget;
|
||||
pub mod fee_payer;
|
||||
pub mod input_parsers;
|
||||
pub mod input_validators;
|
||||
|
|
Loading…
Reference in New Issue