From 90d2dd0935de1343429eb3fba2b8cb47bc2ebf5b Mon Sep 17 00:00:00 2001 From: fishseabowl Date: Fri, 31 May 2024 10:50:39 -0700 Subject: [PATCH] Fix clippy issues --- .../transactions/src/compute_hash.rs | 109 +++++++++++------- 1 file changed, 66 insertions(+), 43 deletions(-) diff --git a/crates/primitives/transactions/src/compute_hash.rs b/crates/primitives/transactions/src/compute_hash.rs index 7a03a280be..311bbdb508 100644 --- a/crates/primitives/transactions/src/compute_hash.rs +++ b/crates/primitives/transactions/src/compute_hash.rs @@ -66,10 +66,15 @@ impl ComputeTransactionHash for InvokeTransactionV0 { let calldata_hash = compute_hash_on_elements(&convert_calldata(self.calldata.clone())); let max_fee = FieldElement::from(self.max_fee.0); - Felt252Wrapper(PedersenHasher::compute_hash_on_elements( - [prefix, version, contract_address, entrypoint_selector, calldata_hash, max_fee, chain_id.into()] - .into_iter(), - )) + Felt252Wrapper(PedersenHasher::compute_hash_on_elements([ + prefix, + version, + contract_address, + entrypoint_selector, + calldata_hash, + max_fee, + chain_id.into(), + ])) .into() } } @@ -84,10 +89,16 @@ impl ComputeTransactionHash for InvokeTransactionV1 { let max_fee = FieldElement::from(self.max_fee.0); let nonce = Felt252Wrapper::from(self.nonce.0).into(); - Felt252Wrapper(PedersenHasher::compute_hash_on_elements( - [prefix, version, sender_address, entrypoint_selector, calldata_hash, max_fee, chain_id.into(), nonce] - .into_iter(), - )) + Felt252Wrapper(PedersenHasher::compute_hash_on_elements([ + prefix, + version, + sender_address, + entrypoint_selector, + calldata_hash, + max_fee, + chain_id.into(), + nonce, + ])) .into() } } @@ -154,10 +165,16 @@ fn compute_hash_declare_v0_or_v1( FieldElement::from(version) }; - Felt252Wrapper(PedersenHasher::compute_hash_on_elements( - [prefix, version, sender_address, zero, class_or_nothing_hash, max_fee, chain_id.into(), nonce_or_class_hash] - .into_iter(), - )) + Felt252Wrapper(PedersenHasher::compute_hash_on_elements([ + prefix, + version, + sender_address, + zero, + class_or_nothing_hash, + max_fee, + chain_id.into(), + nonce_or_class_hash, + ])) .into() } @@ -172,20 +189,17 @@ impl ComputeTransactionHash for DeclareTransactionV2 { let nonce = Felt252Wrapper::from(self.nonce).into(); let compiled_class_hash = Felt252Wrapper::from(self.compiled_class_hash).into(); - Felt252Wrapper(PedersenHasher::compute_hash_on_elements( - [ - prefix, - version, - sender_address, - entrypoint_selector, - calldata, - max_fee, - chain_id.into(), - nonce, - compiled_class_hash, - ] - .into_iter(), - )) + Felt252Wrapper(PedersenHasher::compute_hash_on_elements([ + prefix, + version, + sender_address, + entrypoint_selector, + calldata, + max_fee, + chain_id.into(), + nonce, + compiled_class_hash, + ])) .into() } } @@ -265,10 +279,16 @@ impl ComputeTransactionHash for DeployAccountTransactionV1 { let max_fee = FieldElement::from(self.max_fee.0); let nonce = Felt252Wrapper::from(self.nonce).into(); - Felt252Wrapper(PedersenHasher::compute_hash_on_elements( - [prefix, version, contract_address, entrypoint_selector, calldata_hash, max_fee, chain_id.into(), nonce] - .into_iter(), - )) + Felt252Wrapper(PedersenHasher::compute_hash_on_elements([ + prefix, + version, + contract_address, + entrypoint_selector, + calldata_hash, + max_fee, + chain_id.into(), + nonce, + ])) .into() } } @@ -290,7 +310,7 @@ impl ComputeTransactionHash for DeployAccountTransactionV3 { ) .into(); let nonce = Felt252Wrapper::from(self.nonce.0).into(); - let constructor_calldata_hash = PoseidonHasher::compute_hash_on_elements(constructor_calldata.into_iter()); + let constructor_calldata_hash = PoseidonHasher::compute_hash_on_elements(constructor_calldata); compute_transaction_hash_common_v3( prefix, @@ -321,9 +341,15 @@ impl ComputeTransactionHash for L1HandlerTransaction { let calldata_hash = compute_hash_on_elements(&convert_calldata(self.calldata.clone())); let nonce = Felt252Wrapper::from(self.nonce).into(); - Felt252Wrapper(PedersenHasher::compute_hash_on_elements( - [prefix, version, contract_address, entrypoint_selector, calldata_hash, chain_id.into(), nonce].into_iter(), - )) + Felt252Wrapper(PedersenHasher::compute_hash_on_elements([ + prefix, + version, + contract_address, + entrypoint_selector, + calldata_hash, + chain_id.into(), + nonce, + ])) .into() } } @@ -342,14 +368,11 @@ fn compute_transaction_hash_common_v3( resource_bounds: &ResourceBoundsMapping, additional_data: Vec, ) -> TransactionHash { - let gas_hash = PoseidonHasher::compute_hash_on_elements( - [ - FieldElement::from(tip.0), - prepare_resource_bound_value(resource_bounds, Resource::L1Gas), - prepare_resource_bound_value(resource_bounds, Resource::L2Gas), - ] - .into_iter(), - ); + let gas_hash = PoseidonHasher::compute_hash_on_elements([ + FieldElement::from(tip.0), + prepare_resource_bound_value(resource_bounds, Resource::L1Gas), + prepare_resource_bound_value(resource_bounds, Resource::L2Gas), + ]); let paymaster_hash = PoseidonHasher::compute_hash_on_elements(paymaster_data.0.iter().map(|f| Felt252Wrapper::from(*f).into())); let data_availability_modes = @@ -365,7 +388,7 @@ fn compute_transaction_hash_common_v3( data_availability_modes, ]; data_to_hash.extend(additional_data); - Felt252Wrapper(PoseidonHasher::compute_hash_on_elements(data_to_hash.into_iter())).into() + Felt252Wrapper(PoseidonHasher::compute_hash_on_elements(data_to_hash)).into() } #[cfg(test)]