Skip to content

Commit

Permalink
Merge pull request #1127 from WalletConnect/develop
Browse files Browse the repository at this point in the history
1.8.3
  • Loading branch information
llbartekll authored Sep 20, 2023
2 parents 4f8789b + d432511 commit 192ff62
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 33 deletions.
17 changes: 9 additions & 8 deletions Example/IntegrationTests/Push/NotifyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ final class NotifyTests: XCTestCase {
environment: .sandbox)
let keyserverURL = URL(string: "https://keys.walletconnect.com")!
let client = NotifyClientFactory.create(keyserverURL: keyserverURL,
logger: notifyLogger,
keyValueStorage: keyValueStorage,
keychainStorage: keychain,
groupKeychainStorage: KeychainStorageMock(),
networkInteractor: networkingInteractor,
pairingRegisterer: pairingClient,
pushClient: pushClient,
crypto: DefaultCryptoProvider())
logger: notifyLogger,
keyValueStorage: keyValueStorage,
keychainStorage: keychain,
groupKeychainStorage: KeychainStorageMock(),
networkInteractor: networkingInteractor,
pairingRegisterer: pairingClient,
pushClient: pushClient,
crypto: DefaultCryptoProvider(),
notifyHost: InputConfig.notifyHost)
return client
}

Expand Down
10 changes: 1 addition & 9 deletions Example/IntegrationTests/Push/Publisher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@ import Foundation

