@@ -23,7 +23,7 @@ use crate::ibc::{
2323} ;
2424use crate :: ibc:: { IbcChannelOpenMsg , IbcChannelOpenResponse } ;
2525#[ cfg( feature = "ibc2" ) ]
26- use crate :: ibc2:: Ibc2PacketReceiveMsg ;
26+ use crate :: ibc2:: { Ibc2PacketReceiveMsg , Ibc2PacketTimeoutMsg } ;
2727use crate :: imports:: { ExternalApi , ExternalQuerier , ExternalStorage } ;
2828use crate :: memory:: { Owned , Region } ;
2929use crate :: panic:: install_panic_handler;
@@ -455,8 +455,7 @@ where
455455/// do_ibc_packet_timeout is designed for use with #[entry_point] to make a "C" extern
456456///
457457/// 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.
460459///
461460/// - `Q`: custom query type (see QueryRequest)
462461/// - `C`: custom response message type (see CosmosMsg)
@@ -555,6 +554,35 @@ where
555554 Region :: from_vec ( v) . to_heap_ptr ( ) as u32
556555}
557556
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+
558586fn _do_instantiate < Q , M , C , E > (
559587 instantiate_fn : & dyn Fn ( DepsMut < Q > , Env , MessageInfo , M ) -> Result < Response < C > , E > ,
560588 env_ptr : * mut Region < Owned > ,
@@ -945,3 +973,26 @@ where
945973 let mut deps = make_dependencies ( ) ;
946974 contract_fn ( deps. as_mut ( ) , env, msg) . into ( )
947975}
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