diff --git a/client/src/client.rs b/client/src/client.rs index 3d2178b8c54..6926cb5c44f 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -21,7 +21,7 @@ use http_default::{AsyncWebSocketStream, WebSocketStream}; use iroha_config::{client::Configuration, torii::uri, GetConfiguration, PostConfiguration}; use iroha_crypto::{HashOf, KeyPair}; use iroha_data_model::{ - block::VersionedCommittedBlock, predicate::PredicateBox, prelude::*, + block::VersionedCommittedBlock, isi::Instruction, predicate::PredicateBox, prelude::*, transaction::TransactionPayload, ValidationFail, }; use iroha_logger::prelude::*; diff --git a/client/tests/integration/burn_public_keys.rs b/client/tests/integration/burn_public_keys.rs index 771329e76fe..aece78e66ce 100644 --- a/client/tests/integration/burn_public_keys.rs +++ b/client/tests/integration/burn_public_keys.rs @@ -2,7 +2,7 @@ use iroha_client::client::{account, transaction, Client}; use iroha_crypto::{KeyPair, PublicKey}; -use iroha_data_model::prelude::*; +use iroha_data_model::{isi::Instruction, prelude::*}; use test_network::*; fn submit_and_get( diff --git a/client/tests/integration/events/pipeline.rs b/client/tests/integration/events/pipeline.rs index d649d2c3b1a..40c009ea370 100644 --- a/client/tests/integration/events/pipeline.rs +++ b/client/tests/integration/events/pipeline.rs @@ -116,7 +116,14 @@ fn committed_block_must_be_available_in_kura() { .expect("Failed to submit transaction"); let event = event_iter.next().expect("Block must be committed"); - let Ok(Event::Pipeline(PipelineEvent { entity_kind: PipelineEntityKind::Block, status: PipelineStatus::Committed, hash })) = event else { panic!("Received unexpected event") }; + let Ok(Event::Pipeline(PipelineEvent { + entity_kind: PipelineEntityKind::Block, + status: PipelineStatus::Committed, + hash, + })) = event + else { + panic!("Received unexpected event") + }; let hash = HashOf::from_untyped_unchecked(hash); peer.iroha diff --git a/client/tests/integration/query_errors.rs b/client/tests/integration/query_errors.rs index bbd10f252b3..636048cb75b 100644 --- a/client/tests/integration/query_errors.rs +++ b/client/tests/integration/query_errors.rs @@ -24,7 +24,7 @@ fn non_existent_account_is_specific_error() { match err { ClientQueryError::Validation(ValidationFail::QueryFailed(QueryExecutionFail::Find( err, - ))) => match *err { + ))) => match err { FindError::Domain(id) => assert_eq!(id.name.as_ref(), "regalia"), x => panic!("FindError::Domain expected, got {x:?}"), }, diff --git a/client/tests/integration/triggers/by_call_trigger.rs b/client/tests/integration/triggers/by_call_trigger.rs index 5e725d3ae95..be9c00796a6 100644 --- a/client/tests/integration/triggers/by_call_trigger.rs +++ b/client/tests/integration/triggers/by_call_trigger.rs @@ -200,8 +200,7 @@ fn trigger_should_not_be_executed_with_zero_repeats_count() -> Result<()> { .chain() .last() .expect("At least two error causes expected") - .downcast_ref::>() - .map(std::ops::Deref::deref), + .downcast_ref::(), Some(FindError::Trigger(id)) if *id == trigger_id )); diff --git a/core/src/queue.rs b/core/src/queue.rs index 61fbb133d18..175d8f33a1e 100644 --- a/core/src/queue.rs +++ b/core/src/queue.rs @@ -394,8 +394,9 @@ impl Queue { } fn decrease_per_user_tx_count(&self, account_id: &AccountId) { - let Entry::Occupied(mut occupied) = self.txs_per_user - .entry(account_id.clone()) else { panic!("Call to decrease always should be paired with increase count. This is a bug.") }; + let Entry::Occupied(mut occupied) = self.txs_per_user.entry(account_id.clone()) else { + panic!("Call to decrease always should be paired with increase count. This is a bug.") + }; let count = occupied.get_mut(); if *count > 1 { diff --git a/core/src/smartcontracts/isi/account.rs b/core/src/smartcontracts/isi/account.rs index 0f5033eb5b3..253acdfc1fe 100644 --- a/core/src/smartcontracts/isi/account.rs +++ b/core/src/smartcontracts/isi/account.rs @@ -50,7 +50,7 @@ pub mod isi { match wsv.asset(&asset_id) { Err(err) => match err { QueryExecutionFail::Find(find_err) - if matches!(*find_err, FindError::Asset(_)) => + if matches!(find_err, FindError::Asset(_)) => { assert_can_register(&asset_id.definition_id, wsv, &self.object.value)?; let asset = wsv diff --git a/core/src/smartcontracts/isi/asset.rs b/core/src/smartcontracts/isi/asset.rs index 2445830fe72..5beedff387a 100644 --- a/core/src/smartcontracts/isi/asset.rs +++ b/core/src/smartcontracts/isi/asset.rs @@ -619,7 +619,7 @@ pub mod query { .asset(&id) .map_err(|asset_err| { if let Err(definition_err) = wsv.asset_definition(&id.definition_id) { - Error::Find(Box::new(definition_err)) + Error::Find(definition_err) } else { asset_err } @@ -657,7 +657,7 @@ pub mod query { .map_err(|e| Error::Evaluate(e.to_string()))?; let asset = wsv.asset(&id).map_err(|asset_err| { if let Err(definition_err) = wsv.asset_definition(&id.definition_id) { - Error::Find(Box::new(definition_err)) + Error::Find(definition_err) } else { asset_err } @@ -670,7 +670,7 @@ pub mod query { .map_err(|e| Error::Conversion(e.to_string()))?; Ok(store .get(&key) - .ok_or_else(|| Error::Find(Box::new(FindError::MetadataKey(key))))? + .ok_or_else(|| Error::Find(FindError::MetadataKey(key)))? .clone()) } } diff --git a/core/src/smartcontracts/isi/block.rs b/core/src/smartcontracts/isi/block.rs index 4cfd413c6bb..427da967da2 100644 --- a/core/src/smartcontracts/isi/block.rs +++ b/core/src/smartcontracts/isi/block.rs @@ -47,7 +47,7 @@ impl ValidQuery for FindBlockHeaderByHash { let block = wsv .all_blocks() .find(|block| block.hash() == hash) - .ok_or_else(|| QueryExecutionFail::Find(Box::new(FindError::Block(hash))))?; + .ok_or_else(|| QueryExecutionFail::Find(FindError::Block(hash)))?; Ok(block.as_v1().header.clone()) } diff --git a/core/src/smartcontracts/isi/mod.rs b/core/src/smartcontracts/isi/mod.rs index 13da4987b1b..627316c324d 100644 --- a/core/src/smartcontracts/isi/mod.rs +++ b/core/src/smartcontracts/isi/mod.rs @@ -443,7 +443,7 @@ pub mod prelude { mod tests { #![allow(clippy::restriction)] - use core::str::FromStr; + use core::str::FromStr as _; use std::sync::Arc; use iroha_crypto::KeyPair; diff --git a/core/src/smartcontracts/isi/query.rs b/core/src/smartcontracts/isi/query.rs index 4bec9c74b80..68e5f1ea299 100644 --- a/core/src/smartcontracts/isi/query.rs +++ b/core/src/smartcontracts/isi/query.rs @@ -100,7 +100,9 @@ mod tests { use std::str::FromStr as _; use iroha_crypto::{Hash, HashOf, KeyPair}; - use iroha_data_model::{block::VersionedCommittedBlock, transaction::TransactionLimits}; + use iroha_data_model::{ + block::VersionedCommittedBlock, query::error::FindError, transaction::TransactionLimits, + }; use once_cell::sync::Lazy; use super::*; @@ -384,7 +386,10 @@ mod tests { .sign(ALICE_KEYS.clone())?; let wrong_hash = unapplied_tx.hash(); let not_found = FindTransactionByHash::new(wrong_hash).execute(&wsv); - assert!(not_found.is_err()); + assert!(matches!( + not_found, + Err(Error::Find(FindError::Transaction(_))) + )); let found_accepted = FindTransactionByHash::new(va_tx.hash()).execute(&wsv)?; if found_accepted.transaction.error.is_none() { diff --git a/core/src/smartcontracts/isi/triggers/mod.rs b/core/src/smartcontracts/isi/triggers/mod.rs index 384a4ed076f..3b65b8e420b 100644 --- a/core/src/smartcontracts/isi/triggers/mod.rs +++ b/core/src/smartcontracts/isi/triggers/mod.rs @@ -225,7 +225,7 @@ pub mod query { } = wsv .triggers() .inspect_by_id(&id, |action| action.clone_and_box()) - .ok_or_else(|| Error::Find(Box::new(FindError::Trigger(id.clone()))))?; + .ok_or_else(|| Error::Find(FindError::Trigger(id.clone())))?; let action = Action::new(loaded_executable, repeats, authority, filter).with_metadata(metadata); @@ -253,7 +253,7 @@ pub mod query { .map(Clone::clone) .ok_or_else(|| FindError::MetadataKey(key.clone()).into()) }) - .ok_or_else(|| Error::Find(Box::new(FindError::Trigger(id))))? + .ok_or_else(|| Error::Find(FindError::Trigger(id)))? } } diff --git a/core/src/smartcontracts/isi/world.rs b/core/src/smartcontracts/isi/world.rs index a4909bd0e48..73b1577fab2 100644 --- a/core/src/smartcontracts/isi/world.rs +++ b/core/src/smartcontracts/isi/world.rs @@ -448,7 +448,7 @@ pub mod query { iroha_logger::trace!(%role_id); wsv.world.roles.get(&role_id).map_or_else( - || Err(Error::Find(Box::new(FindError::Role(role_id)))), + || Err(Error::Find(FindError::Role(role_id))), |role_ref| Ok(role_ref.clone()), ) } diff --git a/core/src/tx.rs b/core/src/tx.rs index 09b9b7c1408..ed6df7e699a 100644 --- a/core/src/tx.rs +++ b/core/src/tx.rs @@ -46,6 +46,34 @@ pub enum AcceptTransactionFail { SignatureVerification(#[source] SignatureVerificationFail), } +fn instruction_size(isi: &InstructionBox) -> usize { + use InstructionBox::*; + + match isi { + Register(isi) => isi.object.len() + 1, + Unregister(isi) => isi.object_id.len() + 1, + Mint(isi) => isi.destination_id.len() + isi.object.len() + 1, + Burn(isi) => isi.destination_id.len() + isi.object.len() + 1, + Transfer(isi) => isi.destination_id.len() + isi.object.len() + isi.source_id.len() + 1, + If(isi) => { + let otherwise = isi.otherwise.as_ref().map_or(0, instruction_size); + isi.condition.len() + instruction_size(&isi.then) + otherwise + 1 + } + Pair(isi) => { + instruction_size(&isi.left_instruction) + instruction_size(&isi.right_instruction) + 1 + } + Sequence(isi) => isi.instructions.iter().map(instruction_size).sum::() + 1, + SetKeyValue(isi) => isi.object_id.len() + isi.key.len() + isi.value.len() + 1, + RemoveKeyValue(isi) => isi.object_id.len() + isi.key.len() + 1, + Grant(isi) => isi.object.len() + isi.destination_id.len() + 1, + Revoke(isi) => isi.object.len() + isi.destination_id.len() + 1, + SetParameter(isi) => isi.parameter.len() + 1, + NewParameter(isi) => isi.parameter.len() + 1, + Upgrade(isi) => isi.object.len() + 1, + Fail(_) | ExecuteTrigger(_) => 1, + } +} + impl AcceptedTransaction { /// Accept genesis transaction. Transition from [`GenesisTransaction`] to [`AcceptedTransaction`]. pub fn accept_genesis(tx: GenesisTransaction) -> Self { @@ -65,7 +93,7 @@ impl AcceptedTransaction { Executable::Instructions(instructions) => { let instruction_count: u64 = instructions .iter() - .map(InstructionBox::len) + .map(instruction_size) .sum::() .try_into() .expect("`usize` should always fit in `u64`"); @@ -295,3 +323,67 @@ impl TransactionValidator { }) } } + +#[cfg(test)] +mod tests { + use core::str::FromStr as _; + + use super::*; + + fn if_instruction( + c: impl Into, + then: InstructionBox, + otherwise: Option, + ) -> InstructionBox { + let condition: Expression = c.into(); + let condition = EvaluatesTo::new_unchecked(condition); + Conditional { + condition, + then, + otherwise, + } + .into() + } + + fn fail() -> InstructionBox { + FailBox { + message: String::default(), + } + .into() + } + + #[test] + fn len_empty_sequence() { + assert_eq!(instruction_size(&SequenceBox::new(vec![]).into()), 1); + } + + #[test] + fn len_if_one_branch() { + let instructions = vec![if_instruction( + ContextValue { + value_name: Name::from_str("a").expect("Cannot fail."), + }, + fail(), + None, + )]; + + assert_eq!(instruction_size(&SequenceBox::new(instructions).into()), 4); + } + + #[test] + fn len_sequence_if() { + let instructions = vec![ + fail(), + if_instruction( + ContextValue { + value_name: Name::from_str("b").expect("Cannot fail."), + }, + fail(), + Some(fail()), + ), + fail(), + ]; + + assert_eq!(instruction_size(&SequenceBox::new(instructions).into()), 7); + } +} diff --git a/core/src/wsv.rs b/core/src/wsv.rs index bb7b9e23ff6..1b76a823763 100644 --- a/core/src/wsv.rs +++ b/core/src/wsv.rs @@ -474,7 +474,7 @@ impl WorldStateView { account .assets .get(id) - .ok_or_else(|| QueryExecutionFail::from(Box::new(FindError::Asset(id.clone())))) + .ok_or_else(|| QueryExecutionFail::from(FindError::Asset(id.clone()))) .map(Clone::clone) }, )? diff --git a/core/test_network/src/lib.rs b/core/test_network/src/lib.rs index 00c61b24fdb..9ea4af76363 100644 --- a/core/test_network/src/lib.rs +++ b/core/test_network/src/lib.rs @@ -21,7 +21,7 @@ use iroha_config::{ torii::Configuration as ToriiConfiguration, }; use iroha_core::prelude::*; -use iroha_data_model::{peer::Peer as DataModelPeer, prelude::*}; +use iroha_data_model::{isi::Instruction, peer::Peer as DataModelPeer, prelude::*}; use iroha_genesis::{GenesisNetwork, RawGenesisBlock}; use iroha_logger::{Configuration as LoggerConfiguration, InstrumentFutures}; use iroha_primitives::addr::{socket_addr, SocketAddr}; diff --git a/data_model/derive/src/model.rs b/data_model/derive/src/model.rs index 1605d4a57f5..8a7426baca3 100644 --- a/data_model/derive/src/model.rs +++ b/data_model/derive/src/model.rs @@ -15,7 +15,10 @@ pub fn impl_model(input: &syn::ItemMod) -> TokenStream { } = input; let syn::Visibility::Public(vis_public) = vis else { - abort!(input, "The `model` attribute can only be used on public modules"); + abort!( + input, + "The `model` attribute can only be used on public modules" + ); }; if ident != "model" { abort!( diff --git a/data_model/derive/tests/ui_fail/transparent_api_private_item.stderr b/data_model/derive/tests/ui_fail/transparent_api_private_item.stderr index fb3d3cfeb22..2ff8feb4121 100644 --- a/data_model/derive/tests/ui_fail/transparent_api_private_item.stderr +++ b/data_model/derive/tests/ui_fail/transparent_api_private_item.stderr @@ -8,4 +8,4 @@ note: the struct `QueryPayload` is defined here --> $WORKSPACE/data_model/src/query.rs | | pub use self::model::*; - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ diff --git a/data_model/src/isi.rs b/data_model/src/isi.rs index 1ab82f63f5f..b8257ea719e 100644 --- a/data_model/src/isi.rs +++ b/data_model/src/isi.rs @@ -19,10 +19,7 @@ use super::{expression::EvaluatesTo, prelude::*, IdBox, RegistrableBox, Value}; use crate::{seal, Registered}; /// Marker trait designating instruction -pub trait Instruction: Into + seal::Sealed { - /// Length of contained instructions and queries. - fn len(&self) -> usize; -} +pub trait Instruction: Into + seal::Sealed {} macro_rules! isi { ($($meta:meta)* $item:item) => { @@ -135,124 +132,27 @@ pub mod model { Fail(FailBox), } - impl Instruction for InstructionBox { - fn len(&self) -> usize { - use InstructionBox::*; - - match self { - Register(register_box) => register_box.len(), - Unregister(unregister_box) => unregister_box.len(), - Mint(mint_box) => mint_box.len(), - Burn(burn_box) => burn_box.len(), - Transfer(transfer_box) => transfer_box.len(), - If(if_box) => if_box.len(), - Pair(pair_box) => pair_box.len(), - Sequence(sequence) => sequence.len(), - Fail(fail_box) => fail_box.len(), - SetKeyValue(set_key_value) => set_key_value.len(), - RemoveKeyValue(remove_key_value) => remove_key_value.len(), - Grant(grant_box) => grant_box.len(), - Revoke(revoke_box) => revoke_box.len(), - ExecuteTrigger(execute_trigger) => execute_trigger.len(), - SetParameter(set_parameter) => set_parameter.len(), - NewParameter(new_parameter) => new_parameter.len(), - Upgrade(upgrade_box) => upgrade_box.len(), - } - } - } + impl Instruction for InstructionBox {} - impl Instruction for SetKeyValueBox { - fn len(&self) -> usize { - self.object_id.len() + self.key.len() + self.value.len() + 1 - } - } - impl Instruction for RemoveKeyValueBox { - fn len(&self) -> usize { - self.object_id.len() + self.key.len() + 1 - } - } - impl Instruction for RegisterBox { - fn len(&self) -> usize { - self.object.len() + 1 - } - } - impl Instruction for UnregisterBox { - fn len(&self) -> usize { - self.object_id.len() + 1 - } - } - impl Instruction for MintBox { - fn len(&self) -> usize { - self.destination_id.len() + self.object.len() + 1 - } - } - impl Instruction for BurnBox { - fn len(&self) -> usize { - self.destination_id.len() + self.object.len() + 1 - } - } - impl Instruction for TransferBox { - fn len(&self) -> usize { - self.destination_id.len() + self.object.len() + self.source_id.len() + 1 - } - } - impl Instruction for GrantBox { - fn len(&self) -> usize { - self.object.len() + self.destination_id.len() + 1 - } - } - impl Instruction for RevokeBox { - fn len(&self) -> usize { - self.object.len() + self.destination_id.len() + 1 - } - } - impl Instruction for SetParameterBox { - fn len(&self) -> usize { - self.parameter.len() + 1 - } - } - impl Instruction for NewParameterBox { - fn len(&self) -> usize { - self.parameter.len() + 1 - } - } - impl Instruction for UpgradeBox { - fn len(&self) -> usize { - self.object.len() + 1 - } - } - impl Instruction for ExecuteTriggerBox { - fn len(&self) -> usize { - 1 - } - } - impl Instruction for FailBox { - fn len(&self) -> usize { - 1 - } - } + impl Instruction for SetKeyValueBox {} + impl Instruction for RemoveKeyValueBox {} + impl Instruction for RegisterBox {} + impl Instruction for UnregisterBox {} + impl Instruction for MintBox {} + impl Instruction for BurnBox {} + impl Instruction for TransferBox {} + impl Instruction for GrantBox {} + impl Instruction for RevokeBox {} + impl Instruction for SetParameterBox {} + impl Instruction for NewParameterBox {} + impl Instruction for UpgradeBox {} + impl Instruction for ExecuteTriggerBox {} + impl Instruction for FailBox {} // Composite instructions - impl Instruction for SequenceBox { - fn len(&self) -> usize { - self.instructions - .iter() - .map(InstructionBox::len) - .sum::() - + 1 - } - } - impl Instruction for Conditional { - fn len(&self) -> usize { - let otherwise = self.otherwise.as_ref().map_or(0, InstructionBox::len); - self.condition.len() + self.then.len() + otherwise + 1 - } - } - impl Instruction for Pair { - fn len(&self) -> usize { - self.left_instruction.len() + self.right_instruction.len() + 1 - } - } + impl Instruction for SequenceBox {} + impl Instruction for Conditional {} + impl Instruction for Pair {} } mod transparent { @@ -1266,81 +1166,9 @@ pub mod error { pub mod prelude { pub use super::{ Burn, BurnBox, Conditional, ExecuteTrigger, ExecuteTriggerBox, FailBox, Grant, GrantBox, - Instruction, InstructionBox, Mint, MintBox, NewParameter, NewParameterBox, Pair, Register, - RegisterBox, RemoveKeyValue, RemoveKeyValueBox, Revoke, RevokeBox, SequenceBox, - SetKeyValue, SetKeyValueBox, SetParameter, SetParameterBox, Transfer, TransferBox, - Unregister, UnregisterBox, Upgrade, UpgradeBox, + InstructionBox, Mint, MintBox, NewParameter, NewParameterBox, Pair, Register, RegisterBox, + RemoveKeyValue, RemoveKeyValueBox, Revoke, RevokeBox, SequenceBox, SetKeyValue, + SetKeyValueBox, SetParameter, SetParameterBox, Transfer, TransferBox, Unregister, + UnregisterBox, Upgrade, UpgradeBox, }; } - -#[cfg(test)] -mod tests { - #[cfg(not(feature = "std"))] - use alloc::vec; - use core::str::FromStr; - - use super::*; - - fn if_instruction( - c: impl Into, - then: InstructionBox, - otherwise: Option, - ) -> InstructionBox { - let condition: Expression = c.into(); - let condition = EvaluatesTo::new_unchecked(condition); - Conditional { - condition, - then, - otherwise, - } - .into() - } - - fn fail() -> InstructionBox { - FailBox { - message: String::default(), - } - .into() - } - - #[test] - fn len_empty_sequence() { - assert_eq!(InstructionBox::from(SequenceBox::new(vec![])).len(), 1); - } - - #[test] - fn len_if_one_branch() { - let instructions = vec![if_instruction( - ContextValue { - value_name: Name::from_str("a").expect("Cannot fail."), - }, - fail(), - None, - )]; - - assert_eq!( - InstructionBox::from(SequenceBox::new(instructions)).len(), - 4 - ); - } - - #[test] - fn len_sequence_if() { - let instructions = vec![ - fail(), - if_instruction( - ContextValue { - value_name: Name::from_str("b").expect("Cannot fail."), - }, - fail(), - Some(fail()), - ), - fail(), - ]; - - assert_eq!( - InstructionBox::from(SequenceBox::new(instructions)).len(), - 7 - ); - } -} diff --git a/data_model/src/name.rs b/data_model/src/name.rs index 97d515e1a2f..ab5bf391bbf 100644 --- a/data_model/src/name.rs +++ b/data_model/src/name.rs @@ -55,7 +55,8 @@ impl Name { .chars() .count() .try_into() - .map(|len| range.contains(&len)) else { + .map(|len| range.contains(&len)) + else { return Err(InvalidParameterError::NameLength); }; Ok(()) diff --git a/data_model/src/query.rs b/data_model/src/query.rs index 080fd529879..a2b7f8709ac 100644 --- a/data_model/src/query.rs +++ b/data_model/src/query.rs @@ -1463,7 +1463,7 @@ pub mod error { ), /// Query found nothing. #[display(fmt = "Query found nothing")] - Find(#[cfg_attr(feature = "std", source)] Box), + Find(#[cfg_attr(feature = "std", source)] FindError), /// Query found wrong type of asset. #[display(fmt = "Query found wrong type of asset: {_0}")] Conversion( diff --git a/data_model/src/transaction.rs b/data_model/src/transaction.rs index d400ea77cd0..0b9e7c743b5 100644 --- a/data_model/src/transaction.rs +++ b/data_model/src/transaction.rs @@ -22,8 +22,11 @@ use serde::{Deserialize, Serialize}; pub use self::model::*; use crate::{ - account::AccountId, isi::InstructionBox, metadata::UnlimitedMetadata, name::Name, - prelude::Instruction, Value, + account::AccountId, + isi::{Instruction, InstructionBox}, + metadata::UnlimitedMetadata, + name::Name, + Value, }; #[model] diff --git a/data_model/src/visit.rs b/data_model/src/visit.rs index 650379526c7..3f60589144a 100644 --- a/data_model/src/visit.rs +++ b/data_model/src/visit.rs @@ -477,11 +477,11 @@ pub fn visit_transfer( let object = evaluate_expr!(visitor, authority, ::object()); let (IdBox::AssetId(source_id), IdBox::AccountId(destination_id)) = ( - evaluate_expr!(visitor, authority, ::source_id()), - evaluate_expr!(visitor, authority, ::destination_id()), - ) else { - return visitor.visit_unsupported(authority, isi); - }; + evaluate_expr!(visitor, authority, ::source_id()), + evaluate_expr!(visitor, authority, ::destination_id()), + ) else { + return visitor.visit_unsupported(authority, isi); + }; match object { Value::Numeric(object) => visitor.visit_transfer_asset( diff --git a/ffi/derive/tests/ui_fail/array_as_ptr.stderr b/ffi/derive/tests/ui_fail/array_as_ptr.stderr index 794e4c180a3..d07e598e3da 100644 --- a/ffi/derive/tests/ui_fail/array_as_ptr.stderr +++ b/ffi/derive/tests/ui_fail/array_as_ptr.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> tests/ui_fail/array_as_ptr.rs:9:17 | 9 | __array_arg(arg); - | ----------- ^^^ expected `*mut [u32; 2]`, found array `[u32; 2]` + | ----------- ^^^ expected `*mut [u32; 2]`, found `[u32; 2]` | | | arguments to this function are incorrect | diff --git a/ffi/derive/tests/ui_fail/nested_owned_structure.stderr b/ffi/derive/tests/ui_fail/nested_owned_structure.stderr index 829354e01ee..81ce05019b0 100644 --- a/ffi/derive/tests/ui_fail/nested_owned_structure.stderr +++ b/ffi/derive/tests/ui_fail/nested_owned_structure.stderr @@ -6,4 +6,5 @@ error[E0277]: the trait bound `Vec: NonLocal>` is not sat | = help: the trait `NonLocal>` is implemented for `Vec` = note: required for `Vec>` to implement `COutPtr>>` + = note: required for `Vec>` to implement `FfiOutPtr` = note: this error originates in the attribute macro `ffi_export` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/primitives/tests/ui_fail/must_use_not_used.stderr b/primitives/tests/ui_fail/must_use_not_used.stderr index a950f8cb3fa..685900a0bcf 100644 --- a/primitives/tests/ui_fail/must_use_not_used.stderr +++ b/primitives/tests/ui_fail/must_use_not_used.stderr @@ -9,3 +9,7 @@ note: the lint level is defined here | 1 | #![deny(unused_must_use)] | ^^^^^^^^^^^^^^^ +help: use `let _ = ...` to ignore the resulting value + | +6 | let _ = MustUse::new(5); + | +++++++ diff --git a/primitives/tests/ui_fail/no_conversion.stderr b/primitives/tests/ui_fail/no_conversion.stderr index 26b02ae84bd..1441d135e51 100644 --- a/primitives/tests/ui_fail/no_conversion.stderr +++ b/primitives/tests/ui_fail/no_conversion.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> tests/ui_fail/no_conversion.rs:4:17 | 4 | Fixed::from(-1_f64); - | ----------- ^^^^^^ expected struct `Fixed`, found `f64` + | ----------- ^^^^^^ expected `Fixed`, found `f64` | | | arguments to this function are incorrect | diff --git a/wasm/src/lib.rs b/wasm/src/lib.rs index 8a3c75f594b..96b5b4f2762 100644 --- a/wasm/src/lib.rs +++ b/wasm/src/lib.rs @@ -14,7 +14,7 @@ extern crate alloc; use alloc::{boxed::Box, collections::BTreeMap, format, vec::Vec}; use core::ops::RangeFrom; -use data_model::{prelude::*, query::QueryBox, validator::NeedsValidationBox}; +use data_model::{isi::Instruction, prelude::*, query::QueryBox, validator::NeedsValidationBox}; use debug::DebugExpectExt as _; pub use iroha_data_model as data_model; pub use iroha_wasm_derive::main; diff --git a/wasm_codec/derive/src/lib.rs b/wasm_codec/derive/src/lib.rs index c9234cf9719..06b8b85889e 100644 --- a/wasm_codec/derive/src/lib.rs +++ b/wasm_codec/derive/src/lib.rs @@ -373,8 +373,15 @@ fn classify_fn(fn_sig: &syn::Signature) -> FnClass { }; } - let syn::PathArguments::AngleBracketed(syn::AngleBracketedGenericArguments { args: generics, ..}) = &output_last_segment.arguments else { - abort!(output_last_segment.arguments, "`Result` return type should have generic arguments"); + let syn::PathArguments::AngleBracketed(syn::AngleBracketedGenericArguments { + args: generics, + .. + }) = &output_last_segment.arguments + else { + abort!( + output_last_segment.arguments, + "`Result` return type should have generic arguments" + ); }; let ok_type = classify_ok_type(generics); @@ -434,7 +441,11 @@ fn classify_params_and_state( fn parse_state_param(param: &syn::PatType) -> Result<&syn::Type, Diagnostic> { let syn::Pat::Ident(pat_ident) = &*param.pat else { - return Err(diagnostic!(param, Level::Error, "State parameter should be an ident")); + return Err(diagnostic!( + param, + Level::Error, + "State parameter should be an ident" + )); }; if !["state", "_state"].contains(&&*pat_ident.ident.to_string()) { return Err(diagnostic!( @@ -445,7 +456,11 @@ fn parse_state_param(param: &syn::PatType) -> Result<&syn::Type, Diagnostic> { } let syn::Type::Reference(ty_ref) = &*param.ty else { - return Err(diagnostic!(param.ty, Level::Error, "State parameter should be either reference or mutable reference")); + return Err(diagnostic!( + param.ty, + Level::Error, + "State parameter should be either reference or mutable reference" + )); }; Ok(&*ty_ref.elem) @@ -458,7 +473,10 @@ fn classify_ok_type( .first() .expect_or_abort("First generic argument expected in `Result` return type"); let syn::GenericArgument::Type(ok_type) = ok_generic else { - abort!(ok_generic, "First generic of `Result` return type expected to be a type"); + abort!( + ok_generic, + "First generic of `Result` return type expected to be a type" + ); }; if let syn::Type::Tuple(syn::TypeTuple { elems, .. }) = ok_type { @@ -473,15 +491,17 @@ fn extract_err_type(generics: &Punctuated) .iter() .nth(1) .expect_or_abort("Second generic argument expected in `Result` return type"); - let syn::GenericArgument::Type(err_type) = err_generic else - { - abort!(err_generic, "Second generic of `Result` return type expected to be a type"); + let syn::GenericArgument::Type(err_type) = err_generic else { + abort!( + err_generic, + "Second generic of `Result` return type expected to be a type" + ); }; err_type } fn unwrap_path(ty: &syn::Type) -> &syn::Path { - let syn::Type::Path(syn::TypePath {ref path, ..}) = *ty else { + let syn::Type::Path(syn::TypePath { ref path, .. }) = *ty else { abort!(ty, "Expected path"); };