diff --git a/contracts/feature-tests/composability/proxy-test-first/src/proxy-test-first.rs b/contracts/feature-tests/composability/proxy-test-first/src/proxy-test-first.rs index 7d18e22e3b..26cc9eb679 100644 --- a/contracts/feature-tests/composability/proxy-test-first/src/proxy-test-first.rs +++ b/contracts/feature-tests/composability/proxy-test-first/src/proxy-test-first.rs @@ -81,7 +81,7 @@ pub trait ProxyTestFirst { .to(other_contract) .raw_upgrade() .argument(&456) - .egld(payment.clone_value()) + .egld(payment) .upgrade_contract(&code, CodeMetadata::UPGRADEABLE); } diff --git a/contracts/modules/src/esdt.rs b/contracts/modules/src/esdt.rs index fa02cfd263..f39e5fe650 100644 --- a/contracts/modules/src/esdt.rs +++ b/contracts/modules/src/esdt.rs @@ -66,7 +66,7 @@ pub trait EsdtModule { let egld_returned = self.call_value().egld_value(); self.tx() .to(&initial_caller) - .egld(&*egld_returned) + .egld(egld_returned) .transfer_if_not_empty(); }, } diff --git a/framework/base/src/types/interaction/annotated.rs b/framework/base/src/types/interaction/annotated.rs index afaecf184e..d6b75fc610 100644 --- a/framework/base/src/types/interaction/annotated.rs +++ b/framework/base/src/types/interaction/annotated.rs @@ -1,4 +1,7 @@ -use crate::types::{heap::Address, BigUint, ManagedAddress, ManagedBuffer}; +use crate::{ + proxy_imports::ManagedRef, + types::{heap::Address, BigUint, ManagedAddress, ManagedBuffer}, +}; use super::TxEnv; @@ -175,6 +178,30 @@ where } } +impl<'a, Env> AnnotatedValue> for ManagedRef<'a, Env::Api, BigUint> +where + Env: TxEnv, +{ + fn annotation(&self, _env: &Env) -> ManagedBuffer { + self.to_display() + } + + fn to_value(&self, _env: &Env) -> BigUint { + (*self).clone_value() + } + + fn into_value(self, _env: &Env) -> BigUint { + self.clone_value() + } + + fn with_value_ref(&self, env: &Env, f: F) -> R + where + F: FnOnce(&BigUint) -> R, + { + f(self) + } +} + impl AnnotatedValue> for u64 where Env: TxEnv, diff --git a/framework/base/src/types/interaction/tx_payment/tx_payment_egld_value.rs b/framework/base/src/types/interaction/tx_payment/tx_payment_egld_value.rs index 8fcaab3ceb..b047e584b2 100644 --- a/framework/base/src/types/interaction/tx_payment/tx_payment_egld_value.rs +++ b/framework/base/src/types/interaction/tx_payment/tx_payment_egld_value.rs @@ -1,4 +1,7 @@ -use crate::types::{AnnotatedValue, BigUint}; +use crate::{ + proxy_imports::ManagedRef, + types::{AnnotatedValue, BigUint}, +}; use super::TxEnv; @@ -10,4 +13,5 @@ where impl TxEgldValue for BigUint where Env: TxEnv {} impl TxEgldValue for &BigUint where Env: TxEnv {} +impl<'a, Env> TxEgldValue for ManagedRef<'a, Env::Api, BigUint> where Env: TxEnv {} impl TxEgldValue for u64 where Env: TxEnv {} diff --git a/framework/base/src/types/managed/wrapped/managed_ref.rs b/framework/base/src/types/managed/wrapped/managed_ref.rs index 748c704956..143d79e1d4 100644 --- a/framework/base/src/types/managed/wrapped/managed_ref.rs +++ b/framework/base/src/types/managed/wrapped/managed_ref.rs @@ -54,6 +54,7 @@ where M: ManagedTypeApi, T: ManagedType + Clone, { + /// Syntactic sugar for dereferencing and cloning the object. pub fn clone_value(&self) -> T { self.deref().clone() }