From cc63d7700b05072feaf7f406dbdb99b6b8d5e4a9 Mon Sep 17 00:00:00 2001 From: Arni Hod Date: Sun, 28 Jan 2024 14:44:38 +0200 Subject: [PATCH] style(fee): fix error handle unpack --- .../blockifier/src/transaction/transaction_utils.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/blockifier/src/transaction/transaction_utils.rs b/crates/blockifier/src/transaction/transaction_utils.rs index ca149e30d4..c6e07ba974 100644 --- a/crates/blockifier/src/transaction/transaction_utils.rs +++ b/crates/blockifier/src/transaction/transaction_utils.rs @@ -105,13 +105,12 @@ pub fn calculate_tx_weights( ) -> Result { let mut tx_weights: HashMap = HashMap::new(); let mut cairo_resource_usage: HashMap = actual_resources; - if let Some(value) = cairo_resource_usage.remove("l1_gas_usage") { - tx_weights.insert("gas_weight".to_string(), value); - } else { - return Err(TransactionExecutionError::InvalidTransactionExecutionInfo { + let value = cairo_resource_usage.remove("l1_gas_usage").ok_or( + TransactionExecutionError::InvalidTransactionExecutionInfo { field: "l1_gas_usage".to_string(), - }); - } + }, + )?; + tx_weights.insert("gas_weight".to_string(), value); let os_cairo_usage: HashMap = vm_execution_resources_to_hash_map(additional_os_resources); let cairo_usage = merge_hashmaps(&cairo_resource_usage, &os_cairo_usage);