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

Commit 19ee7ba

Browse files
committed
use try_get_one to parse compute_unit_price and compute_unit_limit
1 parent 7367595 commit 19ee7ba

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
@@ -300,10 +300,13 @@ impl<'a> Config<'a> {
300300
(default_program_id, false)
301301
};
302302

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

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

0 commit comments

Comments
 (0)