@@ -29,6 +29,7 @@ const RECV_PACKET: &str = "recv_packet";
29
29
const WRITE_ACK : & str = "write_acknowledgement" ;
30
30
const ACK_PACKET : & str = "acknowledge_packet" ;
31
31
const TIMEOUT : & str = "timeout_packet" ;
32
+ const TIMEOUT_ON_CLOSE : & str = "timeout_on_close_packet" ;
32
33
33
34
/// Packet event attribute keys
34
35
const PKT_SEQ_ATTRIBUTE_KEY : & str = "packet_sequence" ;
@@ -65,7 +66,7 @@ pub fn try_from_tx(event: &tendermint::abci::Event) -> Option<IBCEvent> {
65
66
let ( packet, write_ack) = extract_packet_and_write_ack_from_tx ( event) ;
66
67
// This event should not have a write ack.
67
68
assert ! ( write_ack. is_none( ) ) ;
68
- Some ( IBCEvent :: SendPacketChannel ( SendPacket {
69
+ Some ( IBCEvent :: SendPacket ( SendPacket {
69
70
height : Default :: default ( ) ,
70
71
packet,
71
72
} ) )
@@ -74,19 +75,17 @@ pub fn try_from_tx(event: &tendermint::abci::Event) -> Option<IBCEvent> {
74
75
let ( packet, write_ack) = extract_packet_and_write_ack_from_tx ( event) ;
75
76
// This event should have a write ack.
76
77
let write_ack = write_ack. unwrap ( ) ;
77
- Some ( IBCEvent :: WriteAcknowledgementChannel (
78
- WriteAcknowledgement {
79
- height : Default :: default ( ) ,
80
- packet,
81
- ack : write_ack,
82
- } ,
83
- ) )
78
+ Some ( IBCEvent :: WriteAcknowledgement ( WriteAcknowledgement {
79
+ height : Default :: default ( ) ,
80
+ packet,
81
+ ack : write_ack,
82
+ } ) )
84
83
}
85
84
ACK_PACKET => {
86
85
let ( packet, write_ack) = extract_packet_and_write_ack_from_tx ( event) ;
87
86
// This event should not have a write ack.
88
87
assert ! ( write_ack. is_none( ) ) ;
89
- Some ( IBCEvent :: AcknowledgePacketChannel ( AcknowledgePacket {
88
+ Some ( IBCEvent :: AcknowledgePacket ( AcknowledgePacket {
90
89
height : Default :: default ( ) ,
91
90
packet,
92
91
} ) )
@@ -95,7 +94,7 @@ pub fn try_from_tx(event: &tendermint::abci::Event) -> Option<IBCEvent> {
95
94
let ( packet, write_ack) = extract_packet_and_write_ack_from_tx ( event) ;
96
95
// This event should not have a write ack.
97
96
assert ! ( write_ack. is_none( ) ) ;
98
- Some ( IBCEvent :: TimeoutPacketChannel ( TimeoutPacket {
97
+ Some ( IBCEvent :: TimeoutPacket ( TimeoutPacket {
99
98
height : Default :: default ( ) ,
100
99
packet,
101
100
} ) )
@@ -334,6 +333,15 @@ impl CloseInit {
334
333
pub fn channel_id ( & self ) -> & Option < ChannelId > {
335
334
& self . 0 . channel_id
336
335
}
336
+ pub fn height ( & self ) -> & block:: Height {
337
+ & self . 0 . height
338
+ }
339
+ pub fn port_id ( & self ) -> & PortId {
340
+ & self . 0 . port_id
341
+ }
342
+ pub fn set_height ( & mut self , height : block:: Height ) {
343
+ self . 0 . height = height;
344
+ }
337
345
}
338
346
339
347
impl From < Attributes > for CloseInit {
@@ -365,6 +373,18 @@ impl From<CloseInit> for IBCEvent {
365
373
}
366
374
}
367
375
376
+ impl std:: fmt:: Display for CloseInit {
377
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> Result < ( ) , std:: fmt:: Error > {
378
+ write ! (
379
+ f,
380
+ "{:?} {} {:?}" ,
381
+ self . height( ) ,
382
+ CLOSE_INIT_EVENT_TYPE ,
383
+ self . 0
384
+ )
385
+ }
386
+ }
387
+
368
388
#[ derive( Debug , Deserialize , Serialize , Clone ) ]
369
389
pub struct CloseConfirm ( Attributes ) ;
370
390
@@ -448,7 +468,7 @@ impl TryFrom<RawObject> for SendPacket {
448
468
449
469
impl From < SendPacket > for IBCEvent {
450
470
fn from ( v : SendPacket ) -> Self {
451
- IBCEvent :: SendPacketChannel ( v)
471
+ IBCEvent :: SendPacket ( v)
452
472
}
453
473
}
454
474
@@ -477,7 +497,7 @@ impl TryFrom<RawObject> for ReceivePacket {
477
497
478
498
impl From < ReceivePacket > for IBCEvent {
479
499
fn from ( v : ReceivePacket ) -> Self {
480
- IBCEvent :: ReceivePacketChannel ( v)
500
+ IBCEvent :: ReceivePacket ( v)
481
501
}
482
502
}
483
503
@@ -513,7 +533,7 @@ impl TryFrom<RawObject> for WriteAcknowledgement {
513
533
514
534
impl From < WriteAcknowledgement > for IBCEvent {
515
535
fn from ( v : WriteAcknowledgement ) -> Self {
516
- IBCEvent :: WriteAcknowledgementChannel ( v)
536
+ IBCEvent :: WriteAcknowledgement ( v)
517
537
}
518
538
}
519
539
@@ -540,7 +560,7 @@ impl TryFrom<RawObject> for AcknowledgePacket {
540
560
541
561
impl From < AcknowledgePacket > for IBCEvent {
542
562
fn from ( v : AcknowledgePacket ) -> Self {
543
- IBCEvent :: AcknowledgePacketChannel ( v)
563
+ IBCEvent :: AcknowledgePacket ( v)
544
564
}
545
565
}
546
566
@@ -568,7 +588,7 @@ impl TryFrom<RawObject> for TimeoutPacket {
568
588
569
589
impl From < TimeoutPacket > for IBCEvent {
570
590
fn from ( v : TimeoutPacket ) -> Self {
571
- IBCEvent :: TimeoutPacketChannel ( v)
591
+ IBCEvent :: TimeoutPacket ( v)
572
592
}
573
593
}
574
594
@@ -577,3 +597,31 @@ impl std::fmt::Display for TimeoutPacket {
577
597
write ! ( f, "{} {} {}" , self . height, TIMEOUT , self . packet)
578
598
}
579
599
}
600
+
601
+ #[ derive( Debug , Deserialize , Serialize , Clone ) ]
602
+ pub struct TimeoutOnClosePacket {
603
+ pub height : block:: Height ,
604
+ pub packet : Packet ,
605
+ }
606
+
607
+ impl TryFrom < RawObject > for TimeoutOnClosePacket {
608
+ type Error = BoxError ;
609
+ fn try_from ( obj : RawObject ) -> Result < Self , Self :: Error > {
610
+ Ok ( TimeoutOnClosePacket {
611
+ height : obj. height ,
612
+ packet : Packet :: try_from ( obj) ?,
613
+ } )
614
+ }
615
+ }
616
+
617
+ impl From < TimeoutOnClosePacket > for IBCEvent {
618
+ fn from ( v : TimeoutOnClosePacket ) -> Self {
619
+ IBCEvent :: TimeoutOnClosePacket ( v)
620
+ }
621
+ }
622
+
623
+ impl std:: fmt:: Display for TimeoutOnClosePacket {
624
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> Result < ( ) , std:: fmt:: Error > {
625
+ write ! ( f, "{} {} {}" , self . height, TIMEOUT_ON_CLOSE , self . packet)
626
+ }
627
+ }
0 commit comments