diff --git a/.github/workflows/actions-nightly.yml b/.github/workflows/actions-nightly.yml index a94745de41..355a53883c 100644 --- a/.github/workflows/actions-nightly.yml +++ b/.github/workflows/actions-nightly.yml @@ -16,7 +16,7 @@ jobs: name: Contracts (nightly) uses: multiversx/mx-sc-actions/.github/workflows/contracts.yml@v3.2.0 with: - rust-toolchain: nightly-2023-12-11 + rust-toolchain: nightly-2024-05-22 path-to-sc-meta: framework/meta enable-contracts-size-report: false mx-scenario-go-version: v2.1.0-alpha diff --git a/contracts/feature-tests/abi-tester/src/abi_test_type.rs b/contracts/feature-tests/abi-tester/src/abi_test_type.rs index ff4f76b744..d37832f20d 100644 --- a/contracts/feature-tests/abi-tester/src/abi_test_type.rs +++ b/contracts/feature-tests/abi-tester/src/abi_test_type.rs @@ -39,5 +39,6 @@ pub struct AbiManagedVecItem { #[type_abi] pub struct OnlyShowsUpInEsdtAttr { + #[allow(dead_code)] pub field: OnlyShowsUpAsNested10, } diff --git a/contracts/feature-tests/abi-tester/tests/abi_tester_abi_test.rs b/contracts/feature-tests/abi-tester/tests/abi_tester_abi_test.rs index 756eb70ea4..4ef78f351b 100644 --- a/contracts/feature-tests/abi-tester/tests/abi_tester_abi_test.rs +++ b/contracts/feature-tests/abi-tester/tests/abi_tester_abi_test.rs @@ -70,7 +70,7 @@ fn abi_tester_esdt_attr_abi_generated_ok() { #[test] fn check_multi_contract_config() { - let mut blockchain = ScenarioWorld::new(); + let blockchain = ScenarioWorld::new(); let multi_contract_config = multiversx_sc_meta::multi_contract_config::( blockchain.current_dir().as_path(), 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 409ce234a7..1c2457494b 100644 --- a/contracts/feature-tests/composability/interact/src/comp_interact_controller.rs +++ b/contracts/feature-tests/composability/interact/src/comp_interact_controller.rs @@ -9,6 +9,7 @@ pub struct ComposabilityInteract { pub wallet_address: Address, pub forw_queue_code: BytesValue, pub vault_code: BytesValue, + #[allow(dead_code)] pub state: State, } diff --git a/framework/base/src/types/interaction/tx_data/tx_code_source.rs b/framework/base/src/types/interaction/tx_data/tx_code_source.rs index e7bb0817ea..0d3c180e16 100644 --- a/framework/base/src/types/interaction/tx_data/tx_code_source.rs +++ b/framework/base/src/types/interaction/tx_data/tx_code_source.rs @@ -14,6 +14,11 @@ where { } +#[diagnostic::on_unimplemented( + message = "Type `{Self}` cannot be used as code (does not implement `TxCodeValue<{Env}>`)", + label = "not a valid smart contract byte code", + note = "there are multiple ways to specify SC byte code, but `{Self}` is not one of them" +)] pub trait TxCodeValue: AnnotatedValue> where Env: TxEnv, @@ -39,6 +44,11 @@ where { } +#[diagnostic::on_unimplemented( + message = "Type `{Self}` cannot be used as code source value (does not implement `TxFromSourceValue<{Env}>`)", + label = "not an address from where to copy the code", + note = "there are multiple ways to specify a code source address, but `{Self}` is not one of them" +)] pub trait TxFromSourceValue: AnnotatedValue> where Env: TxEnv, diff --git a/framework/base/src/types/interaction/tx_exec/tx_exec_async_promises.rs b/framework/base/src/types/interaction/tx_exec/tx_exec_async_promises.rs index ad8d8d4145..1e1dee40a4 100644 --- a/framework/base/src/types/interaction/tx_exec/tx_exec_async_promises.rs +++ b/framework/base/src/types/interaction/tx_exec/tx_exec_async_promises.rs @@ -1,6 +1,6 @@ use crate::{ api::{const_handles, CallTypeApi}, - contract_base::SendRawWrapper, + contract_base::{ErrorHelper, SendRawWrapper}, types::{ interaction::callback_closure::CallbackClosureWithGas, CallbackClosure, ExplicitGas, FunctionCall, ManagedBuffer, ManagedType, OriginalResultMarker, Tx, TxGas, TxGasValue, @@ -143,6 +143,20 @@ where GasValue: TxGasValue>, Callback: TxPromisesCallback, { + /// Launches a transaction as an asynchronous promise (async v2 mechanism). + /// + /// Several such transactions can be launched from a single transaction. + /// + /// Must set: + /// - to + /// - gas + /// - a function call, ideally via a proxy. + /// + /// Value-only promises are not supported. + /// + /// Optionally, can add: + /// - any payment + /// - a promise callback, which also needs explicit gas for callback. pub fn register_promise(self) { let callback_name = self.result_handler.callback_name(); let mut cb_closure_args_serialized = @@ -174,6 +188,65 @@ where } } +impl Tx, (), To, Payment, (), FunctionCall, Callback> +where + Api: CallTypeApi, + To: TxToSpecified>, + Payment: TxPayment>, + Callback: TxPromisesCallback, +{ + /// ## Incorrect call + /// + /// Must set **gas** in order to call `register_promise`. + /// + /// ## Safety + /// + /// This version of the method must never be called. It is only here to provide a more readable error. + pub unsafe fn register_promise(self) { + ErrorHelper::::signal_error_with_message("register_promise requires explicit gas"); + } +} + +impl Tx, (), To, Payment, (), (), Callback> +where + Api: CallTypeApi, + To: TxToSpecified>, + Payment: TxPayment>, + Callback: TxPromisesCallback, +{ + /// ## Incorrect call + /// + /// Must set **gas** and **function call** in order to call `register_promise`. + /// + /// ## Safety + /// + /// This version of the method must never be called. It is only here to provide a more readable error. + pub unsafe fn register_promise(self) { + ErrorHelper::::signal_error_with_message("register_promise requires explicit gas and function call"); + } +} + +impl + Tx, (), To, Payment, ExplicitGas, (), Callback> +where + Api: CallTypeApi, + To: TxToSpecified>, + Payment: TxPayment>, + GasValue: TxGasValue>, + Callback: TxPromisesCallback, +{ + /// ## Incorrect call + /// + /// Must set **function call** in order to call `register_promise`. + /// + /// ## Safety + /// + /// This version of the method must never be called. It is only here to provide a more readable error. + pub unsafe fn register_promise(self) { + ErrorHelper::::signal_error_with_message("register_promise requires function call"); + } +} + impl Tx, (), To, Payment, Gas, FunctionCall, Callback> where diff --git a/framework/base/src/types/interaction/tx_from.rs b/framework/base/src/types/interaction/tx_from.rs index ff5dd73b88..674796e64f 100644 --- a/framework/base/src/types/interaction/tx_from.rs +++ b/framework/base/src/types/interaction/tx_from.rs @@ -13,6 +13,11 @@ where /// Marks the non-empty sender of a transaction. /// /// Enforces the reciipent to be explicitly specified. +#[diagnostic::on_unimplemented( + message = "Type `{Self}` cannot be used as a sender value (does not implement `TxFromSpecified<{Env}>`)", + label = "sender needs to be explicit", + note = "there are multiple ways to specify the sender value for a transaction, but `{Self}` is not one of them" +)] pub trait TxFromSpecified: TxFrom + AnnotatedValue> where diff --git a/framework/base/src/types/interaction/tx_gas.rs b/framework/base/src/types/interaction/tx_gas.rs index 986361e473..2e03cc1470 100644 --- a/framework/base/src/types/interaction/tx_gas.rs +++ b/framework/base/src/types/interaction/tx_gas.rs @@ -4,6 +4,7 @@ use crate::{ types::ManagedBuffer, }; +/// All typed that populate the gas field of a transaction need to implement this trait. pub trait TxGas where Env: TxEnv, @@ -32,6 +33,11 @@ where } } +#[diagnostic::on_unimplemented( + message = "Type `{Self}` cannot be used as gas value (does not implement `TxGasValue<{Env}>`)", + label = "not a valid value for gas", + note = "there are multiple ways to specify the gas value for a transaction, but `{Self}` is not one of them" +)] pub trait TxGasValue: AnnotatedValue where Env: TxEnv, diff --git a/framework/base/src/types/interaction/tx_payment.rs b/framework/base/src/types/interaction/tx_payment.rs index 5abb38c6ee..c5bcc10637 100644 --- a/framework/base/src/types/interaction/tx_payment.rs +++ b/framework/base/src/types/interaction/tx_payment.rs @@ -24,6 +24,11 @@ use crate::{ use super::{AnnotatedValue, FunctionCall, TxEnv, TxFrom, TxToSpecified}; /// Describes a payment that is part of a transaction. +#[diagnostic::on_unimplemented( + message = "Type `{Self}` cannot be used as payment (does not implement `TxPayment<{Env}>`)", + label = "not a valid payment type", + note = "there are multiple ways to specify the transaction payment, but `{Self}` is not one of them" +)] pub trait TxPayment where Env: TxEnv, diff --git a/framework/base/src/types/interaction/tx_result_handler_list/tx_result_handler_list_item.rs b/framework/base/src/types/interaction/tx_result_handler_list/tx_result_handler_list_item.rs index 54e1d0cfa3..9ca98bac65 100644 --- a/framework/base/src/types/interaction/tx_result_handler_list/tx_result_handler_list_item.rs +++ b/framework/base/src/types/interaction/tx_result_handler_list/tx_result_handler_list_item.rs @@ -3,6 +3,11 @@ use crate::types::TxEnv; /// Result handler list item. /// /// It acts as a result handler that produces a single result. +#[diagnostic::on_unimplemented( + message = "Type `{Self}` cannot be used as a decoder result handler (does not implement `RHListItem<{Env}>`)", + label = "not a valid decoder result handler", + note = "there are multiple ways to specify the result handling, but `{Self}` is not one of them" +)] pub trait RHListItem where Env: TxEnv, diff --git a/framework/base/src/types/interaction/tx_to.rs b/framework/base/src/types/interaction/tx_to.rs index 55c77247df..41d5d4ce39 100644 --- a/framework/base/src/types/interaction/tx_to.rs +++ b/framework/base/src/types/interaction/tx_to.rs @@ -13,7 +13,12 @@ impl TxTo for () where Env: TxEnv {} /// Marks the non-empty recipient of a transaction. /// -/// Enforces the reciipent to be explicitly specified. +/// Enforces the recipient to be explicitly specified. +#[diagnostic::on_unimplemented( + message = "Type `{Self}` cannot be used as recipient value (does not implement `TxToSpecified<{Env}>`)", + label = "recipient needs to be explicit", + note = "there are multiple ways to specify the recipient value for a transaction, but `{Self}` is not one of them" +)] pub trait TxToSpecified: TxTo + AnnotatedValue> where Env: TxEnv, diff --git a/framework/derive/src/model/contract_trait.rs b/framework/derive/src/model/contract_trait.rs index a3e5594a5a..3d3f838c7c 100644 --- a/framework/derive/src/model/contract_trait.rs +++ b/framework/derive/src/model/contract_trait.rs @@ -10,6 +10,7 @@ pub struct ContractTrait { /// It is possible to automatically implement a contract module for all contracts that use it indirectly. /// The drawback is that the developer make sure multiple inheritance does not happen. /// This feature is currently disabled. + #[allow(dead_code)] pub auto_inheritance_modules: Vec, pub methods: Vec, diff --git a/framework/derive/src/model/supertrait.rs b/framework/derive/src/model/supertrait.rs index 428bb5ea9c..e5aad040c4 100644 --- a/framework/derive/src/model/supertrait.rs +++ b/framework/derive/src/model/supertrait.rs @@ -6,6 +6,7 @@ pub type ModulePath = Punctuated; #[derive(Clone, Debug)] pub struct Supertrait { pub full_path: syn::Path, + #[allow(dead_code)] pub trait_name: syn::PathSegment, pub module_path: ModulePath, } diff --git a/framework/meta/src/cmd/contract/generate_proxy/proxy_generator.rs b/framework/meta/src/cmd/contract/generate_proxy/proxy_generator.rs index 79a25ad838..5567f4b1ee 100644 --- a/framework/meta/src/cmd/contract/generate_proxy/proxy_generator.rs +++ b/framework/meta/src/cmd/contract/generate_proxy/proxy_generator.rs @@ -40,6 +40,7 @@ const TYPES_FROM_FRAMEWORK: &[&str] = &[ ]; pub struct ProxyGenerator<'a> { + #[allow(dead_code)] pub meta_config: &'a MetaConfig, pub file: Option<&'a mut dyn std::io::Write>, pub proxy_config: &'a ProxyConfigSerde, diff --git a/framework/meta/src/cmd/standalone/install/install_scenario_go.rs b/framework/meta/src/cmd/standalone/install/install_scenario_go.rs index 0a5798f792..9e874fb674 100644 --- a/framework/meta/src/cmd/standalone/install/install_scenario_go.rs +++ b/framework/meta/src/cmd/standalone/install/install_scenario_go.rs @@ -16,6 +16,7 @@ const CARGO_HOME: &str = env!("CARGO_HOME"); #[derive(Clone, Debug)] pub struct ScenarioGoRelease { + #[allow(dead_code)] pub tag_name: String, pub download_url: String, } diff --git a/framework/scenario/tests/scenarios_self_test.rs b/framework/scenario/tests/scenarios_self_test.rs index e45c7ab01e..b6bf9c1883 100644 --- a/framework/scenario/tests/scenarios_self_test.rs +++ b/framework/scenario/tests/scenarios_self_test.rs @@ -1,10 +1,9 @@ use multiversx_sc_scenario::*; -// These tests don't really test any contract, but the testing framework itslef. +// These tests don't really test any contract, but the testing framework itself. fn world() -> ScenarioWorld { - let mut blockchain = ScenarioWorld::new(); - blockchain + ScenarioWorld::new() } /// Checks that externalSteps work fine.