Skip to content

Commit

Permalink
fix: unwrap changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Itshyphen committed Nov 13, 2024
1 parent e6b5846 commit 4cc4fc0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
12 changes: 6 additions & 6 deletions contracts/balanced_dollar/src/balanced_dollar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ pub fn _cross_transfer(
}
let xcall_message = CrossTransfer::new(from.clone().to_string(), to, amount, data);
let rollback = CrossTransferRevert::new(from.clone(), amount);
let icon_bn_usd = get_icon_bnusd(&e).unwrap();
let icon_bn_usd = get_icon_bnusd(&e)?;

let rollback_bytes = rollback.encode(&e, String::from_str(&e, CROSS_TRANSFER_REVERT));
let message_bytes = xcall_message.encode(&e, String::from_str(&e, CROSS_TRANSFER));

let (sources, destinations) = xcall_manager_client(&e, &get_xcall_manager(&e).unwrap()).get_protocols();
let (sources, destinations) = xcall_manager_client(&e, &get_xcall_manager(&e)?).get_protocols();

let message = AnyMessage::CallMessageWithRollback(CallMessageWithRollback {
data: message_bytes,
Expand All @@ -50,7 +50,7 @@ pub fn _cross_transfer(
};

let current_address = e.current_contract_address();
xcall_client(&e, &get_xcall(&e).unwrap()).send_call(&from, &current_address, envelope, &icon_bn_usd);
xcall_client(&e, &get_xcall(&e)?).send_call(&from, &current_address, envelope, &icon_bn_usd);
Ok(())
}

Expand All @@ -72,11 +72,11 @@ pub fn _handle_call_message(
data: Bytes,
protocols: Vec<String>,
) -> Result<(), ContractError> {
let xcall = get_xcall(&e).unwrap();
let xcall = get_xcall(&e)?;
xcall.require_auth();

let method = CrossTransfer::get_method(&e, data.clone());
let icon_bn_usd: String = get_icon_bnusd(&e).unwrap();
let icon_bn_usd: String = get_icon_bnusd(&e)?;
if method == String::from_str(&e, &CROSS_TRANSFER) {
if from != icon_bn_usd {
return Err(ContractError::OnlyIconBnUSD);
Expand All @@ -102,7 +102,7 @@ pub fn _handle_call_message(
} else {
return Err(ContractError::UnknownMessageType);
}
verify_protocol(&e, &get_xcall_manager(&e).unwrap(), protocols)?;
verify_protocol(&e, &get_xcall_manager(&e)?, protocols)?;
Ok(())
}

Expand Down
12 changes: 4 additions & 8 deletions contracts/balanced_dollar/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ impl BalancedDollar {
let name = String::from_str(&e, "Balanced Dollar");
let symbol = String::from_str(&e, "bnUSD");

if decimal > u8::MAX.into() {
panic_with_error!(e, ContractError::DecimalMustFitInAu8)
}

write_metadata(
&e,
TokenMetadata {
Expand Down Expand Up @@ -76,13 +72,13 @@ impl BalancedDollar {
}

pub fn set_upgrade_authority(e: Env, new_upgrade_authority: Address) {
let upgrade_authority = get_upgrade_authority(&e).unwrap();
let upgrade_authority = get_upgrade_authority(&e)?;
upgrade_authority.require_auth();
set_upgrade_authority(&e, new_upgrade_authority);
}

pub fn upgrade(e: Env, new_wasm_hash: BytesN<32>) {
let upgrade_authority = get_upgrade_authority(&e).unwrap();
let upgrade_authority = get_upgrade_authority(&e)?;
upgrade_authority.require_auth();
e.deployer().update_current_contract_wasm(new_wasm_hash);
}
Expand Down Expand Up @@ -145,10 +141,10 @@ impl BalancedDollar {
}

pub fn xcall_manager(e: Env) -> Address {
storage_types::get_xcall_manager(&e).unwrap()
storage_types::get_xcall_manager(&e)?
}

pub fn xcall(e: Env) -> Address {
storage_types::get_xcall(&e).unwrap()
storage_types::get_xcall(&e)?
}
}

0 comments on commit 4cc4fc0

Please sign in to comment.