Skip to content

Commit

Permalink
style: ♻️ Added a map in simultation.rs to increase clean code manners
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbelleng committed Mar 6, 2024
1 parent 648edf6 commit 51257b6
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions crates/pallets/starknet/src/simulations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ impl<T: Config> Pallet<T> {
execution_config: &ExecutionConfig,
transactions: Vec<UserOrL1HandlerTransaction>,
) -> Result<Vec<TransactionExecutionInfo>, PlaceHolderErrorTypeForFailedStarknetExecution> {
let exec_transactions: Vec<Result<TransactionExecutionInfo, TransactionExecutionError>> = transactions
transactions
.iter()
.map(|user_or_l1_tx| match user_or_l1_tx {
UserOrL1HandlerTransaction::User(tx) => {
Expand All @@ -277,16 +277,7 @@ impl<T: Config> Pallet<T> {
Self::execute_message(tx.clone(), chain_id, block_context, execution_config)
}
})
.collect();

let mut execution_infos = Vec::with_capacity(exec_transactions.len());
for result in exec_transactions {
match result {
Ok(info) => execution_infos.push(info),
Err(_err) => return Err(PlaceHolderErrorTypeForFailedStarknetExecution),
}
}

Ok(execution_infos)
.collect::<Result<Vec<_>, _>>()
.map_err(|_| PlaceHolderErrorTypeForFailedStarknetExecution)
}
}

0 comments on commit 51257b6

Please sign in to comment.