From 4ffca0ea5af3834bc0661e2820ff665cf0bd3bbe Mon Sep 17 00:00:00 2001 From: Andrei Marinica Date: Tue, 9 Apr 2024 16:45:44 +0300 Subject: [PATCH] imports - scenario & snippets --- .../tests/linked_list_repeat_blackbox_test.rs | 3 +-- .../tests/price_aggregator_blackbox_test.rs | 12 ++------- .../tests/price_aggregator_stress_blackbox.rs | 12 ++------- .../tests/price_aggregator_whitebox_test.rs | 5 +--- .../adder/interact/src/basic_interact.rs | 19 +++---------- .../tests/adder_blackbox_chained_test.rs | 5 ++-- .../tests/adder_blackbox_legacy_proxy_test.rs | 8 +++--- .../tests/adder_blackbox_raw_steps_test.rs | 2 +- .../adder/tests/adder_blackbox_test.rs | 5 ++-- .../tests/adder_blackbox_upgrade_test.rs | 2 +- .../adder/tests/adder_whitebox_test.rs | 2 +- .../tests/crowdfunding_esdt_blackbox_test.rs | 14 ++-------- .../interact/src/multisig_interact.rs | 18 ++----------- .../interact/src/multisig_interact_nfts.rs | 8 +----- .../interact/src/multisig_interact_wegld.rs | 13 +-------- .../multisig/tests/multisig_blackbox_test.rs | 19 +++---------- .../multisig/tests/multisig_whitebox_test.rs | 21 +-------------- .../rewards_distribution_blackbox_test.rs | 18 +------------ .../feature-tests/abi-tester/src/abi_proxy.rs | 10 ++----- .../interact/src/bf_interact.rs | 16 ++--------- .../basic_features_managed_buffer_test.rs | 3 +-- .../tests/basic_features_managed_vec_test.rs | 3 +-- ...basic_features_ordered_binary_tree_test.rs | 6 ++--- .../basic_features_token_identifier_test.rs | 3 +-- .../tests/forwarder_blackbox_test.rs | 8 +----- .../tests/forwarder_whitebox_test.rs | 9 +------ .../src/call_tree_calling_functions.rs | 13 +++------ .../interact/src/call_tree_deploy.rs | 14 ++-------- .../interact/src/comp_interact_config.rs | 6 ++--- .../interact/src/comp_interact_controller.rs | 12 ++------- .../interact/src/comp_interact_main.rs | 6 +---- .../tests/promises_feature_blackbox_test.rs | 6 +---- .../tests/transfer_role_blackbox_test.rs | 10 +------ .../tests/transfer_role_whitebox_test.rs | 11 +------- .../tests/exchange_features_blackbox_test.rs | 2 +- .../tests/pmf_blackbox_test.rs | 4 +-- .../tests/payable_blackbox_test.rs | 2 +- .../interact-rs/src/interactor_main.rs | 14 +--------- .../tests/tester_blackbox_test.rs | 4 +-- .../tests/tester_whitebox_legacy_test.rs | 15 +++-------- .../tests/gov_module_whitebox_test.rs | 9 +------ .../tests/staking_module_whitebox_test.rs | 9 +------ .../tests/token_merge_module_whitebox_test.rs | 16 ++--------- framework/base/src/imports_reexport.rs | 4 +-- .../generate_snippets/snippet_template_gen.rs | 14 +--------- framework/scenario/src/facade.rs | 5 ++-- .../src/facade/{world_tx => }/expr.rs | 0 .../facade/{world_tx => }/expr/file_expr.rs | 8 +----- .../facade/{world_tx => }/expr/mxsc_expr.rs | 10 ++----- .../facade/{world_tx => }/expr/num_expr.rs | 14 ++++------ framework/scenario/src/facade/world_tx.rs | 4 +-- framework/scenario/src/imports.rs | 27 +++++++++++++++++++ framework/scenario/src/lib.rs | 5 +++- framework/snippets/src/imports.rs | 6 +++++ framework/snippets/src/lib.rs | 3 +++ 55 files changed, 125 insertions(+), 372 deletions(-) rename framework/scenario/src/facade/{world_tx => }/expr.rs (100%) rename framework/scenario/src/facade/{world_tx => }/expr/file_expr.rs (83%) rename framework/scenario/src/facade/{world_tx => }/expr/mxsc_expr.rs (78%) rename framework/scenario/src/facade/{world_tx => }/expr/num_expr.rs (73%) create mode 100644 framework/scenario/src/imports.rs create mode 100644 framework/snippets/src/imports.rs diff --git a/contracts/benchmarks/mappers/linked-list-repeat/tests/linked_list_repeat_blackbox_test.rs b/contracts/benchmarks/mappers/linked-list-repeat/tests/linked_list_repeat_blackbox_test.rs index 47af800bb8..12fde7ba31 100644 --- a/contracts/benchmarks/mappers/linked-list-repeat/tests/linked_list_repeat_blackbox_test.rs +++ b/contracts/benchmarks/mappers/linked-list-repeat/tests/linked_list_repeat_blackbox_test.rs @@ -1,7 +1,6 @@ use benchmark_common::ExampleStruct; use linked_list_repeat::ProxyTrait; -use multiversx_sc::types::{MultiValueEncoded, TokenIdentifier}; -use multiversx_sc_scenario::{api::StaticApi, scenario_model::*, *}; +use multiversx_sc_scenario::imports::*; const WASM_PATH_EXPR: &str = "mxsc:output/linked-list-repeat.mxsc.json"; diff --git a/contracts/core/price-aggregator/tests/price_aggregator_blackbox_test.rs b/contracts/core/price-aggregator/tests/price_aggregator_blackbox_test.rs index b1b28e4fcf..cc2dc7b994 100644 --- a/contracts/core/price-aggregator/tests/price_aggregator_blackbox_test.rs +++ b/contracts/core/price-aggregator/tests/price_aggregator_blackbox_test.rs @@ -2,17 +2,9 @@ use multiversx_price_aggregator_sc::{ price_aggregator_data::{OracleStatus, TimestampedPrice, TokenPair}, ContractObj, PriceAggregator, ProxyTrait as _, MAX_ROUND_DURATION_SECONDS, }; -use multiversx_sc::{ - codec::multi_types::MultiValueVec, - types::{Address, EgldOrEsdtTokenIdentifier}, -}; use multiversx_sc_modules::{pause::ProxyTrait, staking::ProxyTrait as _}; -use multiversx_sc_scenario::{ - api::StaticApi, - managed_address, managed_biguint, managed_buffer, - scenario_model::{Account, AddressValue, ScCallStep, ScDeployStep, SetStateStep, TxExpect}, - ContractInfo, DebugApi, ScenarioWorld, WhiteboxContract, -}; + +use multiversx_sc_scenario::imports::*; const DECIMALS: u8 = 0; const EGLD_TICKER: &[u8] = b"EGLD"; diff --git a/contracts/core/price-aggregator/tests/price_aggregator_stress_blackbox.rs b/contracts/core/price-aggregator/tests/price_aggregator_stress_blackbox.rs index 1170a4d964..44650679d3 100644 --- a/contracts/core/price-aggregator/tests/price_aggregator_stress_blackbox.rs +++ b/contracts/core/price-aggregator/tests/price_aggregator_stress_blackbox.rs @@ -2,17 +2,9 @@ use multiversx_price_aggregator_sc::{ price_aggregator_data::{OracleStatus, TokenPair}, ContractObj, PriceAggregator, ProxyTrait as _, }; -use multiversx_sc::{ - codec::multi_types::MultiValueVec, contract_base::ContractBase, - types::EgldOrEsdtTokenIdentifier, -}; use multiversx_sc_modules::{pause::ProxyTrait, staking::ProxyTrait as _}; -use multiversx_sc_scenario::{ - api::StaticApi, - managed_address, managed_buffer, - scenario_model::{Account, AddressValue, ScCallStep, ScDeployStep, SetStateStep}, - ContractInfo, DebugApi, ScenarioWorld, WhiteboxContract, -}; + +use multiversx_sc_scenario::imports::*; const DECIMALS: u8 = 0; const EGLD_TICKER: &[u8] = b"EGLD"; diff --git a/contracts/core/price-aggregator/tests/price_aggregator_whitebox_test.rs b/contracts/core/price-aggregator/tests/price_aggregator_whitebox_test.rs index a2a432127e..50b05a6a41 100644 --- a/contracts/core/price-aggregator/tests/price_aggregator_whitebox_test.rs +++ b/contracts/core/price-aggregator/tests/price_aggregator_whitebox_test.rs @@ -2,14 +2,11 @@ use multiversx_price_aggregator_sc::{ price_aggregator_data::{OracleStatus, TimestampedPrice, TokenPair}, PriceAggregator, MAX_ROUND_DURATION_SECONDS, }; -use multiversx_sc::types::{EgldOrEsdtTokenIdentifier, MultiValueEncoded}; use multiversx_sc_modules::{ pause::EndpointWrappers as PauseEndpointWrappers, staking::EndpointWrappers as StakingEndpointWrappers, }; -use multiversx_sc_scenario::{ - managed_address, managed_biguint, managed_buffer, scenario_model::*, WhiteboxContract, *, -}; +use multiversx_sc_scenario::imports::*; pub const DECIMALS: u8 = 0; pub const EGLD_TICKER: &[u8] = b"EGLD"; diff --git a/contracts/examples/adder/interact/src/basic_interact.rs b/contracts/examples/adder/interact/src/basic_interact.rs index 6f3d8dbb07..4fc748c95e 100644 --- a/contracts/examples/adder/interact/src/basic_interact.rs +++ b/contracts/examples/adder/interact/src/basic_interact.rs @@ -6,21 +6,8 @@ use adder::adder_proxy; use basic_interact_config::Config; use basic_interact_state::State; use clap::Parser; -use multiversx_sc_snippets::{ - env_logger, - multiversx_sc::types::{Address, ReturnsNewAddress, ReturnsResultConv}, - multiversx_sc_scenario::{ - api::StaticApi, - bech32, - mandos_system::ScenarioRunner, - num_bigint::BigUint, - scenario_format::interpret_trait::{InterpretableFrom, InterpreterContext}, - scenario_model::{BytesValue, Scenario}, - standalone::retrieve_account_as_scenario_set_state, - test_wallets, ContractInfo, NumExpr, WithRawTxResponse, - }, - tokio, Interactor, InteractorPrepareAsync, -}; + +use multiversx_sc_snippets::imports::*; const INTERACTOR_SCENARIO_TRACE_PATH: &str = "interactor_trace.scen.json"; @@ -189,7 +176,7 @@ impl AdderInteract { .to(self.state.adder().to_address()) .typed(adder_proxy::AdderProxy) .sum() - .returns(ReturnsResultConv::::new()) + .returns(ReturnsResultConv::::new()) .prepare_async() .run() .await; diff --git a/contracts/examples/adder/tests/adder_blackbox_chained_test.rs b/contracts/examples/adder/tests/adder_blackbox_chained_test.rs index 05b95ba905..b10b3e3a54 100644 --- a/contracts/examples/adder/tests/adder_blackbox_chained_test.rs +++ b/contracts/examples/adder/tests/adder_blackbox_chained_test.rs @@ -1,6 +1,7 @@ +use multiversx_sc_scenario::imports::*; +use num_bigint::BigUint; + use adder::*; -use multiversx_sc::types::{AddressExpr, ScExpr, WithNewAddress, WithResultConv}; -use multiversx_sc_scenario::{api::StaticApi, num_bigint::BigUint, scenario_model::*, *}; const ADDER_PATH_EXPR: &str = "mxsc:output/adder.mxsc.json"; diff --git a/contracts/examples/adder/tests/adder_blackbox_legacy_proxy_test.rs b/contracts/examples/adder/tests/adder_blackbox_legacy_proxy_test.rs index 1370a064fc..e3a2540386 100644 --- a/contracts/examples/adder/tests/adder_blackbox_legacy_proxy_test.rs +++ b/contracts/examples/adder/tests/adder_blackbox_legacy_proxy_test.rs @@ -1,9 +1,7 @@ +use multiversx_sc_scenario::imports::*; +use num_bigint::BigUint; + use adder::*; -use multiversx_sc::{ - storage::mappers::SingleValue, - types::{AddressExpr, ReturnsResultConv, WithNewAddress}, -}; -use multiversx_sc_scenario::{api::StaticApi, num_bigint::BigUint, scenario_model::*, *}; const ADDER_PATH_EXPR: &str = "mxsc:output/adder.mxsc.json"; diff --git a/contracts/examples/adder/tests/adder_blackbox_raw_steps_test.rs b/contracts/examples/adder/tests/adder_blackbox_raw_steps_test.rs index 92dba83b12..a88e4eb9b6 100644 --- a/contracts/examples/adder/tests/adder_blackbox_raw_steps_test.rs +++ b/contracts/examples/adder/tests/adder_blackbox_raw_steps_test.rs @@ -1,4 +1,4 @@ -use multiversx_sc_scenario::{scenario_model::*, *}; +use multiversx_sc_scenario::imports::*; const ADDER_PATH_EXPR: &str = "mxsc:output/adder.mxsc.json"; diff --git a/contracts/examples/adder/tests/adder_blackbox_test.rs b/contracts/examples/adder/tests/adder_blackbox_test.rs index ec98935ba4..6a3142a207 100644 --- a/contracts/examples/adder/tests/adder_blackbox_test.rs +++ b/contracts/examples/adder/tests/adder_blackbox_test.rs @@ -1,6 +1,7 @@ +use multiversx_sc_scenario::imports::*; +use num_bigint::BigUint; + use adder::*; -use multiversx_sc::types::{AddressExpr, ReturnsResultConv, ScExpr, WithNewAddress}; -use multiversx_sc_scenario::{api::StaticApi, num_bigint::BigUint, scenario_model::*, *}; const ADDER_PATH_EXPR: &str = "mxsc:output/adder.mxsc.json"; diff --git a/contracts/examples/adder/tests/adder_blackbox_upgrade_test.rs b/contracts/examples/adder/tests/adder_blackbox_upgrade_test.rs index 4cb12cad54..5a38f7c5df 100644 --- a/contracts/examples/adder/tests/adder_blackbox_upgrade_test.rs +++ b/contracts/examples/adder/tests/adder_blackbox_upgrade_test.rs @@ -1,4 +1,4 @@ -use multiversx_sc_scenario::{scenario_model::*, *}; +use multiversx_sc_scenario::imports::*; const ADDER_PATH_EXPR: &str = "mxsc:output/adder.mxsc.json"; diff --git a/contracts/examples/adder/tests/adder_whitebox_test.rs b/contracts/examples/adder/tests/adder_whitebox_test.rs index d068aa1b1d..50ad95faa6 100644 --- a/contracts/examples/adder/tests/adder_whitebox_test.rs +++ b/contracts/examples/adder/tests/adder_whitebox_test.rs @@ -1,5 +1,5 @@ use adder::*; -use multiversx_sc_scenario::{scenario_model::*, *}; +use multiversx_sc_scenario::imports::*; const ADDER_PATH_EXPR: &str = "mxsc:output/adder.mxsc.json"; diff --git a/contracts/examples/crowdfunding-esdt/tests/crowdfunding_esdt_blackbox_test.rs b/contracts/examples/crowdfunding-esdt/tests/crowdfunding_esdt_blackbox_test.rs index c6387e5c43..5dceba3659 100644 --- a/contracts/examples/crowdfunding-esdt/tests/crowdfunding_esdt_blackbox_test.rs +++ b/contracts/examples/crowdfunding-esdt/tests/crowdfunding_esdt_blackbox_test.rs @@ -1,16 +1,6 @@ use crowdfunding_esdt::{ProxyTrait as _, Status}; -use multiversx_sc::{ - storage::mappers::SingleValue, - types::{Address, EgldOrEsdtTokenIdentifier}, -}; -use multiversx_sc_scenario::{ - api::StaticApi, - scenario_model::{ - Account, AddressValue, CheckAccount, CheckStateStep, ScCallStep, ScDeployStep, ScQueryStep, - SetStateStep, TxExpect, - }, - ContractInfo, ScenarioWorld, -}; + +use multiversx_sc_scenario::imports::*; use num_bigint::BigUint; const CF_DEADLINE: u64 = 7 * 24 * 60 * 60; // 1 week in seconds diff --git a/contracts/examples/multisig/interact/src/multisig_interact.rs b/contracts/examples/multisig/interact/src/multisig_interact.rs index 65b6c0dbb1..9148af2e86 100644 --- a/contracts/examples/multisig/interact/src/multisig_interact.rs +++ b/contracts/examples/multisig/interact/src/multisig_interact.rs @@ -8,22 +8,8 @@ use clap::Parser; use multisig::multisig_proxy; use multisig_interact_config::Config; use multisig_interact_state::State; -use multiversx_sc_scenario::{ - mandos_system::ScenarioRunner, - multiversx_sc::types::{BigUint, ReturnsNewAddress, ReturnsResult}, - scenario_format::interpret_trait::InterpretableFrom, - standalone::retrieve_account_as_scenario_set_state, - test_wallets, NumExpr, -}; -use multiversx_sc_snippets::{ - dns_address_for_name, env_logger, - multiversx_sc::{codec::multi_types::MultiValueVec, types::Address}, - multiversx_sc_scenario::{ - api::StaticApi, bech32, scenario_format::interpret_trait::InterpreterContext, - scenario_model::*, ContractInfo, - }, - tokio, Interactor, InteractorPrepareAsync, -}; + +use multiversx_sc_snippets::imports::*; const SYSTEM_SC_BECH32: &str = "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u"; const INTERACTOR_SCENARIO_TRACE_PATH: &str = "interactor_trace.scen.json"; diff --git a/contracts/examples/multisig/interact/src/multisig_interact_nfts.rs b/contracts/examples/multisig/interact/src/multisig_interact_nfts.rs index 61788f99af..e7fb0104af 100644 --- a/contracts/examples/multisig/interact/src/multisig_interact_nfts.rs +++ b/contracts/examples/multisig/interact/src/multisig_interact_nfts.rs @@ -1,12 +1,6 @@ use std::time::Duration; -use multiversx_sc_scenario::{ - multiversx_sc::{ - codec::Empty, - types::{FunctionCall, ReturnsResult}, - }, - NumExpr, ReturnsNewTokenIdentifier, -}; +use multiversx_sc_snippets::imports::*; use super::*; diff --git a/contracts/examples/multisig/interact/src/multisig_interact_wegld.rs b/contracts/examples/multisig/interact/src/multisig_interact_wegld.rs index b267f17357..fbfdd6f4a6 100644 --- a/contracts/examples/multisig/interact/src/multisig_interact_wegld.rs +++ b/contracts/examples/multisig/interact/src/multisig_interact_wegld.rs @@ -1,17 +1,6 @@ use std::time::Duration; -use multiversx_sc_scenario::{ - multiversx_sc::types::{FunctionCall, ManagedAddress, ReturnsResult}, - NumExpr, -}; -#[allow(unused_imports)] -use multiversx_sc_snippets::multiversx_sc::types::{ - EsdtTokenPayment, MultiValueEncoded, TokenIdentifier, -}; -use multiversx_sc_snippets::multiversx_sc_scenario::{ - mandos_system::ScenarioRunner, scenario_format::interpret_trait::InterpretableFrom, - standalone::retrieve_account_as_scenario_set_state, -}; +use multiversx_sc_snippets::imports::*; use super::*; diff --git a/contracts/examples/multisig/tests/multisig_blackbox_test.rs b/contracts/examples/multisig/tests/multisig_blackbox_test.rs index 7107a6628e..691c2750db 100644 --- a/contracts/examples/multisig/tests/multisig_blackbox_test.rs +++ b/contracts/examples/multisig/tests/multisig_blackbox_test.rs @@ -1,24 +1,11 @@ +use multiversx_sc::codec::top_encode_to_vec_u8_or_panic; +use multiversx_sc_scenario::imports::*; + use adder::ProxyTrait as _; use multisig::{ multisig_perform::ProxyTrait as _, multisig_propose::ProxyTrait as _, user_role::UserRole, ProxyTrait as _, }; -use multiversx_sc::{ - codec::{ - multi_types::{MultiValueVec, OptionalValue}, - test_util::top_encode_to_vec_u8_or_panic, - }, - storage::mappers::SingleValue, - types::{Address, AddressExpr, CodeMetadata, FunctionCall, ReturnsResult}, -}; -use multiversx_sc_scenario::{ - api::StaticApi, - scenario_model::{ - Account, AddressValue, CheckAccount, CheckStateStep, ScCallStep, ScDeployStep, ScQueryStep, - SetStateStep, TxExpect, - }, - ContractInfo, ScenarioTxRun, ScenarioWorld, -}; use num_bigint::BigUint; const ADDER_ADDRESS_EXPR: &str = "sc:adder"; diff --git a/contracts/examples/multisig/tests/multisig_whitebox_test.rs b/contracts/examples/multisig/tests/multisig_whitebox_test.rs index 227c012bc7..456fc9f96f 100644 --- a/contracts/examples/multisig/tests/multisig_whitebox_test.rs +++ b/contracts/examples/multisig/tests/multisig_whitebox_test.rs @@ -1,5 +1,6 @@ #![allow(unused)] +use multiversx_sc_scenario::imports::*; use std::borrow::Borrow; use adder::Adder; @@ -8,26 +9,6 @@ use multisig::{ multisig_perform::MultisigPerformModule, multisig_propose::MultisigProposeModule, user_role::UserRole, Multisig, }; -use multiversx_sc::{ - api::ManagedTypeApi, - codec::multi_types::OptionalValue, - storage::mappers::SingleValue, - types::{ - Address, BigUint, BoxedBytes, CodeMetadata, FunctionCall, ManagedAddress, ManagedBuffer, - ManagedVec, - }, -}; -use multiversx_sc_scenario::{ - managed_address, managed_biguint, - multiversx_chain_vm::types::VMAddress, - rust_biguint, - scenario_model::{ - Account, AddressValue, CheckAccount, CheckStateStep, ScCallStep, ScDeployStep, ScQueryStep, - SetStateStep, TxExpect, TypedScQuery, - }, - testing_framework::TxResult, - DebugApi, ScenarioWorld, WhiteboxContract, -}; const OWNER_ADDRESS_EXPR: &str = "address:owner"; const PROPOSER_ADDRESS_EXPR: &str = "address:proposer"; diff --git a/contracts/examples/rewards-distribution/tests/rewards_distribution_blackbox_test.rs b/contracts/examples/rewards-distribution/tests/rewards_distribution_blackbox_test.rs index 2902c7832c..4380f0122f 100644 --- a/contracts/examples/rewards-distribution/tests/rewards_distribution_blackbox_test.rs +++ b/contracts/examples/rewards-distribution/tests/rewards_distribution_blackbox_test.rs @@ -1,25 +1,9 @@ mod mock_seed_nft_minter; mod utils; +use multiversx_sc_scenario::imports::*; use std::iter::zip; -use multiversx_sc::{ - codec::multi_types::MultiValue2, - storage::mappers::SingleValue, - types::{ - Address, BigUint, EgldOrEsdtTokenIdentifier, ManagedVec, MultiValueEncoded, - OperationCompletionStatus, TokenIdentifier, - }, -}; -use multiversx_sc_scenario::{ - api::StaticApi, - scenario_model::{ - Account, AddressValue, CheckAccount, CheckStateStep, ScCallStep, ScDeployStep, ScQueryStep, - SetStateStep, TxESDT, TypedResponse, - }, - ContractInfo, DebugApi, ScenarioWorld, WhiteboxContract, -}; - use crate::mock_seed_nft_minter::ProxyTrait as _; use rewards_distribution::{ Bracket, ContractObj, ProxyTrait as _, RewardsDistribution, DIVISION_SAFETY_CONSTANT, diff --git a/contracts/feature-tests/abi-tester/src/abi_proxy.rs b/contracts/feature-tests/abi-tester/src/abi_proxy.rs index b5b4b931c2..66548a21d8 100644 --- a/contracts/feature-tests/abi-tester/src/abi_proxy.rs +++ b/contracts/feature-tests/abi-tester/src/abi_proxy.rs @@ -415,10 +415,7 @@ pub enum AbiEnum { Nothing, Something(i32), SomethingMore(u8, OnlyShowsUpAsNested08), - SomeStruct { - a: u16, - b: OnlyShowsUpAsNested09, - }, + SomeStruct { a: u16, b: OnlyShowsUpAsNested09 }, } #[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)] @@ -509,8 +506,5 @@ pub enum ExplicitDiscriminantMixed { Unit, Tuple(u16), Five, - Struct { - a: u8, - b: u16, - }, + Struct { a: u8, b: u16 }, } diff --git a/contracts/feature-tests/basic-features/interact/src/bf_interact.rs b/contracts/feature-tests/basic-features/interact/src/bf_interact.rs index ceca3ace12..b93f0baac3 100644 --- a/contracts/feature-tests/basic-features/interact/src/bf_interact.rs +++ b/contracts/feature-tests/basic-features/interact/src/bf_interact.rs @@ -8,20 +8,8 @@ use basic_features::{ use bf_interact_config::Config; use bf_interact_state::State; use clap::Parser; -use multiversx_sc_snippets::{ - env_logger, - multiversx_sc::{codec::multi_types::IgnoreValue, types::Address}, - multiversx_sc_scenario::{ - api::StaticApi, - bech32, - mandos_system::ScenarioRunner, - scenario_format::interpret_trait::{InterpretableFrom, InterpreterContext}, - scenario_model::{BytesValue, ScCallStep, ScDeployStep, Scenario, TxExpect}, - standalone::retrieve_account_as_scenario_set_state, - test_wallets, ContractInfo, - }, - tokio, Interactor, -}; + +use multiversx_sc_snippets::imports::*; const INTERACTOR_SCENARIO_TRACE_PATH: &str = "interactor_trace.scen.json"; diff --git a/contracts/feature-tests/basic-features/tests/basic_features_managed_buffer_test.rs b/contracts/feature-tests/basic-features/tests/basic_features_managed_buffer_test.rs index cde4caa56e..88320b17f6 100644 --- a/contracts/feature-tests/basic-features/tests/basic_features_managed_buffer_test.rs +++ b/contracts/feature-tests/basic-features/tests/basic_features_managed_buffer_test.rs @@ -1,5 +1,4 @@ -use multiversx_sc::types::{ManagedAddress, ManagedBuffer}; -use multiversx_sc_scenario::{api::StaticApi, *}; +use multiversx_sc_scenario::imports::*; use basic_features::managed_buffer_features::ManagedBufferFeatures; diff --git a/contracts/feature-tests/basic-features/tests/basic_features_managed_vec_test.rs b/contracts/feature-tests/basic-features/tests/basic_features_managed_vec_test.rs index 62790660d0..fccc91e431 100644 --- a/contracts/feature-tests/basic-features/tests/basic_features_managed_vec_test.rs +++ b/contracts/feature-tests/basic-features/tests/basic_features_managed_vec_test.rs @@ -1,5 +1,4 @@ -use multiversx_sc::types::{BigUint, ManagedVec}; -use multiversx_sc_scenario::{api::StaticApi, *}; +use multiversx_sc_scenario::imports::*; use basic_features::managed_vec_features::ManagedVecFeatures; diff --git a/contracts/feature-tests/basic-features/tests/basic_features_ordered_binary_tree_test.rs b/contracts/feature-tests/basic-features/tests/basic_features_ordered_binary_tree_test.rs index 071da4a958..fe48caecba 100644 --- a/contracts/feature-tests/basic-features/tests/basic_features_ordered_binary_tree_test.rs +++ b/contracts/feature-tests/basic-features/tests/basic_features_ordered_binary_tree_test.rs @@ -1,10 +1,8 @@ #![allow(deprecated)] use basic_features::BasicFeatures; -use multiversx_sc::imports::{OrderedBinaryTreeNode, NULL_NODE_ID}; -use multiversx_sc_scenario::{ - managed_biguint, rust_biguint, testing_framework::BlockchainStateWrapper, -}; + +use multiversx_sc_scenario::imports::*; #[test] fn ordered_binary_tree_test() { diff --git a/contracts/feature-tests/basic-features/tests/basic_features_token_identifier_test.rs b/contracts/feature-tests/basic-features/tests/basic_features_token_identifier_test.rs index 3b85d24b4f..8cfe9ba2d2 100644 --- a/contracts/feature-tests/basic-features/tests/basic_features_token_identifier_test.rs +++ b/contracts/feature-tests/basic-features/tests/basic_features_token_identifier_test.rs @@ -1,5 +1,4 @@ -use multiversx_sc::types::{EgldOrEsdtTokenIdentifier, ManagedBuffer, TokenIdentifier}; -use multiversx_sc_scenario::{api::StaticApi, *}; +use multiversx_sc_scenario::imports::*; use basic_features::token_identifier_features::TokenIdentifierFeatures; diff --git a/contracts/feature-tests/composability/forwarder/tests/forwarder_blackbox_test.rs b/contracts/feature-tests/composability/forwarder/tests/forwarder_blackbox_test.rs index bbe8d68ecb..f6812aa0bc 100644 --- a/contracts/feature-tests/composability/forwarder/tests/forwarder_blackbox_test.rs +++ b/contracts/feature-tests/composability/forwarder/tests/forwarder_blackbox_test.rs @@ -1,12 +1,6 @@ use forwarder::nft::{Color, ProxyTrait as _}; -use multiversx_sc_scenario::{ - api::StaticApi, - scenario_model::{ - Account, CheckAccount, CheckStateStep, ScCallStep, SetStateStep, TransferStep, - }, - ContractInfo, ScenarioWorld, -}; +use multiversx_sc_scenario::imports::*; const USER_ADDRESS_EXPR: &str = "address:user"; const FORWARDER_ADDRESS_EXPR: &str = "sc:forwarder"; diff --git a/contracts/feature-tests/composability/forwarder/tests/forwarder_whitebox_test.rs b/contracts/feature-tests/composability/forwarder/tests/forwarder_whitebox_test.rs index 4cb15d884f..0adb09b286 100644 --- a/contracts/feature-tests/composability/forwarder/tests/forwarder_whitebox_test.rs +++ b/contracts/feature-tests/composability/forwarder/tests/forwarder_whitebox_test.rs @@ -1,12 +1,5 @@ use forwarder::nft::{Color, ForwarderNftModule}; -use multiversx_sc::{contract_base::ContractBase, types::Address}; -use multiversx_sc_scenario::{ - managed_address, managed_biguint, managed_token_id, - scenario_model::{ - Account, AddressValue, CheckAccount, CheckStateStep, ScCallStep, SetStateStep, - }, - ScenarioWorld, WhiteboxContract, -}; +use multiversx_sc_scenario::imports::*; const USER_ADDRESS_EXPR: &str = "address:user"; const FORWARDER_ADDRESS_EXPR: &str = "sc:forwarder"; 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 9e86f5dfdb..9305aca3be 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,16 +1,9 @@ use std::{cell::RefCell, rc::Rc}; use forwarder_queue::QueuedCallType; -use multiversx_sc_snippets::{ - multiversx_sc::types::{EgldOrEsdtTokenIdentifier, EgldOrEsdtTokenPayment, MultiValueEncoded}, - multiversx_sc_scenario::{ - api::StaticApi, - bech32, - num_bigint::BigUint, - scenario_model::{ScCallStep, TxExpect}, - }, - StepBuffer, -}; + +use multiversx_sc_snippets::imports::*; +use num_bigint::BigUint; use crate::{ call_tree::{CallNode, CallState, ForwarderQueueTarget}, 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 c9c2f1498c..46e5c4804d 100644 --- a/contracts/feature-tests/composability/interact/src/call_tree_deploy.rs +++ b/contracts/feature-tests/composability/interact/src/call_tree_deploy.rs @@ -1,20 +1,10 @@ use crate::{call_tree::CallState, comp_interact_controller::ComposabilityInteract}; use forwarder_queue::ProxyTrait as _; -use multiversx_sc_snippets::{ - multiversx_sc::{ - codec::multi_types::OptionalValue, - types::{BoxedBytes, ManagedBuffer}, - }, - multiversx_sc_scenario::{ - api::StaticApi, - bech32, - scenario_model::{ScDeployStep, TypedScDeploy}, - }, - StepBuffer, -}; use vault::ProxyTrait as _; +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; 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 c27957a9fb..cbe6d6498f 100644 --- a/contracts/feature-tests/composability/interact/src/comp_interact_config.rs +++ b/contracts/feature-tests/composability/interact/src/comp_interact_config.rs @@ -1,8 +1,6 @@ use forwarder_queue::QueuedCallType; -use multiversx_sc_snippets::{ - multiversx_sc::types::{EgldOrEsdtTokenIdentifier, TokenIdentifier}, - multiversx_sc_scenario::{api::StaticApi, num_bigint::BigUint}, -}; +use multiversx_sc_snippets::imports::*; +use num_bigint::BigUint; use serde::Deserialize; use std::{fmt::Debug, io::Read, str::FromStr}; diff --git a/contracts/feature-tests/composability/interact/src/comp_interact_controller.rs b/contracts/feature-tests/composability/interact/src/comp_interact_controller.rs index f5851d6e6c..409ce234a7 100644 --- a/contracts/feature-tests/composability/interact/src/comp_interact_controller.rs +++ b/contracts/feature-tests/composability/interact/src/comp_interact_controller.rs @@ -1,14 +1,6 @@ use crate::{call_tree::CallState, comp_interact_config::Config, comp_interact_state::State}; -use multiversx_sc_snippets::{ - multiversx_sc::types::Address, - multiversx_sc_scenario::{ - scenario_format::interpret_trait::{InterpretableFrom, InterpreterContext}, - scenario_model::BytesValue, - test_wallets::judy, - }, - Interactor, -}; +use multiversx_sc_snippets::imports::*; const INTERACTOR_SCENARIO_TRACE_PATH: &str = "comp_interact_trace.scen.json"; @@ -27,7 +19,7 @@ impl ComposabilityInteract { .await .with_tracer(INTERACTOR_SCENARIO_TRACE_PATH) .await; - let wallet_address = interactor.register_wallet(judy()); + let wallet_address = interactor.register_wallet(test_wallets::judy()); let forw_queue_code = BytesValue::interpret_from( "mxsc:../forwarder-queue/output/forwarder-queue.mxsc.json", &InterpreterContext::default(), 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 b6e0ba9778..cefa9272f2 100644 --- a/contracts/feature-tests/composability/interact/src/comp_interact_main.rs +++ b/contracts/feature-tests/composability/interact/src/comp_interact_main.rs @@ -12,11 +12,7 @@ use clap::Parser; use comp_interact_controller::ComposabilityInteract; -use multiversx_sc_snippets::{ - env_logger, - multiversx_sc_scenario::{api::StaticApi, ContractInfo}, - tokio, -}; +use multiversx_sc_snippets::imports::*; #[tokio::main] async fn main() { diff --git a/contracts/feature-tests/composability/tests/promises_feature_blackbox_test.rs b/contracts/feature-tests/composability/tests/promises_feature_blackbox_test.rs index a2ee00c631..e29ff1c7ca 100644 --- a/contracts/feature-tests/composability/tests/promises_feature_blackbox_test.rs +++ b/contracts/feature-tests/composability/tests/promises_feature_blackbox_test.rs @@ -1,9 +1,5 @@ use multiversx_sc::types::BigUint; -use multiversx_sc_scenario::{ - api::StaticApi, - scenario_model::{Account, CheckAccount, CheckStateStep, ScCallStep, SetStateStep}, - ContractInfo, ScenarioWorld, -}; +use multiversx_sc_scenario::imports::*; use promises_features::call_sync_bt::ProxyTrait; diff --git a/contracts/feature-tests/composability/transfer-role-features/tests/transfer_role_blackbox_test.rs b/contracts/feature-tests/composability/transfer-role-features/tests/transfer_role_blackbox_test.rs index acaefbfb1d..2428a9a6bc 100644 --- a/contracts/feature-tests/composability/transfer-role-features/tests/transfer_role_blackbox_test.rs +++ b/contracts/feature-tests/composability/transfer-role-features/tests/transfer_role_blackbox_test.rs @@ -1,12 +1,4 @@ -use multiversx_sc::{codec::multi_types::MultiValueVec, types::Address}; -use multiversx_sc_scenario::{ - api::StaticApi, - scenario_model::{ - Account, AddressValue, CheckAccount, CheckStateStep, ScCallStep, ScDeployStep, - SetStateStep, TxExpect, - }, - ContractInfo, ScenarioWorld, -}; +use multiversx_sc_scenario::imports::*; use transfer_role_features::ProxyTrait as _; const ACCEPT_FUNDS_FUNC_NAME: &[u8] = b"accept_funds"; diff --git a/contracts/feature-tests/composability/transfer-role-features/tests/transfer_role_whitebox_test.rs b/contracts/feature-tests/composability/transfer-role-features/tests/transfer_role_whitebox_test.rs index f50b2f88ba..dc733dede9 100644 --- a/contracts/feature-tests/composability/transfer-role-features/tests/transfer_role_whitebox_test.rs +++ b/contracts/feature-tests/composability/transfer-role-features/tests/transfer_role_whitebox_test.rs @@ -1,14 +1,5 @@ -use multiversx_sc::types::{ - Address, EsdtTokenPayment, ManagedArgBuffer, ManagedVec, MultiValueEncoded, -}; use multiversx_sc_modules::transfer_role_proxy::TransferRoleProxyModule; -use multiversx_sc_scenario::{ - managed_address, managed_biguint, managed_buffer, managed_token_id, - scenario_model::{ - Account, AddressValue, CheckAccount, CheckStateStep, ScCallStep, ScDeployStep, SetStateStep, - }, - ScenarioWorld, WhiteboxContract, -}; +use multiversx_sc_scenario::imports::*; use transfer_role_features::TransferRoleFeatures; const OWNER_ADDRESS_EXPR: &str = "address:owner"; diff --git a/contracts/feature-tests/exchange-features/tests/exchange_features_blackbox_test.rs b/contracts/feature-tests/exchange-features/tests/exchange_features_blackbox_test.rs index 6ea73fb3a6..88c87e3931 100644 --- a/contracts/feature-tests/exchange-features/tests/exchange_features_blackbox_test.rs +++ b/contracts/feature-tests/exchange-features/tests/exchange_features_blackbox_test.rs @@ -1,4 +1,4 @@ -use multiversx_sc_scenario::{scenario_model::*, *}; +use multiversx_sc_scenario::imports::*; const EXCHANGE_FEATURES_PATH_EXPR: &str = "mxsc:output/exchange-features.mxsc.json"; diff --git a/contracts/feature-tests/panic-message-features/tests/pmf_blackbox_test.rs b/contracts/feature-tests/panic-message-features/tests/pmf_blackbox_test.rs index ff14571fd9..66b2d9527e 100644 --- a/contracts/feature-tests/panic-message-features/tests/pmf_blackbox_test.rs +++ b/contracts/feature-tests/panic-message-features/tests/pmf_blackbox_test.rs @@ -1,6 +1,6 @@ mod pmf_proxy; -use multiversx_sc::types::{AddressExpr, ScExpr}; -use multiversx_sc_scenario::{scenario_model::*, *}; + +use multiversx_sc_scenario::imports::*; const OWNER: AddressExpr = AddressExpr("owner"); const SC_PMF: ScExpr = ScExpr("pmf"); diff --git a/contracts/feature-tests/payable-features/tests/payable_blackbox_test.rs b/contracts/feature-tests/payable-features/tests/payable_blackbox_test.rs index 6d86ebe77f..82581c8170 100644 --- a/contracts/feature-tests/payable-features/tests/payable_blackbox_test.rs +++ b/contracts/feature-tests/payable-features/tests/payable_blackbox_test.rs @@ -1,4 +1,4 @@ -use multiversx_sc_scenario::{scenario_model::*, *}; +use multiversx_sc_scenario::imports::*; const PF_PATH_EXPR: &str = "mxsc:output/payable-features.mxsc.json"; diff --git a/contracts/feature-tests/rust-snippets-generator-test/interact-rs/src/interactor_main.rs b/contracts/feature-tests/rust-snippets-generator-test/interact-rs/src/interactor_main.rs index e0999b7644..92d00a227d 100644 --- a/contracts/feature-tests/rust-snippets-generator-test/interact-rs/src/interactor_main.rs +++ b/contracts/feature-tests/rust-snippets-generator-test/interact-rs/src/interactor_main.rs @@ -2,19 +2,7 @@ use rust_snippets_generator_test::{ProxyTrait as _, *}; -use multiversx_sc_snippets::{ - env_logger, - erdrs::wallet::Wallet, - multiversx_sc::{codec::multi_types::*, types::*}, - multiversx_sc_scenario::{ - api::StaticApi, - bech32, - scenario_format::interpret_trait::{InterpretableFrom, InterpreterContext}, - scenario_model::*, - ContractInfo, - }, - sdk, tokio, Interactor, -}; +use multiversx_sc_snippets::imports::*; const GATEWAY: &str = sdk::blockchain::DEVNET_GATEWAY; const PEM: &str = "alice.pem"; diff --git a/contracts/feature-tests/rust-testing-framework-tester/tests/tester_blackbox_test.rs b/contracts/feature-tests/rust-testing-framework-tester/tests/tester_blackbox_test.rs index d544af3a04..d927b1ba4a 100644 --- a/contracts/feature-tests/rust-testing-framework-tester/tests/tester_blackbox_test.rs +++ b/contracts/feature-tests/rust-testing-framework-tester/tests/tester_blackbox_test.rs @@ -1,5 +1,5 @@ -use multiversx_sc_scenario::{api::StaticApi, scenario_model::*, *}; -use rust_testing_framework_tester::*; // TODO: clean up imports +use multiversx_sc_scenario::imports::*; +use rust_testing_framework_tester::*; const WASM_PATH_EXPR: &str = "mxsc:output/rust-testing-framework-tester.mxsc.json"; diff --git a/contracts/feature-tests/rust-testing-framework-tester/tests/tester_whitebox_legacy_test.rs b/contracts/feature-tests/rust-testing-framework-tester/tests/tester_whitebox_legacy_test.rs index 1f56f5bb21..1fad8f653a 100644 --- a/contracts/feature-tests/rust-testing-framework-tester/tests/tester_whitebox_legacy_test.rs +++ b/contracts/feature-tests/rust-testing-framework-tester/tests/tester_whitebox_legacy_test.rs @@ -1,20 +1,11 @@ #![allow(deprecated)] // TODO: migrate tests -use adder::*; -use forwarder::call_sync::*; +use multiversx_sc_scenario::imports::*; use num_traits::ToPrimitive; +use adder::*; use basic_features::BasicFeatures; -use multiversx_sc::{ - codec::Empty, - contract_base::ContractBase, - err_msg, - types::{Address, BigUint, EsdtLocalRole, EsdtTokenPayment, ManagedVec, TokenIdentifier}, -}; -use multiversx_sc_scenario::{ - api::DebugApi, assert_values_eq, managed_address, managed_biguint, managed_buffer, - managed_token_id, rust_biguint, testing_framework::*, -}; +use forwarder::call_sync::*; use rust_testing_framework_tester::{dummy_module::DummyModule, *}; const TEST_OUTPUT_PATH: &str = "test.scen.json"; diff --git a/contracts/feature-tests/use-module/tests/gov_module_whitebox_test.rs b/contracts/feature-tests/use-module/tests/gov_module_whitebox_test.rs index fe90f658e4..267639fd6f 100644 --- a/contracts/feature-tests/use-module/tests/gov_module_whitebox_test.rs +++ b/contracts/feature-tests/use-module/tests/gov_module_whitebox_test.rs @@ -1,15 +1,8 @@ -use multiversx_sc::types::{Address, ManagedVec, MultiValueEncoded}; use multiversx_sc_modules::governance::{ governance_configurable::GovernanceConfigurablePropertiesModule, governance_proposal::VoteType, GovernanceModule, }; -use multiversx_sc_scenario::{ - managed_address, managed_biguint, managed_buffer, managed_token_id, - scenario_model::{ - Account, AddressValue, CheckAccount, CheckStateStep, ScCallStep, ScDeployStep, SetStateStep, - }, - ScenarioWorld, WhiteboxContract, -}; +use multiversx_sc_scenario::imports::*; const GOV_TOKEN_ID_EXPR: &str = "str:GOV-123456"; const GOV_TOKEN_ID: &[u8] = b"GOV-123456"; diff --git a/contracts/feature-tests/use-module/tests/staking_module_whitebox_test.rs b/contracts/feature-tests/use-module/tests/staking_module_whitebox_test.rs index 91a96db16a..049936bb44 100644 --- a/contracts/feature-tests/use-module/tests/staking_module_whitebox_test.rs +++ b/contracts/feature-tests/use-module/tests/staking_module_whitebox_test.rs @@ -1,12 +1,5 @@ -use multiversx_sc::types::{Address, EgldOrEsdtTokenIdentifier, ManagedVec}; use multiversx_sc_modules::staking::StakingModule; -use multiversx_sc_scenario::{ - managed_address, managed_biguint, managed_token_id, - scenario_model::{ - Account, AddressValue, CheckAccount, CheckStateStep, ScCallStep, ScDeployStep, SetStateStep, - }, - ScenarioWorld, WhiteboxContract, -}; +use multiversx_sc_scenario::imports::*; const STAKING_TOKEN_ID_EXPR: &str = "str:STAKE-123456"; const STAKING_TOKEN_ID: &[u8] = b"STAKE-123456"; diff --git a/contracts/feature-tests/use-module/tests/token_merge_module_whitebox_test.rs b/contracts/feature-tests/use-module/tests/token_merge_module_whitebox_test.rs index a970685918..eb93ff155a 100644 --- a/contracts/feature-tests/use-module/tests/token_merge_module_whitebox_test.rs +++ b/contracts/feature-tests/use-module/tests/token_merge_module_whitebox_test.rs @@ -1,20 +1,8 @@ -use multiversx_sc::{ - arrayvec::ArrayVec, - codec::{test_util::top_encode_to_vec_u8_or_panic, Empty}, - contract_base::ContractBase, - storage::mappers::StorageTokenWrapper, - types::{Address, EsdtTokenPayment, ManagedVec}, -}; +use multiversx_sc_scenario::imports::*; + use multiversx_sc_modules::token_merge::{ merged_token_instances::MergedTokenInstances, merged_token_setup::MergedTokenSetupModule, }; -use multiversx_sc_scenario::{ - managed_address, managed_biguint, managed_token_id, - scenario_model::{ - Account, AddressValue, CheckAccount, CheckStateStep, ScCallStep, SetStateStep, TxESDT, - }, - ScenarioWorld, WhiteboxContract, -}; use use_module::token_merge_mod_impl::{CustomAttributes, TokenMergeModImpl}; const OWNER_ADDRESS_EXPR: &str = "address:owner"; diff --git a/framework/base/src/imports_reexport.rs b/framework/base/src/imports_reexport.rs index 710bd8bbf3..e023525e9d 100644 --- a/framework/base/src/imports_reexport.rs +++ b/framework/base/src/imports_reexport.rs @@ -5,8 +5,8 @@ pub mod imports { api::{ErrorApiImpl, ManagedTypeApi, VMApi}, arrayvec::ArrayVec, codec::{ - multi_types::*, CodecFrom, CodecFromSelf, CodecInto, DecodeError, IntoMultiValue, - NestedDecode, NestedEncode, TopDecode, TopEncode, + multi_types::*, CodecFrom, CodecFromSelf, CodecInto, DecodeError, Empty, + IntoMultiValue, NestedDecode, NestedEncode, TopDecode, TopEncode, }, contract_base::{ContractBase, ProxyObjBase, ProxyObjNew}, err_msg, diff --git a/framework/meta/src/cmd/contract/generate_snippets/snippet_template_gen.rs b/framework/meta/src/cmd/contract/generate_snippets/snippet_template_gen.rs index 0feb12e562..093afa908c 100644 --- a/framework/meta/src/cmd/contract/generate_snippets/snippet_template_gen.rs +++ b/framework/meta/src/cmd/contract/generate_snippets/snippet_template_gen.rs @@ -12,19 +12,7 @@ pub(crate) fn write_snippet_imports(file: &mut File, contract_crate_name: &str) use {contract_crate_name}::ProxyTrait as _; use {contract_crate_name}::*; -use multiversx_sc_snippets::{{ - env_logger, - erdrs::wallet::Wallet, - multiversx_sc::{{codec::multi_types::*, types::*}}, - multiversx_sc_scenario::{{ - api::StaticApi, - bech32, - scenario_format::interpret_trait::{{InterpretableFrom, InterpreterContext}}, - scenario_model::*, - ContractInfo, - }}, - sdk, tokio, Interactor, -}}; +use multiversx_sc_snippets::imports::*; " ) .unwrap(); diff --git a/framework/scenario/src/facade.rs b/framework/scenario/src/facade.rs index a37265e0b4..77a00e4792 100644 --- a/framework/scenario/src/facade.rs +++ b/framework/scenario/src/facade.rs @@ -1,13 +1,14 @@ mod contract_info; mod debugger_backend; -pub(crate) mod result_handlers; +pub mod expr; +pub mod result_handlers; mod scenario_world; mod scenario_world_runner; mod scenario_world_steps; mod scenario_world_steps_deprecated; mod scenario_world_whitebox; mod whitebox_contract; -pub(crate) mod world_tx; +pub mod world_tx; pub use contract_info::ContractInfo; pub use scenario_world::ScenarioWorld; diff --git a/framework/scenario/src/facade/world_tx/expr.rs b/framework/scenario/src/facade/expr.rs similarity index 100% rename from framework/scenario/src/facade/world_tx/expr.rs rename to framework/scenario/src/facade/expr.rs diff --git a/framework/scenario/src/facade/world_tx/expr/file_expr.rs b/framework/scenario/src/facade/expr/file_expr.rs similarity index 83% rename from framework/scenario/src/facade/world_tx/expr/file_expr.rs rename to framework/scenario/src/facade/expr/file_expr.rs index d9d3c77756..f197ce4e16 100644 --- a/framework/scenario/src/facade/world_tx/expr/file_expr.rs +++ b/framework/scenario/src/facade/expr/file_expr.rs @@ -1,13 +1,7 @@ -use core::ptr; -use std::path::PathBuf; - use multiversx_chain_scenario_format::{ interpret_trait::InterpreterContext, value_interpreter::interpret_string, }; -use multiversx_sc::types::{ - AnnotatedValue, ManagedAddress, ManagedBuffer, TxEnv, TxFrom, TxFromSpecified, TxTo, - TxToSpecified, -}; +use multiversx_sc::types::{AnnotatedValue, ManagedBuffer}; use crate::{api::StaticApi, ScenarioTxEnvData}; diff --git a/framework/scenario/src/facade/world_tx/expr/mxsc_expr.rs b/framework/scenario/src/facade/expr/mxsc_expr.rs similarity index 78% rename from framework/scenario/src/facade/world_tx/expr/mxsc_expr.rs rename to framework/scenario/src/facade/expr/mxsc_expr.rs index c0f574e8cd..0946b93327 100644 --- a/framework/scenario/src/facade/world_tx/expr/mxsc_expr.rs +++ b/framework/scenario/src/facade/expr/mxsc_expr.rs @@ -1,15 +1,9 @@ -use core::ptr; -use std::path::PathBuf; - use multiversx_chain_scenario_format::{ interpret_trait::InterpreterContext, value_interpreter::interpret_string, }; -use multiversx_sc::types::{ - AnnotatedValue, ManagedAddress, ManagedBuffer, TxCodeValue, TxEnv, TxFrom, TxFromSpecified, - TxTo, TxToSpecified, -}; +use multiversx_sc::types::{AnnotatedValue, ManagedBuffer, TxCodeValue}; -use crate::{api::StaticApi, ScenarioEnvExec, ScenarioTxEnv, ScenarioTxEnvData}; +use crate::ScenarioTxEnv; const MXSC_PREFIX: &str = "mxsc:"; diff --git a/framework/scenario/src/facade/world_tx/expr/num_expr.rs b/framework/scenario/src/facade/expr/num_expr.rs similarity index 73% rename from framework/scenario/src/facade/world_tx/expr/num_expr.rs rename to framework/scenario/src/facade/expr/num_expr.rs index de9137b8fc..704f52496b 100644 --- a/framework/scenario/src/facade/world_tx/expr/num_expr.rs +++ b/framework/scenario/src/facade/expr/num_expr.rs @@ -1,16 +1,12 @@ -use crate::{api::StaticApi, ScenarioEnvExec, ScenarioTxEnv, ScenarioTxEnvData}; -use core::ptr; +use crate::ScenarioTxEnv; + use multiversx_chain_scenario_format::{ interpret_trait::InterpreterContext, value_interpreter::interpret_string, }; use multiversx_sc::{ api::ManagedTypeApi, - types::{ - AnnotatedValue, BigUint, ManagedAddress, ManagedBuffer, TxCodeValue, TxEgldValue, TxEnv, - TxFrom, TxFromSpecified, TxGasValue, TxTo, TxToSpecified, - }, + types::{AnnotatedValue, BigUint, ManagedBuffer, TxEgldValue, TxGasValue}, }; -use std::path::PathBuf; #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct NumExpr<'a>(pub &'a str); @@ -31,7 +27,7 @@ where self.0.into() } - fn to_value(&self, env: &Env) -> BigUint { + fn to_value(&self, _env: &Env) -> BigUint { interpret_big_uint(self.0) } } @@ -44,7 +40,7 @@ where self.0.into() } - fn to_value(&self, env: &Env) -> u64 { + fn to_value(&self, _env: &Env) -> u64 { interpret_big_uint::(self.0).to_u64().unwrap() } } diff --git a/framework/scenario/src/facade/world_tx.rs b/framework/scenario/src/facade/world_tx.rs index b72fe5b88c..2fa69c744e 100644 --- a/framework/scenario/src/facade/world_tx.rs +++ b/framework/scenario/src/facade/world_tx.rs @@ -1,13 +1,11 @@ #![allow(unused)] // TEMP -mod expr; mod scenario_env; mod scenario_env_deploy; mod scenario_env_exec; mod scenario_env_query; mod scenario_rh_impl; -pub use expr::*; -pub use scenario_env::*; +pub use scenario_env::{ScenarioTxEnv, ScenarioTxEnvData, ScenarioTxRun}; pub use scenario_env_exec::ScenarioEnvExec; pub use scenario_env_query::ScenarioEnvQuery; diff --git a/framework/scenario/src/imports.rs b/framework/scenario/src/imports.rs new file mode 100644 index 0000000000..aa30283dc3 --- /dev/null +++ b/framework/scenario/src/imports.rs @@ -0,0 +1,27 @@ +pub use crate::multiversx_sc::imports::*; + +pub use crate::multiversx_sc::codec::test_util::*; + +pub use crate::{ + api::{DebugApi, StaticApi}, + assert_values_eq, bech32, + facade::{ + expr::*, result_handlers::*, world_tx::*, ContractInfo, ScenarioWorld, WhiteboxContract, + }, + managed_address, managed_biguint, managed_buffer, managed_token_id, num_bigint, + num_bigint::BigUint as RustBigUint, + rust_biguint, + scenario::{ + model::{ + Account, AddressValue, BytesValue, CheckAccount, CheckStateStep, ScCallStep, + ScDeployStep, ScQueryStep, Scenario, SetStateStep, TransferStep, TxESDT, TxExpect, + TypedResponse, TypedScCall, TypedScDeploy, + }, + ScenarioRunner, + }, + scenario_format::interpret_trait::{InterpretableFrom, InterpreterContext}, + standalone::retrieve_account_as_scenario_set_state, + test_wallets, + whitebox_legacy::*, + ScenarioTxRun, +}; diff --git a/framework/scenario/src/lib.rs b/framework/scenario/src/lib.rs index 64229851af..4d3fb3b1dc 100644 --- a/framework/scenario/src/lib.rs +++ b/framework/scenario/src/lib.rs @@ -8,7 +8,7 @@ pub mod display_util; mod facade; pub mod managed_test_util; pub mod scenario; -mod scenario_macros; +pub mod scenario_macros; pub mod standalone; pub mod test_wallets; mod vm_go_tool; @@ -43,6 +43,9 @@ pub use facade::{result_handlers::*, world_tx::*, ContractInfo, ScenarioWorld, W use std::path::Path; +/// Imports normally needed in integration tests, grouped together. +pub mod imports; + /// Legacy function for running a scenario test using the Go VM tool. /// /// Use `sc-meta test-gen` to replace all calls to it automatically. diff --git a/framework/snippets/src/imports.rs b/framework/snippets/src/imports.rs new file mode 100644 index 0000000000..b031e0769c --- /dev/null +++ b/framework/snippets/src/imports.rs @@ -0,0 +1,6 @@ +pub use crate::multiversx_sc_scenario::imports::*; + +pub use crate::{dns_address_for_name, Interactor, InteractorPrepareAsync, StepBuffer}; + +pub use env_logger; +pub use tokio; diff --git a/framework/snippets/src/lib.rs b/framework/snippets/src/lib.rs index 70f3f8e792..b94a6517d9 100644 --- a/framework/snippets/src/lib.rs +++ b/framework/snippets/src/lib.rs @@ -18,3 +18,6 @@ pub use multiversx_sc_scenario::{self, multiversx_sc}; pub use multiversx_sdk as erdrs; // TODO: remove pub use multiversx_sdk as sdk; pub use tokio; + +/// Imports normally needed in interactors, grouped together. +pub mod imports;