diff --git a/Example/IntegrationTests/Chat/RegistryTests.swift b/Example/IntegrationTests/Chat/RegistryTests.swift index 55110825c..7a6fb6a1c 100644 --- a/Example/IntegrationTests/Chat/RegistryTests.swift +++ b/Example/IntegrationTests/Chat/RegistryTests.swift @@ -7,7 +7,7 @@ import WalletConnectUtils final class RegistryTests: XCTestCase { func testRegistry() async throws { - let client = HTTPClient(host: "159.65.123.131") + let client = HTTPClient(host: "keys.walletconnect.com") let registry = KeyserverRegistryProvider(client: client) let account = Account("eip155:1:" + Data.randomBytes(count: 16).toHexString())! let pubKey = SigningPrivateKey().publicKey.hexRepresentation diff --git a/Example/Showcase/Classes/DomainLayer/Chat/ChatFactory.swift b/Example/Showcase/Classes/DomainLayer/Chat/ChatFactory.swift index f26f7f311..33eeaadf5 100644 --- a/Example/Showcase/Classes/DomainLayer/Chat/ChatFactory.swift +++ b/Example/Showcase/Classes/DomainLayer/Chat/ChatFactory.swift @@ -9,7 +9,7 @@ class ChatFactory { let relayHost = "relay.walletconnect.com" let projectId = "8ba9ee138960775e5231b70cc5ef1c3a" let keychain = KeychainStorage(serviceIdentifier: "com.walletconnect.showcase") - let client = HTTPClient(host: "159.65.123.131") + let client = HTTPClient(host: "keys.walletconnect.com") let registry = KeyserverRegistryProvider(client: client) let relayClient = RelayClient(relayHost: relayHost, projectId: projectId, keychainStorage: keychain, socketFactory: SocketFactory()) return ChatClient( diff --git a/Sources/Chat/ProtocolServices/Common/MessagingService.swift b/Sources/Chat/ProtocolServices/Common/MessagingService.swift index fca730bbc..828022a36 100644 --- a/Sources/Chat/ProtocolServices/Common/MessagingService.swift +++ b/Sources/Chat/ProtocolServices/Common/MessagingService.swift @@ -34,6 +34,7 @@ class MessagingService { try await networkingInteractor.request(request, topic: topic, envelopeType: .type0) Task(priority: .background) { await messagesStore.add(message) + onMessage?(message) } } diff --git a/Sources/Chat/Services/RegisterService.swift b/Sources/Chat/Services/RegisterService.swift index 242512edc..0734be114 100644 --- a/Sources/Chat/Services/RegisterService.swift +++ b/Sources/Chat/Services/RegisterService.swift @@ -13,6 +13,10 @@ struct RegisterService: HTTPService { .post } + var scheme: String { + return "https" + } + var body: Data? { try? JSONEncoder().encode(userAccount) } diff --git a/Sources/Chat/Services/ResolveService.swift b/Sources/Chat/Services/ResolveService.swift index 16ae57e52..993833c64 100644 --- a/Sources/Chat/Services/ResolveService.swift +++ b/Sources/Chat/Services/ResolveService.swift @@ -14,6 +14,10 @@ struct ResolveService: HTTPService { .get } + var scheme: String { + return "https" + } + var body: Data? { nil } diff --git a/Sources/WalletConnectRelay/HTTP/HTTPService.swift b/Sources/WalletConnectRelay/HTTP/HTTPService.swift index c3487d829..f1b4ee2f6 100644 --- a/Sources/WalletConnectRelay/HTTP/HTTPService.swift +++ b/Sources/WalletConnectRelay/HTTP/HTTPService.swift @@ -11,7 +11,6 @@ public protocol HTTPService { var method: HTTPMethod { get } var body: Data? { get } var queryParameters: [String: String]? { get } - var port: Int? { get } func resolve(for host: String) -> URLRequest? } @@ -21,25 +20,20 @@ public extension HTTPService { "http" } - var port: Int? { - 8080 - } - func resolve(for host: String) -> URLRequest? { var components = URLComponents() - components.scheme = self.scheme + components.scheme = scheme components.host = host - components.port = self.port - components.path = self.path - if let query = self.queryParameters { + components.path = path + if let query = queryParameters { components.queryItems = query.map { URLQueryItem(name: $0.key, value: $0.value) } } guard let url = components.url else { return nil } var request = URLRequest(url: url) - request.httpMethod = self.method.rawValue - request.httpBody = self.body + request.httpMethod = method.rawValue + request.httpBody = body request.addValue("application/json", forHTTPHeaderField: "Content-Type") return request }