Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions smart_contracts/vm2/sdk/src/casper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,10 @@ pub fn create(
None => Err(CallError::InvalidOutput),
},
other_status => {
// #TODO! fix this wrap
Err(CallError::try_from(other_status).expect("Couldn't interpret error from host"))
let Ok(error) = CallError::try_from(other_status) else {
panic!("Couldn't interpret error from host: {}", other_status);
};
Err(error)
}
}
}
Expand Down Expand Up @@ -547,11 +549,9 @@ pub fn transferred_value() -> u64 {
}

/// Transfer tokens from the current contract to another account or contract.
pub fn transfer(target_account: &EntityAddr, amount: u64) -> Result<(), CallError> {
// TODO: the variable name is called target_account, but
// logic would call it with misc addresses. need to confer w/ michal
log!("transfer entity_addr {:?}", target_account);
let bytes = match borsh::to_vec(&(target_account, amount)) {
pub fn transfer(target: &EntityAddr, amount: u64) -> Result<(), CallError> {
log!("transfer entity_addr {:?}", target);
let bytes = match borsh::to_vec(&(target, amount)) {
Ok(bytes) => bytes,
Err(_err) => return Err(CallError::CalleeTrapped),
};
Expand Down
1 change: 0 additions & 1 deletion smart_contracts/vm2/sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ cfg_if::cfg_if! {
}
else {
pub fn set_panic_hook() {
// TODO: What to do?
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion smart_contracts/vm2/sdk/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use core::marker::PhantomData;
use casper_contract_macros::TypeUid;
use casper_executor_wasm_common::{
error::{
CALLEE_GAS_DEPLETED, CALLEE_INPUT_INVALID, CALLEE_NOT_CALLABLE, CALLEE_REVERT_ERROR,
CALLEE_CODE_NOT_FOUND, CALLEE_ENTITY_NOT_FOUND, CALLEE_GAS_DEPLETED, CALLEE_INPUT_INVALID,
CALLEE_LOCKED_PACKAGE, CALLEE_NOT_CALLABLE, CALLEE_NO_ACTIVE_CONTRACT, CALLEE_REVERT_ERROR,
CALLEE_ROLLED_BACK, CALLEE_TRAPPED,
},
keyspace::Keyspace,
Expand Down Expand Up @@ -229,6 +230,10 @@ impl TryFrom<u32> for CallError {
CALLEE_GAS_DEPLETED => Ok(Self::CalleeGasDepleted),
CALLEE_NOT_CALLABLE => Ok(Self::NotCallable),
CALLEE_INPUT_INVALID => Ok(Self::InputInvalid),
CALLEE_NO_ACTIVE_CONTRACT => Ok(Self::NoActiveContract),
CALLEE_CODE_NOT_FOUND => Ok(Self::CodeNotFound),
CALLEE_ENTITY_NOT_FOUND => Ok(Self::EntityNotFound),
CALLEE_LOCKED_PACKAGE => Ok(Self::LockedPackage),
CALLEE_REVERT_ERROR => Ok(Self::CalleeReverted),
_ => Err(()),
}
Expand Down