Skip to content

Commit 9898ecd

Browse files
authored
feat: create managed method to get sft meta (#2)
* feat: create managed method to get sft meta * add changelog and setup version * fix: change order and arg handlers * fix: change version
1 parent 4794613 commit 9898ecd

File tree

8 files changed

+27
-3
lines changed

8 files changed

+27
-3
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22

33
This file contains a centralizes a trace of all published crate versions, with their changes in short.
44

5+
## [klever-chain-vm-executor 0.2.1] - 2024-04-04
6+
7+
- New VM hook: `managedGetSftMetadata`.
8+
- Memory fix.
9+
510
## [klever-chain-vm-executor 0.2.0] - 2023-10-12
11+
612
- New VM hook: `managedGetBackTransfers`.
713
- Memory fix.
814

915
## [klever-chain-vm-executor 0.1.0] - 2023-06-15
16+
1017
This is the initial official release of the VM executor interface. The purpose is for it to be used in the new smart contract debugger architecture.
1118

1219
It targets VM 1.5 and integrates the Wasmer 2.2 implementation.

c-api/libvmexeccapi.h

+1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ typedef struct {
136136
void (*managed_buffer_to_hex_func_ptr)(void *context, int32_t source_handle, int32_t dest_handle);
137137
void (*managed_get_code_metadata_func_ptr)(void *context, int32_t address_handle, int32_t response_handle);
138138
int32_t (*managed_is_builtin_function_func_ptr)(void *context, int32_t function_name_handle);
139+
void (*managed_get_sft_metadata_func_ptr)(void *context, int32_t ticker_handle, int64_t nonce, int32_t data_handle);
139140
int32_t (*big_float_new_from_parts_func_ptr)(void *context, int32_t integral_part, int32_t fractional_part, int32_t exponent);
140141
int32_t (*big_float_new_from_frac_func_ptr)(void *context, int64_t numerator, int64_t denominator);
141142
int32_t (*big_float_new_from_sci_func_ptr)(void *context, int64_t significand, int64_t exponent);

c-api/src/capi_vm_hook_pointers.rs

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ pub struct vm_exec_vm_hook_c_func_pointers {
108108
pub managed_buffer_to_hex_func_ptr: extern "C" fn(context: *mut c_void, source_handle: i32, dest_handle: i32),
109109
pub managed_get_code_metadata_func_ptr: extern "C" fn(context: *mut c_void, address_handle: i32, response_handle: i32),
110110
pub managed_is_builtin_function_func_ptr: extern "C" fn(context: *mut c_void, function_name_handle: i32) -> i32,
111+
pub managed_get_sft_metadata_func_ptr: extern "C" fn(context: *mut c_void, ticker_handle: i32, nonce: i64, data_handle: i32),
111112
pub big_float_new_from_parts_func_ptr: extern "C" fn(context: *mut c_void, integral_part: i32, fractional_part: i32, exponent: i32) -> i32,
112113
pub big_float_new_from_frac_func_ptr: extern "C" fn(context: *mut c_void, numerator: i64, denominator: i64) -> i32,
113114
pub big_float_new_from_sci_func_ptr: extern "C" fn(context: *mut c_void, significand: i64, exponent: i64) -> i32,

c-api/src/capi_vm_hooks.rs

+4
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,10 @@ impl klever_chain_vm_executor::VMHooks for CapiVMHooks {
431431
(self.c_func_pointers_ptr.managed_is_builtin_function_func_ptr)(self.vm_hooks_ptr, function_name_handle)
432432
}
433433

434+
fn managed_get_sft_metadata(&self, ticker_handle: i32, nonce: i64, data_handle: i32) {
435+
(self.c_func_pointers_ptr.managed_get_sft_metadata_func_ptr)(self.vm_hooks_ptr, ticker_handle, nonce, data_handle)
436+
}
437+
434438
fn big_float_new_from_parts(&self, integral_part: i32, fractional_part: i32, exponent: i32) -> i32 {
435439
(self.c_func_pointers_ptr.big_float_new_from_parts_func_ptr)(self.vm_hooks_ptr, integral_part, fractional_part, exponent)
436440
}

vm-executor-wasmer/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[package]
22
name = "klever-chain-vm-executor-wasmer"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
edition = "2021"
55
publish = false # will also be published, but it is not yet ready for that
66

77
[lib]
88

99
[dependencies.klever-chain-vm-executor]
10-
version = "0.2.0"
10+
version = "0.2.1"
1111
path = "../vm-executor"
1212

1313
[dependencies]

vm-executor-wasmer/src/wasmer_imports.rs

+6
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,11 @@ fn wasmer_import_managed_is_builtin_function(env: &VMHooksWrapper, function_name
500500
env.vm_hooks.managed_is_builtin_function(function_name_handle)
501501
}
502502

503+
#[rustfmt::skip]
504+
fn wasmer_import_managed_get_sft_metadata(env: &VMHooksWrapper, ticker_handle: i32, nonce: i64, data_handle: i32) {
505+
env.vm_hooks.managed_get_sft_metadata(ticker_handle, nonce, data_handle)
506+
}
507+
503508
#[rustfmt::skip]
504509
fn wasmer_import_big_float_new_from_parts(env: &VMHooksWrapper, integral_part: i32, fractional_part: i32, exponent: i32) -> i32 {
505510
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
13111316
"managedBufferToHex" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_buffer_to_hex),
13121317
"managedGetCodeMetadata" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_code_metadata),
13131318
"managedIsBuiltinFunction" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_is_builtin_function),
1319+
"managedGetSftMetadata" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_sft_metadata),
13141320
"bigFloatNewFromParts" => Function::new_native_with_env(store, env.clone(), wasmer_import_big_float_new_from_parts),
13151321
"bigFloatNewFromFrac" => Function::new_native_with_env(store, env.clone(), wasmer_import_big_float_new_from_frac),
13161322
"bigFloatNewFromSci" => Function::new_native_with_env(store, env.clone(), wasmer_import_big_float_new_from_sci),

vm-executor/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "klever-chain-vm-executor"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
edition = "2021"
55

66
authors = []

vm-executor/src/vm_hooks.rs

+5
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ pub trait VMHooks: core::fmt::Debug + 'static {
111111
fn managed_buffer_to_hex(&self, source_handle: i32, dest_handle: i32);
112112
fn managed_get_code_metadata(&self, address_handle: i32, response_handle: i32);
113113
fn managed_is_builtin_function(&self, function_name_handle: i32) -> i32;
114+
fn managed_get_sft_metadata(&self, ticker_handle: i32, nonce: i64, data_handle: i32);
114115
fn big_float_new_from_parts(&self, integral_part: i32, fractional_part: i32, exponent: i32) -> i32;
115116
fn big_float_new_from_frac(&self, numerator: i64, denominator: i64) -> i32;
116117
fn big_float_new_from_sci(&self, significand: i64, exponent: i64) -> i32;
@@ -713,6 +714,10 @@ impl VMHooks for VMHooksDefault {
713714
0
714715
}
715716

717+
fn managed_get_sft_metadata(&self, ticker_handle: i32, nonce: i64, data_handle: i32) {
718+
println!("Called: managed_get_sft_metadata");
719+
}
720+
716721
fn big_float_new_from_parts(&self, integral_part: i32, fractional_part: i32, exponent: i32) -> i32 {
717722
println!("Called: big_float_new_from_parts");
718723
0

0 commit comments

Comments
 (0)