diff --git a/Sources/XMTPiOS/ApiClient.swift b/Sources/XMTPiOS/ApiClient.swift index 9309d5da..d85692fd 100644 --- a/Sources/XMTPiOS/ApiClient.swift +++ b/Sources/XMTPiOS/ApiClient.swift @@ -75,14 +75,6 @@ final class GRPCApiClient: ApiClient { } } - static func envToUrl(env: XMTPEnvironment) -> String { - switch env { - case XMTPEnvironment.local: return "http://localhost:5556" - case XMTPEnvironment.dev: return "https://dev.xmtp.network:5556" - case XMTPEnvironment.production: return "https://production.xmtp.network:5556" - } - } - func setAuthToken(_ token: String) { authToken = token } diff --git a/Sources/XMTPiOS/Client.swift b/Sources/XMTPiOS/Client.swift index bab28303..7e6199a8 100644 --- a/Sources/XMTPiOS/Client.swift +++ b/Sources/XMTPiOS/Client.swift @@ -100,7 +100,7 @@ public final class Client { public static func create(account: SigningKey, options: ClientOptions? = nil) async throws -> Client { let options = options ?? ClientOptions() do { - let client = try await LibXMTP.createV2Client(host: GRPCApiClient.envToUrl(env: options.api.env), isSecure: options.api.env != .local) + let client = try await LibXMTP.createV2Client(host: options.api.env.url, isSecure: options.api.env != .local) let apiClient = try GRPCApiClient( environment: options.api.env, secure: options.api.isSecure, @@ -123,7 +123,7 @@ public final class Client { let dbURL = URL.documentsDirectory.appendingPathComponent("xmtp-\(options?.api.env.rawValue ?? "")-\(address).db3") let v3Client = try await LibXMTP.createClient( logger: XMTPLogger(), - host: GRPCApiClient.envToUrl(env: options?.api.env ?? .local), + host: (options?.api.env ?? .local).url, isSecure: (options?.api.env ?? .local) != .local, db: dbURL.path, encryptionKey: options?.mlsEncryptionKey, @@ -242,7 +242,7 @@ public final class Client { let options = options ?? ClientOptions() - let client = try await LibXMTP.createV2Client(host: GRPCApiClient.envToUrl(env: options.api.env), isSecure: options.api.env != .local) + let client = try await LibXMTP.createV2Client(host: options.api.env.url, isSecure: options.api.env != .local) let apiClient = try GRPCApiClient( environment: options.api.env, secure: options.api.isSecure, @@ -296,7 +296,7 @@ public final class Client { public static func canMessage(_ peerAddress: String, options: ClientOptions? = nil) async throws -> Bool { let options = options ?? ClientOptions() - let client = try await LibXMTP.createV2Client(host: GRPCApiClient.envToUrl(env: options.api.env), isSecure: options.api.env != .local) + let client = try await LibXMTP.createV2Client(host: options.api.env.url, isSecure: options.api.env != .local) let apiClient = try GRPCApiClient( environment: options.api.env, secure: options.api.isSecure, diff --git a/Sources/XMTPiOS/XMTPEnvironment.swift b/Sources/XMTPiOS/XMTPEnvironment.swift index e24fe343..1c175069 100644 --- a/Sources/XMTPiOS/XMTPEnvironment.swift +++ b/Sources/XMTPiOS/XMTPEnvironment.swift @@ -9,7 +9,18 @@ import Foundation /// Contains hosts an `ApiClient` can connect to public enum XMTPEnvironment: String, Sendable { - case dev = "dev.xmtp.network", - production = "production.xmtp.network", - local = "localhost" + case dev = "grpc.dev.xmtp.network:443", + production = "grpc.production.xmtp.network:443", + local = "localhost:5556" + + var url: String { + switch self { + case .dev: + return "https://\(rawValue)" + case .production: + return "https://\(rawValue)" + case .local: + return "http://\(rawValue)" + } + } } diff --git a/Tests/XMTPTests/IntegrationTests.swift b/Tests/XMTPTests/IntegrationTests.swift index 37833a77..6bdee833 100644 --- a/Tests/XMTPTests/IntegrationTests.swift +++ b/Tests/XMTPTests/IntegrationTests.swift @@ -27,7 +27,7 @@ final class IntegrationTests: XCTestCase { let authToken = try await authorized.createAuthToken() - let rustClient = try await LibXMTP.createV2Client(host: GRPCApiClient.envToUrl(env: .local), isSecure: false) + let rustClient = try await LibXMTP.createV2Client(host: XMTPEnvironment.local.url, isSecure: false) let api = try GRPCApiClient(environment: .local, secure: false, rustClient: rustClient) api.setAuthToken(authToken) diff --git a/XMTP.podspec b/XMTP.podspec index 0538e2b2..c5a33e6e 100644 --- a/XMTP.podspec +++ b/XMTP.podspec @@ -44,5 +44,5 @@ Pod::Spec.new do |spec| spec.dependency "web3.swift" spec.dependency "GzipSwift" spec.dependency "Connect-Swift", "= 0.3.0" - spec.dependency 'LibXMTP', '= 0.4.1-beta0' + spec.dependency 'LibXMTP', '= 0.4.1-beta3' end