1515// along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
1717use super :: path as connection_path;
18- use super :: types:: { CommitmentPrefix , Identifier } ;
18+ use super :: types:: { CommitmentPrefix , CommitmentProof , Identifier } ;
1919use crate :: ibc;
2020use crate :: ibc:: connection_03:: client_connections_path;
2121use crate :: ibc:: connection_03:: types:: { ConnectionEnd , ConnectionIdentifiersInClient , ConnectionState } ;
@@ -24,6 +24,11 @@ use rlp::{Encodable, Rlp};
2424#[ derive( Default ) ]
2525pub struct Manager { }
2626
27+ // FIXME:
28+ fn get_commiment_prefix ( ) -> String {
29+ "" . to_owned ( )
30+ }
31+
2732impl Manager {
2833 pub fn new ( ) -> Self {
2934 Manager { }
@@ -55,6 +60,71 @@ impl Manager {
5560 Ok ( ( ) )
5661 }
5762
63+ // We can't know the exact format of counterparty parameters
64+ pub fn handle_open_try (
65+ & self ,
66+ ctx : & mut dyn ibc:: Context ,
67+ desired_identifier : Identifier ,
68+ counterparty_connection_identifier : Identifier ,
69+ counterparty_prefix : CommitmentPrefix ,
70+ counterparty_client_identifier : Identifier ,
71+ client_identifier : Identifier ,
72+ counterparty_versions : Vec < String > ,
73+ proof_init : CommitmentProof ,
74+ proof_consensus : CommitmentProof ,
75+ proof_height : u64 ,
76+ consensus_height : u64 ,
77+ ) -> Result < ( ) , String > {
78+ if consensus_height > ctx. get_current_height ( ) {
79+ return Err ( format ! (
80+ "Consensus height {} is greater than current height {}" ,
81+ consensus_height,
82+ ctx. get_current_height( )
83+ ) )
84+ }
85+ let expected = ConnectionEnd {
86+ state : ConnectionState :: INIT ,
87+ counterparty_connection_identifier : desired_identifier,
88+ counterparty_prefix : get_commiment_prefix ( ) ,
89+ client_identifier,
90+ counterparty_client_identifier,
91+ } ;
92+
93+ // let connection =
94+
95+ // consensus_height <
96+ Ok ( ( ) )
97+ }
98+
99+ fn verify_connection_state (
100+ & self ,
101+ ctx : & mut dyn ibc:: Context ,
102+ connection : ConnectionEnd ,
103+ proof_height : u64 ,
104+ proof : CommitmentProof ,
105+ connection_identifier : Identifier ,
106+ connection_end : ConnectionEnd ,
107+ ) -> Result < ( ) , String > {
108+ // let client_manager = ibc::client_02::Manager::new();
109+ // should we use connection.client_identifier?
110+ // let client = client_manager.query(ctx, &connection.client_identifier)?;
111+ // client.verify
112+ let path = format ! ( "connections/{}" , connection_identifier) ;
113+
114+ let
115+ self . client_verify_membership( proof_height, proof, path, connection_end. ) ;
116+ }
117+
118+ fn client_verify_membership (
119+ & self ,
120+ _height : u64 ,
121+ _commitment_proof : CommitmentProof ,
122+ _path : String ,
123+ _value : String ,
124+ ) {
125+ true
126+ }
127+
58128 fn add_connection_to_client (
59129 & self ,
60130 ctx : & mut dyn ibc:: Context ,
0 commit comments