@@ -26,7 +26,7 @@ use crate::ibc::{
2626} ;
2727use crate :: ibc:: { IbcChannelOpenMsg , IbcChannelOpenResponse } ;
2828#[ cfg( feature = "ibc2" ) ]
29- use crate :: ibc2:: { Ibc2PacketReceiveMsg , Ibc2PacketTimeoutMsg } ;
29+ use crate :: ibc2:: { Ibc2PacketAckMsg , Ibc2PacketReceiveMsg , Ibc2PacketTimeoutMsg } ;
3030use crate :: query:: CustomQuery ;
3131use crate :: results:: { ContractResult , QueryResponse , Reply , Response } ;
3232use crate :: serde:: { from_json, to_json_vec} ;
@@ -525,6 +525,35 @@ where
525525 Region :: from_vec ( v) . to_heap_ptr ( ) as u32
526526}
527527
528+ /// do_ibc2_packet_ack is designed for use with #[entry_point] to make a "C" extern
529+ ///
530+ /// contract_fn is called when this chain receives an Ibc2 acknowledge payload on port belonging
531+ /// to this contract
532+ ///
533+ /// - `Q`: custom query type (see QueryRequest)
534+ /// - `C`: custom response message type (see CosmosMsg)
535+ /// - `E`: error type for responses
536+ #[ cfg( feature = "ibc2" ) ]
537+ pub fn do_ibc2_packet_ack < Q , C , E > (
538+ contract_fn : & dyn Fn ( DepsMut < Q > , Env , Ibc2PacketAckMsg ) -> Result < IbcBasicResponse < C > , E > ,
539+ env_ptr : u32 ,
540+ msg_ptr : u32 ,
541+ ) -> u32
542+ where
543+ Q : CustomQuery ,
544+ C : CustomMsg ,
545+ E : ToString ,
546+ {
547+ install_panic_handler ( ) ;
548+ let res = _do_ibc2_packet_ack (
549+ contract_fn,
550+ env_ptr as * mut Region < Owned > ,
551+ msg_ptr as * mut Region < Owned > ,
552+ ) ;
553+ let v = to_json_vec ( & res) . unwrap ( ) ;
554+ Region :: from_vec ( v) . to_heap_ptr ( ) as u32
555+ }
556+
528557/// do_ibc2_packet_receive is designed for use with #[entry_point] to make a "C" extern
529558///
530559/// contract_fn is called when this chain receives an Ibc2 payload on port belonging
@@ -938,6 +967,29 @@ where
938967 contract_fn ( deps. as_mut ( ) , env, msg) . into ( )
939968}
940969
970+ #[ cfg( feature = "ibc2" ) ]
971+ fn _do_ibc2_packet_ack < Q , C , E > (
972+ contract_fn : & dyn Fn ( DepsMut < Q > , Env , Ibc2PacketAckMsg ) -> Result < IbcBasicResponse < C > , E > ,
973+ env_ptr : * mut Region < Owned > ,
974+ msg_ptr : * mut Region < Owned > ,
975+ ) -> ContractResult < IbcBasicResponse < C > >
976+ where
977+ Q : CustomQuery ,
978+ C : CustomMsg ,
979+ E : ToString ,
980+ {
981+ let env: Vec < u8 > =
982+ unsafe { Region :: from_heap_ptr ( ptr:: NonNull :: new ( env_ptr) . unwrap ( ) ) . into_vec ( ) } ;
983+ let msg: Vec < u8 > =
984+ unsafe { Region :: from_heap_ptr ( ptr:: NonNull :: new ( msg_ptr) . unwrap ( ) ) . into_vec ( ) } ;
985+
986+ let env: Env = try_into_contract_result ! ( from_json( env) ) ;
987+ let msg: Ibc2PacketAckMsg = try_into_contract_result ! ( from_json( msg) ) ;
988+
989+ let mut deps = deps_from_imports ( ) ;
990+ contract_fn ( deps. as_mut ( ) , env, msg) . into ( )
991+ }
992+
941993#[ cfg( feature = "ibc2" ) ]
942994fn _do_ibc2_packet_receive < Q , C , E > (
943995 contract_fn : & dyn Fn ( DepsMut < Q > , Env , Ibc2PacketReceiveMsg ) -> Result < IbcReceiveResponse < C > , E > ,
0 commit comments