Skip to content

Commit 62275e7

Browse files
authored
Merge pull request #5366 from igor-casper/core-210
[VM2] SDK Cleanup
2 parents c9dcd97 + 1010049 commit 62275e7

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

smart_contracts/vm2/sdk/src/casper.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,10 @@ pub fn create(
195195
None => Err(CallError::InvalidOutput),
196196
},
197197
other_status => {
198-
// #TODO! fix this wrap
199-
Err(CallError::try_from(other_status).expect("Couldn't interpret error from host"))
198+
let Ok(error) = CallError::try_from(other_status) else {
199+
panic!("Couldn't interpret error from host: {}", other_status);
200+
};
201+
Err(error)
200202
}
201203
}
202204
}
@@ -547,11 +549,9 @@ pub fn transferred_value() -> u64 {
547549
}
548550

549551
/// Transfer tokens from the current contract to another account or contract.
550-
pub fn transfer(target_account: &EntityAddr, amount: u64) -> Result<(), CallError> {
551-
// TODO: the variable name is called target_account, but
552-
// logic would call it with misc addresses. need to confer w/ michal
553-
log!("transfer entity_addr {:?}", target_account);
554-
let bytes = match borsh::to_vec(&(target_account, amount)) {
552+
pub fn transfer(target: &EntityAddr, amount: u64) -> Result<(), CallError> {
553+
log!("transfer entity_addr {:?}", target);
554+
let bytes = match borsh::to_vec(&(target, amount)) {
555555
Ok(bytes) => bytes,
556556
Err(_err) => return Err(CallError::CalleeTrapped),
557557
};

smart_contracts/vm2/sdk/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ cfg_if::cfg_if! {
4545
}
4646
else {
4747
pub fn set_panic_hook() {
48-
// TODO: What to do?
4948
}
5049
}
5150
}

smart_contracts/vm2/sdk/src/types.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use core::marker::PhantomData;
33
use casper_contract_macros::TypeUid;
44
use casper_executor_wasm_common::{
55
error::{
6-
CALLEE_GAS_DEPLETED, CALLEE_INPUT_INVALID, CALLEE_NOT_CALLABLE, CALLEE_REVERT_ERROR,
6+
CALLEE_CODE_NOT_FOUND, CALLEE_ENTITY_NOT_FOUND, CALLEE_GAS_DEPLETED, CALLEE_INPUT_INVALID,
7+
CALLEE_LOCKED_PACKAGE, CALLEE_NOT_CALLABLE, CALLEE_NO_ACTIVE_CONTRACT, CALLEE_REVERT_ERROR,
78
CALLEE_ROLLED_BACK, CALLEE_TRAPPED,
89
},
910
keyspace::Keyspace,
@@ -229,6 +230,10 @@ impl TryFrom<u32> for CallError {
229230
CALLEE_GAS_DEPLETED => Ok(Self::CalleeGasDepleted),
230231
CALLEE_NOT_CALLABLE => Ok(Self::NotCallable),
231232
CALLEE_INPUT_INVALID => Ok(Self::InputInvalid),
233+
CALLEE_NO_ACTIVE_CONTRACT => Ok(Self::NoActiveContract),
234+
CALLEE_CODE_NOT_FOUND => Ok(Self::CodeNotFound),
235+
CALLEE_ENTITY_NOT_FOUND => Ok(Self::EntityNotFound),
236+
CALLEE_LOCKED_PACKAGE => Ok(Self::LockedPackage),
232237
CALLEE_REVERT_ERROR => Ok(Self::CalleeReverted),
233238
_ => Err(()),
234239
}

0 commit comments

Comments
 (0)