Skip to content

Commit

Permalink
NotifyIdentityService removed
Browse files Browse the repository at this point in the history
  • Loading branch information
flypaper0 committed Dec 7, 2023
1 parent ac53c3c commit b82e750
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 58 deletions.
34 changes: 27 additions & 7 deletions Sources/WalletConnectNotify/Client/Wallet/NotifyClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ public class NotifyClient {

public let logger: ConsoleLogging

private let keyserverURL: URL
private let pushClient: PushClient
private let identityService: NotifyIdentityService
private let identityClient: IdentityClient
private let notifyStorage: NotifyStorage
private let notifyAccountProvider: NotifyAccountProvider
private let notifyMessageSubscriber: NotifyMessageSubscriber
Expand All @@ -38,8 +39,9 @@ public class NotifyClient {
private let subscriptionWatcher: SubscriptionWatcher

init(logger: ConsoleLogging,
keyserverURL: URL,
kms: KeyManagementServiceProtocol,
identityService: NotifyIdentityService,
identityClient: IdentityClient,
pushClient: PushClient,
notifyMessageSubscriber: NotifyMessageSubscriber,
notifyStorage: NotifyStorage,
Expand All @@ -57,8 +59,9 @@ public class NotifyClient {
subscriptionWatcher: SubscriptionWatcher
) {
self.logger = logger
self.keyserverURL = keyserverURL
self.pushClient = pushClient
self.identityService = identityService
self.identityClient = identityClient
self.notifyMessageSubscriber = notifyMessageSubscriber
self.notifyStorage = notifyStorage
self.deleteNotifySubscriptionRequester = deleteNotifySubscriptionRequester
Expand All @@ -76,17 +79,22 @@ public class NotifyClient {
}

public func prepareRegistration(account: Account, domain: String, allApps: Bool = true) async throws -> IdentityRegistrationParams {
return try await identityService.prepareRegistration(account: account, domain: domain, allApps: allApps)
return try await identityClient.prepareRegistration(
account: account,
domain: domain,
statement: makeStatement(allApps: allApps),
resources: [keyserverURL.absoluteString]
)
}

public func register(params: IdentityRegistrationParams, signature: CacaoSignature) async throws {
try await identityService.register(params: params, signature: signature)
try await identityClient.register(params: params, signature: signature)
notifyAccountProvider.setAccount(try params.account)
try await subscriptionWatcher.start()
}

public func unregister(account: Account) async throws {
try await identityService.unregister(account: account)
try await identityClient.unregister(account: account)
notifyWatcherAgreementKeysProvider.removeAgreement(account: account)
try notifyStorage.clearDatabase(account: account)
notifyAccountProvider.logout()
Expand Down Expand Up @@ -126,7 +134,7 @@ public class NotifyClient {
}

public func isIdentityRegistered(account: Account) -> Bool {
return identityService.isIdentityRegistered(account: account)
return identityClient.isIdentityRegistered(account: account)
}

public func subscriptionsPublisher(account: Account) -> AnyPublisher<[NotifySubscription], Never> {
Expand All @@ -138,6 +146,18 @@ public class NotifyClient {
}
}

private extension NotifyClient {

func makeStatement(allApps: Bool) -> String {
switch allApps {
case false:
return "I further authorize this app to send me notifications. Read more at https://walletconnect.com/notifications"
case true:
return "I further authorize this app to view and manage my notifications for ALL apps. Read more at https://walletconnect.com/notifications"
}
}
}

#if targetEnvironment(simulator)
extension NotifyClient {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,11 @@ public struct NotifyClientFactory {
let notifySubscriptionsChangedRequestSubscriber = NotifySubscriptionsChangedRequestSubscriber(keyserver: keyserverURL, networkingInteractor: networkInteractor, kms: kms, identityClient: identityClient, logger: logger, groupKeychainStorage: groupKeychainStorage, notifyStorage: notifyStorage, notifySubscriptionsBuilder: notifySubscriptionsBuilder)
let subscriptionWatcher = SubscriptionWatcher(notifyWatchSubscriptionsRequester: notifyWatchSubscriptionsRequester, logger: logger)

let identityService = NotifyIdentityService(keyserverURL: keyserverURL, identityClient: identityClient, logger: logger)

return NotifyClient(
logger: logger,
keyserverURL: keyserverURL,
kms: kms,
identityService: identityService,
identityClient: identityClient,
pushClient: pushClient,
notifyMessageSubscriber: notifyMessageSubscriber,
notifyStorage: notifyStorage,
Expand Down

This file was deleted.

0 comments on commit b82e750

Please sign in to comment.