diff --git a/Sources/Chat/ChatClientFactory.swift b/Sources/Chat/ChatClientFactory.swift index 209246fc7..eb39c4beb 100644 --- a/Sources/Chat/ChatClientFactory.swift +++ b/Sources/Chat/ChatClientFactory.swift @@ -32,12 +32,12 @@ public struct ChatClientFactory { let sentInviteStore = KeyedDatabase(storage: keyValueStorage, identifier: ChatStorageIdentifiers.sentInvites.rawValue) let threadStore = KeyedDatabase(storage: keyValueStorage, identifier: ChatStorageIdentifiers.threads.rawValue) let chatStorage = ChatStorage(accountService: accountService, messageStore: messageStore, receivedInviteStore: receivedInviteStore, sentInviteStore: sentInviteStore, threadStore: threadStore) - let resubscriptionService = ResubscriptionService(networkingInteractor: networkClient, accountService: accountService, chatStorage: chatStorage, logger: logger) - let identityClient = IdentityClientFactory.create(keyserver: keyserverURL, networkingInteractor: networkClient, keychain: keychain, logger: logger) - let invitationHandlingService = InvitationHandlingService(keyserverURL: keyserverURL, networkingInteractor: networkClient, identityClient: identityClient, accountService: accountService, kms: kms, logger: logger, chatStorage: chatStorage) - let inviteService = InviteService(keyserverURL: keyserverURL, networkingInteractor: networkClient, identityClient: identityClient, accountService: accountService, kms: kms, chatStorage: chatStorage, logger: logger) + let resubscriptionService = ResubscriptionService(networkClient: networkClient, accountService: accountService, chatStorage: chatStorage, logger: logger) + let identityClient = IdentityClientFactory.create(keyserver: keyserverURL, networkClient: networkClient, keychain: keychain, logger: logger) + let invitationHandlingService = InvitationHandlingService(keyserverURL: keyserverURL, networkClient: networkClient, identityClient: identityClient, accountService: accountService, kms: kms, logger: logger, chatStorage: chatStorage) + let inviteService = InviteService(keyserverURL: keyserverURL, networkClient: networkClient, identityClient: identityClient, accountService: accountService, kms: kms, chatStorage: chatStorage, logger: logger) let leaveService = LeaveService() - let messagingService = MessagingService(keyserverURL: keyserverURL, networkingInteractor: networkClient, identityClient: identityClient, accountService: accountService, chatStorage: chatStorage, logger: logger) + let messagingService = MessagingService(keyserverURL: keyserverURL, networkClient: networkClient, identityClient: identityClient, accountService: accountService, chatStorage: chatStorage, logger: logger) let client = ChatClient( identityClient: identityClient, diff --git a/Sources/Chat/ProtocolServices/Common/MessagingService.swift b/Sources/Chat/ProtocolServices/Common/MessagingService.swift index bf60e7e55..95760ea7b 100644 --- a/Sources/Chat/ProtocolServices/Common/MessagingService.swift +++ b/Sources/Chat/ProtocolServices/Common/MessagingService.swift @@ -4,7 +4,7 @@ import Combine class MessagingService { private let keyserverURL: URL - private let networkingInteractor: NetworkInteracting + private let networkClient: NetworkInteracting private let identityClient: IdentityClient private let accountService: AccountService private let chatStorage: ChatStorage @@ -18,14 +18,14 @@ class MessagingService { init( keyserverURL: URL, - networkingInteractor: NetworkInteracting, + networkClient: NetworkInteracting, identityClient: IdentityClient, accountService: AccountService, chatStorage: ChatStorage, logger: ConsoleLogging ) { self.keyserverURL = keyserverURL - self.networkingInteractor = networkingInteractor + self.networkClient = networkClient self.identityClient = identityClient self.accountService = accountService self.chatStorage = chatStorage @@ -45,7 +45,7 @@ class MessagingService { ) let protocolMethod = ChatMessageProtocolMethod() let request = RPCRequest(method: protocolMethod.method, params: wrapper) - try await networkingInteractor.request(request, topic: topic, protocolMethod: protocolMethod) + try await networkClient.request(request, topic: topic, protocolMethod: protocolMethod) logger.debug("Message sent on topic: \(topic)") } @@ -58,7 +58,7 @@ private extension MessagingService { } func setUpResponseHandling() { - networkingInteractor.responseSubscription(on: ChatMessageProtocolMethod()) + networkClient.responseSubscription(on: ChatMessageProtocolMethod()) .sink { [unowned self] (payload: ResponseSubscriptionPayload) in logger.debug("Received Receipt response") @@ -80,7 +80,7 @@ private extension MessagingService { } func setUpRequestHandling() { - networkingInteractor.requestSubscription(on: ChatMessageProtocolMethod()) + networkClient.requestSubscription(on: ChatMessageProtocolMethod()) .sink { [unowned self] (payload: RequestSubscriptionPayload) in logger.debug("Received Message Request") @@ -117,7 +117,7 @@ private extension MessagingService { ) let response = RPCResponse(id: payload.id, result: wrapper) - try await networkingInteractor.respond( + try await networkClient.respond( topic: payload.topic, response: response, protocolMethod: ChatMessageProtocolMethod() diff --git a/Sources/Chat/ProtocolServices/Common/ResubscriptionService.swift b/Sources/Chat/ProtocolServices/Common/ResubscriptionService.swift index 8defc9bdd..119e82b15 100644 --- a/Sources/Chat/ProtocolServices/Common/ResubscriptionService.swift +++ b/Sources/Chat/ProtocolServices/Common/ResubscriptionService.swift @@ -2,17 +2,17 @@ import Foundation import Combine class ResubscriptionService { - private let networkingInteractor: NetworkInteracting + private let networkClient: NetworkInteracting private let accountService: AccountService private let logger: ConsoleLogging private var chatStorage: ChatStorage private var publishers = [AnyCancellable]() - init(networkingInteractor: NetworkInteracting, + init(networkClient: NetworkInteracting, accountService: AccountService, chatStorage: ChatStorage, logger: ConsoleLogging) { - self.networkingInteractor = networkingInteractor + self.networkClient = networkClient self.accountService = accountService self.logger = logger self.chatStorage = chatStorage @@ -21,13 +21,13 @@ class ResubscriptionService { } func setUpResubscription() { - networkingInteractor.socketConnectionStatusPublisher + networkClient.socketConnectionStatusPublisher .sink { [unowned self] status in guard status == .connected else { return } Task(priority: .high) { let topics = chatStorage.getAllThreads().map { $0.topic } - try await networkingInteractor.batchSubscribe(topics: topics) + try await networkClient.batchSubscribe(topics: topics) } }.store(in: &publishers) } diff --git a/Sources/Chat/ProtocolServices/Invitee/InvitationHandlingService.swift b/Sources/Chat/ProtocolServices/Invitee/InvitationHandlingService.swift index e34b1e0f6..489a45da3 100644 --- a/Sources/Chat/ProtocolServices/Invitee/InvitationHandlingService.swift +++ b/Sources/Chat/ProtocolServices/Invitee/InvitationHandlingService.swift @@ -4,7 +4,7 @@ import Combine class InvitationHandlingService { private let keyserverURL: URL - private let networkingInteractor: NetworkInteracting + private let networkClient: NetworkInteracting private let identityClient: IdentityClient private let chatStorage: ChatStorage private let accountService: AccountService @@ -18,7 +18,7 @@ class InvitationHandlingService { init( keyserverURL: URL, - networkingInteractor: NetworkInteracting, + networkClient: NetworkInteracting, identityClient: IdentityClient, accountService: AccountService, kms: KeyManagementService, @@ -27,7 +27,7 @@ class InvitationHandlingService { ) { self.keyserverURL = keyserverURL self.kms = kms - self.networkingInteractor = networkingInteractor + self.networkClient = networkClient self.identityClient = identityClient self.accountService = accountService self.logger = logger @@ -57,7 +57,7 @@ class InvitationHandlingService { payload: payload, account: currentAccount ) - try await networkingInteractor.respond( + try await networkClient.respond( topic: acceptTopic, response: RPCResponse(id: inviteId, result: wrapper), protocolMethod: ChatInviteProtocolMethod() @@ -66,7 +66,7 @@ class InvitationHandlingService { let threadSymmetricKey = try kms.performKeyAgreement(selfPublicKey: publicKey, peerPublicKey: inviterPublicKey) let threadTopic = threadSymmetricKey.derivedTopic() try kms.setSymmetricKey(threadSymmetricKey.sharedKey, for: threadTopic) - try await networkingInteractor.subscribe(topic: threadTopic) + try await networkClient.subscribe(topic: threadTopic) logger.debug("Accepting an invite on topic: \(threadTopic)") @@ -93,7 +93,7 @@ class InvitationHandlingService { let rejectTopic = symmAgreementKey.derivedTopic() try kms.setSymmetricKey(symmAgreementKey.sharedKey, for: rejectTopic) - try await networkingInteractor.respondError( + try await networkClient.respondError( topic: rejectTopic, requestId: RPCID(inviteId), protocolMethod: ChatInviteProtocolMethod(), @@ -111,7 +111,7 @@ private extension InvitationHandlingService { } func setUpRequestHandling() { - networkingInteractor.requestSubscription(on: ChatInviteProtocolMethod()) + networkClient.requestSubscription(on: ChatInviteProtocolMethod()) .sink { [unowned self] (payload: RequestSubscriptionPayload) in logger.debug("Did receive an invite") diff --git a/Sources/Chat/ProtocolServices/Inviter/InviteService.swift b/Sources/Chat/ProtocolServices/Inviter/InviteService.swift index 3ff54e7ee..0d3e4a6a1 100644 --- a/Sources/Chat/ProtocolServices/Inviter/InviteService.swift +++ b/Sources/Chat/ProtocolServices/Inviter/InviteService.swift @@ -5,7 +5,7 @@ class InviteService { private var publishers = [AnyCancellable]() private let keyserverURL: URL - private let networkingInteractor: NetworkInteracting + private let networkClient: NetworkInteracting private let identityClient: IdentityClient private let accountService: AccountService private let logger: ConsoleLogging @@ -14,7 +14,7 @@ class InviteService { init( keyserverURL: URL, - networkingInteractor: NetworkInteracting, + networkClient: NetworkInteracting, identityClient: IdentityClient, accountService: AccountService, kms: KeyManagementService, @@ -23,7 +23,7 @@ class InviteService { ) { self.kms = kms self.keyserverURL = keyserverURL - self.networkingInteractor = networkingInteractor + self.networkClient = networkClient self.identityClient = identityClient self.accountService = accountService self.logger = logger @@ -61,8 +61,8 @@ class InviteService { try kms.setSymmetricKey(symKeyI.sharedKey, for: responseTopic) - try await networkingInteractor.subscribe(topic: responseTopic) - try await networkingInteractor.request(request, topic: inviteTopic, protocolMethod: protocolMethod, envelopeType: .type1(pubKey: selfPubKeyY.rawRepresentation)) + try await networkClient.subscribe(topic: responseTopic) + try await networkClient.request(request, topic: inviteTopic, protocolMethod: protocolMethod, envelopeType: .type1(pubKey: selfPubKeyY.rawRepresentation)) let sentInvite = SentInvite( id: inviteId.integer, @@ -83,7 +83,7 @@ class InviteService { private extension InviteService { func setUpResponseHandling() { - networkingInteractor.responseSubscription(on: ChatInviteProtocolMethod()) + networkClient.responseSubscription(on: ChatInviteProtocolMethod()) .sink { [unowned self] (payload: ResponseSubscriptionPayload) in logger.debug("Invite has been accepted") @@ -114,7 +114,7 @@ private extension InviteService { let threadTopic = agreementKeys.derivedTopic() try kms.setSymmetricKey(agreementKeys.sharedKey, for: threadTopic) - try await networkingInteractor.subscribe(topic: threadTopic) + try await networkClient.subscribe(topic: threadTopic) let thread = Thread( topic: threadTopic, diff --git a/Sources/WalletConnectIdentity/IdentityClient.swift b/Sources/WalletConnectIdentity/IdentityClient.swift index 81db5bbf6..e338a0e95 100644 --- a/Sources/WalletConnectIdentity/IdentityClient.swift +++ b/Sources/WalletConnectIdentity/IdentityClient.swift @@ -8,7 +8,7 @@ public enum SigningResult { public typealias SigningCallback = (String) async -> SigningResult public final class IdentityClient { - private let networkingInteractor: NetworkInteracting + private let networkClient: NetworkInteracting private let identityService: IdentityService private let identityStorage: IdentityStorage private let logger: ConsoleLogging @@ -17,14 +17,14 @@ public final class IdentityClient { init( identityService: IdentityService, identityStorage: IdentityStorage, - networkingInteractor: NetworkInteracting, + networkClient: NetworkInteracting, kms: KeyManagementServiceProtocol, logger: ConsoleLogging ) { self.identityService = identityService self.identityStorage = identityStorage self.kms = kms - self.networkingInteractor = networkingInteractor + self.networkClient = networkClient self.logger = logger } @@ -77,12 +77,12 @@ private extension IdentityClient { func subscribeForInvites(inviteKey: AgreementPublicKey) async throws { let topic = inviteKey.rawRepresentation.sha256().toHexString() try kms.setPublicKey(publicKey: inviteKey, for: topic) - try await networkingInteractor.subscribe(topic: topic) + try await networkClient.subscribe(topic: topic) } func unsubscribeFromInvites(inviteKey: AgreementPublicKey) { let topic = inviteKey.rawRepresentation.sha256().toHexString() kms.deletePublicKey(for: topic) - networkingInteractor.unsubscribe(topic: topic) + networkClient.unsubscribe(topic: topic) } } diff --git a/Sources/WalletConnectIdentity/IdentityClientFactory.swift b/Sources/WalletConnectIdentity/IdentityClientFactory.swift index faffea6be..86de6cae7 100644 --- a/Sources/WalletConnectIdentity/IdentityClientFactory.swift +++ b/Sources/WalletConnectIdentity/IdentityClientFactory.swift @@ -4,7 +4,7 @@ public final class IdentityClientFactory { public static func create( keyserver: URL, - networkingInteractor: NetworkInteracting, + networkClient: NetworkInteracting, keychain: KeychainStorageProtocol, logger: ConsoleLogging ) -> IdentityClient { @@ -16,7 +16,7 @@ public final class IdentityClientFactory { return IdentityClient( identityService: identityService, identityStorage: identityStorage, - networkingInteractor: networkingInteractor, + networkClient: networkClient, kms: kms, logger: logger )