Skip to content

Commit

Permalink
Merge pull request #216 from casper-ecosystem/arg_handling_fixes
Browse files Browse the repository at this point in the history
Applying arg_handling fixes to the client
  • Loading branch information
zajko authored Dec 10, 2024
2 parents 04ce58d + eaac944 commit 80bbe5e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lib/cli/arg_handling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const TRANSFER_ARG_AMOUNT: RequiredArg<U512> = RequiredArg::new("amount");
const TRANSFER_ARG_SOURCE: OptionalArg<URef> = OptionalArg::new("source");
const TRANSFER_ARG_TARGET: &str = "target";

const TRANSFER_ARG_ID: OptionalArg<u64> = OptionalArg::new("id");
// "id" for legacy reasons, if the argument is passed it is [Option]
const TRANSFER_ARG_ID: OptionalArg<Option<u64>> = OptionalArg::new("id");

const ADD_BID_ARG_PUBLIC_KEY: RequiredArg<PublicKey> = RequiredArg::new("public_key");
const ADD_BID_ARG_DELEGATION_RATE: RequiredArg<u8> = RequiredArg::new("delegation_rate");
Expand Down Expand Up @@ -88,7 +89,7 @@ impl<T> OptionalArg<T> {
where
T: CLTyped + ToBytes,
{
args.insert(self.name, Some(value))
args.insert(self.name, value)
}
}

Expand All @@ -112,8 +113,8 @@ pub(crate) fn new_transfer_args<A: Into<U512>, T: Into<TransferTarget>>(
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)
}
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 80bbe5e

Please sign in to comment.