From e8c3c3fe41672b1b972ad7c9a98d40e3b4e29c2a Mon Sep 17 00:00:00 2001 From: Mihai Calin Luca Date: Wed, 27 Mar 2024 18:23:20 +0100 Subject: [PATCH 1/8] migration to unified syntax --- .../src/builtin_func_features.rs | 15 +-- .../src/builtin_func_proxy.rs | 107 ++++++++++++++++-- 2 files changed, 108 insertions(+), 14 deletions(-) diff --git a/contracts/feature-tests/composability/builtin-func-features/src/builtin_func_features.rs b/contracts/feature-tests/composability/builtin-func-features/src/builtin_func_features.rs index 81df199e68..dd4183bb94 100644 --- a/contracts/feature-tests/composability/builtin-func-features/src/builtin_func_features.rs +++ b/contracts/feature-tests/composability/builtin-func-features/src/builtin_func_features.rs @@ -7,25 +7,26 @@ multiversx_sc::imports!(); /// Test contract for investigating async calls. #[multiversx_sc::contract] pub trait BuiltinFuncFeatures { - #[proxy] - fn builtin_func_proxy(&self, to: ManagedAddress) -> builtin_func_proxy::Proxy; - #[init] fn init(&self) {} #[endpoint] fn call_set_user_name(&self, address: ManagedAddress, name: ManagedBuffer) { - self.builtin_func_proxy(address) - .set_user_name(&name) + self.tx() + .to(&address) + .typed(builtin_func_proxy::UserBuiltinProxy) + .set_user_name(name) .async_call() .call_and_exit() } #[endpoint] fn call_delete_user_name(&self, address: ManagedAddress) { - self.builtin_func_proxy(address) + self.tx() + .to(&address) + .typed(builtin_func_proxy::UserBuiltinProxy) .delete_user_name() .async_call() - .call_and_exit(); + .call_and_exit() } } diff --git a/contracts/feature-tests/composability/builtin-func-features/src/builtin_func_proxy.rs b/contracts/feature-tests/composability/builtin-func-features/src/builtin_func_proxy.rs index 5499deee5e..66ed7a8fdf 100644 --- a/contracts/feature-tests/composability/builtin-func-features/src/builtin_func_proxy.rs +++ b/contracts/feature-tests/composability/builtin-func-features/src/builtin_func_proxy.rs @@ -1,10 +1,103 @@ -multiversx_sc::imports!(); +// Code generated by the multiversx-sc proxy generator. DO NOT EDIT. -#[multiversx_sc::derive::proxy] -pub trait UserBuiltin { - #[endpoint(SetUserName)] - fn set_user_name(&self, name: &ManagedBuffer); +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// - #[endpoint(DeleteUserName)] - fn delete_user_name(&self); +#![allow(dead_code)] +#![allow(clippy::all)] + +use multiversx_sc::proxy_imports::*; + +pub struct UserBuiltinProxy; + +impl TxProxyTrait for UserBuiltinProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = UserBuiltinProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + UserBuiltinProxyMethods { wrapped_tx: tx } + } +} + +pub struct UserBuiltinProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl UserBuiltinProxyMethods +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 UserBuiltinProxyMethods +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 UserBuiltinProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn set_user_name< + Arg0: CodecInto>, + >( + self, + name: Arg0, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("SetUserName") + .argument(&name) + .original_result() + } + + pub fn delete_user_name( + self, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("DeleteUserName") + .original_result() + } } From c4627e7efee7e5f2acf27582bc53d2b565ae6e48 Mon Sep 17 00:00:00 2001 From: Mihai Calin Luca Date: Thu, 28 Mar 2024 10:36:49 +0100 Subject: [PATCH 2/8] parent child migration and new proxy --- .../child/sc-config.toml | 2 + .../parent/src/child_proxy.rs | 102 ++++++++++++++++++ .../parent/src/lib.rs | 30 +++--- 3 files changed, 120 insertions(+), 14 deletions(-) create mode 100644 contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/child/sc-config.toml create mode 100644 contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/parent/src/child_proxy.rs diff --git a/contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/child/sc-config.toml b/contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/child/sc-config.toml new file mode 100644 index 0000000000..a80372b407 --- /dev/null +++ b/contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/child/sc-config.toml @@ -0,0 +1,2 @@ +[settings] +proxy-paths = ["../parent/src/child_proxy.rs"] \ No newline at end of file diff --git a/contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/parent/src/child_proxy.rs b/contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/parent/src/child_proxy.rs new file mode 100644 index 0000000000..0c28cb1f96 --- /dev/null +++ b/contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/parent/src/child_proxy.rs @@ -0,0 +1,102 @@ +// 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 ChildProxy; + +impl TxProxyTrait for ChildProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = ChildProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + ChildProxyMethods { wrapped_tx: tx } + } +} + +pub struct ChildProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl ChildProxyMethods +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 ChildProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ +} + +#[rustfmt::skip] +impl ChildProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn issue_wrapped_egld< + Arg0: CodecInto>, + Arg1: CodecInto>, + Arg2: CodecInto>, + >( + self, + token_display_name: Arg0, + token_ticker: Arg1, + initial_supply: Arg2, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("issueWrappedEgld") + .argument(&token_display_name) + .argument(&token_ticker) + .argument(&initial_supply) + .original_result() + } + + pub fn wrapped_egld_token_identifier( + self, + ) -> TxProxyCall> { + self.wrapped_tx + .raw_call() + .function_name("getWrappedEgldTokenIdentifier") + .original_result() + } +} diff --git a/contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/parent/src/lib.rs b/contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/parent/src/lib.rs index ddb8a09a09..f334c393f6 100644 --- a/contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/parent/src/lib.rs +++ b/contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/parent/src/lib.rs @@ -2,14 +2,13 @@ multiversx_sc::imports!(); +pub mod child_proxy; + // Base cost for standalone + estimate cost of actual sc call const ISSUE_EXPECTED_GAS_COST: u64 = 90_000_000 + 25_000_000; #[multiversx_sc::contract] pub trait Parent { - #[proxy] - fn child_proxy(&self, to: ManagedAddress) -> child::Proxy; - #[init] fn init(&self) {} @@ -19,13 +18,14 @@ pub trait Parent { #[endpoint(deployChildContract)] fn deploy_child_contract(&self, code: ManagedBuffer) { - let (child_contract_address, _) = self.send_raw().deploy_contract( - self.blockchain().get_gas_left(), - &BigUint::zero(), - &code, - CodeMetadata::DEFAULT, - &ManagedArgBuffer::new(), - ); + let gas_left = self.blockchain().get_gas_left(); + let child_contract_address = self + .tx() + .raw_deploy() + .code(code) + .with_gas_limit(gas_left) + .returns(ReturnsNewAddress) + .sync_call(); self.child_contract_address().set(&child_contract_address); } @@ -40,12 +40,14 @@ pub trait Parent { ) { let issue_cost = self.call_value().egld_value(); let child_contract_adress = self.child_contract_address().get(); - let _: IgnoreValue = self - .child_proxy(child_contract_adress) + + self.tx() + .to(&child_contract_adress) + .typed(child_proxy::ChildProxy) .issue_wrapped_egld(token_display_name, token_ticker, initial_supply) - .with_egld_transfer(issue_cost.clone_value()) + .egld(issue_cost) .with_gas_limit(ISSUE_EXPECTED_GAS_COST) - .execute_on_dest_context(); + .sync_call(); } // storage From 18524321fc842200f7a5c9b5969cd02cff0eacb0 Mon Sep 17 00:00:00 2001 From: Mihai Calin Luca Date: Thu, 28 Mar 2024 11:55:37 +0100 Subject: [PATCH 3/8] promises-features migration to new proxy --- .../src/call_promise_direct.rs | 3 - .../promises-features/src/call_promises.rs | 30 +- .../promises-features/src/call_promises_bt.rs | 18 +- .../promises-features/src/call_sync_bt.rs | 20 +- .../promises-features/src/promises_main.rs | 1 + .../promises-features/src/vault_proxy.rs | 278 ++++++++++++++++++ .../composability/vault/sc-config.toml | 5 +- 7 files changed, 320 insertions(+), 35 deletions(-) create mode 100644 contracts/feature-tests/composability/promises-features/src/vault_proxy.rs diff --git a/contracts/feature-tests/composability/promises-features/src/call_promise_direct.rs b/contracts/feature-tests/composability/promises-features/src/call_promise_direct.rs index 8ce47a10c3..7ae949e214 100644 --- a/contracts/feature-tests/composability/promises-features/src/call_promise_direct.rs +++ b/contracts/feature-tests/composability/promises-features/src/call_promise_direct.rs @@ -3,9 +3,6 @@ multiversx_sc::imports!(); /// Test contract for investigating the new async call framework. #[multiversx_sc::module] pub trait CallPromisesDirectModule { - #[proxy] - fn vault_proxy(&self) -> vault::Proxy; - #[endpoint] #[payable("*")] fn promise_raw_single_token( diff --git a/contracts/feature-tests/composability/promises-features/src/call_promises.rs b/contracts/feature-tests/composability/promises-features/src/call_promises.rs index 616d8c5cb0..6f2dc17287 100644 --- a/contracts/feature-tests/composability/promises-features/src/call_promises.rs +++ b/contracts/feature-tests/composability/promises-features/src/call_promises.rs @@ -1,24 +1,26 @@ multiversx_sc::imports!(); -use crate::common::{self, CallbackData}; +use crate::{ + common::{self, CallbackData}, + vault_proxy, +}; #[multiversx_sc::module] pub trait CallPromisesModule: common::CommonModule { - #[proxy] - fn vault_proxy(&self) -> vault::Proxy; - #[endpoint] #[payable("*")] fn forward_promise_accept_funds(&self, to: ManagedAddress) { let payment = self.call_value().egld_or_single_esdt(); let gas_limit = self.blockchain().get_gas_left() / 2; - self.vault_proxy() - .contract(to) + + self.tx() + .to(&to) + .typed(vault_proxy::VaultProxy) .accept_funds() - .with_egld_or_single_esdt_transfer(payment) .with_gas_limit(gas_limit) - .async_call_promise() - .register_promise() + .with_egld_or_single_esdt_transfer(payment) + .async_call() + .register_promise(); } #[endpoint] @@ -30,14 +32,16 @@ pub trait CallPromisesModule: common::CommonModule { amount: BigUint, ) { let gas_limit = self.blockchain().get_gas_left() - 20_000_000; - self.vault_proxy() - .contract(to) + + self.tx() + .to(&to) + .typed(vault_proxy::VaultProxy) .retrieve_funds(token, token_nonce, amount) .with_gas_limit(gas_limit) - .async_call_promise() + .async_call() .with_callback(self.callbacks().retrieve_funds_callback()) .with_extra_gas_for_callback(10_000_000) - .register_promise() + .register_promise(); } #[promises_callback] diff --git a/contracts/feature-tests/composability/promises-features/src/call_promises_bt.rs b/contracts/feature-tests/composability/promises-features/src/call_promises_bt.rs index e1e2188852..6f5d85179e 100644 --- a/contracts/feature-tests/composability/promises-features/src/call_promises_bt.rs +++ b/contracts/feature-tests/composability/promises-features/src/call_promises_bt.rs @@ -1,13 +1,12 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); -use crate::common::{self, CallbackData}; - +use crate::{ + common::{self, CallbackData}, + vault_proxy, +}; #[multiversx_sc::module] pub trait CallPromisesBackTransfersModule: common::CommonModule { - #[proxy] - fn vault_proxy(&self) -> vault::Proxy; - #[endpoint] fn forward_promise_retrieve_funds_back_transfers( &self, @@ -17,14 +16,15 @@ pub trait CallPromisesBackTransfersModule: common::CommonModule { amount: BigUint, ) { let gas_limit = self.blockchain().get_gas_left() - 20_000_000; - self.vault_proxy() - .contract(to) + self.tx() + .to(&to) + .typed(vault_proxy::VaultProxy) .retrieve_funds(token, token_nonce, amount) .with_gas_limit(gas_limit) - .async_call_promise() + .async_call() .with_callback(self.callbacks().retrieve_funds_back_transfers_callback()) .with_extra_gas_for_callback(10_000_000) - .register_promise() + .register_promise(); } #[promises_callback] diff --git a/contracts/feature-tests/composability/promises-features/src/call_sync_bt.rs b/contracts/feature-tests/composability/promises-features/src/call_sync_bt.rs index d3cc048ccc..1d228d30cd 100644 --- a/contracts/feature-tests/composability/promises-features/src/call_sync_bt.rs +++ b/contracts/feature-tests/composability/promises-features/src/call_sync_bt.rs @@ -1,11 +1,10 @@ +use crate::vault_proxy; + multiversx_sc::imports!(); /// Not directly related to promises, but this contract already has the setup for VM 1.5. #[multiversx_sc::module] pub trait BackTransfersFeatureModule { - #[proxy] - fn vault_proxy(&self) -> vault::Proxy; - #[endpoint] fn forward_sync_retrieve_funds_bt( &self, @@ -15,8 +14,9 @@ pub trait BackTransfersFeatureModule { amount: BigUint, ) { let ((), back_transfers) = self - .vault_proxy() - .contract(to) + .tx() + .to(&to) + .typed(vault_proxy::VaultProxy) .retrieve_funds(token, token_nonce, amount) .execute_on_dest_context_with_back_transfers::<()>(); @@ -40,8 +40,9 @@ pub trait BackTransfersFeatureModule { amount: BigUint, ) { let ((), back_transfers) = self - .vault_proxy() - .contract(to.clone()) + .tx() + .to(&to) + .typed(vault_proxy::VaultProxy) .retrieve_funds(token.clone(), token_nonce, amount.clone()) .execute_on_dest_context_with_back_transfers::<()>(); @@ -56,8 +57,9 @@ pub trait BackTransfersFeatureModule { ); let ((), back_transfers) = self - .vault_proxy() - .contract(to) + .tx() + .to(&to) + .typed(vault_proxy::VaultProxy) .retrieve_funds(token, token_nonce, amount) .execute_on_dest_context_with_back_transfers::<()>(); diff --git a/contracts/feature-tests/composability/promises-features/src/promises_main.rs b/contracts/feature-tests/composability/promises-features/src/promises_main.rs index 11eb5d3935..ddcc00d965 100644 --- a/contracts/feature-tests/composability/promises-features/src/promises_main.rs +++ b/contracts/feature-tests/composability/promises-features/src/promises_main.rs @@ -6,6 +6,7 @@ mod call_promises; mod call_promises_bt; pub mod call_sync_bt; mod common; +pub mod vault_proxy; multiversx_sc::imports!(); diff --git a/contracts/feature-tests/composability/promises-features/src/vault_proxy.rs b/contracts/feature-tests/composability/promises-features/src/vault_proxy.rs new file mode 100644 index 0000000000..f04735e6a5 --- /dev/null +++ b/contracts/feature-tests/composability/promises-features/src/vault_proxy.rs @@ -0,0 +1,278 @@ +// 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 VaultProxy; + +impl TxProxyTrait for VaultProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = VaultProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + VaultProxyMethods { wrapped_tx: tx } + } +} + +pub struct VaultProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl VaultProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + pub fn init< + Arg0: CodecInto>>, + >( + self, + opt_arg_to_echo: Arg0, + ) -> TxProxyDeploy>> { + self.wrapped_tx + .raw_deploy() + .argument(&opt_arg_to_echo) + .original_result() + } +} + +#[rustfmt::skip] +impl VaultProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn upgrade< + Arg0: CodecInto>>, + >( + self, + opt_arg_to_echo: Arg0, + ) -> TxProxyUpgrade>>> { + self.wrapped_tx + .raw_upgrade() + .argument(&opt_arg_to_echo) + .original_result() + } +} + +#[rustfmt::skip] +impl VaultProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn echo_arguments< + Arg0: CodecInto>>, + >( + self, + args: Arg0, + ) -> TxProxyCall>> { + self.wrapped_tx + .raw_call() + .function_name("echo_arguments") + .argument(&args) + .original_result() + } + + pub fn echo_arguments_without_storage< + Arg0: CodecInto>>, + >( + self, + args: Arg0, + ) -> TxProxyCall>> { + self.wrapped_tx + .raw_call() + .function_name("echo_arguments_without_storage") + .argument(&args) + .original_result() + } + + pub fn echo_caller( + self, + ) -> TxProxyCall> { + self.wrapped_tx + .raw_call() + .function_name("echo_caller") + .original_result() + } + + pub fn accept_funds( + self, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("accept_funds") + .original_result() + } + + pub fn accept_funds_echo_payment( + self, + ) -> TxProxyCall, MultiValueEncoded>>> { + self.wrapped_tx + .raw_call() + .function_name("accept_funds_echo_payment") + .original_result() + } + + pub fn accept_funds_single_esdt_transfer( + self, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("accept_funds_single_esdt_transfer") + .original_result() + } + + pub fn reject_funds( + self, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("reject_funds") + .original_result() + } + + pub fn retrieve_funds_with_transfer_exec< + Arg0: CodecInto>, + Arg1: CodecInto>, + Arg2: CodecInto>>, + >( + self, + token: Arg0, + amount: Arg1, + opt_receive_func: Arg2, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("retrieve_funds_with_transfer_exec") + .argument(&token) + .argument(&amount) + .argument(&opt_receive_func) + .original_result() + } + + pub fn retrieve_funds_promises< + Arg0: CodecInto>, + Arg1: CodecInto>>, + >( + self, + back_transfers: Arg0, + back_transfer_value: Arg1, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("retrieve_funds_promises") + .argument(&back_transfers) + .argument(&back_transfer_value) + .original_result() + } + + pub fn retrieve_funds< + Arg0: CodecInto>, + Arg1: CodecInto, + Arg2: CodecInto>, + >( + self, + token: Arg0, + nonce: Arg1, + amount: Arg2, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("retrieve_funds") + .argument(&token) + .argument(&nonce) + .argument(&amount) + .original_result() + } + + pub fn retrieve_multi_funds_async< + Arg0: CodecInto, u64, BigUint>>>, + >( + self, + token_payments: Arg0, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("retrieve_multi_funds_async") + .argument(&token_payments) + .original_result() + } + + pub fn burn_and_create_retrive_async( + self, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("burn_and_create_retrive_async") + .original_result() + } + + pub fn get_owner_address( + self, + ) -> TxProxyCall> { + self.wrapped_tx + .raw_call() + .function_name("get_owner_address") + .original_result() + } + + /// We already leave a trace of the calls using the event logs; + /// this additional counter has the role of showing that storage also gets saved correctly. + pub fn call_counts< + Arg0: CodecInto>, + >( + self, + endpoint: Arg0, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("call_counts") + .argument(&endpoint) + .original_result() + } + + pub fn num_called_retrieve_funds_promises( + self, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("num_called_retrieve_funds_promises") + .original_result() + } + + pub fn num_async_calls_sent_from_child( + self, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("num_async_calls_sent_from_child") + .original_result() + } +} diff --git a/contracts/feature-tests/composability/vault/sc-config.toml b/contracts/feature-tests/composability/vault/sc-config.toml index 33b8945873..969ed9c2a3 100644 --- a/contracts/feature-tests/composability/vault/sc-config.toml +++ b/contracts/feature-tests/composability/vault/sc-config.toml @@ -1,6 +1,9 @@ [settings] main = "main" -proxy-paths = ["../forwarder/src/vault_proxy.rs"] +proxy-paths = [ + "../forwarder/src/vault_proxy.rs", + "../promises-features/src/vault_proxy.rs", +] [contracts.main] name = "vault" From c4ae9765d3751deb4ac97d7162f8fdd88458edc8 Mon Sep 17 00:00:00 2001 From: Mihai Calin Luca Date: Thu, 28 Mar 2024 14:09:39 +0100 Subject: [PATCH 4/8] fix after review --- .../promises-features/src/call_promises.rs | 2 -- .../promises-features/src/call_sync_bt.rs | 15 +++++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/contracts/feature-tests/composability/promises-features/src/call_promises.rs b/contracts/feature-tests/composability/promises-features/src/call_promises.rs index 6f2dc17287..2b116215cc 100644 --- a/contracts/feature-tests/composability/promises-features/src/call_promises.rs +++ b/contracts/feature-tests/composability/promises-features/src/call_promises.rs @@ -19,7 +19,6 @@ pub trait CallPromisesModule: common::CommonModule { .accept_funds() .with_gas_limit(gas_limit) .with_egld_or_single_esdt_transfer(payment) - .async_call() .register_promise(); } @@ -38,7 +37,6 @@ pub trait CallPromisesModule: common::CommonModule { .typed(vault_proxy::VaultProxy) .retrieve_funds(token, token_nonce, amount) .with_gas_limit(gas_limit) - .async_call() .with_callback(self.callbacks().retrieve_funds_callback()) .with_extra_gas_for_callback(10_000_000) .register_promise(); diff --git a/contracts/feature-tests/composability/promises-features/src/call_sync_bt.rs b/contracts/feature-tests/composability/promises-features/src/call_sync_bt.rs index 1d228d30cd..d31ac022dc 100644 --- a/contracts/feature-tests/composability/promises-features/src/call_sync_bt.rs +++ b/contracts/feature-tests/composability/promises-features/src/call_sync_bt.rs @@ -13,12 +13,13 @@ pub trait BackTransfersFeatureModule { token_nonce: u64, amount: BigUint, ) { - let ((), back_transfers) = self + let back_transfers = self .tx() .to(&to) .typed(vault_proxy::VaultProxy) .retrieve_funds(token, token_nonce, amount) - .execute_on_dest_context_with_back_transfers::<()>(); + .returns(ReturnsBackTransfers) + .sync_call(); require!( back_transfers.esdt_payments.len() == 1 || back_transfers.total_egld_amount != 0, @@ -39,12 +40,13 @@ pub trait BackTransfersFeatureModule { token_nonce: u64, amount: BigUint, ) { - let ((), back_transfers) = self + let back_transfers = self .tx() .to(&to) .typed(vault_proxy::VaultProxy) .retrieve_funds(token.clone(), token_nonce, amount.clone()) - .execute_on_dest_context_with_back_transfers::<()>(); + .returns(ReturnsBackTransfers) + .sync_call(); require!( back_transfers.esdt_payments.len() == 1 || back_transfers.total_egld_amount != 0, @@ -56,12 +58,13 @@ pub trait BackTransfersFeatureModule { &back_transfers.esdt_payments.into_multi_value(), ); - let ((), back_transfers) = self + let back_transfers = self .tx() .to(&to) .typed(vault_proxy::VaultProxy) .retrieve_funds(token, token_nonce, amount) - .execute_on_dest_context_with_back_transfers::<()>(); + .returns(ReturnsBackTransfers) + .sync_call(); require!( back_transfers.esdt_payments.len() == 1 || back_transfers.total_egld_amount != 0, From ccaa7abaf4c26224af9a15c7aceb08aafe4d6018 Mon Sep 17 00:00:00 2001 From: Mihai Calin Luca Date: Thu, 28 Mar 2024 15:09:51 +0100 Subject: [PATCH 5/8] proxy test first new proxy and migration to unified --- .../proxy-test-first/src/message_me_proxy.rs | 107 ++++++++++++++++++ .../proxy-test-first/src/pay_me_proxy.rs | 107 ++++++++++++++++++ .../proxy-test-first/src/proxy-test-first.rs | 87 ++++++-------- 3 files changed, 251 insertions(+), 50 deletions(-) create mode 100644 contracts/feature-tests/composability/proxy-test-first/src/message_me_proxy.rs create mode 100644 contracts/feature-tests/composability/proxy-test-first/src/pay_me_proxy.rs 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), From 9ecb3ecc5495a3a58f8b452e954cc48811afe731 Mon Sep 17 00:00:00 2001 From: Mihai Calin Luca Date: Thu, 28 Mar 2024 15:40:05 +0100 Subject: [PATCH 6/8] new proxy and migration for recursive caller --- .../recursive-caller/sc-config.toml | 2 + .../recursive-caller/src/recursive_caller.rs | 24 +- .../recursive-caller/src/self_proxy.rs | 96 ++++++ .../recursive-caller/src/vault_proxy.rs | 278 ++++++++++++++++++ .../composability/vault/sc-config.toml | 1 + 5 files changed, 389 insertions(+), 12 deletions(-) create mode 100644 contracts/feature-tests/composability/recursive-caller/sc-config.toml create mode 100644 contracts/feature-tests/composability/recursive-caller/src/self_proxy.rs create mode 100644 contracts/feature-tests/composability/recursive-caller/src/vault_proxy.rs diff --git a/contracts/feature-tests/composability/recursive-caller/sc-config.toml b/contracts/feature-tests/composability/recursive-caller/sc-config.toml new file mode 100644 index 0000000000..7b21858e3c --- /dev/null +++ b/contracts/feature-tests/composability/recursive-caller/sc-config.toml @@ -0,0 +1,2 @@ +[settings] +proxy-paths = ["src/self_proxy.rs"] diff --git a/contracts/feature-tests/composability/recursive-caller/src/recursive_caller.rs b/contracts/feature-tests/composability/recursive-caller/src/recursive_caller.rs index 617f29e901..407a681927 100644 --- a/contracts/feature-tests/composability/recursive-caller/src/recursive_caller.rs +++ b/contracts/feature-tests/composability/recursive-caller/src/recursive_caller.rs @@ -2,15 +2,12 @@ multiversx_sc::imports!(); +pub mod self_proxy; +pub mod vault_proxy; + /// Test contract for investigating async calls. #[multiversx_sc::contract] pub trait RecursiveCaller { - #[proxy] - fn vault_proxy(&self) -> vault::Proxy; - - #[proxy] - fn self_proxy(&self) -> self::Proxy; - #[init] fn init(&self) {} @@ -24,10 +21,11 @@ pub trait RecursiveCaller { ) { self.recursive_send_funds_event(to, token_identifier, amount, counter); - self.vault_proxy() - .contract(to.clone()) + self.tx() + .to(to) + .typed(vault_proxy::VaultProxy) .accept_funds() - .with_egld_or_single_esdt_transfer((token_identifier.clone(), 0, amount.clone())) + .egld_or_single_esdt((token_identifier.clone(), 0, amount.clone())) .async_call() .with_callback(self.callbacks().recursive_send_funds_callback( to, @@ -35,7 +33,7 @@ pub trait RecursiveCaller { amount, counter, )) - .call_and_exit() + .call_and_exit(); } #[callback] @@ -49,8 +47,10 @@ pub trait RecursiveCaller { self.recursive_send_funds_callback_event(to, token_identifier, amount, counter); if counter > 1 { - self.self_proxy() - .contract(self.blockchain().get_sc_address()) + let self_address = self.blockchain().get_sc_address(); + self.tx() + .to(&self_address) + .typed(self_proxy::RecursiveCallerProxy) .recursive_send_funds(to, token_identifier, amount, counter - 1) .async_call() .call_and_exit() diff --git a/contracts/feature-tests/composability/recursive-caller/src/self_proxy.rs b/contracts/feature-tests/composability/recursive-caller/src/self_proxy.rs new file mode 100644 index 0000000000..8aa039e203 --- /dev/null +++ b/contracts/feature-tests/composability/recursive-caller/src/self_proxy.rs @@ -0,0 +1,96 @@ +// 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 RecursiveCallerProxy; + +impl TxProxyTrait for RecursiveCallerProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = RecursiveCallerProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + RecursiveCallerProxyMethods { wrapped_tx: tx } + } +} + +pub struct RecursiveCallerProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl RecursiveCallerProxyMethods +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 RecursiveCallerProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ +} + +#[rustfmt::skip] +impl RecursiveCallerProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn recursive_send_funds< + Arg0: CodecInto>, + Arg1: CodecInto>, + Arg2: CodecInto>, + Arg3: CodecInto, + >( + self, + to: Arg0, + token_identifier: Arg1, + amount: Arg2, + counter: Arg3, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("recursive_send_funds") + .argument(&to) + .argument(&token_identifier) + .argument(&amount) + .argument(&counter) + .original_result() + } +} diff --git a/contracts/feature-tests/composability/recursive-caller/src/vault_proxy.rs b/contracts/feature-tests/composability/recursive-caller/src/vault_proxy.rs new file mode 100644 index 0000000000..f04735e6a5 --- /dev/null +++ b/contracts/feature-tests/composability/recursive-caller/src/vault_proxy.rs @@ -0,0 +1,278 @@ +// 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 VaultProxy; + +impl TxProxyTrait for VaultProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = VaultProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + VaultProxyMethods { wrapped_tx: tx } + } +} + +pub struct VaultProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl VaultProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + pub fn init< + Arg0: CodecInto>>, + >( + self, + opt_arg_to_echo: Arg0, + ) -> TxProxyDeploy>> { + self.wrapped_tx + .raw_deploy() + .argument(&opt_arg_to_echo) + .original_result() + } +} + +#[rustfmt::skip] +impl VaultProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn upgrade< + Arg0: CodecInto>>, + >( + self, + opt_arg_to_echo: Arg0, + ) -> TxProxyUpgrade>>> { + self.wrapped_tx + .raw_upgrade() + .argument(&opt_arg_to_echo) + .original_result() + } +} + +#[rustfmt::skip] +impl VaultProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn echo_arguments< + Arg0: CodecInto>>, + >( + self, + args: Arg0, + ) -> TxProxyCall>> { + self.wrapped_tx + .raw_call() + .function_name("echo_arguments") + .argument(&args) + .original_result() + } + + pub fn echo_arguments_without_storage< + Arg0: CodecInto>>, + >( + self, + args: Arg0, + ) -> TxProxyCall>> { + self.wrapped_tx + .raw_call() + .function_name("echo_arguments_without_storage") + .argument(&args) + .original_result() + } + + pub fn echo_caller( + self, + ) -> TxProxyCall> { + self.wrapped_tx + .raw_call() + .function_name("echo_caller") + .original_result() + } + + pub fn accept_funds( + self, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("accept_funds") + .original_result() + } + + pub fn accept_funds_echo_payment( + self, + ) -> TxProxyCall, MultiValueEncoded>>> { + self.wrapped_tx + .raw_call() + .function_name("accept_funds_echo_payment") + .original_result() + } + + pub fn accept_funds_single_esdt_transfer( + self, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("accept_funds_single_esdt_transfer") + .original_result() + } + + pub fn reject_funds( + self, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("reject_funds") + .original_result() + } + + pub fn retrieve_funds_with_transfer_exec< + Arg0: CodecInto>, + Arg1: CodecInto>, + Arg2: CodecInto>>, + >( + self, + token: Arg0, + amount: Arg1, + opt_receive_func: Arg2, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("retrieve_funds_with_transfer_exec") + .argument(&token) + .argument(&amount) + .argument(&opt_receive_func) + .original_result() + } + + pub fn retrieve_funds_promises< + Arg0: CodecInto>, + Arg1: CodecInto>>, + >( + self, + back_transfers: Arg0, + back_transfer_value: Arg1, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("retrieve_funds_promises") + .argument(&back_transfers) + .argument(&back_transfer_value) + .original_result() + } + + pub fn retrieve_funds< + Arg0: CodecInto>, + Arg1: CodecInto, + Arg2: CodecInto>, + >( + self, + token: Arg0, + nonce: Arg1, + amount: Arg2, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("retrieve_funds") + .argument(&token) + .argument(&nonce) + .argument(&amount) + .original_result() + } + + pub fn retrieve_multi_funds_async< + Arg0: CodecInto, u64, BigUint>>>, + >( + self, + token_payments: Arg0, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("retrieve_multi_funds_async") + .argument(&token_payments) + .original_result() + } + + pub fn burn_and_create_retrive_async( + self, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("burn_and_create_retrive_async") + .original_result() + } + + pub fn get_owner_address( + self, + ) -> TxProxyCall> { + self.wrapped_tx + .raw_call() + .function_name("get_owner_address") + .original_result() + } + + /// We already leave a trace of the calls using the event logs; + /// this additional counter has the role of showing that storage also gets saved correctly. + pub fn call_counts< + Arg0: CodecInto>, + >( + self, + endpoint: Arg0, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("call_counts") + .argument(&endpoint) + .original_result() + } + + pub fn num_called_retrieve_funds_promises( + self, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("num_called_retrieve_funds_promises") + .original_result() + } + + pub fn num_async_calls_sent_from_child( + self, + ) -> TxProxyCall { + self.wrapped_tx + .raw_call() + .function_name("num_async_calls_sent_from_child") + .original_result() + } +} diff --git a/contracts/feature-tests/composability/vault/sc-config.toml b/contracts/feature-tests/composability/vault/sc-config.toml index 969ed9c2a3..107694e4fe 100644 --- a/contracts/feature-tests/composability/vault/sc-config.toml +++ b/contracts/feature-tests/composability/vault/sc-config.toml @@ -3,6 +3,7 @@ main = "main" proxy-paths = [ "../forwarder/src/vault_proxy.rs", "../promises-features/src/vault_proxy.rs", + "../recursive-caller/src/vault_proxy.rs" ] [contracts.main] From 3bb6cec953461bfd4eaefff96dac8f2bed5e493c Mon Sep 17 00:00:00 2001 From: Andrei Marinica Date: Thu, 28 Mar 2024 16:48:08 +0200 Subject: [PATCH 7/8] proxy test first fix --- .../proxy-test-first/src/proxy-test-first.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) 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 b3ddbf6d5e..58a2dd2684 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 @@ -30,21 +30,13 @@ 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 .tx() .typed(message_me_proxy::MessageMeProxy) .init(123) + .code(code) + .code_metadata(CodeMetadata::UPGRADEABLE) .returns(ReturnsNewAddress) .returns(ReturnsResult) .egld(payment) From 9fd738335c3a453e57e94b0ba1dcd52406e5d5a4 Mon Sep 17 00:00:00 2001 From: Mihai Calin Luca Date: Thu, 28 Mar 2024 16:11:12 +0100 Subject: [PATCH 8/8] removed init and upgrade from builtin proxy functions --- .../src/builtin_func_proxy.rs | 35 ------------------- 1 file changed, 35 deletions(-) diff --git a/contracts/feature-tests/composability/builtin-func-features/src/builtin_func_proxy.rs b/contracts/feature-tests/composability/builtin-func-features/src/builtin_func_proxy.rs index 66ed7a8fdf..8d7d106f66 100644 --- a/contracts/feature-tests/composability/builtin-func-features/src/builtin_func_proxy.rs +++ b/contracts/feature-tests/composability/builtin-func-features/src/builtin_func_proxy.rs @@ -35,41 +35,6 @@ where wrapped_tx: Tx, } -#[rustfmt::skip] -impl UserBuiltinProxyMethods -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 UserBuiltinProxyMethods -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 UserBuiltinProxyMethods where