Skip to content

Commit

Permalink
NetworkInteractor renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
flypaper0 committed Feb 24, 2023
1 parent 6fdb9a0 commit 9aff388
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 38 deletions.
10 changes: 5 additions & 5 deletions Sources/Chat/ChatClientFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ public struct ChatClientFactory {
let sentInviteStore = KeyedDatabase<SentInvite>(storage: keyValueStorage, identifier: ChatStorageIdentifiers.sentInvites.rawValue)
let threadStore = KeyedDatabase<Thread>(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,
Expand Down
14 changes: 7 additions & 7 deletions Sources/Chat/ProtocolServices/Common/MessagingService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)")
}
Expand All @@ -58,7 +58,7 @@ private extension MessagingService {
}

func setUpResponseHandling() {
networkingInteractor.responseSubscription(on: ChatMessageProtocolMethod())
networkClient.responseSubscription(on: ChatMessageProtocolMethod())
.sink { [unowned self] (payload: ResponseSubscriptionPayload<MessagePayload.Wrapper, ReceiptPayload.Wrapper>) in

logger.debug("Received Receipt response")
Expand All @@ -80,7 +80,7 @@ private extension MessagingService {
}

func setUpRequestHandling() {
networkingInteractor.requestSubscription(on: ChatMessageProtocolMethod())
networkClient.requestSubscription(on: ChatMessageProtocolMethod())
.sink { [unowned self] (payload: RequestSubscriptionPayload<MessagePayload.Wrapper>) in

logger.debug("Received Message Request")
Expand Down Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions Sources/Chat/ProtocolServices/Common/ResubscriptionService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,7 +18,7 @@ class InvitationHandlingService {

init(
keyserverURL: URL,
networkingInteractor: NetworkInteracting,
networkClient: NetworkInteracting,
identityClient: IdentityClient,
accountService: AccountService,
kms: KeyManagementService,
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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)")

Expand All @@ -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(),
Expand All @@ -111,7 +111,7 @@ private extension InvitationHandlingService {
}

func setUpRequestHandling() {
networkingInteractor.requestSubscription(on: ChatInviteProtocolMethod())
networkClient.requestSubscription(on: ChatInviteProtocolMethod())
.sink { [unowned self] (payload: RequestSubscriptionPayload<InvitePayload.Wrapper>) in
logger.debug("Did receive an invite")

Expand Down
14 changes: 7 additions & 7 deletions Sources/Chat/ProtocolServices/Inviter/InviteService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -14,7 +14,7 @@ class InviteService {

init(
keyserverURL: URL,
networkingInteractor: NetworkInteracting,
networkClient: NetworkInteracting,
identityClient: IdentityClient,
accountService: AccountService,
kms: KeyManagementService,
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -83,7 +83,7 @@ class InviteService {
private extension InviteService {

func setUpResponseHandling() {
networkingInteractor.responseSubscription(on: ChatInviteProtocolMethod())
networkClient.responseSubscription(on: ChatInviteProtocolMethod())
.sink { [unowned self] (payload: ResponseSubscriptionPayload<InvitePayload.Wrapper, AcceptPayload.Wrapper>) in
logger.debug("Invite has been accepted")

Expand Down Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions Sources/WalletConnectIdentity/IdentityClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down Expand Up @@ -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)
}
}
4 changes: 2 additions & 2 deletions Sources/WalletConnectIdentity/IdentityClientFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public final class IdentityClientFactory {

public static func create(
keyserver: URL,
networkingInteractor: NetworkInteracting,
networkClient: NetworkInteracting,
keychain: KeychainStorageProtocol,
logger: ConsoleLogging
) -> IdentityClient {
Expand All @@ -16,7 +16,7 @@ public final class IdentityClientFactory {
return IdentityClient(
identityService: identityService,
identityStorage: identityStorage,
networkingInteractor: networkingInteractor,
networkClient: networkClient,
kms: kms,
logger: logger
)
Expand Down

0 comments on commit 9aff388

Please sign in to comment.