Skip to content

Commit

Permalink
Unused removed
Browse files Browse the repository at this point in the history
  • Loading branch information
flypaper0 committed Sep 4, 2023
1 parent 86210c8 commit 71c9886
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
4 changes: 0 additions & 4 deletions Sources/WalletConnectNotify/Client/Wallet/NotifyClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ public class NotifyClient {
return notifyStorage.newSubscriptionPublisher
}

public var subscriptionErrorPublisher: AnyPublisher<Error, Never> {
return notifySubscribeResponseSubscriber.subscriptionErrorPublisher
}

public var deleteSubscriptionPublisher: AnyPublisher<String, Never> {
return notifyStorage.deleteSubscriptionPublisher
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ class NotifySubscribeResponseSubscriber {
case couldNotCreateSubscription
}

private let subscriptionErrorSubject = PassthroughSubject<Error, Never>()

var subscriptionErrorPublisher: AnyPublisher<Error, Never> {
return subscriptionErrorSubject.eraseToAnyPublisher()
}

private let networkingInteractor: NetworkInteracting
private let kms: KeyManagementServiceProtocol
private var publishers = [AnyCancellable]()
Expand Down Expand Up @@ -53,7 +47,7 @@ class NotifySubscribeResponseSubscriber {

guard let responseKeys = kms.getAgreementSecret(for: payload.topic) else {
logger.debug("No symmetric key for topic \(payload.topic)")
return subscriptionErrorSubject.send(Errors.couldNotCreateSubscription)
throw Errors.couldNotCreateSubscription
}

// get keypair Y
Expand Down Expand Up @@ -82,19 +76,19 @@ class NotifySubscribeResponseSubscriber {
try await networkingInteractor.subscribe(topic: notifySubscriptionTopic)
} catch {
logger.debug("NotifySubscribeResponseSubscriber: error: \(error)")
return subscriptionErrorSubject.send(Errors.couldNotCreateSubscription)
throw Errors.couldNotCreateSubscription
}

guard let metadata = metadata else {
logger.debug("NotifySubscribeResponseSubscriber: no metadata for topic: \(notifySubscriptionTopic!)")
return subscriptionErrorSubject.send(Errors.couldNotCreateSubscription)
throw Errors.couldNotCreateSubscription
}
dappsMetadataStore.delete(forKey: payload.topic)
let expiry = Date(timeIntervalSince1970: TimeInterval(claims.exp))
let scope: [String: ScopeValue] = subscribedTypes.reduce(into: [:]) { $0[$1.name] = ScopeValue(description: $1.description, enabled: true) }
let notifySubscription = NotifySubscription(topic: notifySubscriptionTopic, account: account, relay: RelayProtocolOptions(protocol: "irn", data: nil), metadata: metadata, scope: scope, expiry: expiry, symKey: agreementKeysP.sharedKey.hexRepresentation)

try await notifyStorage.setSubscription(notifySubscription)
notifyStorage.setSubscription(notifySubscription)

logger.debug("NotifySubscribeResponseSubscriber: unsubscribing response topic: \(payload.topic)")
networkingInteractor.unsubscribe(topic: payload.topic)
Expand Down

0 comments on commit 71c9886

Please sign in to comment.