solana_clap_utils/
compute_budget.rs1use {
2 crate::{input_validators::is_parsable, ArgConstant},
3 clap::Arg,
4};
5
6pub const COMPUTE_UNIT_PRICE_ARG: ArgConstant<'static> = ArgConstant {
7 name: "compute_unit_price",
8 long: "--with-compute-unit-price",
9 help: "Set compute unit price for transaction, in increments of 0.000001 lamports per compute \
10 unit.",
11};
12
13pub const COMPUTE_UNIT_LIMIT_ARG: ArgConstant<'static> = ArgConstant {
14 name: "compute_unit_limit",
15 long: "--with-compute-unit-limit",
16 help: "Set compute unit limit for transaction.",
17};
18
19pub fn compute_unit_price_arg<'a, 'b>() -> Arg<'a, 'b> {
20 Arg::with_name(COMPUTE_UNIT_PRICE_ARG.name)
21 .long(COMPUTE_UNIT_PRICE_ARG.long)
22 .takes_value(true)
23 .value_name("COMPUTE-UNIT-PRICE")
24 .validator(is_parsable::<u64>)
25 .help(COMPUTE_UNIT_PRICE_ARG.help)
26}
27
28pub fn compute_unit_limit_arg<'a, 'b>() -> Arg<'a, 'b> {
29 Arg::with_name(COMPUTE_UNIT_LIMIT_ARG.name)
30 .long(COMPUTE_UNIT_LIMIT_ARG.long)
31 .takes_value(true)
32 .value_name("COMPUTE-UNIT-LIMIT")
33 .validator(is_parsable::<u32>)
34 .help(COMPUTE_UNIT_LIMIT_ARG.help)
35}
36
37#[derive(Clone, Copy, Debug, PartialEq)]
38pub enum ComputeUnitLimit {
39 Default,
43 Static(u32),
45 Simulated,
47 SimulatedWithExtraPercentage(u8),
49}