From b76615218aae62a8711e1c88ca29798df287c277 Mon Sep 17 00:00:00 2001 From: Andrei Marinica Date: Fri, 14 Jul 2023 14:11:53 +0300 Subject: [PATCH] ScDeployStep code metadata default --- .../adder/interact/src/adder_interact.rs | 7 +------ .../interact-rs/src/multisig_interact.rs | 6 +----- .../interact/src/bf_interact.rs | 3 +-- .../interact/src/call_tree_deploy.rs | 4 +--- .../interact-rs/src/lib.rs | 1 - .../snippet_sc_functions_gen.rs | 1 - .../src/scenario/model/step/step_sc_deploy.rs | 19 ++++++++++++++++++- 7 files changed, 22 insertions(+), 19 deletions(-) diff --git a/contracts/examples/adder/interact/src/adder_interact.rs b/contracts/examples/adder/interact/src/adder_interact.rs index 66aa65e724..fdfecfd047 100644 --- a/contracts/examples/adder/interact/src/adder_interact.rs +++ b/contracts/examples/adder/interact/src/adder_interact.rs @@ -8,10 +8,7 @@ use adder_interact_state::State; use clap::Parser; use multiversx_sc_snippets::{ env_logger, - multiversx_sc::{ - storage::mappers::SingleValue, - types::{Address, CodeMetadata}, - }, + multiversx_sc::{storage::mappers::SingleValue, types::Address}, multiversx_sc_scenario::{ api::StaticApi, bech32, @@ -106,7 +103,6 @@ impl AdderInteract { ScDeployStep::new() .call(self.state.default_adder().init(BigUint::from(0u64))) .from(&self.wallet_address) - .code_metadata(CodeMetadata::all()) .code(&self.adder_code) .gas_limit("5,000,000") .expect(TxExpect::ok()), @@ -138,7 +134,6 @@ impl AdderInteract { let typed_sc_deploy = ScDeployStep::new() .call(self.state.default_adder().init(0u32)) .from(&self.wallet_address) - .code_metadata(CodeMetadata::all()) .code(&self.adder_code) .gas_limit("70,000,000") .expect(TxExpect::ok()); diff --git a/contracts/examples/multisig/interact-rs/src/multisig_interact.rs b/contracts/examples/multisig/interact-rs/src/multisig_interact.rs index c0f203bc9b..933f9f0ddd 100644 --- a/contracts/examples/multisig/interact-rs/src/multisig_interact.rs +++ b/contracts/examples/multisig/interact-rs/src/multisig_interact.rs @@ -19,9 +19,7 @@ use multiversx_sc_scenario::{ use multiversx_sc_snippets::{ dns_address_for_name, env_logger, multiversx_sc::{ - codec::multi_types::MultiValueVec, - storage::mappers::SingleValue, - types::{Address, CodeMetadata}, + codec::multi_types::MultiValueVec, storage::mappers::SingleValue, types::Address, }, multiversx_sc_scenario::{ api::StaticApi, bech32, scenario_format::interpret_trait::InterpreterContext, @@ -167,7 +165,6 @@ impl MultisigInteract { .init(Config::load_config().quorum(), board) .into_blockchain_call() .from(&self.wallet_address) - .code_metadata(CodeMetadata::all()) .code(&self.multisig_code) .gas_limit("70,000,000") .expect(TxExpect::ok()); @@ -205,7 +202,6 @@ impl MultisigInteract { .init(Config::load_config().quorum(), board.clone()), ) .from(&self.wallet_address) - .code_metadata(CodeMetadata::all()) .code(&self.multisig_code) .gas_limit("70,000,000") .expect(TxExpect::ok()); 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 c3b60fa137..4259fd2186 100644 --- a/contracts/feature-tests/basic-features/interact/src/bf_interact.rs +++ b/contracts/feature-tests/basic-features/interact/src/bf_interact.rs @@ -10,7 +10,7 @@ use bf_interact_state::State; use clap::Parser; use multiversx_sc_snippets::{ env_logger, - multiversx_sc::types::{Address, CodeMetadata}, + multiversx_sc::types::Address, multiversx_sc_scenario::{ api::StaticApi, bech32, @@ -106,7 +106,6 @@ impl BasicFeaturesInteract { ScDeployStep::new() .call(self.state.default_contract().init()) .from(&self.wallet_address) - .code_metadata(CodeMetadata::all()) .code(&self.code_expr) .gas_limit("4,000,000") .expect(TxExpect::ok()), 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 91c2e2b574..e072b17308 100644 --- a/contracts/feature-tests/composability/interact/src/call_tree_deploy.rs +++ b/contracts/feature-tests/composability/interact/src/call_tree_deploy.rs @@ -4,7 +4,7 @@ use forwarder_queue::ProxyTrait as _; use multiversx_sc_snippets::{ multiversx_sc::{ codec::multi_types::OptionalValue, - types::{BoxedBytes, CodeMetadata, ManagedBuffer}, + types::{BoxedBytes, ManagedBuffer}, }, multiversx_sc_scenario::{ api::StaticApi, @@ -84,7 +84,6 @@ impl ComposabilityInteract { .init(OptionalValue::::None), ) .from(&self.wallet_address) - .code_metadata(CodeMetadata::all()) .code(&self.vault_code) .gas_limit("70,000,000") .expect(TxExpect::ok()); @@ -104,7 +103,6 @@ impl ComposabilityInteract { let typed_sc_deploy = ScDeployStep::new() .call(self.state.default_forwarder_queue_address().init()) .from(&self.wallet_address) - .code_metadata(CodeMetadata::all()) .code(&self.forw_queue_code) .gas_limit("70,000,000") .expect(TxExpect::ok()); diff --git a/contracts/feature-tests/rust-snippets-generator-test/interact-rs/src/lib.rs b/contracts/feature-tests/rust-snippets-generator-test/interact-rs/src/lib.rs index 47d239cd98..e1adf9fb9c 100644 --- a/contracts/feature-tests/rust-snippets-generator-test/interact-rs/src/lib.rs +++ b/contracts/feature-tests/rust-snippets-generator-test/interact-rs/src/lib.rs @@ -85,7 +85,6 @@ impl State { .init() .into_blockchain_call() .from(&self.wallet_address) - .code_metadata(CodeMetadata::all()) .contract_code( "file:../output/rust-snippets-generator-test.wasm", &InterpreterContext::default(), diff --git a/framework/meta/src/cmd/contract/generate_snippets/snippet_sc_functions_gen.rs b/framework/meta/src/cmd/contract/generate_snippets/snippet_sc_functions_gen.rs index 5f4e7abafd..ce81e57b20 100644 --- a/framework/meta/src/cmd/contract/generate_snippets/snippet_sc_functions_gen.rs +++ b/framework/meta/src/cmd/contract/generate_snippets/snippet_sc_functions_gen.rs @@ -56,7 +56,6 @@ fn write_deploy_method_impl( .{}({}) .into_blockchain_call() .from(&self.wallet_address) - .code_metadata(CodeMetadata::all()) .contract_code({}, &InterpreterContext::default()) .gas_limit(DEFAULT_GAS_LIMIT); diff --git a/framework/scenario/src/scenario/model/step/step_sc_deploy.rs b/framework/scenario/src/scenario/model/step/step_sc_deploy.rs index f4144b9005..bf5d12af1c 100644 --- a/framework/scenario/src/scenario/model/step/step_sc_deploy.rs +++ b/framework/scenario/src/scenario/model/step/step_sc_deploy.rs @@ -14,7 +14,7 @@ use crate::multiversx_sc::types::{CodeMetadata, ContractDeploy}; use super::{convert_call_args, TypedScDeploy}; -#[derive(Debug, Default, Clone)] +#[derive(Debug, Clone)] pub struct ScDeployStep { pub id: String, pub tx_id: Option, @@ -25,6 +25,23 @@ pub struct ScDeployStep { pub response: Option, } +impl Default for ScDeployStep { + fn default() -> Self { + Self { + id: Default::default(), + tx_id: Default::default(), + explicit_tx_hash: Default::default(), + comment: Default::default(), + tx: Box::new(TxDeploy { + code_metadata: CodeMetadata::all(), + ..Default::default() + }), + expect: Default::default(), + response: Default::default(), + } + } +} + impl ScDeployStep { pub fn new() -> Self { Self::default()