Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit c376044

Browse files
committed
use try_get_one to parse compute_unit_price and compute_unit_limit
1 parent b84bb8b commit c376044

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

token/cli/src/config.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,13 @@ impl<'a> Config<'a> {
299299
(default_program_id, false)
300300
};
301301

302-
// need to specify a compute limit if compute price and blockhash are specified
303-
if matches.is_present(BLOCKHASH_ARG.name)
304-
&& matches.is_present(COMPUTE_UNIT_PRICE_ARG.name)
305-
&& !matches.is_present(COMPUTE_UNIT_LIMIT_ARG.name)
302+
if matches.try_contains_id(BLOCKHASH_ARG.name).unwrap_or(false)
303+
&& matches
304+
.try_contains_id(COMPUTE_UNIT_PRICE_ARG.name)
305+
.unwrap_or(false)
306+
&& !matches
307+
.try_contains_id(COMPUTE_UNIT_LIMIT_ARG.name)
308+
.unwrap_or(false)
306309
{
307310
clap::Error::with_description(
308311
format!(
@@ -320,8 +323,17 @@ impl<'a> Config<'a> {
320323
.flatten()
321324
.copied();
322325

323-
let compute_unit_price = value_of(matches, COMPUTE_UNIT_PRICE_ARG.name);
324-
let compute_unit_limit = value_of(matches, COMPUTE_UNIT_LIMIT_ARG.name)
326+
let compute_unit_price = matches
327+
.try_get_one::<u64>(COMPUTE_UNIT_PRICE_ARG.name)
328+
.ok()
329+
.flatten()
330+
.copied();
331+
332+
let compute_unit_limit = matches
333+
.try_get_one::<u32>(COMPUTE_UNIT_PRICE_ARG.name)
334+
.ok()
335+
.flatten()
336+
.copied()
325337
.map(ComputeUnitLimit::Static)
326338
.unwrap_or_else(|| {
327339
if nonce_blockhash.is_some() {

0 commit comments

Comments
 (0)