diff --git a/contracts/feature-tests/composability/proxy-test-first/src/message_me_proxy.rs b/contracts/feature-tests/composability/proxy-test-first/src/message_me_proxy.rs new file mode 100644 index 0000000000..ea01aa79d5 --- /dev/null +++ b/contracts/feature-tests/composability/proxy-test-first/src/message_me_proxy.rs @@ -0,0 +1,107 @@ +// Code generated by the multiversx-sc proxy generator. DO NOT EDIT. + +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// + +#![allow(dead_code)] +#![allow(clippy::all)] + +use multiversx_sc::proxy_imports::*; + +pub struct MessageMeProxy; + +impl TxProxyTrait for MessageMeProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = MessageMeProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + MessageMeProxyMethods { wrapped_tx: tx } + } +} + +pub struct MessageMeProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl MessageMeProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + pub fn init< + Arg0: CodecInto, + >( + self, + init_arg: Arg0, + ) -> TxProxyDeploy { + self.wrapped_tx + .raw_deploy() + .argument(&init_arg) + .original_result() + } +} + +#[rustfmt::skip] +impl MessageMeProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn upgrade( + self, + ) -> TxProxyUpgrade { + self.wrapped_tx + .raw_upgrade() + .original_result() + } +} + +#[rustfmt::skip] +impl MessageMeProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn message_me< + Arg0: CodecInto, + Arg1: CodecInto>, + Arg2: CodecInto>, + Arg3: CodecInto>, + >( + self, + arg1: Arg0, + arg2: Arg1, + arg3: Arg2, + arg4: Arg3, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("messageMe") + .argument(&arg1) + .argument(&arg2) + .argument(&arg3) + .argument(&arg4) + .original_result() + } +} diff --git a/contracts/feature-tests/composability/proxy-test-first/src/pay_me_proxy.rs b/contracts/feature-tests/composability/proxy-test-first/src/pay_me_proxy.rs new file mode 100644 index 0000000000..8cf9369cf9 --- /dev/null +++ b/contracts/feature-tests/composability/proxy-test-first/src/pay_me_proxy.rs @@ -0,0 +1,107 @@ +// Code generated by the multiversx-sc proxy generator. DO NOT EDIT. + +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// + +#![allow(dead_code)] +#![allow(clippy::all)] + +use multiversx_sc::proxy_imports::*; + +pub struct PayMeProxy; + +impl TxProxyTrait for PayMeProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = PayMeProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + PayMeProxyMethods { wrapped_tx: tx } + } +} + +pub struct PayMeProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl PayMeProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + pub fn init( + self, + ) -> TxProxyDeploy { + self.wrapped_tx + .raw_deploy() + .original_result() + } +} + +#[rustfmt::skip] +impl PayMeProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn upgrade( + self, + ) -> TxProxyUpgrade { + self.wrapped_tx + .raw_upgrade() + .original_result() + } +} + +#[rustfmt::skip] +impl PayMeProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn pay_me< + Arg0: CodecInto, + >( + self, + arg1: Arg0, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("payMe") + .argument(&arg1) + .original_result() + } + + pub fn pay_me_with_result< + Arg0: CodecInto, + >( + self, + arg1: Arg0, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("payMeWithResult") + .argument(&arg1) + .original_result() + } +} 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 26cc9eb679..b3ddbf6d5e 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 @@ -4,46 +4,14 @@ multiversx_sc::imports!(); use hex_literal::hex; +pub mod message_me_proxy; +pub mod pay_me_proxy; + static HARDCODED_ADDRESS: [u8; 32] = hex!("fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe"); -mod pay_me_proxy { - multiversx_sc::imports!(); - - #[multiversx_sc::proxy] - pub trait PayMe { - #[payable("EGLD")] - #[endpoint(payMe)] - fn pay_me(&self, arg1: i64); - - #[payable("EGLD")] - #[endpoint(payMeWithResult)] - fn pay_me_with_result(&self, arg1: i64); - } -} - -mod message_me_proxy { - multiversx_sc::imports!(); - - #[multiversx_sc::proxy] - pub trait MessageMe { - #[init] - #[payable("EGLD")] - fn init(&self, init_arg: i32) -> i32; - - #[endpoint(messageMe)] - fn message_me(&self, arg1: i64, arg2: &BigUint, arg3: Vec, arg4: &ManagedAddress); - } -} - #[multiversx_sc::contract] pub trait ProxyTestFirst { - #[proxy] - fn pay_me_proxy(&self) -> pay_me_proxy::Proxy; - - #[proxy] - fn message_me_proxy(&self) -> message_me_proxy::Proxy; - #[storage_get("other_contract")] fn get_other_contract(&self) -> ManagedAddress; @@ -62,11 +30,26 @@ pub trait ProxyTestFirst { #[endpoint(deploySecondContract)] fn deploy_second_contract(&self, code: ManagedBuffer) -> i32 { let payment = self.call_value().egld_value(); + // let (address, init_result) = self + // .tx() + // .egld(payment) + // .raw_deploy() + // .code(code) + // .code_metadata(CodeMetadata::UPGRADEABLE) + // .argument(&123) + // .returns(ReturnsNewAddress) + // .returns(ReturnsResult) + // .sync_call(); + let (address, init_result) = self - .message_me_proxy() + .tx() + .typed(message_me_proxy::MessageMeProxy) .init(123) - .with_egld_transfer(payment.clone_value()) - .deploy_contract::(&code, CodeMetadata::UPGRADEABLE); + .returns(ReturnsNewAddress) + .returns(ReturnsResult) + .egld(payment) + .sync_call(); + self.set_other_contract(&address); init_result + 1 } @@ -90,12 +73,13 @@ pub trait ProxyTestFirst { fn forward_to_other_contract(&self) { let payment = self.call_value().egld_value(); let other_contract = self.get_other_contract(); - self.pay_me_proxy() - .contract(other_contract) + self.tx() + .to(&other_contract) + .typed(pay_me_proxy::PayMeProxy) .pay_me(0x56) - .with_egld_transfer(payment.clone_value()) + .egld(payment) .async_call() - .call_and_exit() + .call_and_exit(); } #[payable("EGLD")] @@ -103,20 +87,22 @@ pub trait ProxyTestFirst { fn forward_to_other_contract_with_callback(&self) { let payment = self.call_value().egld_value(); let other_contract = self.get_other_contract(); - self.pay_me_proxy() - .contract(other_contract) + self.tx() + .to(&other_contract) + .typed(pay_me_proxy::PayMeProxy) .pay_me_with_result(0x56) - .with_egld_transfer(payment.clone_value()) + .egld(payment) .async_call() .with_callback(self.callbacks().pay_callback()) - .call_and_exit() + .call_and_exit(); } #[endpoint(messageOtherContract)] fn message_other_contract(&self) { let other_contract = self.get_other_contract(); - self.message_me_proxy() - .contract(other_contract) + self.tx() + .to(&other_contract) + .typed(message_me_proxy::MessageMeProxy) .message_me( 0x01, &BigUint::from(2u32), @@ -130,8 +116,9 @@ pub trait ProxyTestFirst { #[endpoint(messageOtherContractWithCallback)] fn message_other_contract_with_callback(&self) { let other_contract = self.get_other_contract(); - self.message_me_proxy() - .contract(other_contract) + self.tx() + .to(&other_contract) + .typed(message_me_proxy::MessageMeProxy) .message_me( 0x01, &BigUint::from(2u32),