From eaac944615b169a1b44d43252be856f4602877c5 Mon Sep 17 00:00:00 2001 From: Jakub Zajkowski Date: Thu, 5 Dec 2024 03:09:28 -0800 Subject: [PATCH] Applying arg_handling fixes to the client --- lib/cli/arg_handling.rs | 9 +++++---- lib/cli/tests.rs | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/cli/arg_handling.rs b/lib/cli/arg_handling.rs index ee205cd..0160a87 100644 --- a/lib/cli/arg_handling.rs +++ b/lib/cli/arg_handling.rs @@ -9,7 +9,8 @@ const TRANSFER_ARG_AMOUNT: RequiredArg = RequiredArg::new("amount"); const TRANSFER_ARG_SOURCE: OptionalArg = OptionalArg::new("source"); const TRANSFER_ARG_TARGET: &str = "target"; -const TRANSFER_ARG_ID: OptionalArg = OptionalArg::new("id"); +// "id" for legacy reasons, if the argument is passed it is [Option] +const TRANSFER_ARG_ID: OptionalArg> = OptionalArg::new("id"); const ADD_BID_ARG_PUBLIC_KEY: RequiredArg = RequiredArg::new("public_key"); const ADD_BID_ARG_DELEGATION_RATE: RequiredArg = RequiredArg::new("delegation_rate"); @@ -88,7 +89,7 @@ impl OptionalArg { where T: CLTyped + ToBytes, { - args.insert(self.name, Some(value)) + args.insert(self.name, value) } } @@ -112,8 +113,8 @@ pub(crate) fn new_transfer_args, T: Into>( TransferTarget::URef(uref) => args.insert(TRANSFER_ARG_TARGET, uref)?, } TRANSFER_ARG_AMOUNT.insert(&mut args, amount.into())?; - if let Some(id) = maybe_id { - TRANSFER_ARG_ID.insert(&mut args, id)?; + if maybe_id.is_some() { + TRANSFER_ARG_ID.insert(&mut args, maybe_id)?; } Ok(args) } diff --git a/lib/cli/tests.rs b/lib/cli/tests.rs index f5187ea..5d63be0 100644 --- a/lib/cli/tests.rs +++ b/lib/cli/tests.rs @@ -1451,7 +1451,7 @@ mod transaction { let maybe_source = Some(source_uref); - let source_uref_cl = &CLValue::from_t(Some(&source_uref)).unwrap(); + let source_uref_cl = &CLValue::from_t(&source_uref).unwrap(); let target_uref_cl = &CLValue::from_t(target_uref).unwrap(); let transaction_string_params = TransactionStrParams {