Skip to content

Commit b82e750

Browse files
committed
NotifyIdentityService removed
1 parent ac53c3c commit b82e750

File tree

3 files changed

+29
-58
lines changed

3 files changed

+29
-58
lines changed

Sources/WalletConnectNotify/Client/Wallet/NotifyClient.swift

+27-7
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ public class NotifyClient {
2222

2323
public let logger: ConsoleLogging
2424

25+
private let keyserverURL: URL
2526
private let pushClient: PushClient
26-
private let identityService: NotifyIdentityService
27+
private let identityClient: IdentityClient
2728
private let notifyStorage: NotifyStorage
2829
private let notifyAccountProvider: NotifyAccountProvider
2930
private let notifyMessageSubscriber: NotifyMessageSubscriber
@@ -38,8 +39,9 @@ public class NotifyClient {
3839
private let subscriptionWatcher: SubscriptionWatcher
3940

4041
init(logger: ConsoleLogging,
42+
keyserverURL: URL,
4143
kms: KeyManagementServiceProtocol,
42-
identityService: NotifyIdentityService,
44+
identityClient: IdentityClient,
4345
pushClient: PushClient,
4446
notifyMessageSubscriber: NotifyMessageSubscriber,
4547
notifyStorage: NotifyStorage,
@@ -57,8 +59,9 @@ public class NotifyClient {
5759
subscriptionWatcher: SubscriptionWatcher
5860
) {
5961
self.logger = logger
62+
self.keyserverURL = keyserverURL
6063
self.pushClient = pushClient
61-
self.identityService = identityService
64+
self.identityClient = identityClient
6265
self.notifyMessageSubscriber = notifyMessageSubscriber
6366
self.notifyStorage = notifyStorage
6467
self.deleteNotifySubscriptionRequester = deleteNotifySubscriptionRequester
@@ -76,17 +79,22 @@ public class NotifyClient {
7679
}
7780

7881
public func prepareRegistration(account: Account, domain: String, allApps: Bool = true) async throws -> IdentityRegistrationParams {
79-
return try await identityService.prepareRegistration(account: account, domain: domain, allApps: allApps)
82+
return try await identityClient.prepareRegistration(
83+
account: account,
84+
domain: domain,
85+
statement: makeStatement(allApps: allApps),
86+
resources: [keyserverURL.absoluteString]
87+
)
8088
}
8189

8290
public func register(params: IdentityRegistrationParams, signature: CacaoSignature) async throws {
83-
try await identityService.register(params: params, signature: signature)
91+
try await identityClient.register(params: params, signature: signature)
8492
notifyAccountProvider.setAccount(try params.account)
8593
try await subscriptionWatcher.start()
8694
}
8795

8896
public func unregister(account: Account) async throws {
89-
try await identityService.unregister(account: account)
97+
try await identityClient.unregister(account: account)
9098
notifyWatcherAgreementKeysProvider.removeAgreement(account: account)
9199
try notifyStorage.clearDatabase(account: account)
92100
notifyAccountProvider.logout()
@@ -126,7 +134,7 @@ public class NotifyClient {
126134
}
127135

128136
public func isIdentityRegistered(account: Account) -> Bool {
129-
return identityService.isIdentityRegistered(account: account)
137+
return identityClient.isIdentityRegistered(account: account)
130138
}
131139

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

149+
private extension NotifyClient {
150+
151+
func makeStatement(allApps: Bool) -> String {
152+
switch allApps {
153+
case false:
154+
return "I further authorize this app to send me notifications. Read more at https://walletconnect.com/notifications"
155+
case true:
156+
return "I further authorize this app to view and manage my notifications for ALL apps. Read more at https://walletconnect.com/notifications"
157+
}
158+
}
159+
}
160+
141161
#if targetEnvironment(simulator)
142162
extension NotifyClient {
143163

Sources/WalletConnectNotify/Client/Wallet/NotifyClientFactory.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,11 @@ public struct NotifyClientFactory {
6969
let notifySubscriptionsChangedRequestSubscriber = NotifySubscriptionsChangedRequestSubscriber(keyserver: keyserverURL, networkingInteractor: networkInteractor, kms: kms, identityClient: identityClient, logger: logger, groupKeychainStorage: groupKeychainStorage, notifyStorage: notifyStorage, notifySubscriptionsBuilder: notifySubscriptionsBuilder)
7070
let subscriptionWatcher = SubscriptionWatcher(notifyWatchSubscriptionsRequester: notifyWatchSubscriptionsRequester, logger: logger)
7171

72-
let identityService = NotifyIdentityService(keyserverURL: keyserverURL, identityClient: identityClient, logger: logger)
73-
7472
return NotifyClient(
7573
logger: logger,
74+
keyserverURL: keyserverURL,
7675
kms: kms,
77-
identityService: identityService,
76+
identityClient: identityClient,
7877
pushClient: pushClient,
7978
notifyMessageSubscriber: notifyMessageSubscriber,
8079
notifyStorage: notifyStorage,

Sources/WalletConnectNotify/Client/Wallet/NotifyIdentityService.swift

-48
This file was deleted.

0 commit comments

Comments
 (0)