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