Skip to content

Commit

Permalink
[KLC-1209] Add Get Multi KDA CallValue without KLV (#11)
Browse files Browse the repository at this point in the history
* add get_multi_kda_without_klv_call_value

* vec to slice lint
  • Loading branch information
fbsobreira authored Nov 19, 2024
1 parent be17ac9 commit ecd185b
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions c-api/libvmexeccapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ typedef struct {
void (*managed_get_return_data_func_ptr)(void *context, int32_t result_id, int32_t result_handle);
void (*managed_get_kda_call_value_func_ptr)(void *context, int32_t kda_call_value_handle, int32_t kda_handle);
void (*managed_get_multi_kda_call_value_func_ptr)(void *context, int32_t multi_call_value_handle);
void (*managed_get_multi_kda_without_klv_call_value_func_ptr)(void *context, int32_t multi_call_value_handle);
void (*managed_get_back_transfers_func_ptr)(void *context, int32_t kda_transfers_value_handle, int32_t call_value_handle);
void (*managed_get_kda_balance_func_ptr)(void *context, int32_t address_handle, int32_t token_id_handle, int64_t nonce, int32_t value_handle);
void (*managed_get_user_kda_func_ptr)(void *context, int32_t address_handle, int32_t ticker_handle, int64_t nonce, int32_t balance_handle, int32_t frozen_handle, int32_t last_claim_handle, int32_t buckets_handle, int32_t mime_handle, int32_t metadata_handle);
Expand Down
1 change: 1 addition & 0 deletions c-api/src/capi_vm_hook_pointers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ pub struct vm_exec_vm_hook_c_func_pointers {
pub managed_get_return_data_func_ptr: extern "C" fn(context: *mut c_void, result_id: i32, result_handle: i32),
pub managed_get_kda_call_value_func_ptr: extern "C" fn(context: *mut c_void, kda_call_value_handle: i32, kda_handle: i32),
pub managed_get_multi_kda_call_value_func_ptr: extern "C" fn(context: *mut c_void, multi_call_value_handle: i32),
pub managed_get_multi_kda_without_klv_call_value_func_ptr: extern "C" fn(context: *mut c_void, multi_call_value_handle: i32),
pub managed_get_back_transfers_func_ptr: extern "C" fn(context: *mut c_void, kda_transfers_value_handle: i32, call_value_handle: i32),
pub managed_get_kda_balance_func_ptr: extern "C" fn(context: *mut c_void, address_handle: i32, token_id_handle: i32, nonce: i64, value_handle: i32),
pub managed_get_user_kda_func_ptr: extern "C" fn(context: *mut c_void, address_handle: i32, ticker_handle: i32, nonce: i64, balance_handle: i32, frozen_handle: i32, last_claim_handle: i32, buckets_handle: i32, mime_handle: i32, metadata_handle: i32),
Expand Down
4 changes: 4 additions & 0 deletions c-api/src/capi_vm_hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ impl klever_chain_vm_executor::VMHooks for CapiVMHooks {
(self.c_func_pointers_ptr.managed_get_multi_kda_call_value_func_ptr)(self.vm_hooks_ptr, multi_call_value_handle)
}

fn managed_get_multi_kda_without_klv_call_value(&self, multi_call_value_handle: i32) {
(self.c_func_pointers_ptr.managed_get_multi_kda_without_klv_call_value_func_ptr)(self.vm_hooks_ptr, multi_call_value_handle)
}

fn managed_get_back_transfers(&self, kda_transfers_value_handle: i32, call_value_handle: i32) {
(self.c_func_pointers_ptr.managed_get_back_transfers_func_ptr)(self.vm_hooks_ptr, kda_transfers_value_handle, call_value_handle)
}
Expand Down
6 changes: 6 additions & 0 deletions vm-executor-wasmer/src/wasmer_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,11 @@ fn wasmer_import_managed_get_multi_kda_call_value(env: &VMHooksWrapper, multi_ca
env.vm_hooks.managed_get_multi_kda_call_value(multi_call_value_handle)
}

#[rustfmt::skip]
fn wasmer_import_managed_get_multi_kda_without_klv_call_value(env: &VMHooksWrapper, multi_call_value_handle: i32) {
env.vm_hooks.managed_get_multi_kda_without_klv_call_value(multi_call_value_handle)
}

#[rustfmt::skip]
fn wasmer_import_managed_get_back_transfers(env: &VMHooksWrapper, kda_transfers_value_handle: i32, call_value_handle: i32) {
env.vm_hooks.managed_get_back_transfers(kda_transfers_value_handle, call_value_handle)
Expand Down Expand Up @@ -1298,6 +1303,7 @@ pub fn generate_import_object(store: &Store, env: &VMHooksWrapper) -> ImportObje
"managedGetReturnData" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_return_data),
"managedGetKDACallValue" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_kda_call_value),
"managedGetMultiKDACallValue" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_multi_kda_call_value),
"managedGetMultiKDAWithoutKLVCallValue" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_multi_kda_without_klv_call_value),
"managedGetBackTransfers" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_back_transfers),
"managedGetKDABalance" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_kda_balance),
"managedGetUserKDA" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_user_kda),
Expand Down
2 changes: 1 addition & 1 deletion vm-executor-wasmer/src/wasmer_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ fn get_memories(wasmer_instance: &wasmer::Instance) -> Vec<(&String, &wasmer::Me
memories
}

fn validate_memories(memories: &Vec<(&String, &wasmer::Memory)>) -> Result<(), ExecutorError> {
fn validate_memories(memories: &[(&String, &wasmer::Memory)]) -> Result<(), ExecutorError> {
if memories.is_empty() {
return Err(Box::new(ServiceError::new(
"no memory declared in smart contract",
Expand Down
5 changes: 5 additions & 0 deletions vm-executor/src/vm_hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ pub trait VMHooks: core::fmt::Debug + 'static {
fn managed_get_return_data(&self, result_id: i32, result_handle: i32);
fn managed_get_kda_call_value(&self, kda_call_value_handle: i32, kda_handle: i32);
fn managed_get_multi_kda_call_value(&self, multi_call_value_handle: i32);
fn managed_get_multi_kda_without_klv_call_value(&self, multi_call_value_handle: i32);
fn managed_get_back_transfers(&self, kda_transfers_value_handle: i32, call_value_handle: i32);
fn managed_get_kda_balance(&self, address_handle: i32, token_id_handle: i32, nonce: i64, value_handle: i32);
fn managed_get_user_kda(&self, address_handle: i32, ticker_handle: i32, nonce: i64, balance_handle: i32, frozen_handle: i32, last_claim_handle: i32, buckets_handle: i32, mime_handle: i32, metadata_handle: i32);
Expand Down Expand Up @@ -635,6 +636,10 @@ impl VMHooks for VMHooksDefault {
println!("Called: managed_get_multi_kda_call_value");
}

fn managed_get_multi_kda_without_klv_call_value(&self, multi_call_value_handle: i32) {
println!("Called: managed_get_multi_kda_without_klv_call_value");
}

fn managed_get_back_transfers(&self, kda_transfers_value_handle: i32, call_value_handle: i32) {
println!("Called: managed_get_back_transfers");
}
Expand Down

0 comments on commit ecd185b

Please sign in to comment.