@@ -23,7 +23,7 @@ use crate::ibc::{
23
23
} ;
24
24
use crate :: ibc:: { IbcChannelOpenMsg , IbcChannelOpenResponse } ;
25
25
#[ cfg( feature = "ibc2" ) ]
26
- use crate :: ibc2:: Ibc2PacketReceiveMsg ;
26
+ use crate :: ibc2:: { Ibc2PacketReceiveMsg , Ibc2PacketTimeoutMsg } ;
27
27
use crate :: imports:: { ExternalApi , ExternalQuerier , ExternalStorage } ;
28
28
use crate :: memory:: { Owned , Region } ;
29
29
use crate :: panic:: install_panic_handler;
@@ -455,8 +455,7 @@ where
455
455
/// do_ibc_packet_timeout is designed for use with #[entry_point] to make a "C" extern
456
456
///
457
457
/// contract_fn is called when a packet that this contract previously sent has provably
458
- /// timedout and will never be relayed to the calling chain. This generally behaves
459
- /// like ick_ack_fn upon an acknowledgement containing an error.
458
+ /// timed out and will never be relayed to the destination chain.
460
459
///
461
460
/// - `Q`: custom query type (see QueryRequest)
462
461
/// - `C`: custom response message type (see CosmosMsg)
@@ -555,6 +554,35 @@ where
555
554
Region :: from_vec ( v) . to_heap_ptr ( ) as u32
556
555
}
557
556
557
+ /// do_ibc2_packet_timeout is designed for use with #[entry_point] to make a "C" extern
558
+ ///
559
+ /// contract_fn is called when a packet that this contract previously sent has provably
560
+ /// timed out and will never be relayed to the destination chain.
561
+ ///
562
+ /// - `Q`: custom query type (see QueryRequest)
563
+ /// - `C`: custom response message type (see CosmosMsg)
564
+ /// - `E`: error type for responses
565
+ #[ cfg( feature = "ibc2" ) ]
566
+ pub fn do_ibc2_packet_timeout < Q , C , E > (
567
+ contract_fn : & dyn Fn ( DepsMut < Q > , Env , Ibc2PacketTimeoutMsg ) -> Result < IbcBasicResponse < C > , E > ,
568
+ env_ptr : u32 ,
569
+ msg_ptr : u32 ,
570
+ ) -> u32
571
+ where
572
+ Q : CustomQuery ,
573
+ C : CustomMsg ,
574
+ E : ToString ,
575
+ {
576
+ install_panic_handler ( ) ;
577
+ let res = _do_ibc2_packet_timeout (
578
+ contract_fn,
579
+ env_ptr as * mut Region < Owned > ,
580
+ msg_ptr as * mut Region < Owned > ,
581
+ ) ;
582
+ let v = to_json_vec ( & res) . unwrap ( ) ;
583
+ Region :: from_vec ( v) . to_heap_ptr ( ) as u32
584
+ }
585
+
558
586
fn _do_instantiate < Q , M , C , E > (
559
587
instantiate_fn : & dyn Fn ( DepsMut < Q > , Env , MessageInfo , M ) -> Result < Response < C > , E > ,
560
588
env_ptr : * mut Region < Owned > ,
@@ -945,3 +973,26 @@ where
945
973
let mut deps = make_dependencies ( ) ;
946
974
contract_fn ( deps. as_mut ( ) , env, msg) . into ( )
947
975
}
976
+
977
+ #[ cfg( feature = "ibc2" ) ]
978
+ fn _do_ibc2_packet_timeout < Q , C , E > (
979
+ contract_fn : & dyn Fn ( DepsMut < Q > , Env , Ibc2PacketTimeoutMsg ) -> Result < IbcBasicResponse < C > , E > ,
980
+ env_ptr : * mut Region < Owned > ,
981
+ msg_ptr : * mut Region < Owned > ,
982
+ ) -> ContractResult < IbcBasicResponse < C > >
983
+ where
984
+ Q : CustomQuery ,
985
+ C : CustomMsg ,
986
+ E : ToString ,
987
+ {
988
+ let env: Vec < u8 > =
989
+ unsafe { Region :: from_heap_ptr ( ptr:: NonNull :: new ( env_ptr) . unwrap ( ) ) . into_vec ( ) } ;
990
+ let msg: Vec < u8 > =
991
+ unsafe { Region :: from_heap_ptr ( ptr:: NonNull :: new ( msg_ptr) . unwrap ( ) ) . into_vec ( ) } ;
992
+
993
+ let env: Env = try_into_contract_result ! ( from_json( env) ) ;
994
+ let msg: Ibc2PacketTimeoutMsg = try_into_contract_result ! ( from_json( msg) ) ;
995
+
996
+ let mut deps = make_dependencies ( ) ;
997
+ contract_fn ( deps. as_mut ( ) , env, msg) . into ( )
998
+ }
0 commit comments