class Publisher {
func notify(topic: String, account: Account, message: NotifyMessage) async throws {
let url = URL(string: "https://\(InputConfig.castHost)/\(InputConfig.gmDappProjectId)/notify")!
print("________________________________________")
print("________________________________________")
print("________________________________________")
print(InputConfig.gmDappHost)
print("________________________________________")
print("________________________________________")
print("________________________________________")

let url = URL(string: "https://\(InputConfig.notifyHost)/\(InputConfig.gmDappProjectId)/notify")!
var request = URLRequest(url: url)
let notifyRequestPayload = NotifyRequest(notification: message, accounts: [account])
let encoder = JSONEncoder()
Expand Down
8 changes: 4 additions & 4 deletions Example/Shared/Tests/InputConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ struct InputConfig {
return config(for: "RELAY_HOST")!
}

static var castHost: String {
return config(for: "CAST_HOST")!
}

static var gmDappProjectId: String {
return config(for: "GM_DAPP_PROJECT_ID")!
}
Expand All @@ -26,6 +22,10 @@ struct InputConfig {
return config(for: "JS_CLIENT_API_HOST")!
}

static var notifyHost: String {
return config(for: "CAST_HOST")!
}

static var relayUrl: String {
return "wss://\(relayHost)"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation

public struct NotifyClientFactory {

public static func create(groupIdentifier: String, networkInteractor: NetworkInteracting, pairingRegisterer: PairingRegisterer, pushClient: PushClient, crypto: CryptoProvider) -> NotifyClient {
public static func create(groupIdentifier: String, networkInteractor: NetworkInteracting, pairingRegisterer: PairingRegisterer, pushClient: PushClient, crypto: CryptoProvider, notifyHost: String) -> NotifyClient {
let logger = ConsoleLogger(prefix: "🔔",loggingLevel: .debug)
let keyValueStorage = UserDefaults.standard
let keyserverURL = URL(string: "https://keys.walletconnect.com")!
Expand All @@ -18,7 +18,8 @@ public struct NotifyClientFactory {
networkInteractor: networkInteractor,
pairingRegisterer: pairingRegisterer,
pushClient: pushClient,
crypto: crypto
crypto: crypto,
notifyHost: notifyHost
)
}

Expand All @@ -31,7 +32,8 @@ public struct NotifyClientFactory {
networkInteractor: NetworkInteracting,
pairingRegisterer: PairingRegisterer,
pushClient: PushClient,
crypto: CryptoProvider
crypto: CryptoProvider,
notifyHost: String
) -> NotifyClient {
let kms = KeyManagementService(keychain: keychainStorage)
let subscriptionStore = KeyedDatabase<NotifySubscription>(storage: keyValueStorage, identifier: NotifyStorageIdntifiers.notifySubscription)
Expand All @@ -56,7 +58,7 @@ public struct NotifyClientFactory {

let subscriptionsAutoUpdater = SubscriptionsAutoUpdater(notifyUpdateRequester: notifyUpdateRequester, logger: logger, notifyStorage: notifyStorage)

let notifyWatchSubscriptionsRequester = NotifyWatchSubscriptionsRequester(keyserverURL: keyserverURL, networkingInteractor: networkInteractor, identityClient: identityClient, logger: logger, kms: kms, webDidResolver: webDidResolver)
let notifyWatchSubscriptionsRequester = NotifyWatchSubscriptionsRequester(keyserverURL: keyserverURL, networkingInteractor: networkInteractor, identityClient: identityClient, logger: logger, kms: kms, webDidResolver: webDidResolver, notifyHost: notifyHost)
let notifySubscriptionsBuilder = NotifySubscriptionsBuilder(notifyConfigProvider: notifyConfigProvider)
let notifyWatchSubscriptionsResponseSubscriber = NotifyWatchSubscriptionsResponseSubscriber(networkingInteractor: networkInteractor, kms: kms, logger: logger, notifyStorage: notifyStorage, groupKeychainStorage: groupKeychainStorage, notifySubscriptionsBuilder: notifySubscriptionsBuilder)
let notifySubscriptionsChangedRequestSubscriber = NotifySubscriptionsChangedRequestSubscriber(keyserver: keyserverURL, networkingInteractor: networkInteractor, kms: kms, identityClient: identityClient, logger: logger, groupKeychainStorage: groupKeychainStorage, notifyStorage: notifyStorage, notifySubscriptionsBuilder: notifySubscriptionsBuilder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class NotifyWatchSubscriptionsRequester {
private let kms: KeyManagementService
private let logger: ConsoleLogging
private let webDidResolver: NotifyWebDidResolver
private let notifyServerUrl = "notify.walletconnect.com"
private let notifyHost: String
private var account: Account?
private var publishers = Set<AnyCancellable>()

Expand All @@ -18,14 +18,16 @@ class NotifyWatchSubscriptionsRequester {
identityClient: IdentityClient,
logger: ConsoleLogging,
kms: KeyManagementService,
webDidResolver: NotifyWebDidResolver
webDidResolver: NotifyWebDidResolver,
notifyHost: String
) {
self.keyserverURL = keyserverURL
self.identityClient = identityClient
self.networkingInteractor = networkingInteractor
self.logger = logger
self.kms = kms
self.webDidResolver = webDidResolver
self.notifyHost = notifyHost
setUpWatchSubscriptionsOnSocketConnection()
}

Expand All @@ -49,8 +51,8 @@ class NotifyWatchSubscriptionsRequester {

logger.debug("Watching subscriptions")

let notifyServerPublicKey = try await webDidResolver.resolveAgreementKey(domain: notifyServerUrl)
let notifyServerAuthenticationKey = try await webDidResolver.resolveAuthenticationKey(domain: notifyServerUrl)
let notifyServerPublicKey = try await webDidResolver.resolveAgreementKey(domain: notifyHost)
let notifyServerAuthenticationKey = try await webDidResolver.resolveAuthenticationKey(domain: notifyHost)
let notifyServerAuthenticationDidKey = DIDKey(rawData: notifyServerAuthenticationKey)
let watchSubscriptionsTopic = notifyServerPublicKey.rawRepresentation.sha256().toHexString()

Expand Down
7 changes: 4 additions & 3 deletions Sources/WalletConnectNotify/Notify.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public class Notify {
networkInteractor: Networking.interactor,
pairingRegisterer: Pair.registerer,
pushClient: Push.instance,
crypto: config.crypto
crypto: config.crypto,
notifyHost: config.notifyHost
)
}()

Expand All @@ -20,8 +21,8 @@ public class Notify {
private init() { }

/// Wallet's configuration method
static public func configure(pushHost: String = "echo.walletconnect.com", groupIdentifier: String, environment: APNSEnvironment, crypto: CryptoProvider) {
Notify.config = Notify.Config(pushHost: pushHost, groupIdentifier: groupIdentifier, environment: environment, crypto: crypto)
static public func configure(pushHost: String = "echo.walletconnect.com", groupIdentifier: String, environment: APNSEnvironment, crypto: CryptoProvider, notifyHost: String = "notify.walletconnect.com") {
Notify.config = Notify.Config(pushHost: pushHost, groupIdentifier: groupIdentifier, environment: environment, crypto: crypto, notifyHost: notifyHost)
}

}
1 change: 1 addition & 0 deletions Sources/WalletConnectNotify/NotifyConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ extension Notify {
let groupIdentifier: String
let environment: APNSEnvironment
let crypto: CryptoProvider
let notifyHost: String
}
}
2 changes: 1 addition & 1 deletion Sources/WalletConnectRelay/PackageConfig.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version": "1.8.2"}
{"version": "1.8.3"}

0 comments on commit 192ff62

Please sign in to comment.