@@ -80,10 +80,9 @@ pub enum Actor {
80
80
}
81
81
82
82
impl Connection {
83
- pub async fn create ( source_id : & str , autohop_enabled : bool , agency_client : & AgencyClient ) -> VcxResult < Self > {
83
+ pub async fn create ( source_id : & str , wallet_handle : WalletHandle , agency_client : & AgencyClient , autohop_enabled : bool ) -> VcxResult < Self > {
84
84
trace ! ( "Connection::create >>> source_id: {}" , source_id) ;
85
- // todo: Would be cleaner to pass wallet_handle as argument instead of reading off AgencyClient
86
- let pairwise_info = PairwiseInfo :: create ( agency_client. get_wallet_handle ( ) ) . await ?;
85
+ let pairwise_info = PairwiseInfo :: create ( wallet_handle) . await ?;
87
86
let cloud_agent_info = CloudAgentInfo :: create ( agency_client, & pairwise_info) . await ?;
88
87
Ok ( Self {
89
88
cloud_agent_info,
@@ -92,9 +91,9 @@ impl Connection {
92
91
} )
93
92
}
94
93
95
- pub async fn create_with_invite ( source_id : & str , invitation : Invitation , autohop_enabled : bool , agency_client : & AgencyClient ) -> VcxResult < Self > {
94
+ pub async fn create_with_invite ( source_id : & str , wallet_handle : WalletHandle , agency_client : & AgencyClient , invitation : Invitation , autohop_enabled : bool ) -> VcxResult < Self > {
96
95
trace ! ( "Connection::create_with_invite >>> source_id: {}, invitation: {:?}" , source_id, invitation) ;
97
- let pairwise_info = PairwiseInfo :: create ( agency_client . get_wallet_handle ( ) ) . await ?;
96
+ let pairwise_info = PairwiseInfo :: create ( wallet_handle ) . await ?;
98
97
let cloud_agent_info = CloudAgentInfo :: create ( agency_client, & pairwise_info) . await ?;
99
98
let mut connection = Self {
100
99
cloud_agent_info,
@@ -183,15 +182,6 @@ impl Connection {
183
182
self . cloud_agent_info . clone ( )
184
183
}
185
184
186
- // pub fn bootstrap_agent_info(&self) -> Option<&PairwiseInfo> {
187
- // match &self.connection_sm {
188
- // SmConnection::Inviter(sm_inviter) => {
189
- // sm_inviter.prev_agent_info()
190
- // }
191
- // SmConnection::Invitee(_sm_invitee) => None
192
- // }
193
- // }
194
-
195
185
pub fn remote_did ( & self ) -> VcxResult < String > {
196
186
match & self . connection_sm {
197
187
SmConnection :: Inviter ( sm_inviter) => {
@@ -355,19 +345,6 @@ impl Connection {
355
345
}
356
346
}
357
347
358
- // fn _get_bootstrap_agent_messages(&self, remote_vk: VcxResult<String>, bootstrap_agent_info: Option<&PairwiseInfo>) -> VcxResult<Option<(HashMap<String, A2AMessage>, PairwiseInfo)>> {
359
- // let expected_sender_vk = match remote_vk {
360
- // Ok(vk) => vk,
361
- // Err(_) => return Ok(None)
362
- // };
363
- // if let Some(bootstrap_agent_info) = bootstrap_agent_info {
364
- // trace!("Connection::_get_bootstrap_agent_messages >>> Inviter found no message to handle on main connection agent. Will check bootstrap agent.");
365
- // let messages = bootstrap_agent_info.get_messages(&expected_sender_vk)?;
366
- // return Ok(Some((messages, bootstrap_agent_info.clone())));
367
- // }
368
- // Ok(None)
369
- // }
370
-
371
348
fn _update_state ( & mut self , wallet_handle : WalletHandle , message : Option < A2AMessage > , agency_client : AgencyClient ) -> BoxFuture < ' _ , VcxResult < ( ) > > {
372
349
Box :: pin ( async move {
373
350
let ( new_connection_sm, can_autohop) = match & self . connection_sm {
@@ -404,18 +381,8 @@ impl Connection {
404
381
self . cloud_agent_info ( ) . clone ( ) . update_message_status ( agency_client, self . pairwise_info ( ) , uid) . await ?;
405
382
}
406
383
None => {
407
- // Todo: Restore lookup into bootstrap cloud agent
408
- // self.bootstrap_agent_info()
409
- // if let Some((messages, bootstrap_agent_info)) = self._get_bootstrap_agent_messages(self.remote_vk(), )? {
410
- // if let Some((uid, message)) = self.find_message_to_handle(messages) {
411
- // trace!("Connection::update_state >>> handling message found on bootstrap agent uid: {:?}", uid);
412
- // self._update_state(Some(message))?;
413
- // bootstrap_agent_info.update_message_status(uid)?;
414
- // }
415
- // } else {
416
384
trace ! ( "Connection::update_state >>> trying to update state without message" ) ;
417
385
self . _update_state ( wallet_handle, None , agency_client. clone ( ) ) . await ?;
418
- // }
419
386
}
420
387
}
421
388
Ok ( ( ) )
@@ -851,7 +818,7 @@ mod tests {
851
818
let _setup = SetupMocks :: init ( ) ;
852
819
let agency_client = AgencyClient :: new ( ) ;
853
820
enable_agency_mocks ( ) ;
854
- let connection = Connection :: create_with_invite ( "abc" , Invitation :: Pairwise ( _pairwise_invitation ( ) ) , true , & agency_client ) . await . unwrap ( ) ;
821
+ let connection = Connection :: create_with_invite ( "abc" , WalletHandle ( 0 ) , & agency_client , Invitation :: Pairwise ( _pairwise_invitation ( ) ) , true ) . await . unwrap ( ) ;
855
822
assert_eq ! ( connection. get_state( ) , ConnectionState :: Invitee ( InviteeState :: Invited ) ) ;
856
823
}
857
824
@@ -860,7 +827,7 @@ mod tests {
860
827
let _setup = SetupMocks :: init ( ) ;
861
828
let agency_client = AgencyClient :: new ( ) ;
862
829
enable_agency_mocks ( ) ;
863
- let connection = Connection :: create_with_invite ( "abc" , Invitation :: Public ( _public_invitation ( ) ) , true , & agency_client ) . await . unwrap ( ) ;
830
+ let connection = Connection :: create_with_invite ( "abc" , WalletHandle ( 0 ) , & agency_client , Invitation :: Public ( _public_invitation ( ) ) , true ) . await . unwrap ( ) ;
864
831
assert_eq ! ( connection. get_state( ) , ConnectionState :: Invitee ( InviteeState :: Invited ) ) ;
865
832
}
866
833
@@ -871,13 +838,13 @@ mod tests {
871
838
enable_agency_mocks ( ) ;
872
839
873
840
let pub_inv = _public_invitation_random_id ( ) ;
874
- let mut connection = Connection :: create_with_invite ( "abcd" , Invitation :: Public ( pub_inv. clone ( ) ) , true , & agency_client ) . await . unwrap ( ) ;
841
+ let mut connection = Connection :: create_with_invite ( "abcd" , WalletHandle ( 0 ) , & agency_client , Invitation :: Public ( pub_inv. clone ( ) ) , true ) . await . unwrap ( ) ;
875
842
connection. connect ( WalletHandle ( 0 ) , & agency_client) . await . unwrap ( ) ;
876
843
assert_eq ! ( connection. get_state( ) , ConnectionState :: Invitee ( InviteeState :: Requested ) ) ;
877
844
assert_ne ! ( connection. get_thread_id( ) , pub_inv. id. 0 ) ;
878
845
879
846
let pw_inv = _pairwise_invitation_random_id ( ) ;
880
- let mut connection = Connection :: create_with_invite ( "dcba" , Invitation :: Pairwise ( pw_inv. clone ( ) ) , true , & agency_client ) . await . unwrap ( ) ;
847
+ let mut connection = Connection :: create_with_invite ( "dcba" , WalletHandle ( 0 ) , & agency_client , Invitation :: Pairwise ( pw_inv. clone ( ) ) , true ) . await . unwrap ( ) ;
881
848
connection. connect ( WalletHandle ( 0 ) , & agency_client) . await . unwrap ( ) ;
882
849
assert_eq ! ( connection. get_state( ) , ConnectionState :: Invitee ( InviteeState :: Requested ) ) ;
883
850
assert_eq ! ( connection. get_thread_id( ) , pw_inv. id. 0 ) ;
@@ -934,7 +901,7 @@ mod tests {
934
901
async fn test_serialize_deserialize ( ) {
935
902
let _setup = SetupMocks :: init ( ) ;
936
903
937
- let connection = Connection :: create ( "test_serialize_deserialize" , true , & _dummy_agency_client ( ) ) . await . unwrap ( ) ;
904
+ let connection = Connection :: create ( "test_serialize_deserialize" , WalletHandle ( 0 ) , & _dummy_agency_client ( ) , true ) . await . unwrap ( ) ;
938
905
let first_string = connection. to_string ( ) . unwrap ( ) ;
939
906
940
907
let connection2 = Connection :: from_string ( & first_string) . unwrap ( ) ;
@@ -947,7 +914,7 @@ mod tests {
947
914
async fn test_serialize_deserialize_serde ( ) {
948
915
let _setup = SetupMocks :: init ( ) ;
949
916
950
- let connection = Connection :: create ( "test_serialize_deserialize" , true , & _dummy_agency_client ( ) ) . await . unwrap ( ) ;
917
+ let connection = Connection :: create ( "test_serialize_deserialize" , WalletHandle ( 0 ) , & _dummy_agency_client ( ) , true ) . await . unwrap ( ) ;
951
918
let first_string = serde_json:: to_string ( & connection) . unwrap ( ) ;
952
919
953
920
let connection: Connection = serde_json:: from_str ( & first_string) . unwrap ( ) ;
0 commit comments