Skip to content

Commit

Permalink
unified syntax - deprecated prepare_async()
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Oct 14, 2024
1 parent 6857224 commit 168179d
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 36 deletions.
8 changes: 0 additions & 8 deletions contracts/examples/multisig/interact/src/multisig_interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ impl MultisigInteract {
.code(&self.multisig_code)
.gas(NumExpr("100,000,000"))
.returns(ReturnsNewBech32Address)
.prepare_async()
.run()
.await;

Expand Down Expand Up @@ -202,7 +201,6 @@ impl MultisigInteract {
.from(&self.wallet_address)
.to(self.state.current_multisig_address())
.egld(BigUint::from(50_000_000_000_000_000u64)) // 0,05 or 5 * 10^16
.prepare_async()
.run()
.await;
}
Expand All @@ -220,7 +218,6 @@ impl MultisigInteract {
.gas(gas_expr)
.typed(multisig_proxy::MultisigProxy)
.perform_action_endpoint(action_id)
.prepare_async()
.run()
.await;

Expand Down Expand Up @@ -273,7 +270,6 @@ impl MultisigInteract {
.typed(multisig_proxy::MultisigProxy)
.quorum_reached(action_id)
.returns(ReturnsResult)
.prepare_async()
.run()
.await
}
Expand All @@ -285,7 +281,6 @@ impl MultisigInteract {
.typed(multisig_proxy::MultisigProxy)
.signed(signer, action_id)
.returns(ReturnsResult)
.prepare_async()
.run()
.await
}
Expand Down Expand Up @@ -340,7 +335,6 @@ impl MultisigInteract {
.gas(NumExpr("30,000,000"))
.typed(multisig_proxy::MultisigProxy)
.dns_register(dns_address, name)
.prepare_async()
.run()
.await;

Expand All @@ -355,7 +349,6 @@ impl MultisigInteract {
.typed(multisig_proxy::MultisigProxy)
.quorum()
.returns(ReturnsResult)
.prepare_async()
.run()
.await;

Expand All @@ -370,7 +363,6 @@ impl MultisigInteract {
.typed(multisig_proxy::MultisigProxy)
.num_board_members()
.returns(ReturnsResult)
.prepare_async()
.run()
.await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ impl MultisigInteract {
.argument(&0u32),
)
.returns(ReturnsResult)
.prepare_async()
.run()
.await;

Expand All @@ -75,7 +74,6 @@ impl MultisigInteract {
.typed(multisig_proxy::MultisigProxy)
.perform_action_endpoint(action_id)
.returns(ReturnsNewTokenIdentifier)
.prepare_async()
.run()
.await;
self.collection_token_identifier = new_token_id.to_string();
Expand All @@ -102,7 +100,6 @@ impl MultisigInteract {
.argument(&COLLECTION_TICKER),
)
.returns(ReturnsResult)
.prepare_async()
.run()
.await;

Expand All @@ -127,7 +124,6 @@ impl MultisigInteract {
.typed(multisig_proxy::MultisigProxy)
.perform_action_endpoint(action_id)
.returns(ReturnsNewTokenIdentifier)
.prepare_async()
.run()
.await;
self.collection_token_identifier = new_token_id;
Expand Down Expand Up @@ -156,7 +152,6 @@ impl MultisigInteract {
.argument(&"ESDTRoleNFTCreate"),
)
.returns(ReturnsResult)
.prepare_async()
.run()
.await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ impl MultisigInteract {
.typed(multisig_proxy::MultisigProxy)
.propose_async_call(&self.config.wegld_address, WRAP_AMOUNT, function_call)
.returns(ReturnsResult)
.prepare_async()
.run()
.await;

Expand All @@ -72,7 +71,6 @@ impl MultisigInteract {
.typed(wegld_proxy::EgldEsdtSwapProxy)
.wrapped_egld_token_id()
.returns(ReturnsResult)
.prepare_async()
.run()
.await;

Expand Down Expand Up @@ -104,7 +102,6 @@ impl MultisigInteract {
.typed(multisig_proxy::MultisigProxy)
.propose_async_call(normalized_to, 0u64, normalized_data)
.returns(ReturnsResult)
.prepare_async()
.run()
.await;

Expand Down
7 changes: 2 additions & 5 deletions contracts/examples/ping-pong-egld/dapp/src/interactor.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
use imports::{Address, Bech32Address, BytesValue};
use multiversx_sc_snippets_dapp::*;
use multiversx_sc_snippets_dapp::imports::*;
use serde::{Deserialize, Serialize};

const GATEWAY: &str = sdk::core::gateway::DEVNET_GATEWAY;
const GATEWAY: &str = multiversx_sc_snippets_dapp::sdk::core::gateway::DEVNET_GATEWAY;
const CONTRACT_ADDRESS: &str = "erd1qqqqqqqqqqqqqpgq6tqvj5f59xrgxwrtwy30elgpu7l4zrv6d8ssnjdwxq";
const PING_PONG_CODE: &[u8] = include_bytes!("../ping-pong-egld.wasm");

use multiversx_sc_snippets_dapp::imports::*;

#[derive(Debug, Default, Serialize, Deserialize)]
pub struct Config {
gateway: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use crate::interactor::ContractInteract;
use multiversx_sc_snippets_dapp::imports::{
Bech32Address, BigUint, IgnoreValue, InteractorPrepareAsync, OptionalValue, ReturnsMessage,
ReturnsNewBech32Address, ReturnsStatus,
};
use multiversx_sc_snippets_dapp::imports::*;

use super::proxy;

Expand All @@ -29,7 +26,6 @@ pub async fn deploy_sc() -> Result<Bech32Address, String> {
.returns(ReturnsNewBech32Address)
.returns(ReturnsStatus)
.returns(ReturnsMessage)
.prepare_async()
.run()
.await;

Expand Down Expand Up @@ -57,7 +53,6 @@ pub async fn ping() -> Result<String, String> {
.typed(proxy::PingPongProxy)
.ping(_data)
.egld(BigUint::from(amount))
.prepare_async()
.run()
.await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ impl BasicFeaturesInteract {
.code(&self.code_expr)
.gas(NumExpr("4,000,000"))
.returns(ReturnsNewBech32Address)
.prepare_async()
.run()
.await;

Expand All @@ -103,7 +102,6 @@ impl BasicFeaturesInteract {
.gas(NumExpr("600,000,000"))
.typed(basic_features_proxy::BasicFeaturesProxy)
.store_bytes(value)
.prepare_async()
.run()
.await;

Expand All @@ -118,7 +116,6 @@ impl BasicFeaturesInteract {
.typed(basic_features_proxy::BasicFeaturesProxy)
.load_bytes()
.returns(ReturnsResult)
.prepare_async()
.run()
.await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ impl ComposabilityInteract {
.to(&root_addr)
.typed(forwarder_queue_proxy::ForwarderQueueProxy)
.forward_queued_calls()
.prepare_async()
.run()
.await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn write_deploy_method_impl(file: &mut File, init_abi: &EndpointAbi, name: &Stri
.init({})
.code(&self.contract_code)
.returns(ReturnsNewAddress)
.prepare_async()
.run()
.await;
let new_address_bech32 = bech32::encode(&new_address);
Expand Down Expand Up @@ -101,7 +101,7 @@ fn write_upgrade_endpoint_impl(file: &mut File, upgrade_abi: &EndpointAbi, name:
.code(&self.contract_code)
.code_metadata(CodeMetadata::UPGRADEABLE)
.returns(ReturnsNewAddress)
.prepare_async()
.run()
.await;
Expand Down Expand Up @@ -214,7 +214,7 @@ fn write_contract_call(file: &mut File, endpoint_abi: &EndpointAbi, name: &Strin
.typed(proxy::{}Proxy)
.{}({}){}
.returns(ReturnsResultUnmanaged)
.prepare_async()
.run()
.await;
Expand All @@ -237,7 +237,7 @@ fn write_contract_query(file: &mut File, endpoint_abi: &EndpointAbi, name: &Stri
.typed(proxy::{}Proxy)
.{}({})
.returns(ReturnsResultUnmanaged)
.prepare_async()
.run()
.await;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ where
pub trait InteractorPrepareAsync {
type Exec;

#[deprecated(
since = "0.54.0",
note = "Calling `.prepare_async()` no longer necessary, `.run()` can be called directly."
)]
fn prepare_async(self) -> Self::Exec;
}

Expand Down
4 changes: 3 additions & 1 deletion framework/snippets-dapp/src/imports.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
pub use crate::multiversx_sc_scenario::imports::*;

pub use multiversx_sc_snippets_base::{
dns_address_for_name, InteractorBase, InteractorPrepareAsync, StepBuffer,
dns_address_for_name, InteractorBase, InteractorPrepareAsync, InteractorRunAsync, StepBuffer,
};

pub use multiversx_sdk_dapp::{core::test_wallets, data::keystore::InsertPassword, wallet::Wallet};

pub use crate::DappInteractor;

pub use env_logger;
2 changes: 2 additions & 0 deletions tools/interactor-system-func-calls/src/system_sc_interact.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(deprecated)] // TODO: move prepare_async calls to a test for backwards compatibility and delete from here

mod system_sc_interact_cli;
mod system_sc_interact_config;
mod system_sc_interact_state;
Expand Down

0 comments on commit 168179d

Please sign in to comment.