diff --git a/clap-utils/src/compute_budget.rs b/clap-utils/src/compute_budget.rs new file mode 100644 index 000000000..af9edba1d --- /dev/null +++ b/clap-utils/src/compute_budget.rs @@ -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::) + .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::) + .help(COMPUTE_UNIT_LIMIT_ARG.help) +} diff --git a/clap-utils/src/compute_unit_price.rs b/clap-utils/src/compute_unit_price.rs index f8fd279d9..18f060bc1 100644 --- a/clap-utils/src/compute_unit_price.rs +++ b/clap-utils/src/compute_unit_price.rs @@ -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}; diff --git a/clap-utils/src/lib.rs b/clap-utils/src/lib.rs index 43d4fa6f8..58a27b242 100644 --- a/clap-utils/src/lib.rs +++ b/clap-utils/src/lib.rs @@ -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; diff --git a/clap-v3-utils/src/compute_budget.rs b/clap-v3-utils/src/compute_budget.rs new file mode 100644 index 000000000..7b34e114b --- /dev/null +++ b/clap-v3-utils/src/compute_budget.rs @@ -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) +} diff --git a/clap-v3-utils/src/lib.rs b/clap-v3-utils/src/lib.rs index 5000f7e1d..c3edf98dc 100644 --- a/clap-v3-utils/src/lib.rs +++ b/clap-v3-utils/src/lib.rs @@ -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;