diff --git a/crates/client/rpc/src/versions/v0_7_1/methods/read/estimate_fee.rs b/crates/client/rpc/src/versions/v0_7_1/methods/read/estimate_fee.rs index 3c7436330..c981e283b 100644 --- a/crates/client/rpc/src/versions/v0_7_1/methods/read/estimate_fee.rs +++ b/crates/client/rpc/src/versions/v0_7_1/methods/read/estimate_fee.rs @@ -46,16 +46,19 @@ pub async fn estimate_fee( let execution_results = exec_context.re_execute_transactions([], transactions, true, validate)?; - let fee_estimates = execution_results.iter().enumerate().try_fold(Vec::new(), |mut acc, (index, result)| { - if result.execution_info.is_reverted() { - return Err(StarknetRpcApiError::TxnExecutionError { - tx_index: index, - error: result.execution_info.revert_error.clone().unwrap_or_default(), - }); - } - acc.push(exec_context.execution_result_to_fee_estimate(result)); - Ok(acc) - })?; + let fee_estimates = execution_results.iter().enumerate().try_fold( + Vec::with_capacity(execution_results.len()), + |mut acc, (index, result)| { + if result.execution_info.is_reverted() { + return Err(StarknetRpcApiError::TxnExecutionError { + tx_index: index, + error: result.execution_info.revert_error.clone().unwrap_or_default(), + }); + } + acc.push(exec_context.execution_result_to_fee_estimate(result)); + Ok(acc) + }, + )?; Ok(fee_estimates) }