diff --git a/c-api/libvmexeccapi.h b/c-api/libvmexeccapi.h index 84d60bb..3634bd2 100644 --- a/c-api/libvmexeccapi.h +++ b/c-api/libvmexeccapi.h @@ -136,6 +136,7 @@ typedef struct { void (*managed_get_code_metadata_func_ptr)(void *context, int32_t address_handle, int32_t response_handle); int32_t (*managed_is_builtin_function_func_ptr)(void *context, int32_t function_name_handle); void (*managed_get_sft_metadata_func_ptr)(void *context, int32_t ticker_handle, int64_t nonce, int32_t data_handle); + int32_t (*managed_acc_has_perm_func_ptr)(void *context, int64_t ops, int32_t source_acc_addr, int32_t target_acc_addr); int32_t (*big_float_new_from_parts_func_ptr)(void *context, int32_t integral_part, int32_t fractional_part, int32_t exponent); int32_t (*big_float_new_from_frac_func_ptr)(void *context, int64_t numerator, int64_t denominator); int32_t (*big_float_new_from_sci_func_ptr)(void *context, int64_t significand, int64_t exponent); diff --git a/c-api/src/capi_vm_hook_pointers.rs b/c-api/src/capi_vm_hook_pointers.rs index be0312c..6ddbcda 100644 --- a/c-api/src/capi_vm_hook_pointers.rs +++ b/c-api/src/capi_vm_hook_pointers.rs @@ -108,6 +108,7 @@ pub struct vm_exec_vm_hook_c_func_pointers { pub managed_get_code_metadata_func_ptr: extern "C" fn(context: *mut c_void, address_handle: i32, response_handle: i32), pub managed_is_builtin_function_func_ptr: extern "C" fn(context: *mut c_void, function_name_handle: i32) -> i32, pub managed_get_sft_metadata_func_ptr: extern "C" fn(context: *mut c_void, ticker_handle: i32, nonce: i64, data_handle: i32), + pub managed_acc_has_perm_func_ptr: extern "C" fn(context: *mut c_void, ops: i64, source_acc_addr: i32, target_acc_addr: i32) -> i32, pub big_float_new_from_parts_func_ptr: extern "C" fn(context: *mut c_void, integral_part: i32, fractional_part: i32, exponent: i32) -> i32, pub big_float_new_from_frac_func_ptr: extern "C" fn(context: *mut c_void, numerator: i64, denominator: i64) -> i32, pub big_float_new_from_sci_func_ptr: extern "C" fn(context: *mut c_void, significand: i64, exponent: i64) -> i32, diff --git a/c-api/src/capi_vm_hooks.rs b/c-api/src/capi_vm_hooks.rs index 9e93ae9..5e02858 100644 --- a/c-api/src/capi_vm_hooks.rs +++ b/c-api/src/capi_vm_hooks.rs @@ -431,6 +431,10 @@ impl klever_chain_vm_executor::VMHooks for CapiVMHooks { (self.c_func_pointers_ptr.managed_get_sft_metadata_func_ptr)(self.vm_hooks_ptr, ticker_handle, nonce, data_handle) } + fn managed_acc_has_perm(&self, ops: i64, source_acc_addr: i32, target_acc_addr: i32) -> i32 { + (self.c_func_pointers_ptr.managed_acc_has_perm_func_ptr)(self.vm_hooks_ptr, ops, source_acc_addr, target_acc_addr) + } + fn big_float_new_from_parts(&self, integral_part: i32, fractional_part: i32, exponent: i32) -> i32 { (self.c_func_pointers_ptr.big_float_new_from_parts_func_ptr)(self.vm_hooks_ptr, integral_part, fractional_part, exponent) } diff --git a/vm-executor-wasmer/src/wasmer_imports.rs b/vm-executor-wasmer/src/wasmer_imports.rs index a297fd5..333ccde 100644 --- a/vm-executor-wasmer/src/wasmer_imports.rs +++ b/vm-executor-wasmer/src/wasmer_imports.rs @@ -500,6 +500,11 @@ fn wasmer_import_managed_get_sft_metadata(env: &VMHooksWrapper, ticker_handle: i env.vm_hooks.managed_get_sft_metadata(ticker_handle, nonce, data_handle) } +#[rustfmt::skip] +fn wasmer_import_managed_acc_has_perm(env: &VMHooksWrapper, ops: i64, source_acc_addr: i32, target_acc_addr: i32) -> i32 { + env.vm_hooks.managed_acc_has_perm(ops, source_acc_addr, target_acc_addr) +} + #[rustfmt::skip] fn wasmer_import_big_float_new_from_parts(env: &VMHooksWrapper, integral_part: i32, fractional_part: i32, exponent: i32) -> i32 { env.vm_hooks.big_float_new_from_parts(integral_part, fractional_part, exponent) @@ -1311,6 +1316,7 @@ pub fn generate_import_object(store: &Store, env: &VMHooksWrapper) -> ImportObje "managedGetCodeMetadata" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_code_metadata), "managedIsBuiltinFunction" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_is_builtin_function), "managedGetSftMetadata" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_sft_metadata), + "managedAccHasPerm" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_acc_has_perm), "bigFloatNewFromParts" => Function::new_native_with_env(store, env.clone(), wasmer_import_big_float_new_from_parts), "bigFloatNewFromFrac" => Function::new_native_with_env(store, env.clone(), wasmer_import_big_float_new_from_frac), "bigFloatNewFromSci" => Function::new_native_with_env(store, env.clone(), wasmer_import_big_float_new_from_sci), diff --git a/vm-executor/src/vm_hooks.rs b/vm-executor/src/vm_hooks.rs index c87ffeb..582be7c 100644 --- a/vm-executor/src/vm_hooks.rs +++ b/vm-executor/src/vm_hooks.rs @@ -111,6 +111,7 @@ pub trait VMHooks: core::fmt::Debug + 'static { fn managed_get_code_metadata(&self, address_handle: i32, response_handle: i32); fn managed_is_builtin_function(&self, function_name_handle: i32) -> i32; fn managed_get_sft_metadata(&self, ticker_handle: i32, nonce: i64, data_handle: i32); + fn managed_acc_has_perm(&self, ops: i64, source_acc_addr: i32, target_acc_addr: i32) -> i32; fn big_float_new_from_parts(&self, integral_part: i32, fractional_part: i32, exponent: i32) -> i32; fn big_float_new_from_frac(&self, numerator: i64, denominator: i64) -> i32; fn big_float_new_from_sci(&self, significand: i64, exponent: i64) -> i32; @@ -713,6 +714,11 @@ impl VMHooks for VMHooksDefault { println!("Called: managed_get_sft_metadata"); } + fn managed_acc_has_perm(&self, ops: i64, source_acc_addr: i32, target_acc_addr: i32) -> i32 { + println!("Called: managed_acc_has_perm"); + 0 + } + fn big_float_new_from_parts(&self, integral_part: i32, fractional_part: i32, exponent: i32) -> i32 { println!("Called: big_float_new_from_parts"); 0