diff --git a/contracts/feature-tests/composability/esdt-contract-pair/first-contract/src/lib.rs b/contracts/feature-tests/composability/esdt-contract-pair/first-contract/src/lib.rs index ad089ef4ce..7ce368781a 100644 --- a/contracts/feature-tests/composability/esdt-contract-pair/first-contract/src/lib.rs +++ b/contracts/feature-tests/composability/esdt-contract-pair/first-contract/src/lib.rs @@ -94,7 +94,7 @@ pub trait FirstContract { self.tx() .to(&second_contract_address) .gas(gas_left) - .raw_call(ManagedBuffer::from(SECOND_CONTRACT_REJECT_ESDT_PAYMENT)) + .raw_call(SECOND_CONTRACT_REJECT_ESDT_PAYMENT) .single_esdt(&expected_token_identifier, 0u64, &esdt_value) .transfer_execute(); } diff --git a/contracts/feature-tests/composability/scenarios/forw_raw_sync_echo.scen.json b/contracts/feature-tests/composability/scenarios/forw_raw_sync_echo.scen.json index ed599f9492..a34e9497fd 100644 --- a/contracts/feature-tests/composability/scenarios/forw_raw_sync_echo.scen.json +++ b/contracts/feature-tests/composability/scenarios/forw_raw_sync_echo.scen.json @@ -158,4 +158,4 @@ } } ] -} \ No newline at end of file +} diff --git a/contracts/feature-tests/composability/scenarios/forw_raw_sync_echo_caller.scen.json b/contracts/feature-tests/composability/scenarios/forw_raw_sync_echo_caller.scen.json index 0bfa9fd894..a964ec9e19 100644 --- a/contracts/feature-tests/composability/scenarios/forw_raw_sync_echo_caller.scen.json +++ b/contracts/feature-tests/composability/scenarios/forw_raw_sync_echo_caller.scen.json @@ -133,4 +133,4 @@ } } ] -} \ No newline at end of file +} diff --git a/contracts/feature-tests/rust-testing-framework-tester/src/lib.rs b/contracts/feature-tests/rust-testing-framework-tester/src/lib.rs index 7a5b181028..8aae4d0b79 100644 --- a/contracts/feature-tests/rust-testing-framework-tester/src/lib.rs +++ b/contracts/feature-tests/rust-testing-framework-tester/src/lib.rs @@ -193,13 +193,10 @@ pub trait RustTestingFrameworkTester: dummy_module::DummyModule { #[endpoint] fn call_other_contract_add_async_call(&self, other_sc_address: ManagedAddress, value: BigUint) { - let mut args = ManagedArgBuffer::new(); - args.push_arg(&value); - self.tx() .to(&other_sc_address) - .raw_call("call") - .arguments_raw(args) + .raw_call("add") + .argument(&value) .async_call_and_exit(); } @@ -215,15 +212,12 @@ pub trait RustTestingFrameworkTester: dummy_module::DummyModule { #[endpoint] fn execute_on_dest_add_value(&self, other_sc_address: ManagedAddress, value: BigUint) { - let mut args = ManagedArgBuffer::new(); - args.push_arg(value); - let gas_left = self.blockchain().get_gas_left(); self.tx() .to(&other_sc_address) .gas(gas_left) .raw_call("addValue") - .arguments_raw(args) + .argument(&value) .sync_call(); } diff --git a/framework/base/src/types/interaction/tx_exec/tx_exec_upgrade.rs b/framework/base/src/types/interaction/tx_exec/tx_exec_upgrade.rs index 01a0107d68..74285517c7 100644 --- a/framework/base/src/types/interaction/tx_exec/tx_exec_upgrade.rs +++ b/framework/base/src/types/interaction/tx_exec/tx_exec_upgrade.rs @@ -1,6 +1,7 @@ use crate::{ api::CallTypeApi, contract_base::SendRawWrapper, + proxy_imports::TxToSpecified, tuple_util::NestedTupleFlatten, types::{ Code, CodeMetadata, DeployRawResult, FromSource, ManagedAddress, ManagedBuffer, ManagedVec, @@ -79,100 +80,11 @@ where } } -impl - Tx< - TxScEnv, - (), - &ManagedAddress, - Payment, - Gas, - UpgradeCall, FromSource>, - RH, - > -where - Api: CallTypeApi, - Payment: TxPaymentEgldOnly>, - Gas: TxGas>, - FromSourceValue: TxFromSourceValue>, - RH: TxEmptyResultHandler>, -{ - /// Launches the upgrade from source async call. - /// - /// TODO: change return type to `!`. - pub fn upgrade_async_call_and_exit(self) { - let gas = self.gas.explicit_or_gas_left(&self.env); - self.payment.with_egld_value(&self.env, |egld_value| { - SendRawWrapper::::new().upgrade_from_source_contract( - self.to, - gas, - egld_value, - &self.data.code_source.0.into_value(&self.env), - self.data.code_metadata, - &self.data.arg_buffer, - ); - }); - } -} - -impl - Tx, (), ManagedAddress, Payment, Gas, UpgradeCall, ()>, RH> -where - Api: CallTypeApi, - Payment: TxPaymentEgldOnly>, - Gas: TxGas>, - RH: TxEmptyResultHandler>, -{ - /// Backwards compatibility, immitates the old API. - /// - /// Note that the data type (the `UpgradeCall`) doesn't have the code set. - /// This is because the old API was passing it as paramter, so we use it from the `code` argument. - /// - /// Also note that the code metadata is taken from the `code_metadata` argument. - /// If another one was previously set in the `Tx` object, that one will be ignored. - pub fn upgrade_contract(self, code: &ManagedBuffer, code_metadata: CodeMetadata) { - let gas = self.gas.explicit_or_gas_left(&self.env); - self.payment.with_egld_value(&self.env, |egld_value| { - SendRawWrapper::::new().upgrade_contract( - &self.to, - gas, - egld_value, - code, - code_metadata, - &self.data.arg_buffer, - ); - }); - } - - /// Backwards compatibility, immitates the old API. - /// - /// Note that the data type (the `UpgradeCall`) doesn't have the code set. - /// This is because the old API was passing it as paramter, so we use it from the `code` argument. - /// - /// Also note that the code metadata is taken from the `code_metadata` argument. - /// If another one was previously set in the `Tx` object, that one will be ignored. - pub fn upgrade_from_source( - self, - source_address: &ManagedAddress, - code_metadata: CodeMetadata, - ) { - let gas = self.gas.explicit_or_gas_left(&self.env); - self.payment.with_egld_value(&self.env, |egld_value| { - SendRawWrapper::::new().upgrade_from_source_contract( - &self.to, - gas, - egld_value, - source_address, - code_metadata, - &self.data.arg_buffer, - ); - }); - } -} - -impl - Tx, (), &ManagedAddress, Payment, Gas, UpgradeCall, ()>, RH> +impl + Tx, (), To, Payment, Gas, UpgradeCall, ()>, RH> where Api: CallTypeApi, + To: TxToSpecified>, Payment: TxPaymentEgldOnly>, Gas: TxGas>, RH: TxEmptyResultHandler>, @@ -187,14 +99,16 @@ where pub fn upgrade_contract(self, code: &ManagedBuffer, code_metadata: CodeMetadata) { let gas = self.gas.explicit_or_gas_left(&self.env); self.payment.with_egld_value(&self.env, |egld_value| { - SendRawWrapper::::new().upgrade_contract( - self.to, - gas, - egld_value, - code, - code_metadata, - &self.data.arg_buffer, - ); + self.to.with_value_ref(&self.env, |to| { + SendRawWrapper::::new().upgrade_contract( + to, + gas, + egld_value, + code, + code_metadata, + &self.data.arg_buffer, + ); + }); }); } @@ -212,14 +126,16 @@ where ) { let gas = self.gas.explicit_or_gas_left(&self.env); self.payment.with_egld_value(&self.env, |egld_value| { - SendRawWrapper::::new().upgrade_from_source_contract( - self.to, - gas, - egld_value, - source_address, - code_metadata, - &self.data.arg_buffer, - ); + self.to.with_value_ref(&self.env, |to| { + SendRawWrapper::::new().upgrade_from_source_contract( + to, + gas, + egld_value, + source_address, + code_metadata, + &self.data.arg_buffer, + ); + }); }); } }