diff --git a/smart_contracts/vm2/sdk/src/casper.rs b/smart_contracts/vm2/sdk/src/casper.rs index db76dfcfca..f9a21ee3ac 100644 --- a/smart_contracts/vm2/sdk/src/casper.rs +++ b/smart_contracts/vm2/sdk/src/casper.rs @@ -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) } } } @@ -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), }; diff --git a/smart_contracts/vm2/sdk/src/lib.rs b/smart_contracts/vm2/sdk/src/lib.rs index 03953bf338..845f149e4f 100644 --- a/smart_contracts/vm2/sdk/src/lib.rs +++ b/smart_contracts/vm2/sdk/src/lib.rs @@ -45,7 +45,6 @@ cfg_if::cfg_if! { } else { pub fn set_panic_hook() { - // TODO: What to do? } } } diff --git a/smart_contracts/vm2/sdk/src/types.rs b/smart_contracts/vm2/sdk/src/types.rs index 4e35a3f4ba..6b261adbf9 100644 --- a/smart_contracts/vm2/sdk/src/types.rs +++ b/smart_contracts/vm2/sdk/src/types.rs @@ -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, @@ -229,6 +230,10 @@ impl TryFrom 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(()), }