@@ -54,7 +54,7 @@ impl From<&String> for EventKind {
5454pub struct BlockResult {
5555 pub height : u64 ,
5656 pub begin_events : Vec < Event > ,
57- pub finalize_events : Vec < Event > ,
57+ pub end_events : Vec < Event > ,
5858}
5959
6060#[ derive( Debug , Clone ) ]
@@ -412,51 +412,44 @@ impl TxAttributesType {
412412
413413impl From < TendermintBlockResultResponse > for BlockResult {
414414 fn from ( value : TendermintBlockResultResponse ) -> Self {
415+ fn cast_event ( event : & tendermint:: abci:: Event ) -> Event {
416+ let kind = EventKind :: from ( & event. kind ) ;
417+ let raw_attributes = event. attributes . iter ( ) . fold (
418+ BTreeMap :: default ( ) ,
419+ |mut acc, attribute| {
420+ acc. insert (
421+ String :: from ( attribute. key_str ( ) . unwrap ( ) ) ,
422+ String :: from ( attribute. value_str ( ) . unwrap ( ) ) ,
423+ ) ;
424+ acc
425+ } ,
426+ ) ;
427+ let attributes =
428+ TxAttributesType :: deserialize ( & kind, & raw_attributes) ;
429+ Event { kind, attributes }
430+ }
431+
415432 let begin_events = value
416433 . begin_block_events
417434 . unwrap_or_default ( )
418435 . iter ( )
419- . map ( |event| {
420- let kind = EventKind :: from ( & event. kind ) ;
421- let raw_attributes = event. attributes . iter ( ) . fold (
422- BTreeMap :: default ( ) ,
423- |mut acc, attribute| {
424- acc. insert (
425- String :: from ( attribute. key_str ( ) . unwrap ( ) ) ,
426- String :: from ( attribute. value_str ( ) . unwrap ( ) ) ,
427- ) ;
428- acc
429- } ,
430- ) ;
431- let attributes =
432- TxAttributesType :: deserialize ( & kind, & raw_attributes) ;
433- Event { kind, attributes }
434- } )
436+ . map ( cast_event)
435437 . collect :: < Vec < Event > > ( ) ;
436- let finalize_events = value
437- . finalize_block_events
438+ // NOTE: starting with comet v0.38, end events are only avialable from
439+ // the `finalize_block_events` field. For backward-compatibility
440+ // reasons we still evaluate the `end_block_events` field as
441+ // well and merge the two outputs
442+ let end_events = value
443+ . end_block_events
444+ . unwrap_or_default ( )
438445 . iter ( )
439- . map ( |event| {
440- let kind = EventKind :: from ( & event. kind ) ;
441- let raw_attributes = event. attributes . iter ( ) . fold (
442- BTreeMap :: default ( ) ,
443- |mut acc, attribute| {
444- acc. insert (
445- String :: from ( attribute. key_str ( ) . unwrap ( ) ) ,
446- String :: from ( attribute. value_str ( ) . unwrap ( ) ) ,
447- ) ;
448- acc
449- } ,
450- ) ;
451- let attributes =
452- TxAttributesType :: deserialize ( & kind, & raw_attributes) ;
453- Event { kind, attributes }
454- } )
446+ . map ( cast_event)
447+ . chain ( value. finalize_block_events . iter ( ) . map ( cast_event) )
455448 . collect :: < Vec < Event > > ( ) ;
456449 Self {
457450 height : value. height . value ( ) ,
458451 begin_events,
459- finalize_events ,
452+ end_events ,
460453 }
461454 }
462455}
@@ -470,7 +463,7 @@ impl From<&TendermintBlockResultResponse> for BlockResult {
470463impl BlockResult {
471464 pub fn is_wrapper_tx_applied ( & self , tx_hash : & Id ) -> TransactionExitStatus {
472465 let exit_status = self
473- . finalize_events
466+ . end_events
474467 . iter ( )
475468 . filter_map ( |event| {
476469 if let Some ( TxAttributesType :: TxApplied ( data) ) =
@@ -489,7 +482,7 @@ impl BlockResult {
489482 }
490483
491484 pub fn gas_used ( & self , tx_hash : & Id ) -> Option < String > {
492- self . finalize_events
485+ self . end_events
493486 . iter ( )
494487 . filter_map ( |event| {
495488 if let Some ( TxAttributesType :: TxApplied ( data) ) =
@@ -510,7 +503,7 @@ impl BlockResult {
510503 inner_hash : & Id ,
511504 ) -> TransactionExitStatus {
512505 let exit_status = self
513- . finalize_events
506+ . end_events
514507 . iter ( )
515508 . filter_map ( |event| {
516509 if let Some ( TxAttributesType :: TxApplied ( data) ) =
@@ -531,7 +524,7 @@ impl BlockResult {
531524 }
532525
533526 pub fn masp_ref ( & self , indexed_tx : & IndexedTx ) -> Option < ( MaspRef , bool ) > {
534- self . finalize_events
527+ self . end_events
535528 . iter ( )
536529 . find_map ( |event| match event. kind {
537530 EventKind :: MaspFeePayment => {
0 commit comments