Skip to content

Commit ecd185b

Browse files
authored
[KLC-1209] Add Get Multi KDA CallValue without KLV (#11)
* add get_multi_kda_without_klv_call_value * vec to slice lint
1 parent be17ac9 commit ecd185b

File tree

6 files changed

+18
-1
lines changed

6 files changed

+18
-1
lines changed

c-api/libvmexeccapi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ typedef struct {
118118
void (*managed_get_return_data_func_ptr)(void *context, int32_t result_id, int32_t result_handle);
119119
void (*managed_get_kda_call_value_func_ptr)(void *context, int32_t kda_call_value_handle, int32_t kda_handle);
120120
void (*managed_get_multi_kda_call_value_func_ptr)(void *context, int32_t multi_call_value_handle);
121+
void (*managed_get_multi_kda_without_klv_call_value_func_ptr)(void *context, int32_t multi_call_value_handle);
121122
void (*managed_get_back_transfers_func_ptr)(void *context, int32_t kda_transfers_value_handle, int32_t call_value_handle);
122123
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);
123124
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);

c-api/src/capi_vm_hook_pointers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ pub struct vm_exec_vm_hook_c_func_pointers {
9090
pub managed_get_return_data_func_ptr: extern "C" fn(context: *mut c_void, result_id: i32, result_handle: i32),
9191
pub managed_get_kda_call_value_func_ptr: extern "C" fn(context: *mut c_void, kda_call_value_handle: i32, kda_handle: i32),
9292
pub managed_get_multi_kda_call_value_func_ptr: extern "C" fn(context: *mut c_void, multi_call_value_handle: i32),
93+
pub managed_get_multi_kda_without_klv_call_value_func_ptr: extern "C" fn(context: *mut c_void, multi_call_value_handle: i32),
9394
pub managed_get_back_transfers_func_ptr: extern "C" fn(context: *mut c_void, kda_transfers_value_handle: i32, call_value_handle: i32),
9495
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),
9596
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),

c-api/src/capi_vm_hooks.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,10 @@ impl klever_chain_vm_executor::VMHooks for CapiVMHooks {
359359
(self.c_func_pointers_ptr.managed_get_multi_kda_call_value_func_ptr)(self.vm_hooks_ptr, multi_call_value_handle)
360360
}
361361

362+
fn managed_get_multi_kda_without_klv_call_value(&self, multi_call_value_handle: i32) {
363+
(self.c_func_pointers_ptr.managed_get_multi_kda_without_klv_call_value_func_ptr)(self.vm_hooks_ptr, multi_call_value_handle)
364+
}
365+
362366
fn managed_get_back_transfers(&self, kda_transfers_value_handle: i32, call_value_handle: i32) {
363367
(self.c_func_pointers_ptr.managed_get_back_transfers_func_ptr)(self.vm_hooks_ptr, kda_transfers_value_handle, call_value_handle)
364368
}

vm-executor-wasmer/src/wasmer_imports.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,11 @@ fn wasmer_import_managed_get_multi_kda_call_value(env: &VMHooksWrapper, multi_ca
410410
env.vm_hooks.managed_get_multi_kda_call_value(multi_call_value_handle)
411411
}
412412

413+
#[rustfmt::skip]
414+
fn wasmer_import_managed_get_multi_kda_without_klv_call_value(env: &VMHooksWrapper, multi_call_value_handle: i32) {
415+
env.vm_hooks.managed_get_multi_kda_without_klv_call_value(multi_call_value_handle)
416+
}
417+
413418
#[rustfmt::skip]
414419
fn wasmer_import_managed_get_back_transfers(env: &VMHooksWrapper, kda_transfers_value_handle: i32, call_value_handle: i32) {
415420
env.vm_hooks.managed_get_back_transfers(kda_transfers_value_handle, call_value_handle)
@@ -1298,6 +1303,7 @@ pub fn generate_import_object(store: &Store, env: &VMHooksWrapper) -> ImportObje
12981303
"managedGetReturnData" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_return_data),
12991304
"managedGetKDACallValue" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_kda_call_value),
13001305
"managedGetMultiKDACallValue" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_multi_kda_call_value),
1306+
"managedGetMultiKDAWithoutKLVCallValue" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_multi_kda_without_klv_call_value),
13011307
"managedGetBackTransfers" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_back_transfers),
13021308
"managedGetKDABalance" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_kda_balance),
13031309
"managedGetUserKDA" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_user_kda),

vm-executor-wasmer/src/wasmer_instance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ fn get_memories(wasmer_instance: &wasmer::Instance) -> Vec<(&String, &wasmer::Me
146146
memories
147147
}
148148

149-
fn validate_memories(memories: &Vec<(&String, &wasmer::Memory)>) -> Result<(), ExecutorError> {
149+
fn validate_memories(memories: &[(&String, &wasmer::Memory)]) -> Result<(), ExecutorError> {
150150
if memories.is_empty() {
151151
return Err(Box::new(ServiceError::new(
152152
"no memory declared in smart contract",

vm-executor/src/vm_hooks.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ pub trait VMHooks: core::fmt::Debug + 'static {
9393
fn managed_get_return_data(&self, result_id: i32, result_handle: i32);
9494
fn managed_get_kda_call_value(&self, kda_call_value_handle: i32, kda_handle: i32);
9595
fn managed_get_multi_kda_call_value(&self, multi_call_value_handle: i32);
96+
fn managed_get_multi_kda_without_klv_call_value(&self, multi_call_value_handle: i32);
9697
fn managed_get_back_transfers(&self, kda_transfers_value_handle: i32, call_value_handle: i32);
9798
fn managed_get_kda_balance(&self, address_handle: i32, token_id_handle: i32, nonce: i64, value_handle: i32);
9899
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);
@@ -635,6 +636,10 @@ impl VMHooks for VMHooksDefault {
635636
println!("Called: managed_get_multi_kda_call_value");
636637
}
637638

639+
fn managed_get_multi_kda_without_klv_call_value(&self, multi_call_value_handle: i32) {
640+
println!("Called: managed_get_multi_kda_without_klv_call_value");
641+
}
642+
638643
fn managed_get_back_transfers(&self, kda_transfers_value_handle: i32, call_value_handle: i32) {
639644
println!("Called: managed_get_back_transfers");
640645
}

0 commit comments

Comments
 (0)