diff --git a/Cargo.lock b/Cargo.lock index 03b513f21e..454c2c033d 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -1501,13 +1501,10 @@ name = "interact" version = "0.0.0" dependencies = [ "clap", - "forwarder-queue", - "multiversx-sc-modules", + "multiversx-sc", "multiversx-sc-snippets", - "promises-features", "serde", "toml", - "vault", ] [[package]] diff --git a/contracts/feature-tests/composability/forwarder-queue/sc-config.toml b/contracts/feature-tests/composability/forwarder-queue/sc-config.toml index 7ace04ba7c..161c5f7ce3 100644 --- a/contracts/feature-tests/composability/forwarder-queue/sc-config.toml +++ b/contracts/feature-tests/composability/forwarder-queue/sc-config.toml @@ -8,3 +8,6 @@ name = "forwarder-queue" name = "forwarder-queue-promises" add-labels = ["promises-callback"] ei = "1.3" + +[[proxy]] +path = "../interact/src/forwarder_queue_proxy.rs" diff --git a/contracts/feature-tests/composability/forwarder-queue/src/forwarder_queue.rs b/contracts/feature-tests/composability/forwarder-queue/src/forwarder_queue.rs index 376fc61d76..1d97b48fc3 100644 --- a/contracts/feature-tests/composability/forwarder-queue/src/forwarder_queue.rs +++ b/contracts/feature-tests/composability/forwarder-queue/src/forwarder_queue.rs @@ -4,7 +4,8 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, Clone)] +#[type_abi] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, Clone)] pub enum QueuedCallType { Sync, LegacyAsync, @@ -12,7 +13,8 @@ pub enum QueuedCallType { Promise, } -#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, Clone)] +#[type_abi] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, Clone)] pub struct QueuedCall { pub call_type: QueuedCallType, pub to: ManagedAddress, diff --git a/contracts/feature-tests/composability/interact/Cargo.toml b/contracts/feature-tests/composability/interact/Cargo.toml index b58dc2c5a7..366f82213f 100644 --- a/contracts/feature-tests/composability/interact/Cargo.toml +++ b/contracts/feature-tests/composability/interact/Cargo.toml @@ -14,18 +14,9 @@ clap = { version = "4.4.7", features = ["derive"] } serde = { version = "1.0", features = ["derive"] } toml = "0.8.6" -[dependencies.vault] -path = "../vault" - -[dependencies.forwarder-queue] -path = "../forwarder-queue" - -[dependencies.promises-features] -path = "../promises-features" - -[dependencies.multiversx-sc-modules] +[dependencies.multiversx-sc] version = "0.50.1" -path = "../../../../contracts/modules" +path = "../../../../framework/base" [dependencies.multiversx-sc-snippets] version = "0.50.1" diff --git a/contracts/feature-tests/composability/interact/src/call_tree_calling_functions.rs b/contracts/feature-tests/composability/interact/src/call_tree_calling_functions.rs index 9305aca3be..0cb35bdbec 100644 --- a/contracts/feature-tests/composability/interact/src/call_tree_calling_functions.rs +++ b/contracts/feature-tests/composability/interact/src/call_tree_calling_functions.rs @@ -1,15 +1,13 @@ use std::{cell::RefCell, rc::Rc}; -use forwarder_queue::QueuedCallType; - use multiversx_sc_snippets::imports::*; use num_bigint::BigUint; use crate::{ call_tree::{CallNode, CallState, ForwarderQueueTarget}, comp_interact_controller::ComposabilityInteract, + forwarder_queue_proxy::{self, QueuedCallType}, }; -use forwarder_queue::ProxyTrait; const FORWARD_QUEUED_CALLS_ENDPOINT: &str = "forward_queued_calls"; const DEFAULT_GAS_LIMIT: u64 = 10_000_000; @@ -24,7 +22,7 @@ impl ComposabilityInteract { payment_nonce: u64, payment_amount: BigUint, ) { - let mut steps = Vec::new(); + let mut buffer = self.interactor.homogenous_call_buffer(); for fwd_rc in forwarders { let (fwd_name, fwd_children) = { @@ -35,8 +33,6 @@ impl ComposabilityInteract { let fwd = fwd_rc.borrow(); fwd.address.clone().unwrap() }; - let fwd_addr_bech32 = bech32::encode(&fwd_addr); - let fwd_addr_expr = format!("bech32:{fwd_addr_bech32}"); for child in &fwd_children { match child { @@ -48,29 +44,26 @@ impl ComposabilityInteract { child_fwd.address.clone().unwrap() }; - let typed_sc_call = ScCallStep::new() - .call( - self.state - .forwarder_queue_from_addr(&fwd_addr_expr) - .add_queued_call( - call_type.clone(), - child_fwd_addr, - DEFAULT_GAS_LIMIT, - FORWARD_QUEUED_CALLS_ENDPOINT, - MultiValueEncoded::::new(), - ) - .with_egld_or_single_esdt_transfer( - EgldOrEsdtTokenPayment::new( - payment_token.clone(), - payment_nonce, - payment_amount.clone().into(), - ), - ), - ) - .from(&self.wallet_address) - .gas_limit("70,000,000"); - - steps.push(typed_sc_call); + buffer.push_tx(|tx| { + tx.from(&self.wallet_address) + .to(&fwd_addr) + .gas(70_000_000u64) + .typed(forwarder_queue_proxy::ForwarderQueueProxy) + .add_queued_call( + call_type.clone(), + child_fwd_addr, + DEFAULT_GAS_LIMIT, + FORWARD_QUEUED_CALLS_ENDPOINT, + MultiValueEncoded::::new(), + ) + .payment(EgldOrEsdtTokenPayment::new( + payment_token.clone(), + payment_nonce, + payment_amount.clone().into(), + )) + .returns(ReturnsStatus) + .returns(ReturnsResult) + }); }, CallNode::Vault(vault_rc) => { // Call Vault @@ -80,46 +73,41 @@ impl ComposabilityInteract { vault.address.clone().unwrap() }; - let typed_sc_call = ScCallStep::new() - .call( - self.state - .forwarder_queue_from_addr(&fwd_addr_expr) - .add_queued_call( - call_type.clone(), - vault_addr, - DEFAULT_GAS_LIMIT, - endpoint_name, - MultiValueEncoded::::new(), - ) - .with_egld_or_single_esdt_transfer( - EgldOrEsdtTokenPayment::new( - payment_token.clone(), - payment_nonce, - payment_amount.clone().into(), - ), - ), - ) - .from(&self.wallet_address) - .gas_limit("70,000,000"); - - steps.push(typed_sc_call); + buffer.push_tx(|tx| { + tx.from(&self.wallet_address) + .to(&fwd_addr) + .gas(70_000_000u64) + .typed(forwarder_queue_proxy::ForwarderQueueProxy) + .add_queued_call( + call_type.clone(), + vault_addr, + DEFAULT_GAS_LIMIT, + endpoint_name, + MultiValueEncoded::::new(), + ) + .payment(EgldOrEsdtTokenPayment::new( + payment_token.clone(), + payment_nonce, + payment_amount.clone().into(), + )) + .returns(ReturnsStatus) + .returns(ReturnsResult) + }); }, } } } - self.interactor - .multi_sc_exec(StepBuffer::from_sc_call_vec(&mut steps)) - .await; - for step in steps.iter() { - if !step.response().is_success() { - println!( - "perform 'add_queued_call' failed with: {}", - step.response().tx_error - ); + let results = buffer.run().await; + + for (index, (status, result)) in results.iter().enumerate() { + if !status == 0u64 { + println!("perform 'add_queued_call' failed with error code {status}"); continue; } - println!("successfully performed action 'add_queued_call'"); + println!( + "successfully performed action {index} 'add_queued_call' with result {result:?}" + ); } } @@ -128,21 +116,16 @@ impl ComposabilityInteract { let root_addr_ref = call_state.root.borrow(); root_addr_ref.address.clone().unwrap() }; - let root_addr_bech32 = bech32::encode(&root_addr); - let root_addr_expr = format!("bech32:{root_addr_bech32}"); self.interactor - .sc_call( - ScCallStep::new() - .call( - self.state - .forwarder_queue_from_addr(&root_addr_expr) - .forward_queued_calls(), - ) - .from(&self.wallet_address) - .gas_limit("70,000,000") - .expect(TxExpect::ok().additional_error_message("calling root failed with: ")), - ) + .tx() + .from(&self.wallet_address) + .gas(70_000_000u64) + .to(&root_addr) + .typed(forwarder_queue_proxy::ForwarderQueueProxy) + .forward_queued_calls() + .prepare_async() + .run() .await; println!("successfully called root"); diff --git a/contracts/feature-tests/composability/interact/src/call_tree_deploy.rs b/contracts/feature-tests/composability/interact/src/call_tree_deploy.rs index 46e5c4804d..09d859008c 100644 --- a/contracts/feature-tests/composability/interact/src/call_tree_deploy.rs +++ b/contracts/feature-tests/composability/interact/src/call_tree_deploy.rs @@ -1,100 +1,65 @@ -use crate::{call_tree::CallState, comp_interact_controller::ComposabilityInteract}; - -use forwarder_queue::ProxyTrait as _; -use vault::ProxyTrait as _; +use crate::{ + call_tree::CallState, comp_interact_controller::ComposabilityInteract, forwarder_queue_proxy, vault_proxy +}; use multiversx_sc_snippets::imports::*; impl ComposabilityInteract { pub async fn deploy_call_tree_contracts(&mut self, call_state: &CallState) { - let mut typed_vault_deploys = self.typed_sc_deploy_vault(call_state).await; - let mut typed_forwarder_deploys = self.typed_sc_deploy_forwarder_queue(call_state).await; - - let mut steps = Vec::new(); - for typed_sc_deploy in &mut typed_vault_deploys { - steps.push(typed_sc_deploy.as_mut()); - } - for typed_sc_deploy in &mut typed_forwarder_deploys { - steps.push(typed_sc_deploy.as_mut()); - } - - self.interactor - .multi_sc_exec(StepBuffer::from_sc_deploy_vec(&mut steps)) - .await; + let vault_deploy_addresses = self.typed_sc_deploy_vault(call_state).await; + let forwarder_deploy_addresses = self.typed_sc_deploy_forwarder_queue(call_state).await; let mut vault_iter = call_state.vaults.iter(); - for step in typed_vault_deploys.iter() { - if let Some(new_address) = step.response().new_deployed_address.clone() { - let new_address_bech32 = bech32::encode(&new_address); - let rc_vault = vault_iter.next().unwrap(); - let mut vault = rc_vault.borrow_mut(); - println!( - "New vault {0} deployed address: {1}", - vault.name, new_address_bech32 - ); + for address in vault_deploy_addresses.iter() { + let rc_vault = vault_iter.next().unwrap(); + let mut vault = rc_vault.borrow_mut(); + println!("New vault {0} deployed address: {1}", vault.name, address); - vault.address = Some(new_address); - } else { - println!("deploy failed"); - return; - } + vault.address = Some(address.to_address()); } let mut fwd_iter = call_state.forwarders.iter(); - for step in typed_forwarder_deploys.iter() { - if let Some(new_address) = step.response().new_deployed_address.clone() { - let new_address_bech32 = bech32::encode(&new_address); - let rc_fwd = fwd_iter.next().unwrap(); - let mut fwd = rc_fwd.borrow_mut(); - println!( - "New forwarder {0} deployed address: {1}", - fwd.name, new_address_bech32 - ); + for address in forwarder_deploy_addresses.iter() { + let rc_fwd = fwd_iter.next().unwrap(); + let mut fwd = rc_fwd.borrow_mut(); + println!("New forwarder {0} deployed address: {1}", fwd.name, address); - fwd.address = Some(new_address); - } else { - println!("deploy failed"); - return; - } + fwd.address = Some(address.to_address()); } } - pub async fn typed_sc_deploy_vault( - &mut self, - call_state: &CallState, - ) -> Vec>>> { - let mut typed_vault_deploys = Vec::new(); + pub async fn typed_sc_deploy_vault(&mut self, call_state: &CallState) -> Vec { + let mut buffer = self.interactor.homogenous_call_buffer(); for _ in call_state.vaults.iter() { - let typed_sc_deploy = ScDeployStep::new() - .call( - self.state - .default_vault_address() - .init(OptionalValue::::None), - ) - .from(&self.wallet_address) - .code(&self.vault_code) - .gas_limit("70,000,000"); - - typed_vault_deploys.push(typed_sc_deploy); + buffer.push_tx(|tx| { + tx.from(&self.wallet_address) + .typed(vault_proxy::VaultProxy) + .init(OptionalValue::::None) + .code(&self.vault_code) + .gas(NumExpr("70,000,000")) + .returns(ReturnsNewBech32Address) + }); } - typed_vault_deploys + + buffer.run().await } pub async fn typed_sc_deploy_forwarder_queue( &mut self, call_state: &CallState, - ) -> Vec> { - let mut typed_forwarder_deploys = Vec::new(); - + ) -> Vec { + let mut buffer = self.interactor.homogenous_call_buffer(); for _ in call_state.forwarders.iter() { - let typed_sc_deploy = ScDeployStep::new() - .call(self.state.default_forwarder_queue_address().init()) - .from(&self.wallet_address) - .code(&self.forw_queue_code) - .gas_limit("70,000,000"); - - typed_forwarder_deploys.push(typed_sc_deploy); + buffer.push_tx(|tx| { + tx.from(&self.wallet_address) + .typed(forwarder_queue_proxy::ForwarderQueueProxy) + .init() + .code(&self.forw_queue_code) + .gas(NumExpr("70,000,000")) + .returns(ReturnsNewBech32Address) + }); } - typed_forwarder_deploys + + buffer.run().await } } diff --git a/contracts/feature-tests/composability/interact/src/comp_interact_config.rs b/contracts/feature-tests/composability/interact/src/comp_interact_config.rs index cbe6d6498f..d09c2323f7 100644 --- a/contracts/feature-tests/composability/interact/src/comp_interact_config.rs +++ b/contracts/feature-tests/composability/interact/src/comp_interact_config.rs @@ -1,9 +1,10 @@ -use forwarder_queue::QueuedCallType; use multiversx_sc_snippets::imports::*; use num_bigint::BigUint; use serde::Deserialize; use std::{fmt::Debug, io::Read, str::FromStr}; +use crate::forwarder_queue_proxy::QueuedCallType; + /// Config file const CONFIG_FILE: &str = "config.toml"; diff --git a/contracts/feature-tests/composability/interact/src/comp_interact_main.rs b/contracts/feature-tests/composability/interact/src/comp_interact_main.rs index 9f4a6d6872..9f5fb1f296 100644 --- a/contracts/feature-tests/composability/interact/src/comp_interact_main.rs +++ b/contracts/feature-tests/composability/interact/src/comp_interact_main.rs @@ -1,5 +1,4 @@ #![allow(clippy::too_many_arguments)] -#![allow(deprecated)] // TODO: switch to unified syntax mod call_tree; mod call_tree_calling_functions; @@ -9,10 +8,11 @@ mod comp_interact_config; mod comp_interact_controller; mod comp_interact_state; -use clap::Parser; +mod vault_proxy; +mod forwarder_queue_proxy; +use clap::Parser; use comp_interact_controller::ComposabilityInteract; - use multiversx_sc_snippets::imports::*; #[tokio::main] diff --git a/contracts/feature-tests/composability/interact/src/comp_interact_state.rs b/contracts/feature-tests/composability/interact/src/comp_interact_state.rs index f9f676636c..fc2b7be1ad 100644 --- a/contracts/feature-tests/composability/interact/src/comp_interact_state.rs +++ b/contracts/feature-tests/composability/interact/src/comp_interact_state.rs @@ -1,20 +1,12 @@ -use crate::{ContractInfo, StaticApi}; use serde::{Deserialize, Serialize}; use std::{ io::{Read, Write}, path::Path, }; -/// Default contract address -const DEFAULT_CONTRACT_ADDRESS: &str = - "0x0000000000000000000000000000000000000000000000000000000000000000"; - /// State file const STATE_FILE: &str = "state.toml"; -pub type VaultContract = ContractInfo>; -pub type ForwarderQueueContract = ContractInfo>; - /// Composability Interact state #[derive(Debug, Default, Serialize, Deserialize)] pub struct State { @@ -35,21 +27,6 @@ impl State { Self::default() } } - - /// Returns the forwarder-queue contract - pub fn forwarder_queue_from_addr(&self, address: &str) -> ForwarderQueueContract { - ForwarderQueueContract::new(address) - } - - /// Returns the vault contract with default address - pub fn default_vault_address(&self) -> VaultContract { - VaultContract::new(DEFAULT_CONTRACT_ADDRESS) - } - - /// Returns the forwarder-queue contract with default address - pub fn default_forwarder_queue_address(&self) -> ForwarderQueueContract { - ForwarderQueueContract::new(DEFAULT_CONTRACT_ADDRESS) - } } impl Drop for State { diff --git a/contracts/feature-tests/composability/interact/src/forwarder_queue_proxy.rs b/contracts/feature-tests/composability/interact/src/forwarder_queue_proxy.rs new file mode 100644 index 0000000000..da3775365f --- /dev/null +++ b/contracts/feature-tests/composability/interact/src/forwarder_queue_proxy.rs @@ -0,0 +1,251 @@ +// 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 ForwarderQueueProxy; + +impl TxProxyTrait for ForwarderQueueProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = ForwarderQueueProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + ForwarderQueueProxyMethods { wrapped_tx: tx } + } +} + +pub struct ForwarderQueueProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl ForwarderQueueProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + pub fn init( + self, + ) -> TxTypedDeploy { + self.wrapped_tx + .payment(NotPayable) + .raw_deploy() + .original_result() + } +} + +#[rustfmt::skip] +impl ForwarderQueueProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn queued_calls( + self, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("queued_calls") + .original_result() + } + + pub fn add_queued_call_sync< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg>>, + >( + self, + to: Arg0, + endpoint_name: Arg1, + args: Arg2, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("add_queued_call_sync") + .argument(&to) + .argument(&endpoint_name) + .argument(&args) + .original_result() + } + + pub fn add_queued_call_legacy_async< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg>>, + >( + self, + to: Arg0, + endpoint_name: Arg1, + args: Arg2, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("add_queued_call_legacy_async") + .argument(&to) + .argument(&endpoint_name) + .argument(&args) + .original_result() + } + + pub fn add_queued_call_transfer_execute< + Arg0: ProxyArg>, + Arg1: ProxyArg, + Arg2: ProxyArg>, + Arg3: ProxyArg>>, + >( + self, + to: Arg0, + gas_limit: Arg1, + endpoint_name: Arg2, + args: Arg3, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("add_queued_call_transfer_execute") + .argument(&to) + .argument(&gas_limit) + .argument(&endpoint_name) + .argument(&args) + .original_result() + } + + pub fn add_queued_call_transfer_esdt< + Arg0: ProxyArg>, + Arg1: ProxyArg, + Arg2: ProxyArg>, + Arg3: ProxyArg>, + Arg4: ProxyArg>, + Arg5: ProxyArg>>, + >( + self, + to: Arg0, + gas_limit: Arg1, + endpoint_name: Arg2, + token: Arg3, + amount: Arg4, + args: Arg5, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("add_queued_call_transfer_esdt") + .argument(&to) + .argument(&gas_limit) + .argument(&endpoint_name) + .argument(&token) + .argument(&amount) + .argument(&args) + .original_result() + } + + pub fn add_queued_call_promise< + Arg0: ProxyArg>, + Arg1: ProxyArg, + Arg2: ProxyArg>, + Arg3: ProxyArg>>, + >( + self, + to: Arg0, + gas_limit: Arg1, + endpoint_name: Arg2, + args: Arg3, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("add_queued_call_promise") + .argument(&to) + .argument(&gas_limit) + .argument(&endpoint_name) + .argument(&args) + .original_result() + } + + pub fn add_queued_call< + Arg0: ProxyArg, + Arg1: ProxyArg>, + Arg2: ProxyArg, + Arg3: ProxyArg>, + Arg4: ProxyArg>>, + >( + self, + call_type: Arg0, + to: Arg1, + gas_limit: Arg2, + endpoint_name: Arg3, + args: Arg4, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("add_queued_call") + .argument(&call_type) + .argument(&to) + .argument(&gas_limit) + .argument(&endpoint_name) + .argument(&args) + .original_result() + } + + pub fn forward_queued_calls( + self, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("forward_queued_calls") + .original_result() + } + + pub fn callback_count( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("callback_count") + .original_result() + } + + pub fn callback_payments( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("callback_payments") + .original_result() + } +} + +#[type_abi] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, Clone)] +pub struct QueuedCall +where + Api: ManagedTypeApi, +{ + pub call_type: QueuedCallType, + pub to: ManagedAddress, + pub gas_limit: u64, + pub endpoint_name: ManagedBuffer, + pub args: ManagedArgBuffer, + pub payments: EgldOrMultiEsdtPayment, +} + +#[type_abi] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, Clone)] +pub enum QueuedCallType { + Sync, + LegacyAsync, + TransferExecute, + Promise, +} diff --git a/contracts/feature-tests/composability/interact/src/vault_proxy.rs b/contracts/feature-tests/composability/interact/src/vault_proxy.rs new file mode 100644 index 0000000000..24e6f12e69 --- /dev/null +++ b/contracts/feature-tests/composability/interact/src/vault_proxy.rs @@ -0,0 +1,273 @@ +// 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: ProxyArg>>, + >( + self, + opt_arg_to_echo: Arg0, + ) -> TxTypedDeploy>> { + self.wrapped_tx + .payment(NotPayable) + .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: ProxyArg>>, + >( + self, + opt_arg_to_echo: Arg0, + ) -> TxTypedUpgrade>>> { + self.wrapped_tx + .payment(NotPayable) + .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: ProxyArg>>, + >( + self, + args: Arg0, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("echo_arguments") + .argument(&args) + .original_result() + } + + pub fn echo_arguments_without_storage< + Arg0: ProxyArg>>, + >( + self, + args: Arg0, + ) -> TxTypedCall>> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("echo_arguments_without_storage") + .argument(&args) + .original_result() + } + + pub fn echo_caller( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("echo_caller") + .original_result() + } + + pub fn accept_funds( + self, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("accept_funds") + .original_result() + } + + pub fn accept_funds_echo_payment( + self, + ) -> TxTypedCall, MultiValueEncoded>>> { + self.wrapped_tx + .raw_call("accept_funds_echo_payment") + .original_result() + } + + pub fn accept_funds_single_esdt_transfer( + self, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("accept_funds_single_esdt_transfer") + .original_result() + } + + pub fn reject_funds( + self, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("reject_funds") + .original_result() + } + + pub fn retrieve_funds_with_transfer_exec< + Arg0: ProxyArg>, + Arg1: ProxyArg>, + Arg2: ProxyArg>>, + >( + self, + token: Arg0, + amount: Arg1, + opt_receive_func: Arg2, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("retrieve_funds_with_transfer_exec") + .argument(&token) + .argument(&amount) + .argument(&opt_receive_func) + .original_result() + } + + pub fn retrieve_funds_promises< + Arg0: ProxyArg>, + Arg1: ProxyArg>>, + >( + self, + back_transfers: Arg0, + back_transfer_value: Arg1, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("retrieve_funds_promises") + .argument(&back_transfers) + .argument(&back_transfer_value) + .original_result() + } + + pub fn retrieve_funds< + Arg0: ProxyArg>, + Arg1: ProxyArg, + Arg2: ProxyArg>, + >( + self, + token: Arg0, + nonce: Arg1, + amount: Arg2, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("retrieve_funds") + .argument(&token) + .argument(&nonce) + .argument(&amount) + .original_result() + } + + pub fn retrieve_multi_funds_async< + Arg0: ProxyArg, u64, BigUint>>>, + >( + self, + token_payments: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("retrieve_multi_funds_async") + .argument(&token_payments) + .original_result() + } + + pub fn burn_and_create_retrieve_async( + self, + ) -> TxTypedCall { + self.wrapped_tx + .raw_call("burn_and_create_retrieve_async") + .original_result() + } + + pub fn get_owner_address( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("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: ProxyArg>, + >( + self, + endpoint: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("call_counts") + .argument(&endpoint) + .original_result() + } + + pub fn num_called_retrieve_funds_promises( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("num_called_retrieve_funds_promises") + .original_result() + } + + pub fn num_async_calls_sent_from_child( + self, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("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 130812eff2..5a76bc3096 100644 --- a/contracts/feature-tests/composability/vault/sc-config.toml +++ b/contracts/feature-tests/composability/vault/sc-config.toml @@ -24,3 +24,6 @@ path = "../promises-features/src/vault_proxy.rs" [[proxy]] path = "../recursive-caller/src/vault_proxy.rs" + +[[proxy]] +path = "../interact/src/vault_proxy.rs"