Skip to content

Commit

Permalink
propagate optional argument errors in utils.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas089 committed Mar 31, 2024
1 parent 8303247 commit ac334b0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ result
target
.tmp
.nixos-test-history
contracts/deposit-contract-tests/.env
.env
4 changes: 2 additions & 2 deletions kairos-contracts/deposit-contracts/contract/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use constants::{
KAIROS_MOST_RECENT_DEPOSIT_COUNTER, RUNTIME_ARG_AMOUNT, RUNTIME_ARG_TEMP_PURSE,
SECURITY_BADGES,
};
mod detail;
use detail::{get_immediate_caller, get_optional_named_arg_with_user_errors};
mod utils;
use utils::{get_immediate_caller, get_optional_named_arg_with_user_errors};
mod error;
use error::DepositError;
mod security;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use alloc::{collections::BTreeMap, vec, vec::Vec};

use crate::{
constants::SECURITY_BADGES,
detail::{get_immediate_caller, get_uref},
error::DepositError,
utils::{get_immediate_caller, get_uref},
};
#[allow(unused_imports)]
use casper_contract::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ pub fn get_optional_named_arg_with_user_errors<T: FromBytes>(
let maybe_named_arg_with_user_errors = get_named_arg_with_user_errors::<T>(name, invalid);
match maybe_named_arg_with_user_errors {
Ok(val) => Some(val),
Err(_) => None,
Err(err) => match err {
DepositError::MissingOptionalArgument => None,
_ => runtime::revert(err),
},
}
}

Expand Down

0 comments on commit ac334b0

Please sign in to comment.