From 084a968006525b6fadeb054ef90e44ad9a83c6f5 Mon Sep 17 00:00:00 2001 From: Andrei Marinica Date: Tue, 27 Jun 2023 16:46:03 +0300 Subject: [PATCH] vm - separate RawHandle alias --- vm/src/tx_mock/tx_managed_types/handle_map.rs | 2 +- vm/src/tx_mock/tx_managed_types/tx_big_float.rs | 2 +- vm/src/tx_mock/tx_managed_types/tx_big_int.rs | 3 ++- vm/src/tx_mock/tx_managed_types/tx_managed_buffer.rs | 4 ++-- vm/src/tx_mock/tx_managed_types/tx_managed_map.rs | 2 +- vm/src/vm_hooks/vh_handler/vh_blockchain.rs | 7 ++----- vm/src/vm_hooks/vh_handler/vh_call_value.rs | 3 +-- vm/src/vm_hooks/vh_handler/vh_crypto.rs | 3 +-- vm/src/vm_hooks/vh_handler/vh_endpoint_arg.rs | 2 +- vm/src/vm_hooks/vh_handler/vh_endpoint_finish.rs | 2 +- vm/src/vm_hooks/vh_handler/vh_error.rs | 4 +--- vm/src/vm_hooks/vh_handler/vh_log.rs | 4 +--- vm/src/vm_hooks/vh_handler/vh_managed_types.rs | 2 +- .../vm_hooks/vh_handler/vh_managed_types/vh_big_float.rs | 6 +++--- vm/src/vm_hooks/vh_handler/vh_managed_types/vh_big_int.rs | 3 ++- .../vh_handler/vh_managed_types/vh_managed_buffer.rs | 2 +- .../vm_hooks/vh_handler/vh_managed_types/vh_managed_map.rs | 3 +-- vm/src/vm_hooks/vh_handler/vh_send.rs | 4 +--- vm/src/vm_hooks/vh_handler/vh_storage.rs | 6 ++++-- 19 files changed, 28 insertions(+), 36 deletions(-) diff --git a/vm/src/tx_mock/tx_managed_types/handle_map.rs b/vm/src/tx_mock/tx_managed_types/handle_map.rs index a9d6476daf..62f9c04659 100644 --- a/vm/src/tx_mock/tx_managed_types/handle_map.rs +++ b/vm/src/tx_mock/tx_managed_types/handle_map.rs @@ -1,4 +1,4 @@ -use multiversx_sc::api::RawHandle; +use crate::types::RawHandle; use std::collections::HashMap; #[derive(Debug)] diff --git a/vm/src/tx_mock/tx_managed_types/tx_big_float.rs b/vm/src/tx_mock/tx_managed_types/tx_big_float.rs index d17478e880..5152ae9ada 100644 --- a/vm/src/tx_mock/tx_managed_types/tx_big_float.rs +++ b/vm/src/tx_mock/tx_managed_types/tx_big_float.rs @@ -1,4 +1,4 @@ -use multiversx_sc::api::RawHandle; +use crate::types::RawHandle; use super::TxManagedTypes; diff --git a/vm/src/tx_mock/tx_managed_types/tx_big_int.rs b/vm/src/tx_mock/tx_managed_types/tx_big_int.rs index 3306bf963f..b4f0ec2dff 100644 --- a/vm/src/tx_mock/tx_managed_types/tx_big_int.rs +++ b/vm/src/tx_mock/tx_managed_types/tx_big_int.rs @@ -1,6 +1,7 @@ use std::cmp::Ordering; -use multiversx_sc::{api::RawHandle, types::BoxedBytes}; +use crate::types::RawHandle; +use multiversx_sc::types::BoxedBytes; use num_bigint::Sign; use num_traits::Zero; diff --git a/vm/src/tx_mock/tx_managed_types/tx_managed_buffer.rs b/vm/src/tx_mock/tx_managed_types/tx_managed_buffer.rs index b5fcec54e1..3a24439610 100644 --- a/vm/src/tx_mock/tx_managed_types/tx_managed_buffer.rs +++ b/vm/src/tx_mock/tx_managed_types/tx_managed_buffer.rs @@ -1,11 +1,11 @@ use multiversx_sc::{ - api::{handle_to_be_bytes, InvalidSliceError, RawHandle}, + api::{handle_to_be_bytes, InvalidSliceError}, types::BoxedBytes, }; use crate::{ tx_mock::{TxFunctionName, TxTokenTransfer}, - types::{CodeMetadata, VMAddress}, + types::{CodeMetadata, RawHandle, VMAddress}, }; use super::TxManagedTypes; diff --git a/vm/src/tx_mock/tx_managed_types/tx_managed_map.rs b/vm/src/tx_mock/tx_managed_types/tx_managed_map.rs index b428c9875c..1a61d6de66 100644 --- a/vm/src/tx_mock/tx_managed_types/tx_managed_map.rs +++ b/vm/src/tx_mock/tx_managed_types/tx_managed_map.rs @@ -1,4 +1,4 @@ -use multiversx_sc::api::RawHandle; +use crate::types::RawHandle; use super::{ManagedMapImpl, TxManagedTypes}; diff --git a/vm/src/vm_hooks/vh_handler/vh_blockchain.rs b/vm/src/vm_hooks/vh_handler/vh_blockchain.rs index c1837a3eaa..b117742a5a 100644 --- a/vm/src/vm_hooks/vh_handler/vh_blockchain.rs +++ b/vm/src/vm_hooks/vh_handler/vh_blockchain.rs @@ -1,13 +1,10 @@ use crate::{ num_bigint, - types::VMAddress, + types::{RawHandle, VMAddress}, vm_hooks::VMHooksHandlerSource, world_mock::{EsdtData, EsdtInstance}, }; -use multiversx_sc::{ - api::RawHandle, - types::{EsdtLocalRole, EsdtLocalRoleFlags}, -}; +use multiversx_sc::types::{EsdtLocalRole, EsdtLocalRoleFlags}; use num_bigint::BigInt; use num_traits::Zero; diff --git a/vm/src/vm_hooks/vh_handler/vh_call_value.rs b/vm/src/vm_hooks/vh_handler/vh_call_value.rs index a8d52091c2..877f72a4a0 100644 --- a/vm/src/vm_hooks/vh_handler/vh_call_value.rs +++ b/vm/src/vm_hooks/vh_handler/vh_call_value.rs @@ -1,5 +1,4 @@ -use crate::{num_bigint, vm_err_msg, vm_hooks::VMHooksHandlerSource}; -use multiversx_sc::api::RawHandle; +use crate::{num_bigint, types::RawHandle, vm_err_msg, vm_hooks::VMHooksHandlerSource}; use num_traits::Zero; use super::VMHooksManagedTypes; diff --git a/vm/src/vm_hooks/vh_handler/vh_crypto.rs b/vm/src/vm_hooks/vh_handler/vh_crypto.rs index c6071e9a93..f401a2942f 100644 --- a/vm/src/vm_hooks/vh_handler/vh_crypto.rs +++ b/vm/src/vm_hooks/vh_handler/vh_crypto.rs @@ -1,5 +1,4 @@ -use crate::{crypto_functions, vm_hooks::VMHooksHandlerSource}; -use multiversx_sc::api::RawHandle; +use crate::{crypto_functions, types::RawHandle, vm_hooks::VMHooksHandlerSource}; pub trait VMHooksCrypto: VMHooksHandlerSource { fn sha256_managed(&self, dest: RawHandle, data_handle: RawHandle) { diff --git a/vm/src/vm_hooks/vh_handler/vh_endpoint_arg.rs b/vm/src/vm_hooks/vh_handler/vh_endpoint_arg.rs index c89101d69b..f072e1b880 100644 --- a/vm/src/vm_hooks/vh_handler/vh_endpoint_arg.rs +++ b/vm/src/vm_hooks/vh_handler/vh_endpoint_arg.rs @@ -3,7 +3,7 @@ use crate::{ vm_hooks::VMHooksHandlerSource, }; -use multiversx_sc::api::RawHandle; +use crate::types::RawHandle; use num_traits::cast::ToPrimitive; use super::VMHooksManagedTypes; diff --git a/vm/src/vm_hooks/vh_handler/vh_endpoint_finish.rs b/vm/src/vm_hooks/vh_handler/vh_endpoint_finish.rs index af0700532a..4f6db953f9 100644 --- a/vm/src/vm_hooks/vh_handler/vh_endpoint_finish.rs +++ b/vm/src/vm_hooks/vh_handler/vh_endpoint_finish.rs @@ -1,8 +1,8 @@ use crate::{ num_bigint::{BigInt, BigUint}, + types::RawHandle, vm_hooks::{VMHooksHandlerSource, VMHooksManagedTypes}, }; -use multiversx_sc::api::RawHandle; /// Interface to only be used by code generated by the macros. /// The smart contract code doesn't have access to these methods directly. diff --git a/vm/src/vm_hooks/vh_handler/vh_error.rs b/vm/src/vm_hooks/vh_handler/vh_error.rs index 68ea6f0819..93ef714ed8 100644 --- a/vm/src/vm_hooks/vh_handler/vh_error.rs +++ b/vm/src/vm_hooks/vh_handler/vh_error.rs @@ -1,6 +1,4 @@ -use multiversx_sc::api::RawHandle; - -use crate::vm_hooks::VMHooksHandlerSource; +use crate::{types::RawHandle, vm_hooks::VMHooksHandlerSource}; use super::VMHooksManagedTypes; diff --git a/vm/src/vm_hooks/vh_handler/vh_log.rs b/vm/src/vm_hooks/vh_handler/vh_log.rs index ed43e8a809..868df836e7 100644 --- a/vm/src/vm_hooks/vh_handler/vh_log.rs +++ b/vm/src/vm_hooks/vh_handler/vh_log.rs @@ -1,6 +1,4 @@ -use multiversx_sc::api::RawHandle; - -use crate::{tx_mock::TxLog, vm_hooks::VMHooksHandlerSource}; +use crate::{tx_mock::TxLog, types::RawHandle, vm_hooks::VMHooksHandlerSource}; pub trait VMHooksLog: VMHooksHandlerSource { fn managed_write_log(&self, topics_handle: RawHandle, data_handle: RawHandle) { diff --git a/vm/src/vm_hooks/vh_handler/vh_managed_types.rs b/vm/src/vm_hooks/vh_handler/vh_managed_types.rs index 6cde65f57e..0985a5a15a 100644 --- a/vm/src/vm_hooks/vh_handler/vh_managed_types.rs +++ b/vm/src/vm_hooks/vh_handler/vh_managed_types.rs @@ -10,7 +10,7 @@ pub use vh_managed_map::VMHooksManagedMap; use std::fmt::Debug; -use multiversx_sc::api::RawHandle; +use crate::types::RawHandle; use super::VMHooksError; diff --git a/vm/src/vm_hooks/vh_handler/vh_managed_types/vh_big_float.rs b/vm/src/vm_hooks/vh_handler/vh_managed_types/vh_big_float.rs index e752a5f950..dd2637e863 100644 --- a/vm/src/vm_hooks/vh_handler/vh_managed_types/vh_big_float.rs +++ b/vm/src/vm_hooks/vh_handler/vh_managed_types/vh_big_float.rs @@ -1,4 +1,5 @@ use crate::{ + types::RawHandle, vm_err_msg, vm_hooks::{VMHooksError, VMHooksHandlerSource}, }; @@ -6,10 +7,9 @@ use core::{ cmp::Ordering, ops::{Add, Div, Mul, Neg, Sub}, }; -use std::convert::TryInto; - -use multiversx_sc::{api::RawHandle, codec::num_bigint::BigInt}; +use num_bigint::BigInt; use num_traits::ToPrimitive; +use std::convert::TryInto; macro_rules! binary_op_method { ($method_name:ident, $rust_op_name:ident) => { diff --git a/vm/src/vm_hooks/vh_handler/vh_managed_types/vh_big_int.rs b/vm/src/vm_hooks/vh_handler/vh_managed_types/vh_big_int.rs index 64ef3918cf..9c9e57520b 100644 --- a/vm/src/vm_hooks/vh_handler/vh_managed_types/vh_big_int.rs +++ b/vm/src/vm_hooks/vh_handler/vh_managed_types/vh_big_int.rs @@ -1,6 +1,7 @@ use crate::{ num_bigint, tx_mock::big_int_to_i64, + types::RawHandle, vm_err_msg, vm_hooks::{VMHooksError, VMHooksHandlerSource}, }; @@ -8,7 +9,7 @@ use core::{ cmp::Ordering, ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Rem, Shl, Shr, Sub}, }; -use multiversx_sc::{api::RawHandle, types::heap::BoxedBytes}; +use multiversx_sc::types::heap::BoxedBytes; use num_traits::{pow, sign::Signed}; use std::convert::TryInto; diff --git a/vm/src/vm_hooks/vh_handler/vh_managed_types/vh_managed_buffer.rs b/vm/src/vm_hooks/vh_handler/vh_managed_types/vh_managed_buffer.rs index ad8098da9a..70f1e69f08 100644 --- a/vm/src/vm_hooks/vh_handler/vh_managed_types/vh_managed_buffer.rs +++ b/vm/src/vm_hooks/vh_handler/vh_managed_types/vh_managed_buffer.rs @@ -1,4 +1,4 @@ -use multiversx_sc::api::RawHandle; +use crate::types::RawHandle; use crate::vm_hooks::VMHooksHandlerSource; diff --git a/vm/src/vm_hooks/vh_handler/vh_managed_types/vh_managed_map.rs b/vm/src/vm_hooks/vh_handler/vh_managed_types/vh_managed_map.rs index bbe9614bb6..8d905afb38 100644 --- a/vm/src/vm_hooks/vh_handler/vh_managed_types/vh_managed_map.rs +++ b/vm/src/vm_hooks/vh_handler/vh_managed_types/vh_managed_map.rs @@ -1,5 +1,4 @@ -use crate::vm_hooks::VMHooksHandlerSource; -use multiversx_sc::api::RawHandle; +use crate::{types::RawHandle, vm_hooks::VMHooksHandlerSource}; pub trait VMHooksManagedMap: VMHooksHandlerSource { fn mm_new(&self) -> RawHandle { diff --git a/vm/src/vm_hooks/vh_handler/vh_send.rs b/vm/src/vm_hooks/vh_handler/vh_send.rs index b03bbadc16..e1dc494b5d 100644 --- a/vm/src/vm_hooks/vh_handler/vh_send.rs +++ b/vm/src/vm_hooks/vh_handler/vh_send.rs @@ -5,11 +5,9 @@ use crate::{ UPGRADE_CONTRACT_FUNC_NAME, }, tx_mock::{AsyncCallTxData, Promise, TxFunctionName, TxTokenTransfer}, - types::{top_encode_big_uint, top_encode_u64, CodeMetadata, VMAddress}, + types::{top_encode_big_uint, top_encode_u64, CodeMetadata, RawHandle, VMAddress}, vm_hooks::VMHooksHandlerSource, }; - -use multiversx_sc::api::RawHandle; use num_traits::Zero; fn append_endpoint_name_and_args( diff --git a/vm/src/vm_hooks/vh_handler/vh_storage.rs b/vm/src/vm_hooks/vh_handler/vh_storage.rs index 21d386bab0..6787faec4f 100644 --- a/vm/src/vm_hooks/vh_handler/vh_storage.rs +++ b/vm/src/vm_hooks/vh_handler/vh_storage.rs @@ -1,5 +1,7 @@ -use crate::{types::VMAddress, vm_hooks::VMHooksHandlerSource}; -use multiversx_sc::api::RawHandle; +use crate::{ + types::{RawHandle, VMAddress}, + vm_hooks::VMHooksHandlerSource, +}; use super::VMHooksManagedTypes;