forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clap-utils: Add more compute unit helpers (solana-labs#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
- Loading branch information
Showing
5 changed files
with
72 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters