Skip to content

Commit

Permalink
Revert to Option
Browse files Browse the repository at this point in the history
  • Loading branch information
gRoussac committed Jul 17, 2024
1 parent 9f35cf3 commit 94e8785
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions smart_contracts/contract/src/contract_api/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ pub fn get_named_arg<T: FromBytes>(name: &str) -> T {
///
/// Note that this is only relevant to contracts stored on-chain since a contract deployed directly
/// is not invoked with any arguments.
pub fn try_get_named_arg<T: FromBytes>(name: &str) -> Result<T, ApiError> {
let arg_size = get_named_arg_size(name).unwrap_or(0);
pub fn try_get_named_arg<T: FromBytes>(name: &str) -> Option<T> {
let arg_size = get_named_arg_size(name)?;
let arg_bytes = if arg_size > 0 {
let res = {
let data_non_null_ptr = contract_api::alloc_bytes(arg_size);
Expand All @@ -222,7 +222,7 @@ pub fn try_get_named_arg<T: FromBytes>(name: &str) -> Result<T, ApiError> {
// Avoids allocation with 0 bytes and a call to get_named_arg
Vec::new()
};
bytesrepr::deserialize(arg_bytes).map_err(|_| ApiError::InvalidArgument)
bytesrepr::deserialize(arg_bytes).ok()
}

/// Returns the caller of the current context, i.e. the [`AccountHash`] of the account which made
Expand Down

0 comments on commit 94e8785

Please sign in to comment.