From 7df7cf3635c5d8c227b51e5a169b2b4234f13634 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Fri, 20 Dec 2024 09:54:22 -0800 Subject: [PATCH 1/2] bump versions --- LibXMTP.podspec | 4 +-- Package.swift | 4 +-- Sources/LibXMTP/libxmtp-version.txt | 4 +-- Sources/LibXMTP/xmtpv3.swift | 48 ++++++++++++++++++++++------- 4 files changed, 43 insertions(+), 17 deletions(-) diff --git a/LibXMTP.podspec b/LibXMTP.podspec index 78f465c..cbc7163 100644 --- a/LibXMTP.podspec +++ b/LibXMTP.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'LibXMTP' - s.version = '3.0.14' + s.version = '3.0.15' s.summary = 'XMTP shared Rust code that powers cross-platform SDKs' s.homepage = 'https://github.com/xmtp/libxmtp-swift' @@ -10,7 +10,7 @@ Pod::Spec.new do |s| s.platform = :ios, '14.0', :macos, '11.0' s.swift_version = '5.3' - s.source = { :http => "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-eccce06/LibXMTPSwiftFFI.zip", :type => :zip } + s.source = { :http => "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-33c06af/LibXMTPSwiftFFI.zip", :type => :zip } s.vendored_frameworks = 'LibXMTPSwiftFFI.xcframework' s.source_files = 'Sources/LibXMTP/**/*' end diff --git a/Package.swift b/Package.swift index 380c392..0328e91 100644 --- a/Package.swift +++ b/Package.swift @@ -27,8 +27,8 @@ let package = Package( ), .binaryTarget( name: "LibXMTPSwiftFFI", - url: "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-eccce06/LibXMTPSwiftFFI.zip", - checksum: "50aa2f37ac40182d7c6ea1847a6a89c9eca72275552d932b11f022a2cd2882cd" + url: "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-33c06af/LibXMTPSwiftFFI.zip", + checksum: "d7e0667ebea3d5e68bf8d6a6d014219263697436ee1714e89fe9a7362f38925b" ), .testTarget(name: "LibXMTPTests", dependencies: ["LibXMTP"]), ] diff --git a/Sources/LibXMTP/libxmtp-version.txt b/Sources/LibXMTP/libxmtp-version.txt index 153a32f..3de9cf4 100644 --- a/Sources/LibXMTP/libxmtp-version.txt +++ b/Sources/LibXMTP/libxmtp-version.txt @@ -1,3 +1,3 @@ -Version: eccce061 +Version: 33c06af6 Branch: main -Date: 2024-12-18 17:39:46 +0000 +Date: 2024-12-20 17:34:43 +0000 diff --git a/Sources/LibXMTP/xmtpv3.swift b/Sources/LibXMTP/xmtpv3.swift index 284d230..3d0a345 100644 --- a/Sources/LibXMTP/xmtpv3.swift +++ b/Sources/LibXMTP/xmtpv3.swift @@ -1701,6 +1701,8 @@ public protocol FfiConversationsProtocol: AnyObject { func createGroup(accountAddresses: [String], opts: FfiCreateGroupOptions) async throws -> FfiConversation + func getHmacKeys() throws -> [Data: [FfiHmacKey]] + func getSyncGroup() throws -> FfiConversation func list(opts: FfiListConversationsOptions) async throws -> [FfiConversation] @@ -1825,6 +1827,12 @@ open class FfiConversations: ) } + open func getHmacKeys() throws -> [Data: [FfiHmacKey]] { + return try FfiConverterDictionaryDataSequenceTypeFfiHmacKey.lift(rustCallWithError(FfiConverterTypeGenericError.lift) { + uniffi_xmtpv3_fn_method_fficonversations_get_hmac_keys(self.uniffiClonePointer(), $0) + }) + } + open func getSyncGroup() throws -> FfiConversation { return try FfiConverterTypeFfiConversation.lift(rustCallWithError(FfiConverterTypeGenericError.lift) { uniffi_xmtpv3_fn_method_fficonversations_get_sync_group(self.uniffiClonePointer(), $0) @@ -3554,8 +3562,6 @@ public protocol FfiXmtpClientProtocol: AnyObject { func getConsentState(entityType: FfiConsentEntityType, entity: String) async throws -> FfiConsentState - func getHmacKeys() throws -> [FfiHmacKey] - func getLatestInboxState(inboxId: String) async throws -> FfiInboxState func inboxId() -> String @@ -3795,12 +3801,6 @@ open class FfiXmtpClient: ) } - open func getHmacKeys() throws -> [FfiHmacKey] { - return try FfiConverterSequenceTypeFfiHmacKey.lift(rustCallWithError(FfiConverterTypeGenericError.lift) { - uniffi_xmtpv3_fn_method_ffixmtpclient_get_hmac_keys(self.uniffiClonePointer(), $0) - }) - } - open func getLatestInboxState(inboxId: String) async throws -> FfiInboxState { return try await uniffiRustCallAsync( @@ -7358,6 +7358,32 @@ private struct FfiConverterDictionaryStringBool: FfiConverterRustBuffer { } } +#if swift(>=5.8) + @_documentation(visibility: private) +#endif +private struct FfiConverterDictionaryDataSequenceTypeFfiHmacKey: FfiConverterRustBuffer { + public static func write(_ value: [Data: [FfiHmacKey]], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for (key, value) in value { + FfiConverterData.write(key, into: &buf) + FfiConverterSequenceTypeFfiHmacKey.write(value, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Data: [FfiHmacKey]] { + let len: Int32 = try readInt(&buf) + var dict = [Data: [FfiHmacKey]]() + dict.reserveCapacity(Int(len)) + for _ in 0 ..< len { + let key = try FfiConverterData.read(from: &buf) + let value = try FfiConverterSequenceTypeFfiHmacKey.read(from: &buf) + dict[key] = value + } + return dict + } +} + private let UNIFFI_RUST_FUTURE_POLL_READY: Int8 = 0 private let UNIFFI_RUST_FUTURE_POLL_MAYBE_READY: Int8 = 1 @@ -7805,6 +7831,9 @@ private var initializationResult: InitializationResult = { if uniffi_xmtpv3_checksum_method_fficonversations_create_group() != 7282 { return InitializationResult.apiChecksumMismatch } + if uniffi_xmtpv3_checksum_method_fficonversations_get_hmac_keys() != 44064 { + return InitializationResult.apiChecksumMismatch + } if uniffi_xmtpv3_checksum_method_fficonversations_get_sync_group() != 42973 { return InitializationResult.apiChecksumMismatch } @@ -7958,9 +7987,6 @@ private var initializationResult: InitializationResult = { if uniffi_xmtpv3_checksum_method_ffixmtpclient_get_consent_state() != 58208 { return InitializationResult.apiChecksumMismatch } - if uniffi_xmtpv3_checksum_method_ffixmtpclient_get_hmac_keys() != 36015 { - return InitializationResult.apiChecksumMismatch - } if uniffi_xmtpv3_checksum_method_ffixmtpclient_get_latest_inbox_state() != 3165 { return InitializationResult.apiChecksumMismatch } From 0e0222e122a4a50dbfb4ccce0145e3afa6ecc8f7 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Fri, 20 Dec 2024 15:23:58 -0800 Subject: [PATCH 2/2] bump versions again --- LibXMTP.podspec | 2 +- Package.swift | 4 +- Sources/LibXMTP/libxmtp-version.txt | 4 +- Sources/LibXMTP/xmtpv3.swift | 145 ++++++++++++++++++++++++++++ 4 files changed, 150 insertions(+), 5 deletions(-) diff --git a/LibXMTP.podspec b/LibXMTP.podspec index cbc7163..f53fe8a 100644 --- a/LibXMTP.podspec +++ b/LibXMTP.podspec @@ -10,7 +10,7 @@ Pod::Spec.new do |s| s.platform = :ios, '14.0', :macos, '11.0' s.swift_version = '5.3' - s.source = { :http => "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-33c06af/LibXMTPSwiftFFI.zip", :type => :zip } + s.source = { :http => "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-7d863bd/LibXMTPSwiftFFI.zip", :type => :zip } s.vendored_frameworks = 'LibXMTPSwiftFFI.xcframework' s.source_files = 'Sources/LibXMTP/**/*' end diff --git a/Package.swift b/Package.swift index 0328e91..2fda224 100644 --- a/Package.swift +++ b/Package.swift @@ -27,8 +27,8 @@ let package = Package( ), .binaryTarget( name: "LibXMTPSwiftFFI", - url: "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-33c06af/LibXMTPSwiftFFI.zip", - checksum: "d7e0667ebea3d5e68bf8d6a6d014219263697436ee1714e89fe9a7362f38925b" + url: "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-7d863bd/LibXMTPSwiftFFI.zip", + checksum: "0b496c3b016338b88d7b5b62828030b6107c0ee195bd869d0309507237a53bff" ), .testTarget(name: "LibXMTPTests", dependencies: ["LibXMTP"]), ] diff --git a/Sources/LibXMTP/libxmtp-version.txt b/Sources/LibXMTP/libxmtp-version.txt index 3de9cf4..a374f73 100644 --- a/Sources/LibXMTP/libxmtp-version.txt +++ b/Sources/LibXMTP/libxmtp-version.txt @@ -1,3 +1,3 @@ -Version: 33c06af6 +Version: 7d863bde Branch: main -Date: 2024-12-20 17:34:43 +0000 +Date: 2024-12-20 22:46:38 +0000 diff --git a/Sources/LibXMTP/xmtpv3.swift b/Sources/LibXMTP/xmtpv3.swift index 3d0a345..7ab1134 100644 --- a/Sources/LibXMTP/xmtpv3.swift +++ b/Sources/LibXMTP/xmtpv3.swift @@ -1581,6 +1581,105 @@ public func FfiConverterTypeFfiConversationCallback_lower(_ value: FfiConversati return FfiConverterTypeFfiConversationCallback.lower(value) } +public protocol FfiConversationListItemProtocol: AnyObject {} + +open class FfiConversationListItem: + FfiConversationListItemProtocol +{ + fileprivate let pointer: UnsafeMutableRawPointer! + + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. + #if swift(>=5.8) + @_documentation(visibility: private) + #endif + public struct NoPointer { + public init() {} + } + + // TODO: We'd like this to be `private` but for Swifty reasons, + // we can't implement `FfiConverter` without making this `required` and we can't + // make it `required` without making it `public`. + public required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + self.pointer = pointer + } + + // This constructor can be used to instantiate a fake object. + // - Parameter noPointer: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject]. + // + // - Warning: + // Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing [Pointer] the FFI lower functions will crash. + #if swift(>=5.8) + @_documentation(visibility: private) + #endif + public init(noPointer _: NoPointer) { + pointer = nil + } + + #if swift(>=5.8) + @_documentation(visibility: private) + #endif + public func uniffiClonePointer() -> UnsafeMutableRawPointer { + return try! rustCall { uniffi_xmtpv3_fn_clone_fficonversationlistitem(self.pointer, $0) } + } + + // No primary constructor declared for this class. + + deinit { + guard let pointer = pointer else { + return + } + + try! rustCall { uniffi_xmtpv3_fn_free_fficonversationlistitem(pointer, $0) } + } +} + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif +public struct FfiConverterTypeFfiConversationListItem: FfiConverter { + typealias FfiType = UnsafeMutableRawPointer + typealias SwiftType = FfiConversationListItem + + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> FfiConversationListItem { + return FfiConversationListItem(unsafeFromRawPointer: pointer) + } + + public static func lower(_ value: FfiConversationListItem) -> UnsafeMutableRawPointer { + return value.uniffiClonePointer() + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FfiConversationListItem { + let v: UInt64 = try readInt(&buf) + // The Rust code won't compile if a pointer won't fit in a UInt64. + // We have to go via `UInt` because that's the thing that's the size of a pointer. + let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v)) + if ptr == nil { + throw UniffiInternalError.unexpectedNullPointer + } + return try lift(ptr!) + } + + public static func write(_ value: FfiConversationListItem, into buf: inout [UInt8]) { + // This fiddling is because `Int` is the thing that's the same size as a pointer. + // The Rust code won't compile if a pointer won't fit in a `UInt64`. + writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value))))) + } +} + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif +public func FfiConverterTypeFfiConversationListItem_lift(_ pointer: UnsafeMutableRawPointer) throws -> FfiConversationListItem { + return try FfiConverterTypeFfiConversationListItem.lift(pointer) +} + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif +public func FfiConverterTypeFfiConversationListItem_lower(_ value: FfiConversationListItem) -> UnsafeMutableRawPointer { + return FfiConverterTypeFfiConversationListItem.lower(value) +} + public protocol FfiConversationMetadataProtocol: AnyObject { func conversationType() -> FfiConversationType @@ -1707,6 +1806,8 @@ public protocol FfiConversationsProtocol: AnyObject { func list(opts: FfiListConversationsOptions) async throws -> [FfiConversation] + func listConversations() async throws -> [FfiConversationListItem] + func listDms(opts: FfiListConversationsOptions) async throws -> [FfiConversation] func listGroups(opts: FfiListConversationsOptions) async throws -> [FfiConversation] @@ -1856,6 +1957,22 @@ open class FfiConversations: ) } + open func listConversations() async throws -> [FfiConversationListItem] { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_xmtpv3_fn_method_fficonversations_list_conversations( + self.uniffiClonePointer() + ) + }, + pollFunc: ffi_xmtpv3_rust_future_poll_rust_buffer, + completeFunc: ffi_xmtpv3_rust_future_complete_rust_buffer, + freeFunc: ffi_xmtpv3_rust_future_free_rust_buffer, + liftFunc: FfiConverterSequenceTypeFfiConversationListItem.lift, + errorHandler: FfiConverterTypeGenericError.lift + ) + } + open func listDms(opts: FfiListConversationsOptions) async throws -> [FfiConversation] { return try await uniffiRustCallAsync( @@ -7082,6 +7199,31 @@ private struct FfiConverterSequenceTypeFfiConversation: FfiConverterRustBuffer { } } +#if swift(>=5.8) + @_documentation(visibility: private) +#endif +private struct FfiConverterSequenceTypeFfiConversationListItem: FfiConverterRustBuffer { + typealias SwiftType = [FfiConversationListItem] + + public static func write(_ value: [FfiConversationListItem], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeFfiConversationListItem.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [FfiConversationListItem] { + let len: Int32 = try readInt(&buf) + var seq = [FfiConversationListItem]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + try seq.append(FfiConverterTypeFfiConversationListItem.read(from: &buf)) + } + return seq + } +} + #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -7840,6 +7982,9 @@ private var initializationResult: InitializationResult = { if uniffi_xmtpv3_checksum_method_fficonversations_list() != 42790 { return InitializationResult.apiChecksumMismatch } + if uniffi_xmtpv3_checksum_method_fficonversations_list_conversations() != 29098 { + return InitializationResult.apiChecksumMismatch + } if uniffi_xmtpv3_checksum_method_fficonversations_list_dms() != 41576 { return InitializationResult.apiChecksumMismatch }