@@ -8,11 +8,11 @@ pub mod conn_open_confirm;
88pub mod conn_open_init;
99pub mod conn_open_try;
1010
11- /// Unpacks the client state from the provided [`Any`] type .
11+ /// Unpacks the client state from the format that is stored at the counterparty chain .
1212///
13- /// Currently, the IBC-go enabled chains stores Wasm LightClient states in a
14- /// WasmClientState wrapper. This function unpacks the client state from
15- /// the WasmClientState wrapper if the client identifier is of Wasm client type.
13+ /// Currently, the IBC-go enabled chains stores Wasm LightClient states in a WasmClientState
14+ /// wrapper. This function unpacks the client state from the WasmClientState wrapper
15+ /// if the client identifier at counterparty is of Wasm client type.
1616pub ( crate ) fn unpack_host_client_state < CS > (
1717 value : Any ,
1818 host_client_id_at_counterparty : & ClientId ,
2121 CS : TryFrom < Any > ,
2222 <CS as TryFrom < Any > >:: Error : Into < ClientError > ,
2323{
24- #[ cfg( feature = "wasm-wrapped- client-state " ) ]
24+ #[ cfg( feature = "wasm-client" ) ]
2525 if host_client_id_at_counterparty. is_wasm_client_id ( ) {
2626 use ibc_client_wasm_types:: client_state:: ClientState as WasmClientState ;
2727 use ibc_core_connection_types:: error:: ConnectionError ;
@@ -46,10 +46,44 @@ where
4646 Ok ( CS :: try_from ( value) . map_err ( Into :: < ClientError > :: into) ?)
4747 }
4848
49- #[ cfg( not( feature = "wasm-wrapped- client-state " ) ) ]
49+ #[ cfg( not( feature = "wasm-client" ) ) ]
5050 {
5151 // this avoids lint warning for unused variable.
5252 let _ = host_client_id_at_counterparty;
5353 Ok ( CS :: try_from ( value) . map_err ( Into :: < ClientError > :: into) ?)
5454 }
5555}
56+
57+ /// Pack the host consensus state in the expected format stored at the counterparty chain.
58+ ///
59+ /// Currently, the IBC-go enabled chains stores Wasm LightClient states in a WasmConsensusState
60+ /// wrapper. This function packs the consensus state in the WasmConsensusState wrapper
61+ /// if the client identifier at counterparty is of Wasm client type.
62+ pub ( crate ) fn pack_host_consensus_state < CS > (
63+ value : CS ,
64+ host_client_id_at_counterparty : & ClientId ,
65+ ) -> Any
66+ where
67+ CS : Into < Any > ,
68+ {
69+ let any_value = value. into ( ) ;
70+
71+ #[ cfg( feature = "wasm-client" ) ]
72+ if host_client_id_at_counterparty. is_wasm_client_id ( ) {
73+ use ibc_client_wasm_types:: consensus_state:: ConsensusState as WasmConsensusState ;
74+ use prost:: Message ;
75+
76+ let wasm_consensus_state = WasmConsensusState :: new ( any_value. encode_to_vec ( ) ) ;
77+
78+ wasm_consensus_state. into ( )
79+ } else {
80+ any_value
81+ }
82+
83+ #[ cfg( not( feature = "wasm-client" ) ) ]
84+ {
85+ // this avoids lint warning for unused variable.
86+ let _ = host_client_id_at_counterparty;
87+ any_value
88+ }
89+ }
0 commit comments