diff --git a/Package.swift b/Package.swift index 7acda25b..567f7ac6 100644 --- a/Package.swift +++ b/Package.swift @@ -25,7 +25,7 @@ let package = Package( .package(url: "https://github.com/1024jp/GzipSwift", from: "5.2.0"), .package(url: "https://github.com/bufbuild/connect-swift", exact: "0.12.0"), .package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.0.0"), - .package(url: "https://github.com/xmtp/libxmtp-swift", exact: "0.5.0-beta2"), + .package(url: "https://github.com/xmtp/libxmtp-swift", exact: "0.5.1-beta0"), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. diff --git a/Sources/XMTPiOS/Client.swift b/Sources/XMTPiOS/Client.swift index 65f99dfb..3bbc7bfb 100644 --- a/Sources/XMTPiOS/Client.swift +++ b/Sources/XMTPiOS/Client.swift @@ -128,24 +128,27 @@ public final class Client { } static func initV3Client( - address: String, + accountAddress: String, options: ClientOptions?, - source: LegacyIdentitySource, privateKeyBundleV1: PrivateKeyBundleV1, signingKey: SigningKey? ) async throws -> (FfiXmtpClient?, String) { if options?.mlsAlpha == true, options?.api.env.supportsMLS == true { - var inboxId = try await getInboxIdForAddress( - logger: XMTPLogger(), - host: (options?.api.env ?? .local).url, - isSecure: options?.api.env.isSecure == true, - accountAddress: address - ) - if inboxId?.isEmpty ?? true { + let address = accountAddress.lowercased() + + var inboxId: String + do { + inboxId = try await getInboxIdForAddress( + logger: XMTPLogger(), + host: (options?.api.env ?? .local).url, + isSecure: options?.api.env.isSecure == true, + accountAddress: address + ) ?? generateInboxId(accountAddress: address, nonce: 0) + } catch { inboxId = generateInboxId(accountAddress: address, nonce: 0) } - let alias = "xmtp-\(options?.api.env.rawValue ?? "")-\(inboxId ?? address).db3" + let alias = "xmtp-\(options?.api.env.rawValue ?? "")-\(inboxId).db3" let dbURL = URL.documentsDirectory.appendingPathComponent(alias).path let encryptionKey = options?.mlsEncryptionKey @@ -156,8 +159,9 @@ public final class Client { isSecure: options?.api.env.isSecure == true, db: dbURL, encryptionKey: encryptionKey, + inboxId: inboxId, accountAddress: address, - legacyIdentitySource: source, + nonce: 0, legacySignedPrivateKeyProto: try privateKeyBundleV1.toV2().identityKey.serializedData() ) @@ -184,12 +188,11 @@ public final class Client { } static func create(account: SigningKey, apiClient: ApiClient, options: ClientOptions? = nil) async throws -> Client { - let (privateKeyBundleV1, source) = try await loadOrCreateKeys(for: account, apiClient: apiClient, options: options) + let privateKeyBundleV1 = try await loadOrCreateKeys(for: account, apiClient: apiClient, options: options) let (v3Client, dbPath) = try await initV3Client( - address: account.address, + accountAddress: account.address, options: options, - source: source, privateKeyBundleV1: privateKeyBundleV1, signingKey: account ) @@ -206,13 +209,13 @@ public final class Client { return client } - static func loadOrCreateKeys(for account: SigningKey, apiClient: ApiClient, options: ClientOptions? = nil) async throws -> (PrivateKeyBundleV1, LegacyIdentitySource) { + static func loadOrCreateKeys(for account: SigningKey, apiClient: ApiClient, options: ClientOptions? = nil) async throws -> PrivateKeyBundleV1 { if let keys = try await loadPrivateKeys(for: account, apiClient: apiClient, options: options) { print("loading existing private keys.") #if DEBUG print("Loaded existing private keys.") #endif - return (keys, .network) + return keys } else { #if DEBUG print("No existing keys found, creating new bundle.") @@ -229,7 +232,7 @@ public final class Client { Envelope(topic: .userPrivateStoreKeyBundle(account.address), timestamp: Date(), message: encryptedKeys.serializedData()), ]) - return (keys, .keyGenerator) + return keys } } @@ -281,9 +284,8 @@ public final class Client { let options = options ?? ClientOptions() let (v3Client, dbPath) = try await initV3Client( - address: address, + accountAddress: address, options: options, - source: .static, privateKeyBundleV1: v1Bundle, signingKey: nil ) diff --git a/XMTP.podspec b/XMTP.podspec index a92f86ca..c8f5381b 100644 --- a/XMTP.podspec +++ b/XMTP.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |spec| # spec.name = "XMTP" - spec.version = "0.11.1" + spec.version = "0.11.2" spec.summary = "XMTP SDK Cocoapod" # This description is used to generate tags and improve search results. @@ -44,5 +44,5 @@ Pod::Spec.new do |spec| spec.dependency "web3.swift" spec.dependency "GzipSwift" spec.dependency "Connect-Swift", "= 0.12.0" - spec.dependency 'LibXMTP', '= 0.5.0-beta2' + spec.dependency 'LibXMTP', '= 0.5.1-beta0' end diff --git a/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index d5a75fad..1fa3e748 100644 --- a/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/XMTPiOSExample/XMTPiOSExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -59,8 +59,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/xmtp/libxmtp-swift", "state" : { - "revision" : "6540f22eab6748748ede67c5a94d8188060fcbf9", - "version" : "0.5.0-beta2" + "revision" : "bc7e65b4db73430ae259bce32b391eefa82d4071", + "version" : "0.5.1-beta0" } }, {