From 6b822cb83eb5027e5b68158e32e009f492526ec3 Mon Sep 17 00:00:00 2001 From: hyperyuri Date: Thu, 4 Apr 2024 12:28:48 -0300 Subject: [PATCH 1/4] feat: create managed method to get sft meta --- c-api/libvmexeccapi.h | 1 + c-api/src/capi_vm_hook_pointers.rs | 1 + c-api/src/capi_vm_hooks.rs | 4 ++++ vm-executor-wasmer/src/wasmer_imports.rs | 6 ++++++ vm-executor/src/vm_hooks.rs | 5 +++++ 5 files changed, 17 insertions(+) diff --git a/c-api/libvmexeccapi.h b/c-api/libvmexeccapi.h index f614678..9740a14 100644 --- a/c-api/libvmexeccapi.h +++ b/c-api/libvmexeccapi.h @@ -123,6 +123,7 @@ typedef struct { 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); void (*managed_get_kda_token_data_func_ptr)(void *context, int32_t address_handle, int32_t ticker_handle, int64_t nonce, int32_t precision_handle, int32_t id_handle, int32_t name_handle, int32_t creator_handle, int32_t logo_handle, int32_t uris_handle, int32_t initial_supply_handle, int32_t circulating_supply_handle, int32_t max_supply_handle, int32_t minted_handle, int32_t burned_handle, int32_t royalties_handle, int32_t properties_handle, int32_t attributes_handle, int32_t roles_handle, int32_t issue_date_handle); + void (*managed_get_sft_metadata_func_ptr)(void *context, int32_t ticker_handle, int64_t nonce, int32_t max_supply_handle, int32_t circulation_supply_handle, int32_t meta_handle); void (*managed_get_kda_roles_func_ptr)(void *context, int32_t ticker_handle, int32_t roles_handle); void (*managed_upgrade_from_source_contract_func_ptr)(void *context, int32_t dest_handle, int64_t gas, int32_t value_handle, int32_t address_handle, int32_t code_metadata_handle, int32_t arguments_handle, int32_t result_handle); void (*managed_upgrade_contract_func_ptr)(void *context, int32_t dest_handle, int64_t gas, int32_t value_handle, int32_t code_handle, int32_t code_metadata_handle, int32_t arguments_handle, int32_t result_handle); diff --git a/c-api/src/capi_vm_hook_pointers.rs b/c-api/src/capi_vm_hook_pointers.rs index c937fc5..3337861 100644 --- a/c-api/src/capi_vm_hook_pointers.rs +++ b/c-api/src/capi_vm_hook_pointers.rs @@ -95,6 +95,7 @@ pub struct vm_exec_vm_hook_c_func_pointers { 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), pub managed_get_kda_token_data_func_ptr: extern "C" fn(context: *mut c_void, address_handle: i32, ticker_handle: i32, nonce: i64, precision_handle: i32, id_handle: i32, name_handle: i32, creator_handle: i32, logo_handle: i32, uris_handle: i32, initial_supply_handle: i32, circulating_supply_handle: i32, max_supply_handle: i32, minted_handle: i32, burned_handle: i32, royalties_handle: i32, properties_handle: i32, attributes_handle: i32, roles_handle: i32, issue_date_handle: i32), + pub managed_get_sft_metadata_func_ptr: extern "C" fn(context: *mut c_void, ticker_handle: i32, nonce: i64, max_supply_handle: i32, circulation_supply_handle: i32, meta_handle: i32), pub managed_get_kda_roles_func_ptr: extern "C" fn(context: *mut c_void, ticker_handle: i32, roles_handle: i32), pub managed_upgrade_from_source_contract_func_ptr: extern "C" fn(context: *mut c_void, dest_handle: i32, gas: i64, value_handle: i32, address_handle: i32, code_metadata_handle: i32, arguments_handle: i32, result_handle: i32), pub managed_upgrade_contract_func_ptr: extern "C" fn(context: *mut c_void, dest_handle: i32, gas: i64, value_handle: i32, code_handle: i32, code_metadata_handle: i32, arguments_handle: i32, result_handle: i32), diff --git a/c-api/src/capi_vm_hooks.rs b/c-api/src/capi_vm_hooks.rs index d157079..8d9fd35 100644 --- a/c-api/src/capi_vm_hooks.rs +++ b/c-api/src/capi_vm_hooks.rs @@ -379,6 +379,10 @@ impl klever_chain_vm_executor::VMHooks for CapiVMHooks { (self.c_func_pointers_ptr.managed_get_kda_token_data_func_ptr)(self.vm_hooks_ptr, address_handle, ticker_handle, nonce, precision_handle, id_handle, name_handle, creator_handle, logo_handle, uris_handle, initial_supply_handle, circulating_supply_handle, max_supply_handle, minted_handle, burned_handle, royalties_handle, properties_handle, attributes_handle, roles_handle, issue_date_handle) } + fn managed_get_sft_metadata(&self, ticker_handle: i32, nonce: i64, max_supply_handle: i32, circulation_supply_handle: i32, meta_handle: i32) { + (self.c_func_pointers_ptr.managed_get_sft_metadata_func_ptr)(self.vm_hooks_ptr, ticker_handle, nonce, max_supply_handle, circulation_supply_handle, meta_handle) + } + fn managed_get_kda_roles(&self, ticker_handle: i32, roles_handle: i32) { (self.c_func_pointers_ptr.managed_get_kda_roles_func_ptr)(self.vm_hooks_ptr, ticker_handle, roles_handle) } diff --git a/vm-executor-wasmer/src/wasmer_imports.rs b/vm-executor-wasmer/src/wasmer_imports.rs index dcd0ee2..02afe88 100644 --- a/vm-executor-wasmer/src/wasmer_imports.rs +++ b/vm-executor-wasmer/src/wasmer_imports.rs @@ -435,6 +435,11 @@ fn wasmer_import_managed_get_kda_token_data(env: &VMHooksWrapper, address_handle env.vm_hooks.managed_get_kda_token_data(address_handle, ticker_handle, nonce, precision_handle, id_handle, name_handle, creator_handle, logo_handle, uris_handle, initial_supply_handle, circulating_supply_handle, max_supply_handle, minted_handle, burned_handle, royalties_handle, properties_handle, attributes_handle, roles_handle, issue_date_handle) } +#[rustfmt::skip] +fn wasmer_import_managed_get_sft_metadata(env: &VMHooksWrapper, ticker_handle: i32, nonce: i64, max_supply_handle: i32, circulation_supply_handle: i32, meta_handle: i32) { + env.vm_hooks.managed_get_sft_metadata(ticker_handle, nonce, max_supply_handle, circulation_supply_handle, meta_handle) +} + #[rustfmt::skip] fn wasmer_import_managed_get_kda_roles(env: &VMHooksWrapper, ticker_handle: i32, roles_handle: i32) { env.vm_hooks.managed_get_kda_roles(ticker_handle, roles_handle) @@ -1298,6 +1303,7 @@ pub fn generate_import_object(store: &Store, env: &VMHooksWrapper) -> ImportObje "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), "managedGetKDATokenData" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_kda_token_data), + "managedGetSftMetadata" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_sft_metadata), "managedGetKDARoles" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_kda_roles), "managedUpgradeFromSourceContract" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_upgrade_from_source_contract), "managedUpgradeContract" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_upgrade_contract), diff --git a/vm-executor/src/vm_hooks.rs b/vm-executor/src/vm_hooks.rs index eb9fc7c..fd02729 100644 --- a/vm-executor/src/vm_hooks.rs +++ b/vm-executor/src/vm_hooks.rs @@ -98,6 +98,7 @@ pub trait VMHooks: core::fmt::Debug + 'static { 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); fn managed_get_kda_token_data(&self, address_handle: i32, ticker_handle: i32, nonce: i64, precision_handle: i32, id_handle: i32, name_handle: i32, creator_handle: i32, logo_handle: i32, uris_handle: i32, initial_supply_handle: i32, circulating_supply_handle: i32, max_supply_handle: i32, minted_handle: i32, burned_handle: i32, royalties_handle: i32, properties_handle: i32, attributes_handle: i32, roles_handle: i32, issue_date_handle: i32); + fn managed_get_sft_metadata(&self, ticker_handle: i32, nonce: i64, max_supply_handle: i32, circulation_supply_handle: i32, meta_handle: i32); fn managed_get_kda_roles(&self, ticker_handle: i32, roles_handle: i32); fn managed_upgrade_from_source_contract(&self, dest_handle: i32, gas: i64, value_handle: i32, address_handle: i32, code_metadata_handle: i32, arguments_handle: i32, result_handle: i32); fn managed_upgrade_contract(&self, dest_handle: i32, gas: i64, value_handle: i32, code_handle: i32, code_metadata_handle: i32, arguments_handle: i32, result_handle: i32); @@ -654,6 +655,10 @@ impl VMHooks for VMHooksDefault { println!("Called: managed_get_kda_token_data"); } + fn managed_get_sft_metadata(&self, ticker_handle: i32, nonce: i64, max_supply_handle: i32, circulation_supply_handle: i32, meta_handle: i32) { + println!("Called: managed_get_sft_metadata"); + } + fn managed_get_kda_roles(&self, ticker_handle: i32, roles_handle: i32) { println!("Called: managed_get_kda_roles"); } From 6eadbc61ac90498243ea3d239889925428f7a074 Mon Sep 17 00:00:00 2001 From: hyperyuri Date: Thu, 4 Apr 2024 12:32:09 -0300 Subject: [PATCH 2/4] add changelog and setup version --- CHANGELOG.md | 4 ++++ vm-executor-wasmer/Cargo.toml | 4 ++-- vm-executor/Cargo.toml | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17a85df..c0b264b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ This file contains a centralizes a trace of all published crate versions, with their changes in short. +## [klever-chain-vm-executor 0.3.0] - 2024-04-04 +- New VM hook: `managedGetSftMetadata`. +- Memory fix. + ## [klever-chain-vm-executor 0.2.0] - 2023-10-12 - New VM hook: `managedGetBackTransfers`. - Memory fix. diff --git a/vm-executor-wasmer/Cargo.toml b/vm-executor-wasmer/Cargo.toml index 22d64b5..e14dc13 100644 --- a/vm-executor-wasmer/Cargo.toml +++ b/vm-executor-wasmer/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "klever-chain-vm-executor-wasmer" -version = "0.2.0" +version = "0.3.0" edition = "2021" publish = false # will also be published, but it is not yet ready for that [lib] [dependencies.klever-chain-vm-executor] -version = "0.2.0" +version = "0.3.0" path = "../vm-executor" [dependencies] diff --git a/vm-executor/Cargo.toml b/vm-executor/Cargo.toml index a3d3b5d..4e3116e 100644 --- a/vm-executor/Cargo.toml +++ b/vm-executor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "klever-chain-vm-executor" -version = "0.2.0" +version = "0.3.0" edition = "2021" authors = [] From 7df5709241b2dc18c818ccd12167569b8e96b732 Mon Sep 17 00:00:00 2001 From: hyperyuri Date: Thu, 4 Apr 2024 18:28:34 -0300 Subject: [PATCH 3/4] fix: change order and arg handlers --- c-api/libvmexeccapi.h | 2 +- c-api/src/capi_vm_hook_pointers.rs | 2 +- c-api/src/capi_vm_hooks.rs | 8 ++++---- vm-executor-wasmer/src/wasmer_imports.rs | 12 ++++++------ vm-executor/src/vm_hooks.rs | 10 +++++----- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/c-api/libvmexeccapi.h b/c-api/libvmexeccapi.h index 9740a14..61b57d3 100644 --- a/c-api/libvmexeccapi.h +++ b/c-api/libvmexeccapi.h @@ -123,7 +123,6 @@ typedef struct { 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); void (*managed_get_kda_token_data_func_ptr)(void *context, int32_t address_handle, int32_t ticker_handle, int64_t nonce, int32_t precision_handle, int32_t id_handle, int32_t name_handle, int32_t creator_handle, int32_t logo_handle, int32_t uris_handle, int32_t initial_supply_handle, int32_t circulating_supply_handle, int32_t max_supply_handle, int32_t minted_handle, int32_t burned_handle, int32_t royalties_handle, int32_t properties_handle, int32_t attributes_handle, int32_t roles_handle, int32_t issue_date_handle); - void (*managed_get_sft_metadata_func_ptr)(void *context, int32_t ticker_handle, int64_t nonce, int32_t max_supply_handle, int32_t circulation_supply_handle, int32_t meta_handle); void (*managed_get_kda_roles_func_ptr)(void *context, int32_t ticker_handle, int32_t roles_handle); void (*managed_upgrade_from_source_contract_func_ptr)(void *context, int32_t dest_handle, int64_t gas, int32_t value_handle, int32_t address_handle, int32_t code_metadata_handle, int32_t arguments_handle, int32_t result_handle); void (*managed_upgrade_contract_func_ptr)(void *context, int32_t dest_handle, int64_t gas, int32_t value_handle, int32_t code_handle, int32_t code_metadata_handle, int32_t arguments_handle, int32_t result_handle); @@ -137,6 +136,7 @@ typedef struct { void (*managed_buffer_to_hex_func_ptr)(void *context, int32_t source_handle, int32_t dest_handle); 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 (*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 3337861..e177924 100644 --- a/c-api/src/capi_vm_hook_pointers.rs +++ b/c-api/src/capi_vm_hook_pointers.rs @@ -95,7 +95,6 @@ pub struct vm_exec_vm_hook_c_func_pointers { 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), pub managed_get_kda_token_data_func_ptr: extern "C" fn(context: *mut c_void, address_handle: i32, ticker_handle: i32, nonce: i64, precision_handle: i32, id_handle: i32, name_handle: i32, creator_handle: i32, logo_handle: i32, uris_handle: i32, initial_supply_handle: i32, circulating_supply_handle: i32, max_supply_handle: i32, minted_handle: i32, burned_handle: i32, royalties_handle: i32, properties_handle: i32, attributes_handle: i32, roles_handle: i32, issue_date_handle: i32), - pub managed_get_sft_metadata_func_ptr: extern "C" fn(context: *mut c_void, ticker_handle: i32, nonce: i64, max_supply_handle: i32, circulation_supply_handle: i32, meta_handle: i32), pub managed_get_kda_roles_func_ptr: extern "C" fn(context: *mut c_void, ticker_handle: i32, roles_handle: i32), pub managed_upgrade_from_source_contract_func_ptr: extern "C" fn(context: *mut c_void, dest_handle: i32, gas: i64, value_handle: i32, address_handle: i32, code_metadata_handle: i32, arguments_handle: i32, result_handle: i32), pub managed_upgrade_contract_func_ptr: extern "C" fn(context: *mut c_void, dest_handle: i32, gas: i64, value_handle: i32, code_handle: i32, code_metadata_handle: i32, arguments_handle: i32, result_handle: i32), @@ -109,6 +108,7 @@ pub struct vm_exec_vm_hook_c_func_pointers { pub managed_buffer_to_hex_func_ptr: extern "C" fn(context: *mut c_void, source_handle: i32, dest_handle: i32), 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 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 8d9fd35..ac40035 100644 --- a/c-api/src/capi_vm_hooks.rs +++ b/c-api/src/capi_vm_hooks.rs @@ -379,10 +379,6 @@ impl klever_chain_vm_executor::VMHooks for CapiVMHooks { (self.c_func_pointers_ptr.managed_get_kda_token_data_func_ptr)(self.vm_hooks_ptr, address_handle, ticker_handle, nonce, precision_handle, id_handle, name_handle, creator_handle, logo_handle, uris_handle, initial_supply_handle, circulating_supply_handle, max_supply_handle, minted_handle, burned_handle, royalties_handle, properties_handle, attributes_handle, roles_handle, issue_date_handle) } - fn managed_get_sft_metadata(&self, ticker_handle: i32, nonce: i64, max_supply_handle: i32, circulation_supply_handle: i32, meta_handle: i32) { - (self.c_func_pointers_ptr.managed_get_sft_metadata_func_ptr)(self.vm_hooks_ptr, ticker_handle, nonce, max_supply_handle, circulation_supply_handle, meta_handle) - } - fn managed_get_kda_roles(&self, ticker_handle: i32, roles_handle: i32) { (self.c_func_pointers_ptr.managed_get_kda_roles_func_ptr)(self.vm_hooks_ptr, ticker_handle, roles_handle) } @@ -435,6 +431,10 @@ impl klever_chain_vm_executor::VMHooks for CapiVMHooks { (self.c_func_pointers_ptr.managed_is_builtin_function_func_ptr)(self.vm_hooks_ptr, function_name_handle) } + fn managed_get_sft_metadata(&self, ticker_handle: i32, nonce: i64, data_handle: i32) { + (self.c_func_pointers_ptr.managed_get_sft_metadata_func_ptr)(self.vm_hooks_ptr, ticker_handle, nonce, data_handle) + } + 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 02afe88..353c857 100644 --- a/vm-executor-wasmer/src/wasmer_imports.rs +++ b/vm-executor-wasmer/src/wasmer_imports.rs @@ -435,11 +435,6 @@ fn wasmer_import_managed_get_kda_token_data(env: &VMHooksWrapper, address_handle env.vm_hooks.managed_get_kda_token_data(address_handle, ticker_handle, nonce, precision_handle, id_handle, name_handle, creator_handle, logo_handle, uris_handle, initial_supply_handle, circulating_supply_handle, max_supply_handle, minted_handle, burned_handle, royalties_handle, properties_handle, attributes_handle, roles_handle, issue_date_handle) } -#[rustfmt::skip] -fn wasmer_import_managed_get_sft_metadata(env: &VMHooksWrapper, ticker_handle: i32, nonce: i64, max_supply_handle: i32, circulation_supply_handle: i32, meta_handle: i32) { - env.vm_hooks.managed_get_sft_metadata(ticker_handle, nonce, max_supply_handle, circulation_supply_handle, meta_handle) -} - #[rustfmt::skip] fn wasmer_import_managed_get_kda_roles(env: &VMHooksWrapper, ticker_handle: i32, roles_handle: i32) { env.vm_hooks.managed_get_kda_roles(ticker_handle, roles_handle) @@ -505,6 +500,11 @@ fn wasmer_import_managed_is_builtin_function(env: &VMHooksWrapper, function_name env.vm_hooks.managed_is_builtin_function(function_name_handle) } +#[rustfmt::skip] +fn wasmer_import_managed_get_sft_metadata(env: &VMHooksWrapper, ticker_handle: i32, nonce: i64, data_handle: i32) { + env.vm_hooks.managed_get_sft_metadata(ticker_handle, nonce, data_handle) +} + #[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) @@ -1303,7 +1303,6 @@ pub fn generate_import_object(store: &Store, env: &VMHooksWrapper) -> ImportObje "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), "managedGetKDATokenData" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_kda_token_data), - "managedGetSftMetadata" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_sft_metadata), "managedGetKDARoles" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_kda_roles), "managedUpgradeFromSourceContract" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_upgrade_from_source_contract), "managedUpgradeContract" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_upgrade_contract), @@ -1317,6 +1316,7 @@ pub fn generate_import_object(store: &Store, env: &VMHooksWrapper) -> ImportObje "managedBufferToHex" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_buffer_to_hex), "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), "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 fd02729..4342e3b 100644 --- a/vm-executor/src/vm_hooks.rs +++ b/vm-executor/src/vm_hooks.rs @@ -98,7 +98,6 @@ pub trait VMHooks: core::fmt::Debug + 'static { 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); fn managed_get_kda_token_data(&self, address_handle: i32, ticker_handle: i32, nonce: i64, precision_handle: i32, id_handle: i32, name_handle: i32, creator_handle: i32, logo_handle: i32, uris_handle: i32, initial_supply_handle: i32, circulating_supply_handle: i32, max_supply_handle: i32, minted_handle: i32, burned_handle: i32, royalties_handle: i32, properties_handle: i32, attributes_handle: i32, roles_handle: i32, issue_date_handle: i32); - fn managed_get_sft_metadata(&self, ticker_handle: i32, nonce: i64, max_supply_handle: i32, circulation_supply_handle: i32, meta_handle: i32); fn managed_get_kda_roles(&self, ticker_handle: i32, roles_handle: i32); fn managed_upgrade_from_source_contract(&self, dest_handle: i32, gas: i64, value_handle: i32, address_handle: i32, code_metadata_handle: i32, arguments_handle: i32, result_handle: i32); fn managed_upgrade_contract(&self, dest_handle: i32, gas: i64, value_handle: i32, code_handle: i32, code_metadata_handle: i32, arguments_handle: i32, result_handle: i32); @@ -112,6 +111,7 @@ pub trait VMHooks: core::fmt::Debug + 'static { fn managed_buffer_to_hex(&self, source_handle: i32, dest_handle: i32); 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 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; @@ -655,10 +655,6 @@ impl VMHooks for VMHooksDefault { println!("Called: managed_get_kda_token_data"); } - fn managed_get_sft_metadata(&self, ticker_handle: i32, nonce: i64, max_supply_handle: i32, circulation_supply_handle: i32, meta_handle: i32) { - println!("Called: managed_get_sft_metadata"); - } - fn managed_get_kda_roles(&self, ticker_handle: i32, roles_handle: i32) { println!("Called: managed_get_kda_roles"); } @@ -718,6 +714,10 @@ impl VMHooks for VMHooksDefault { 0 } + fn managed_get_sft_metadata(&self, ticker_handle: i32, nonce: i64, data_handle: i32) { + println!("Called: managed_get_sft_metadata"); + } + fn big_float_new_from_parts(&self, integral_part: i32, fractional_part: i32, exponent: i32) -> i32 { println!("Called: big_float_new_from_parts"); 0 From 46c4b21b72517cc65da8528bd31a00c1a01d65b2 Mon Sep 17 00:00:00 2001 From: hyperyuri Date: Fri, 5 Apr 2024 11:47:24 -0300 Subject: [PATCH 4/4] fix: change version --- CHANGELOG.md | 5 ++++- vm-executor-wasmer/Cargo.toml | 4 ++-- vm-executor/Cargo.toml | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0b264b..1cf4b7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,15 +2,18 @@ This file contains a centralizes a trace of all published crate versions, with their changes in short. -## [klever-chain-vm-executor 0.3.0] - 2024-04-04 +## [klever-chain-vm-executor 0.2.1] - 2024-04-04 + - New VM hook: `managedGetSftMetadata`. - Memory fix. ## [klever-chain-vm-executor 0.2.0] - 2023-10-12 + - New VM hook: `managedGetBackTransfers`. - Memory fix. ## [klever-chain-vm-executor 0.1.0] - 2023-06-15 + 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. It targets VM 1.5 and integrates the Wasmer 2.2 implementation. diff --git a/vm-executor-wasmer/Cargo.toml b/vm-executor-wasmer/Cargo.toml index e14dc13..79ebc5b 100644 --- a/vm-executor-wasmer/Cargo.toml +++ b/vm-executor-wasmer/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "klever-chain-vm-executor-wasmer" -version = "0.3.0" +version = "0.2.1" edition = "2021" publish = false # will also be published, but it is not yet ready for that [lib] [dependencies.klever-chain-vm-executor] -version = "0.3.0" +version = "0.2.1" path = "../vm-executor" [dependencies] diff --git a/vm-executor/Cargo.toml b/vm-executor/Cargo.toml index 4e3116e..24d79ba 100644 --- a/vm-executor/Cargo.toml +++ b/vm-executor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "klever-chain-vm-executor" -version = "0.3.0" +version = "0.2.1" edition = "2021" authors = []