@@ -19,8 +19,8 @@ use namada_token::utils::is_masp_transfer;
1919use namada_tx:: action:: Read ;
2020use namada_tx:: data:: protocol:: { ProtocolTx , ProtocolTxType } ;
2121use namada_tx:: data:: {
22- BatchResults , BatchedTxResult , ExtendedTxResult , TxResult , VpStatusFlags ,
23- VpsResult , WrapperTx ,
22+ BatchedTxResult , ExtendedTxResult , TxResult , VpStatusFlags , VpsResult ,
23+ WrapperTx ,
2424} ;
2525use namada_tx:: { BatchedTxRef , Tx , TxCommitments } ;
2626use namada_vote_ext:: EthereumTxData ;
@@ -275,17 +275,14 @@ where
275275 } ,
276276 ) ?;
277277
278- Ok ( TxResult {
279- gas_used : tx_gas_meter. borrow ( ) . get_tx_consumed_gas ( ) ,
280- batch_results : {
281- let mut batch_results = BatchResults :: new ( ) ;
282- batch_results. insert_inner_tx_result (
283- wrapper_hash,
284- either:: Right ( cmt) ,
285- Ok ( batched_tx_result) ,
286- ) ;
287- batch_results
288- } ,
278+ Ok ( {
279+ let mut batch_results = TxResult :: new ( ) ;
280+ batch_results. insert_inner_tx_result (
281+ wrapper_hash,
282+ either:: Right ( cmt) ,
283+ Ok ( batched_tx_result) ,
284+ ) ;
285+ batch_results
289286 }
290287 . to_extended_result ( None ) )
291288 }
@@ -296,17 +293,14 @@ where
296293 let batched_tx_result =
297294 apply_protocol_tx ( protocol_tx. tx , tx. data ( cmt) , state) ?;
298295
299- Ok ( TxResult {
300- batch_results : {
301- let mut batch_results = BatchResults :: new ( ) ;
302- batch_results. insert_inner_tx_result (
303- None ,
304- either:: Right ( cmt) ,
305- Ok ( batched_tx_result) ,
306- ) ;
307- batch_results
308- } ,
309- ..Default :: default ( )
296+ Ok ( {
297+ let mut batch_results = TxResult :: new ( ) ;
298+ batch_results. insert_inner_tx_result (
299+ None ,
300+ either:: Right ( cmt) ,
301+ Ok ( batched_tx_result) ,
302+ ) ;
303+ batch_results
310304 }
311305 . to_extended_result ( None ) )
312306 }
@@ -382,16 +376,11 @@ where
382376 ) {
383377 Err ( Error :: GasError ( ref msg) ) => {
384378 // Gas error aborts the execution of the entire batch
385- extended_tx_result. tx_result . gas_used =
386- tx_gas_meter. borrow ( ) . get_tx_consumed_gas ( ) ;
387- extended_tx_result
388- . tx_result
389- . batch_results
390- . insert_inner_tx_result (
391- wrapper_hash,
392- either:: Right ( cmt) ,
393- Err ( Error :: GasError ( msg. to_owned ( ) ) ) ,
394- ) ;
379+ extended_tx_result. tx_result . insert_inner_tx_result (
380+ wrapper_hash,
381+ either:: Right ( cmt) ,
382+ Err ( Error :: GasError ( msg. to_owned ( ) ) ) ,
383+ ) ;
395384 state. write_log_mut ( ) . drop_tx ( ) ;
396385 return Err ( DispatchError {
397386 error : Error :: GasError ( msg. to_owned ( ) ) ,
@@ -402,16 +391,11 @@ where
402391 let is_accepted =
403392 matches ! ( & res, Ok ( result) if result. is_accepted( ) ) ;
404393
405- extended_tx_result
406- . tx_result
407- . batch_results
408- . insert_inner_tx_result (
409- wrapper_hash,
410- either:: Right ( cmt) ,
411- res,
412- ) ;
413- extended_tx_result. tx_result . gas_used =
414- tx_gas_meter. borrow ( ) . get_tx_consumed_gas ( ) ;
394+ extended_tx_result. tx_result . insert_inner_tx_result (
395+ wrapper_hash,
396+ either:: Right ( cmt) ,
397+ res,
398+ ) ;
415399 if is_accepted {
416400 // If the transaction was a masp one append the
417401 // transaction refs for the events
@@ -488,9 +472,9 @@ where
488472 shell_params. state . write_log_mut ( ) . commit_batch ( ) ;
489473
490474 let ( batch_results, masp_tx_refs) = payment_result. map_or_else (
491- || ( BatchResults :: default ( ) , None ) ,
475+ || ( TxResult :: default ( ) , None ) ,
492476 |( batched_result, masp_section_ref) | {
493- let mut batch = BatchResults :: default ( ) ;
477+ let mut batch = TxResult :: default ( ) ;
494478 batch. insert_inner_tx_result (
495479 // Ok to unwrap cause if we have a batched result it means
496480 // we've executed the first tx in the batch
@@ -508,11 +492,7 @@ where
508492 . add_wrapper_gas ( tx_bytes)
509493 . map_err ( |err| Error :: GasError ( err. to_string ( ) ) ) ?;
510494
511- Ok ( TxResult {
512- gas_used : tx_gas_meter. borrow ( ) . get_tx_consumed_gas ( ) ,
513- batch_results,
514- }
515- . to_extended_result ( masp_tx_refs) )
495+ Ok ( batch_results. to_extended_result ( masp_tx_refs) )
516496}
517497
518498/// Perform the actual transfer of fees from the fee payer to the block
@@ -702,7 +682,7 @@ where
702682 let gas_scale = get_gas_scale ( & * * state) . map_err ( Error :: StorageError ) ?;
703683
704684 let mut gas_meter = TxGasMeter :: new (
705- namada_gas:: Gas :: from_whole_units ( max_gas_limit, gas_scale)
685+ namada_gas:: Gas :: from_whole_units ( max_gas_limit. into ( ) , gas_scale)
706686 . ok_or_else ( || {
707687 Error :: GasError ( "Overflow in gas expansion" . to_string ( ) )
708688 } ) ?,
0 commit comments