diff --git a/contracts/balanced_dollar/src/balanced_dollar.rs b/contracts/balanced_dollar/src/balanced_dollar.rs index 8d8bbca..895dd21 100644 --- a/contracts/balanced_dollar/src/balanced_dollar.rs +++ b/contracts/balanced_dollar/src/balanced_dollar.rs @@ -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, @@ -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, ¤t_address, envelope, &icon_bn_usd); + xcall_client(&e, &get_xcall(&e)?).send_call(&from, ¤t_address, envelope, &icon_bn_usd); Ok(()) } @@ -72,11 +72,11 @@ pub fn _handle_call_message( data: Bytes, protocols: Vec, ) -> 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); @@ -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(()) } diff --git a/contracts/balanced_dollar/src/contract.rs b/contracts/balanced_dollar/src/contract.rs index 2f5d7b3..1ed053f 100644 --- a/contracts/balanced_dollar/src/contract.rs +++ b/contracts/balanced_dollar/src/contract.rs @@ -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 { @@ -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); } @@ -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)? } }