Skip to content

Commit

Permalink
Merge branch 'feat/unified' into uegld-replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Mar 22, 2024
2 parents f0b1bb0 + e2dc435 commit ec17ab0
Show file tree
Hide file tree
Showing 31 changed files with 582 additions and 635 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use core::marker::PhantomData;
use codec::Empty;

use crate::{
api::StorageMapperApi,
imports::{ErrorApiImpl, ManagedType},
api::{ErrorApiImpl, StorageMapperApi},
storage::StorageKey,
storage_set,
types::ManagedType,
};

use super::{
Expand Down
6 changes: 3 additions & 3 deletions framework/base/src/types/interaction/contract_call_convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ where
function_call: self
.basic
.function_call
.convert_to_single_transfer_fungible_call(payment),
.convert_to_single_transfer_fungible_call(&payment),
explicit_gas_limit: self.basic.explicit_gas_limit,
_return_type: PhantomData,
},
Expand All @@ -55,7 +55,7 @@ where
function_call: self
.basic
.function_call
.convert_to_single_transfer_nft_call(&self.basic.to, payment),
.convert_to_single_transfer_nft_call(&self.basic.to, &payment),
explicit_gas_limit: self.basic.explicit_gas_limit,
_return_type: PhantomData,
},
Expand All @@ -78,7 +78,7 @@ where
function_call: self
.basic
.function_call
.convert_to_multi_transfer_esdt_call(&self.basic.to, payments),
.convert_to_multi_transfer_esdt_call(&self.basic.to, &payments),
explicit_gas_limit: self.basic.explicit_gas_limit,
_return_type: PhantomData,
},
Expand Down
7 changes: 2 additions & 5 deletions framework/base/src/types/interaction/deploy_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ use multiversx_sc_codec::TopEncodeMulti;

use crate::types::{CodeMetadata, ManagedBuffer, ManagedBufferCachedBuilder};

use super::{
Code, FunctionCall, ManagedArgBuffer, Tx, TxCodeSource, TxData, TxEnv, TxFrom, TxGas,
TxPayment, TxTo,
};
use super::{ManagedArgBuffer, TxCodeSource, TxData, TxEnv};

/// Holds deploy data: code, code metadata, and arguments.
pub struct DeployCall<Env, CodeSource>
Expand Down Expand Up @@ -42,7 +39,7 @@ where

