diff --git a/contracts/examples/proxy-pause/src/proxy_pause.rs b/contracts/examples/proxy-pause/src/proxy_pause.rs index aa5f07e7d6..8e3cedd919 100644 --- a/contracts/examples/proxy-pause/src/proxy_pause.rs +++ b/contracts/examples/proxy-pause/src/proxy_pause.rs @@ -36,7 +36,14 @@ pub trait PauseProxy { fn for_each_contract(&self, f: F) where - F: Fn(pause_sc_proxy::PausableProxyMethods, (), &ManagedAddress, ()>), + F: Fn( + pause_sc_proxy::PausableProxyMethods< + TxScEnv, + (), + ManagedRef, + (), + >, + ), { for contract_address in self.contracts().iter() { f(self diff --git a/contracts/feature-tests/composability/vault/src/vault.rs b/contracts/feature-tests/composability/vault/src/vault.rs index a14da93521..1fb32cccdd 100644 --- a/contracts/feature-tests/composability/vault/src/vault.rs +++ b/contracts/feature-tests/composability/vault/src/vault.rs @@ -222,7 +222,7 @@ pub trait Vault { )); } - self.tx().to_caller().payment(new_tokens).transfer(); + self.tx().to(ToCaller).payment(new_tokens).transfer(); } #[event("accept_funds")] diff --git a/contracts/modules/src/transfer_role_proxy.rs b/contracts/modules/src/transfer_role_proxy.rs index d5249ce04c..89e258c7b9 100644 --- a/contracts/modules/src/transfer_role_proxy.rs +++ b/contracts/modules/src/transfer_role_proxy.rs @@ -27,7 +27,7 @@ pub trait TransferRoleProxyModule { transaction: Tx< TxScEnv, (), - &ManagedAddress, + ManagedRef<'_, ManagedAddress>, &ManagedVec>, (), FunctionCall, @@ -72,7 +72,7 @@ pub trait TransferRoleProxyModule { transaction: Tx< TxScEnv, (), - &ManagedAddress, + ManagedRef<'_, ManagedAddress>, &ManagedVec>, (), FunctionCall, @@ -81,7 +81,7 @@ pub trait TransferRoleProxyModule { opt_custom_callback: Option>, ) -> ! { require!( - self.destination_whitelist().contains(transaction.to), + self.destination_whitelist().contains(&transaction.to), "Destination address not whitelisted" ); diff --git a/framework/base/src/api/managed_types/const_handles.rs b/framework/base/src/api/managed_types/const_handles.rs index 1657d18e67..92a02d9f8b 100644 --- a/framework/base/src/api/managed_types/const_handles.rs +++ b/framework/base/src/api/managed_types/const_handles.rs @@ -24,6 +24,7 @@ pub const MBUF_TEMPORARY_2: RawHandle = -26; pub const ADDRESS_CALLER: RawHandle = -30; pub const ADDRESS_SELF: RawHandle = -31; +pub const ADDRESS_ESDT_SYSTEM: RawHandle = -32; pub const NEW_HANDLE_START_FROM: RawHandle = -100; // > -100 reserved for APIs diff --git a/framework/base/src/contract_base/wrappers/blockchain_wrapper.rs b/framework/base/src/contract_base/wrappers/blockchain_wrapper.rs index 5a7f36a722..7564ffbcd2 100644 --- a/framework/base/src/contract_base/wrappers/blockchain_wrapper.rs +++ b/framework/base/src/contract_base/wrappers/blockchain_wrapper.rs @@ -8,11 +8,11 @@ use crate::{ }, codec::TopDecode, err_msg::{ONLY_OWNER_CALLER, ONLY_USER_ACCOUNT_CALLER}, - storage::{self}, + storage, types::{ BackTransfers, BigUint, CodeMetadata, EgldOrEsdtTokenIdentifier, EsdtLocalRoleFlags, - EsdtTokenData, EsdtTokenType, ManagedAddress, ManagedBuffer, ManagedByteArray, ManagedType, - ManagedVec, TokenIdentifier, + EsdtTokenData, EsdtTokenType, ManagedAddress, ManagedBuffer, ManagedByteArray, ManagedRef, + ManagedType, ManagedVec, TokenIdentifier, }, }; @@ -54,6 +54,13 @@ where ManagedAddress::from_handle(handle) } + #[inline] + pub fn get_caller_ref(&self) -> ManagedRef<'static, A, ManagedAddress> { + let handle: A::ManagedBufferHandle = use_raw_handle(const_handles::ADDRESS_CALLER); + A::blockchain_api_impl().load_caller_managed(handle.clone()); + unsafe { ManagedRef::wrap_handle(handle) } + } + #[deprecated(since = "0.41.0", note = "Please use method `get_sc_address` instead.")] #[cfg(feature = "alloc")] #[inline] @@ -68,6 +75,13 @@ where ManagedAddress::from_handle(handle) } + #[inline] + pub fn get_sc_address_ref(&self) -> ManagedRef<'static, A, ManagedAddress> { + let handle: A::ManagedBufferHandle = use_raw_handle(const_handles::ADDRESS_SELF); + A::blockchain_api_impl().load_sc_address_managed(handle.clone()); + unsafe { ManagedRef::wrap_handle(handle) } + } + #[inline] pub fn get_owner_address(&self) -> ManagedAddress { let handle: A::ManagedBufferHandle = use_raw_handle(A::static_var_api_impl().next_handle()); diff --git a/framework/base/src/contract_base/wrappers/send_wrapper.rs b/framework/base/src/contract_base/wrappers/send_wrapper.rs index 11a8f748fc..0d461e97da 100644 --- a/framework/base/src/contract_base/wrappers/send_wrapper.rs +++ b/framework/base/src/contract_base/wrappers/send_wrapper.rs @@ -5,6 +5,7 @@ use crate::codec::Empty; use crate::{ api::{BlockchainApi, CallTypeApi, StorageReadApi}, codec, + proxy_imports::ManagedRef, types::{ system_proxy, BigUint, ContractCallNoPayment, ESDTSystemSCAddress, EgldOrEsdtTokenIdentifier, EsdtTokenPayment, FunctionCall, GasLeft, ManagedAddress, @@ -48,7 +49,12 @@ where /// Backwards compatibility, synonymous to `esdt_system_sc_tx`, which is the more appropriate name now. pub fn esdt_system_sc_proxy( &self, - ) -> system_proxy::ESDTSystemSCProxyMethods, (), ESDTSystemSCAddress, ()> { + ) -> system_proxy::ESDTSystemSCProxyMethods< + TxScEnv, + (), + ManagedRef<'static, A, ManagedAddress>, + (), + > { self.esdt_system_sc_tx() } @@ -56,7 +62,12 @@ where /// It has the destination address set, as well as the contract type (as specified in the proxy). pub fn esdt_system_sc_tx( &self, - ) -> system_proxy::ESDTSystemSCProxyMethods, (), ESDTSystemSCAddress, ()> { + ) -> system_proxy::ESDTSystemSCProxyMethods< + TxScEnv, + (), + ManagedRef<'static, A, ManagedAddress>, + (), + > { Tx::new_tx_from_sc() .to(ESDTSystemSCAddress) .typed(system_proxy::ESDTSystemSCProxy) diff --git a/framework/base/src/storage/mappers/token/non_fungible_token_mapper.rs b/framework/base/src/storage/mappers/token/non_fungible_token_mapper.rs index 3e886f21de..921ec84e14 100644 --- a/framework/base/src/storage/mappers/token/non_fungible_token_mapper.rs +++ b/framework/base/src/storage/mappers/token/non_fungible_token_mapper.rs @@ -5,7 +5,7 @@ use crate::{ storage_clear, storage_get, storage_set, types::{ system_proxy::ESDTSystemSCProxy, ESDTSystemSCAddress, EgldPayment, FunctionCall, - OriginalResultMarker, Tx, TxScEnv, + ManagedRef, OriginalResultMarker, Tx, TxScEnv, }, }; @@ -34,7 +34,7 @@ const INVALID_TOKEN_TYPE_ERR_MSG: &[u8] = b"Invalid token type for NonFungible i pub type IssueCallTo = Tx< TxScEnv, (), - ESDTSystemSCAddress, + ManagedRef<'static, Api, ManagedAddress>, EgldPayment, (), FunctionCall, diff --git a/framework/base/src/types/interaction/annotated/annotated_impl_managed_address.rs b/framework/base/src/types/interaction/annotated/annotated_impl_managed_address.rs index 403ccf4603..05801cf685 100644 --- a/framework/base/src/types/interaction/annotated/annotated_impl_managed_address.rs +++ b/framework/base/src/types/interaction/annotated/annotated_impl_managed_address.rs @@ -1,4 +1,7 @@ -use crate::types::{heap::Address, ManagedAddress, ManagedBuffer}; +use crate::{ + proxy_imports::ManagedRef, + types::{heap::Address, ManagedAddress, ManagedBuffer}, +}; use super::{AnnotatedValue, TxEnv}; @@ -50,6 +53,31 @@ where } } +impl AnnotatedValue> + for ManagedRef<'_, Env::Api, ManagedAddress> +where + Env: TxEnv, +{ + fn annotation(&self, _env: &Env) -> ManagedBuffer { + self.hex_expr() + } + + fn to_value(&self, _env: &Env) -> ManagedAddress { + (*self).clone_value() + } + + fn into_value(self, _env: &Env) -> ManagedAddress { + self.clone_value() + } + + fn with_value_ref(&self, _env: &Env, f: F) -> R + where + F: FnOnce(&ManagedAddress) -> R, + { + f(self) + } +} + impl AnnotatedValue> for Address where Env: TxEnv, diff --git a/framework/base/src/types/interaction/expr/address_expr.rs b/framework/base/src/types/interaction/expr/address_expr.rs index dddfa5b53c..4b257582f0 100644 --- a/framework/base/src/types/interaction/expr/address_expr.rs +++ b/framework/base/src/types/interaction/expr/address_expr.rs @@ -1,8 +1,11 @@ use core::ptr; -use crate::types::{ - AnnotatedValue, ManagedAddress, ManagedBuffer, TxEnv, TxFrom, TxFromSpecified, TxTo, - TxToSpecified, +use crate::{ + proxy_imports::TxToInto, + types::{ + AnnotatedValue, ManagedAddress, ManagedBuffer, TxEnv, TxFrom, TxFromSpecified, TxTo, + TxToSpecified, + }, }; const ADDRESS_PREFIX: &str = "address:"; @@ -38,6 +41,16 @@ where impl TxFromSpecified for AddressExpr where Env: TxEnv {} impl TxTo for AddressExpr where Env: TxEnv {} impl TxToSpecified for AddressExpr where Env: TxEnv {} +impl TxToInto for AddressExpr +where + Env: TxEnv, +{ + type Into = Self; + + fn into_recipient(self) -> Self::Into { + self + } +} impl AddressExpr { pub const fn eval_to_array(&self) -> [u8; 32] { diff --git a/framework/base/src/types/interaction/expr/sc_expr.rs b/framework/base/src/types/interaction/expr/sc_expr.rs index aa57b1af30..29df9c799c 100644 --- a/framework/base/src/types/interaction/expr/sc_expr.rs +++ b/framework/base/src/types/interaction/expr/sc_expr.rs @@ -1,8 +1,11 @@ use core::ptr; -use crate::types::{ - heap::Address, AnnotatedValue, ManagedAddress, ManagedBuffer, TxEnv, TxFrom, TxFromSpecified, - TxTo, TxToSpecified, +use crate::{ + proxy_imports::TxToInto, + types::{ + heap::Address, AnnotatedValue, ManagedAddress, ManagedBuffer, TxEnv, TxFrom, + TxFromSpecified, TxTo, TxToSpecified, + }, }; const SC_PREFIX: &str = "sc:"; @@ -47,6 +50,16 @@ where impl<'a, Env> TxFromSpecified for ScExpr<'a> where Env: TxEnv {} impl<'a, Env> TxTo for ScExpr<'a> where Env: TxEnv {} impl<'a, Env> TxToSpecified for ScExpr<'a> where Env: TxEnv {} +impl<'a, Env> TxToInto for ScExpr<'a> +where + Env: TxEnv, +{ + type Into = Self; + + fn into_recipient(self) -> Self::Into { + self + } +} impl<'a> ScExpr<'a> { pub const fn eval_to_array(&self) -> [u8; 32] { diff --git a/framework/base/src/types/interaction/markers/esdt_system_sc_address.rs b/framework/base/src/types/interaction/markers/esdt_system_sc_address.rs index 8d59b682be..3e8a88a3eb 100644 --- a/framework/base/src/types/interaction/markers/esdt_system_sc_address.rs +++ b/framework/base/src/types/interaction/markers/esdt_system_sc_address.rs @@ -2,7 +2,8 @@ use hex_literal::hex; use multiversx_sc_codec::{CodecFrom, EncodeErrorHandler, TopEncode, TopEncodeOutput}; use crate::{ - api::{CallTypeApi, ManagedTypeApi}, + api::{const_handles, use_raw_handle, CallTypeApi, ManagedBufferApiImpl, ManagedTypeApi}, + proxy_imports::{ManagedRef, TxToInto}, types::{AnnotatedValue, ManagedAddress, ManagedBuffer, TxScEnv, TxTo, TxToSpecified}, }; @@ -49,6 +50,18 @@ where impl TxTo> for ESDTSystemSCAddress where Api: CallTypeApi {} impl TxToSpecified> for ESDTSystemSCAddress where Api: CallTypeApi {} +impl TxToInto> for ESDTSystemSCAddress +where + Api: CallTypeApi, +{ + type Into = ManagedRef<'static, Api, ManagedAddress>; + + fn into_recipient(self) -> Self::Into { + let handle: Api::ManagedBufferHandle = use_raw_handle(const_handles::ADDRESS_ESDT_SYSTEM); + Api::managed_type_impl().mb_overwrite(handle.clone(), &SYSTEM_SC_ADDRESS_BYTES); + unsafe { ManagedRef::wrap_handle(handle) } + } +} impl TopEncode for ESDTSystemSCAddress { fn top_encode_or_handle_err(&self, output: O, h: H) -> Result<(), H::HandledErr> diff --git a/framework/base/src/types/interaction/markers/to_caller.rs b/framework/base/src/types/interaction/markers/to_caller.rs index f24191ce9f..e2aed9cfd3 100644 --- a/framework/base/src/types/interaction/markers/to_caller.rs +++ b/framework/base/src/types/interaction/markers/to_caller.rs @@ -1,35 +1,19 @@ use crate::{ - api::{const_handles, use_raw_handle, BlockchainApi, BlockchainApiImpl, CallTypeApi}, + api::CallTypeApi, contract_base::BlockchainWrapper, - types::{ - AnnotatedValue, ManagedAddress, ManagedBuffer, ManagedType, TxScEnv, TxTo, TxToSpecified, - }, + types::{ManagedAddress, ManagedRef, TxScEnv, TxToInto}, }; /// Indicates that transaction should be sent to the caller (the sender of the current transaction). pub struct ToCaller; -impl AnnotatedValue, ManagedAddress> for ToCaller +impl TxToInto> for ToCaller where - Api: CallTypeApi + BlockchainApi, + Api: CallTypeApi, { - fn annotation(&self, env: &TxScEnv) -> ManagedBuffer { - self.with_address_ref(env, |addr_ref| addr_ref.hex_expr()) - } - - fn to_value(&self, _env: &TxScEnv) -> ManagedAddress { - BlockchainWrapper::::new().get_caller() - } + type Into = ManagedRef<'static, Api, ManagedAddress>; - fn with_value_ref(&self, _env: &TxScEnv, f: F) -> R - where - F: FnOnce(&ManagedAddress) -> R, - { - let caller_handle: Api::ManagedBufferHandle = use_raw_handle(const_handles::ADDRESS_CALLER); - Api::blockchain_api_impl().load_caller_managed(caller_handle.clone()); - f(&ManagedAddress::from_handle(caller_handle)) + fn into_recipient(self) -> Self::Into { + BlockchainWrapper::::new().get_caller_ref() } } - -impl TxTo> for ToCaller where Api: CallTypeApi + BlockchainApi {} -impl TxToSpecified> for ToCaller where Api: CallTypeApi + BlockchainApi {} diff --git a/framework/base/src/types/interaction/markers/to_self.rs b/framework/base/src/types/interaction/markers/to_self.rs index dee4d5ed3a..9127568a43 100644 --- a/framework/base/src/types/interaction/markers/to_self.rs +++ b/framework/base/src/types/interaction/markers/to_self.rs @@ -1,36 +1,19 @@ use crate::{ - api::{const_handles, use_raw_handle, BlockchainApi, BlockchainApiImpl, CallTypeApi}, + api::CallTypeApi, contract_base::BlockchainWrapper, - types::{ - AnnotatedValue, ManagedAddress, ManagedBuffer, ManagedType, TxScEnv, TxTo, TxToSpecified, - }, + types::{ManagedAddress, ManagedRef, TxScEnv, TxToInto}, }; /// Indicates that transaction should be sent to itself. pub struct ToSelf; -impl AnnotatedValue, ManagedAddress> for ToSelf +impl TxToInto> for ToSelf where - Api: CallTypeApi + BlockchainApi, + Api: CallTypeApi, { - fn annotation(&self, env: &TxScEnv) -> ManagedBuffer { - self.with_address_ref(env, |addr_ref| addr_ref.hex_expr()) - } - - fn to_value(&self, _env: &TxScEnv) -> ManagedAddress { - BlockchainWrapper::::new().get_sc_address() - } + type Into = ManagedRef<'static, Api, ManagedAddress>; - fn with_value_ref(&self, _env: &TxScEnv, f: F) -> R - where - F: FnOnce(&ManagedAddress) -> R, - { - let sc_address_handle: Api::ManagedBufferHandle = - use_raw_handle(const_handles::ADDRESS_CALLER); - Api::blockchain_api_impl().load_sc_address_managed(sc_address_handle.clone()); - f(&ManagedAddress::from_handle(sc_address_handle)) + fn into_recipient(self) -> Self::Into { + BlockchainWrapper::::new().get_sc_address_ref() } } - -impl TxTo> for ToSelf where Api: CallTypeApi + BlockchainApi {} -impl TxToSpecified> for ToSelf where Api: CallTypeApi + BlockchainApi {} diff --git a/framework/base/src/types/interaction/tx.rs b/framework/base/src/types/interaction/tx.rs index 98d88e499a..170901dd66 100644 --- a/framework/base/src/types/interaction/tx.rs +++ b/framework/base/src/types/interaction/tx.rs @@ -1,11 +1,9 @@ use crate::{ api::CallTypeApi, - contract_base::BlockchainWrapper, types::{ BigUint, CodeMetadata, EgldOrEsdtTokenIdentifier, EgldOrEsdtTokenPayment, EgldOrEsdtTokenPaymentRefs, EgldOrMultiEsdtPayment, EsdtTokenPayment, EsdtTokenPaymentRefs, - ManagedAddress, ManagedBuffer, ManagedOption, ManagedVec, MultiEsdtPayment, - TokenIdentifier, + ManagedBuffer, ManagedOption, ManagedVec, MultiEsdtPayment, TokenIdentifier, }, }; @@ -17,7 +15,7 @@ use super::{ FunctionCall, ManagedArgBuffer, OriginalResultMarker, RHList, RHListAppendNoRet, RHListAppendRet, RHListItem, TxCodeSource, TxCodeValue, TxData, TxDataFunctionCall, TxEgldValue, TxEnv, TxFrom, TxFromSourceValue, TxGas, TxGasValue, TxPayment, TxPaymentEgldOnly, - TxProxyTrait, TxResultHandler, TxScEnv, TxTo, TxToSpecified, UpgradeCall, + TxProxyTrait, TxResultHandler, TxScEnv, TxTo, TxToInto, TxToSpecified, UpgradeCall, }; #[must_use] @@ -137,14 +135,14 @@ where /// Specifies the recipient of the transaction. /// /// Allows argument to also be `()`. - pub fn to(self, to: To) -> Tx + pub fn to(self, to: To) -> Tx where - To: TxTo, + To: TxToInto, { Tx { env: self.env, from: self.from, - to, + to: to.into_recipient(), payment: self.payment, gas: self.gas, data: self.data, @@ -152,9 +150,27 @@ where } } - pub fn to_caller(self) -> Tx, Payment, Gas, Data, RH> { - let caller = BlockchainWrapper::::new().get_caller(); - self.to(caller) + /// Only needed for the old proxies. + /// + /// Bypasses the `TxToInto` mechanism. + /// + /// Can also be called with `()` argument. + /// + /// Don't call directly, use `.to(...)` instead. + #[doc(hidden)] + pub fn override_to(self, to: To) -> Tx + where + To: TxTo, + { + Tx { + env: self.env, + from: self.from, + to, + payment: self.payment, + gas: self.gas, + data: self.data, + result_handler: self.result_handler, + } } } diff --git a/framework/base/src/types/interaction/tx_to.rs b/framework/base/src/types/interaction/tx_to.rs index 6ba0f6eec8..62b4809bfd 100644 --- a/framework/base/src/types/interaction/tx_to.rs +++ b/framework/base/src/types/interaction/tx_to.rs @@ -1,4 +1,7 @@ -use crate::types::{heap::Address, ManagedAddress}; +use crate::{ + proxy_imports::ManagedRef, + types::{heap::Address, ManagedAddress}, +}; use super::{AnnotatedValue, TxEnv}; @@ -25,14 +28,76 @@ where } } +pub trait TxToInto +where + Env: TxEnv, +{ + type Into: TxToSpecified; + + fn into_recipient(self) -> Self::Into; +} + impl TxTo for ManagedAddress where Env: TxEnv {} impl TxToSpecified for ManagedAddress where Env: TxEnv {} +impl TxToInto for ManagedAddress +where + Env: TxEnv, +{ + type Into = Self; + + fn into_recipient(self) -> Self::Into { + self + } +} + +impl TxTo for ManagedRef<'_, Env::Api, ManagedAddress> where Env: TxEnv {} +impl TxToSpecified for ManagedRef<'_, Env::Api, ManagedAddress> where Env: TxEnv {} +impl TxToInto for ManagedRef<'_, Env::Api, ManagedAddress> +where + Env: TxEnv, +{ + type Into = Self; + + fn into_recipient(self) -> Self::Into { + self + } +} impl TxTo for &ManagedAddress where Env: TxEnv {} impl TxToSpecified for &ManagedAddress where Env: TxEnv {} +impl<'a, Env> TxToInto for &'a ManagedAddress +where + Env: TxEnv, +{ + type Into = ManagedRef<'a, Env::Api, ManagedAddress>; + + fn into_recipient(self) -> Self::Into { + ManagedRef::from(self) + } +} impl TxTo for Address where Env: TxEnv {} impl TxToSpecified for Address where Env: TxEnv {} +impl TxToInto for Address +where + Env: TxEnv, +{ + type Into = Self; + + fn into_recipient(self) -> Self::Into { + self + } +} impl TxTo for &Address where Env: TxEnv {} impl TxToSpecified for &Address where Env: TxEnv {} +impl TxToInto for &Address +where + Env: TxEnv, +{ + type Into = Self; + + fn into_recipient(self) -> Self::Into { + self + } +} diff --git a/framework/derive/src/generate/proxy_gen.rs b/framework/derive/src/generate/proxy_gen.rs index b904c69f20..f658fc0727 100644 --- a/framework/derive/src/generate/proxy_gen.rs +++ b/framework/derive/src/generate/proxy_gen.rs @@ -177,7 +177,7 @@ pub fn generate_proxy_endpoint(m: &Method, endpoint_name: String) -> proc_macro2 #[allow(clippy::type_complexity)] #msig { multiversx_sc::types::TxBaseWithEnv::new_tx_from_sc() - .to(self.extract_proxy_to()) + .override_to(self.extract_proxy_to()) .original_result() .raw_call(#endpoint_name) #payment_init @@ -260,7 +260,7 @@ pub fn generate_proxy_deploy(init_method: &Method) -> proc_macro2::TokenStream { #payment_init #(#arg_push_snippets)* .original_result() - .to(self.extract_proxy_to()) // still accepted, until we separate the upgrade constructor completely + .override_to(self.extract_proxy_to()) // still accepted, until we separate the upgrade constructor completely } }; diff --git a/framework/scenario/src/facade/contract_info.rs b/framework/scenario/src/facade/contract_info.rs index 2652732494..829ad2ff28 100644 --- a/framework/scenario/src/facade/contract_info.rs +++ b/framework/scenario/src/facade/contract_info.rs @@ -1,7 +1,7 @@ use std::ops::{Deref, DerefMut}; use multiversx_sc::types::{ - AnnotatedValue, ManagedBuffer, TxEnv, TxFrom, TxFromSpecified, TxTo, TxToSpecified, + AnnotatedValue, ManagedBuffer, TxEnv, TxFrom, TxFromSpecified, TxTo, TxToInto, TxToSpecified, }; use crate::multiversx_sc::{ @@ -149,3 +149,15 @@ where P: ProxyObjNew, { } + +impl TxToInto for &ContractInfo

+where + Env: TxEnv, + P: ProxyObjNew, +{ + type Into = Self; + + fn into_recipient(self) -> Self::Into { + self + } +} diff --git a/framework/scenario/src/facade/expr/bech32_address.rs b/framework/scenario/src/facade/expr/bech32_address.rs index abc9d00cff..23fb277b19 100644 --- a/framework/scenario/src/facade/expr/bech32_address.rs +++ b/framework/scenario/src/facade/expr/bech32_address.rs @@ -6,7 +6,7 @@ use multiversx_sc::{ codec::*, types::{ Address, AnnotatedValue, ManagedAddress, ManagedBuffer, TxEnv, TxFrom, TxFromSpecified, - TxTo, TxToSpecified, + TxTo, TxToInto, TxToSpecified, }, }; use serde::{Deserialize, Serialize}; @@ -101,6 +101,16 @@ where impl TxFromSpecified for Bech32Address where Env: TxEnv {} impl TxTo for Bech32Address where Env: TxEnv {} impl TxToSpecified for Bech32Address where Env: TxEnv {} +impl TxToInto for Bech32Address +where + Env: TxEnv, +{ + type Into = Self; + + fn into_recipient(self) -> Self::Into { + self + } +} impl AnnotatedValue> for &Bech32Address where @@ -126,6 +136,16 @@ where impl TxFromSpecified for &Bech32Address where Env: TxEnv {} impl TxTo for &Bech32Address where Env: TxEnv {} impl TxToSpecified for &Bech32Address where Env: TxEnv {} +impl TxToInto for &Bech32Address +where + Env: TxEnv, +{ + type Into = Self; + + fn into_recipient(self) -> Self::Into { + self + } +} impl Display for Bech32Address { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {