diff --git a/node/src/types/transaction/arg_handling.rs b/node/src/types/transaction/arg_handling.rs index 0fe19b5145..e31ff8394c 100644 --- a/node/src/types/transaction/arg_handling.rs +++ b/node/src/types/transaction/arg_handling.rs @@ -15,7 +15,8 @@ use tracing::debug; 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"); @@ -111,8 +112,8 @@ impl OptionalArg { Some(value) => value, None => return Ok(None), }; - let value = parse_cl_value(cl_value, self.name)?; - Ok(value) + let value = parse_cl_value::(cl_value, self.name)?; + Ok(Some(value)) } #[cfg(test)] @@ -120,7 +121,7 @@ impl OptionalArg { where T: CLTyped + ToBytes, { - args.insert(self.name, Some(value)) + args.insert(self.name, value) } } @@ -165,8 +166,8 @@ pub 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) } @@ -591,7 +592,7 @@ mod tests { }; let expected_error = InvalidTransactionV1::UnexpectedArgType { arg_name: TRANSFER_ARG_SOURCE.name.to_string(), - expected: vec![Option::::cl_type()], + expected: vec![URef::cl_type()], got: CLType::U8, }; assert_eq!( diff --git a/types/src/transaction/transaction_v1/arg_handling.rs b/types/src/transaction/transaction_v1/arg_handling.rs index 1650e055b6..3bd8f7a14b 100644 --- a/types/src/transaction/transaction_v1/arg_handling.rs +++ b/types/src/transaction/transaction_v1/arg_handling.rs @@ -8,8 +8,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"); @@ -77,7 +77,7 @@ impl OptionalArg { where T: CLTyped + ToBytes, { - args.insert(self.name, Some(value)) + args.insert(self.name, value) } } @@ -101,8 +101,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) }