fn to_call_data_string(&self) -> ManagedBuffer<Env::Api> {
// Implement as needed for deployment-specific data
let mut result = ManagedBufferCachedBuilder::default();
let result = ManagedBufferCachedBuilder::default();
// result.append_managed_buffer(&self.code);
// Add other fields as needed
result.into_managed_buffer()
Expand Down
2 changes: 1 addition & 1 deletion framework/base/src/types/interaction/expr/address_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl<Env> TxToSpecified<Env> for AddressExpr
where
Env: TxEnv,
{
fn with_address_ref<F, R>(&self, env: &Env, f: F) -> R
fn with_address_ref<F, R>(&self, _env: &Env, f: F) -> R
where
F: FnOnce(&ManagedAddress<Env::Api>) -> R,
{
Expand Down
2 changes: 1 addition & 1 deletion framework/base/src/types/interaction/expr/sc_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl<'a, Env> TxToSpecified<Env> for ScExpr<'a>
where
Env: TxEnv,
{
fn with_address_ref<F, R>(&self, env: &Env, f: F) -> R
fn with_address_ref<F, R>(&self, _env: &Env, f: F) -> R
where
F: FnOnce(&ManagedAddress<Env::Api>) -> R,
{
Expand Down
8 changes: 4 additions & 4 deletions framework/base/src/types/interaction/function_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ where
/// Constructs `ESDTTransfer` builtin function call.
pub(super) fn convert_to_single_transfer_fungible_call(
self,
payment: EsdtTokenPayment<Api>,
payment: &EsdtTokenPayment<Api>,
) -> FunctionCall<Api> {
FunctionCall::new(ESDT_TRANSFER_FUNC_NAME)
.argument(&payment.token_identifier)
Expand All @@ -177,7 +177,7 @@ where
pub(super) fn convert_to_single_transfer_nft_call(
self,
to: &ManagedAddress<Api>,
payment: EsdtTokenPayment<Api>,
payment: &EsdtTokenPayment<Api>,
) -> FunctionCall<Api> {
FunctionCall::new(ESDT_NFT_TRANSFER_FUNC_NAME)
.argument(&payment.token_identifier)
Expand All @@ -191,13 +191,13 @@ where
pub(super) fn convert_to_multi_transfer_esdt_call(
self,
to: &ManagedAddress<Api>,
payments: ManagedVec<Api, EsdtTokenPayment<Api>>,
payments: &ManagedVec<Api, EsdtTokenPayment<Api>>,
) -> FunctionCall<Api> {
let mut result = FunctionCall::new(ESDT_MULTI_TRANSFER_FUNC_NAME)
.argument(&to)
.argument(&payments.len());

for payment in payments.into_iter() {
for payment in payments {
result = result
.argument(&payment.token_identifier)
.argument(&payment.token_nonce)
Expand Down
6 changes: 0 additions & 6 deletions framework/base/src/types/interaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ mod tx_env_sc;
mod tx_from;
mod tx_gas;
mod tx_payment;
mod tx_payment_egld;
mod tx_payment_egld_value;
mod tx_payment_normalize;
mod tx_proxy;
mod tx_result_handler;
mod tx_rh_list;
Expand Down Expand Up @@ -73,9 +70,6 @@ pub use tx_env_sc::*;
pub use tx_from::*;
pub use tx_gas::*;
pub use tx_payment::*;
pub use tx_payment_egld::*;
pub use tx_payment_egld_value::TxEgldValue;
pub use tx_payment_normalize::TxPaymentNormalize;
pub use tx_proxy::*;
pub use tx_result_handler::*;
pub use tx_rh_list::*;
Expand Down
23 changes: 11 additions & 12 deletions framework/base/src/types/interaction/tx.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
use crate::{
api::{self, CallTypeApi, ManagedTypeApi},
contract_base::{BlockchainWrapper, SendRawWrapper},
api::CallTypeApi,
contract_base::BlockchainWrapper,
types::{
BigUint, CodeMetadata, EgldOrEsdtTokenPayment, EsdtTokenPayment, ManagedAddress,
ManagedBuffer, ManagedOption, ManagedVec, MultiEsdtPayment,
},
};
use alloc::boxed::Box;

use multiversx_sc_codec::TopEncodeMulti;

use super::{
contract_call_exec::UNSPECIFIED_GAS_LIMIT, contract_call_trait::ContractCallBase,
AnnotatedValue, AsyncCall, Code, ContractCallNoPayment, ContractCallWithEgld, ContractDeploy,
DeployCall, Egld, EgldPayment, ExplicitGas, FromSource, FunctionCall, ManagedArgBuffer,
OriginalResultMarker, RHList, RHListAppendNoRet, RHListAppendRet, RHListItem, TxCodeSource,
TxCodeValue, TxData, TxDataFunctionCall, TxEgldValue, TxEnv, TxFrom, TxFromSourceValue,
TxFromSpecified, TxGas, TxPayment, TxPaymentEgldOnly, TxPaymentNormalize, TxProxyTrait,
contract_call_exec::UNSPECIFIED_GAS_LIMIT, contract_call_trait::ContractCallBase, Code,
ContractCallNoPayment, ContractCallWithEgld, ContractDeploy, DeployCall, Egld, EgldPayment,
ExplicitGas, FromSource, FunctionCall, ManagedArgBuffer, OriginalResultMarker, RHList,
RHListAppendNoRet, RHListAppendRet, RHListItem, TxCodeSource, TxCodeValue, TxData, TxEgldValue,
TxEnv, TxFrom, TxFromSourceValue, TxGas, TxPayment, TxPaymentEgldOnly, TxProxyTrait,
TxResultHandler, TxScEnv, TxTo, TxToSpecified,
};

Expand Down Expand Up @@ -566,7 +565,7 @@ impl<Api, To, Payment, OriginalResult> ContractCallBase<Api>
where
Api: CallTypeApi + 'static,
To: TxToSpecified<TxScEnv<Api>>,
Payment: TxPaymentNormalize<TxScEnv<Api>, (), To>,
Payment: TxPayment<TxScEnv<Api>>,
OriginalResult: TopEncodeMulti,
{
type OriginalResult = OriginalResult;
Expand Down Expand Up @@ -623,7 +622,7 @@ where
RH: TxResultHandler<Env>,
{
pub fn code<CodeValue>(
mut self,
self,
code: CodeValue,
) -> Tx<Env, From, To, Payment, Gas, DeployCall<Env, Code<CodeValue>>, RH>
where
Expand All @@ -641,7 +640,7 @@ where
}

pub fn from_source<FromSourceValue>(
mut self,
self,
source_address: FromSourceValue,
) -> Tx<Env, From, To, Payment, Gas, DeployCall<Env, FromSource<FromSourceValue>>, RH>
where
Expand Down
4 changes: 2 additions & 2 deletions framework/base/src/types/interaction/tx_call_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{

use super::{
OriginalResultMarker, Tx, TxData, TxDataFunctionCall, TxEnv, TxFrom, TxGas, TxPayment,
TxPaymentNormalize, TxResultHandler, TxScEnv, TxTo, TxToSpecified,
TxResultHandler, TxScEnv, TxTo, TxToSpecified,
};

pub trait TxAsyncCallCallback<Api>: TxResultHandler<TxScEnv<Api>>
Expand Down Expand Up @@ -119,7 +119,7 @@ impl<Api, To, Payment, FC, RH> Tx<TxScEnv<Api>, (), To, Payment, (), FC, RH>
where
Api: CallTypeApi,
To: TxToSpecified<TxScEnv<Api>>,
Payment: TxPaymentNormalize<TxScEnv<Api>, (), To>,
Payment: TxPayment<TxScEnv<Api>>,
FC: TxDataFunctionCall<TxScEnv<Api>>,
RH: TxAsyncCallCallback<Api>,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{

use super::{
callback_closure::CallbackClosureWithGas, ExplicitGas, FunctionCall, OriginalResultMarker, Tx,
TxGas, TxPayment, TxPaymentNormalize, TxResultHandler, TxScEnv, TxToSpecified,
TxGas, TxPayment, TxResultHandler, TxScEnv, TxToSpecified,
};

pub trait TxPromisesCallback<Api>: TxResultHandler<TxScEnv<Api>>
Expand Down Expand Up @@ -122,7 +122,7 @@ impl<Api, To, Payment, Callback>
where
Api: CallTypeApi,
To: TxToSpecified<TxScEnv<Api>>,
Payment: TxPaymentNormalize<TxScEnv<Api>, (), To>,
Payment: TxPayment<TxScEnv<Api>>,
Callback: TxPromisesCallback<Api>,
{
pub fn register_promise(self) {
Expand Down
5 changes: 2 additions & 3 deletions framework/base/src/types/interaction/tx_call_deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ use crate::{

use super::{
contract_call_exec::decode_result, Code, ConsNoRet, ConsRet, DeployCall, FromSource,
OriginalResultMarker, RHList, RHListItem, Tx, TxCodeValue, TxDataFunctionCall,
TxEmptyResultHandler, TxEnv, TxFromSourceValue, TxGas, TxPayment, TxPaymentEgldOnly,
TxResultHandler, TxScEnv, TxToSpecified,
OriginalResultMarker, RHList, RHListItem, Tx, TxCodeValue, TxEmptyResultHandler, TxEnv,
TxFromSourceValue, TxGas, TxPaymentEgldOnly, TxResultHandler, TxScEnv,
};

pub trait RHListItemDeploy<Env, Original>: RHListItem<Env, Original>
Expand Down
7 changes: 3 additions & 4 deletions framework/base/src/types/interaction/tx_call_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ use crate::{

use super::{
contract_call_exec::decode_result, BackTransfers, ConsNoRet, ConsRet, OriginalResultMarker,
RHList, RHListItem, Tx, TxDataFunctionCall, TxEnv, TxGas, TxPayment, TxPaymentNormalize,
TxScEnv, TxToSpecified,
RHList, RHListItem, Tx, TxDataFunctionCall, TxEnv, TxGas, TxPayment, TxScEnv, TxToSpecified,
};

pub trait RHListItemSync<Env, Original>: RHListItem<Env, Original>
Expand Down Expand Up @@ -90,7 +89,7 @@ impl<Api, To, Payment, Gas, FC, RH> Tx<TxScEnv<Api>, (), To, Payment, Gas, FC, R
where
Api: CallTypeApi,
To: TxToSpecified<TxScEnv<Api>>,
Payment: TxPaymentNormalize<TxScEnv<Api>, (), To>,
Payment: TxPayment<TxScEnv<Api>>,
Gas: TxGas<TxScEnv<Api>>,
FC: TxDataFunctionCall<TxScEnv<Api>>,
RH: RHListSync<TxScEnv<Api>>,
Expand Down Expand Up @@ -133,7 +132,7 @@ impl<Api, To, Payment, Gas, FC, OriginalResult>
where
Api: CallTypeApi,
To: TxToSpecified<TxScEnv<Api>>,
Payment: TxPaymentNormalize<TxScEnv<Api>, (), To>,
Payment: TxPayment<TxScEnv<Api>>,
Gas: TxGas<TxScEnv<Api>>,
FC: TxDataFunctionCall<TxScEnv<Api>>,
{
Expand Down
5 changes: 1 addition & 4 deletions framework/base/src/types/interaction/tx_code_source.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use crate::{
api::ManagedTypeApi,
types::{ManagedAddress, ManagedBuffer},
};
use crate::types::{ManagedAddress, ManagedBuffer};

use super::{AnnotatedValue, TxEnv};

Expand Down
6 changes: 2 additions & 4 deletions framework/base/src/types/interaction/tx_data.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use crate::{
api::ManagedTypeApi,
contract_base::SendRawWrapper,
formatter::SCLowerHex,
types::{CodeMetadata, ManagedAddress, ManagedBuffer, ManagedBufferCachedBuilder, ManagedVec},
types::{ManagedBuffer, ManagedBufferCachedBuilder},
};

use super::{FunctionCall, ManagedArgBuffer, Tx, TxEnv, TxFrom, TxGas, TxPayment, TxTo};
use super::{FunctionCall, TxEnv};

pub trait TxData<Env>
where
Expand Down
7 changes: 1 addition & 6 deletions framework/base/src/types/interaction/tx_env.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
use crate::{
api::CallTypeApi,
types::{ManagedAddress, ManagedBuffer},
};

use super::AnnotatedValue;
use crate::{api::CallTypeApi, types::ManagedAddress};

pub trait TxEnv: Sized {
type Api: CallTypeApi;
Expand Down
4 changes: 1 addition & 3 deletions framework/base/src/types/interaction/tx_env_sc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use crate::{
types::ManagedAddress,
};

use super::{
contract_call_exec::TRANSFER_EXECUTE_DEFAULT_LEFTOVER, AnnotatedValue, Tx, TxBaseWithEnv, TxEnv,
};
use super::{contract_call_exec::TRANSFER_EXECUTE_DEFAULT_LEFTOVER, Tx, TxBaseWithEnv, TxEnv};

pub struct TxScEnv<Api>
where
Expand Down
2 changes: 1 addition & 1 deletion framework/base/src/types/interaction/tx_gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ where
env.default_gas()
}

fn explicit_or_gas_left(&self, env: &Env) -> u64 {
fn explicit_or_gas_left(&self, _env: &Env) -> u64 {
Env::Api::blockchain_api_impl().get_gas_left()
}
}
Expand Down
Loading

0 comments on commit ec17ab0

Please sign in to comment.