From eff8145d3067a16f9f50c72fe8b32c58ec591331 Mon Sep 17 00:00:00 2001 From: cameronvoell Date: Thu, 13 Feb 2025 09:16:36 -0800 Subject: [PATCH 1/2] update libxmtp version file --- Sources/LibXMTP/libxmtp-version.txt | 6 +- Sources/LibXMTP/xmtpv3.swift | 309 +++++++++++++++++++++++++--- 2 files changed, 278 insertions(+), 37 deletions(-) diff --git a/Sources/LibXMTP/libxmtp-version.txt b/Sources/LibXMTP/libxmtp-version.txt index f6d122d..c8c0179 100644 --- a/Sources/LibXMTP/libxmtp-version.txt +++ b/Sources/LibXMTP/libxmtp-version.txt @@ -1,3 +1,3 @@ -Version: f5b10896 -Branch: main -Date: 2025-02-10 16:52:01 +0000 +Version: 2063bfb3 +Branch: cv/multi-attachment-content-type +Date: 2025-02-13 15:07:17 +0000 diff --git a/Sources/LibXMTP/xmtpv3.swift b/Sources/LibXMTP/xmtpv3.swift index 65552b1..79a0ab8 100644 --- a/Sources/LibXMTP/xmtpv3.swift +++ b/Sources/LibXMTP/xmtpv3.swift @@ -5652,6 +5652,59 @@ public func FfiConverterTypeFfiMessageWithReactions_lower(_ value: FfiMessageWit return FfiConverterTypeFfiMessageWithReactions.lower(value) } +public struct FfiMultiRemoteAttachment { + public var attachments: [FfiRemoteAttachmentInfo] + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(attachments: [FfiRemoteAttachmentInfo]) { + self.attachments = attachments + } +} + +extension FfiMultiRemoteAttachment: Equatable, Hashable { + public static func == (lhs: FfiMultiRemoteAttachment, rhs: FfiMultiRemoteAttachment) -> Bool { + if lhs.attachments != rhs.attachments { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(attachments) + } +} + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif +public struct FfiConverterTypeFfiMultiRemoteAttachment: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FfiMultiRemoteAttachment { + return + try FfiMultiRemoteAttachment( + attachments: FfiConverterSequenceTypeFfiRemoteAttachmentInfo.read(from: &buf) + ) + } + + public static func write(_ value: FfiMultiRemoteAttachment, into buf: inout [UInt8]) { + FfiConverterSequenceTypeFfiRemoteAttachmentInfo.write(value.attachments, into: &buf) + } +} + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif +public func FfiConverterTypeFfiMultiRemoteAttachment_lift(_ buf: RustBuffer) throws -> FfiMultiRemoteAttachment { + return try FfiConverterTypeFfiMultiRemoteAttachment.lift(buf) +} + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif +public func FfiConverterTypeFfiMultiRemoteAttachment_lower(_ value: FfiMultiRemoteAttachment) -> RustBuffer { + return FfiConverterTypeFfiMultiRemoteAttachment.lower(value) +} + public struct FfiPagingInfo { public var limit: UInt32 public var cursor: FfiCursor? @@ -5968,6 +6021,115 @@ public func FfiConverterTypeFfiReaction_lower(_ value: FfiReaction) -> RustBuffe return FfiConverterTypeFfiReaction.lower(value) } +public struct FfiRemoteAttachmentInfo { + public var secret: Data + public var contentDigest: String + public var nonce: Data + public var scheme: String + public var url: String + public var salt: Data + public var contentLength: UInt32? + public var filename: String? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(secret: Data, contentDigest: String, nonce: Data, scheme: String, url: String, salt: Data, contentLength: UInt32?, filename: String?) { + self.secret = secret + self.contentDigest = contentDigest + self.nonce = nonce + self.scheme = scheme + self.url = url + self.salt = salt + self.contentLength = contentLength + self.filename = filename + } +} + +extension FfiRemoteAttachmentInfo: Equatable, Hashable { + public static func == (lhs: FfiRemoteAttachmentInfo, rhs: FfiRemoteAttachmentInfo) -> Bool { + if lhs.secret != rhs.secret { + return false + } + if lhs.contentDigest != rhs.contentDigest { + return false + } + if lhs.nonce != rhs.nonce { + return false + } + if lhs.scheme != rhs.scheme { + return false + } + if lhs.url != rhs.url { + return false + } + if lhs.salt != rhs.salt { + return false + } + if lhs.contentLength != rhs.contentLength { + return false + } + if lhs.filename != rhs.filename { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(secret) + hasher.combine(contentDigest) + hasher.combine(nonce) + hasher.combine(scheme) + hasher.combine(url) + hasher.combine(salt) + hasher.combine(contentLength) + hasher.combine(filename) + } +} + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif +public struct FfiConverterTypeFfiRemoteAttachmentInfo: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FfiRemoteAttachmentInfo { + return + try FfiRemoteAttachmentInfo( + secret: FfiConverterData.read(from: &buf), + contentDigest: FfiConverterString.read(from: &buf), + nonce: FfiConverterData.read(from: &buf), + scheme: FfiConverterString.read(from: &buf), + url: FfiConverterString.read(from: &buf), + salt: FfiConverterData.read(from: &buf), + contentLength: FfiConverterOptionUInt32.read(from: &buf), + filename: FfiConverterOptionString.read(from: &buf) + ) + } + + public static func write(_ value: FfiRemoteAttachmentInfo, into buf: inout [UInt8]) { + FfiConverterData.write(value.secret, into: &buf) + FfiConverterString.write(value.contentDigest, into: &buf) + FfiConverterData.write(value.nonce, into: &buf) + FfiConverterString.write(value.scheme, into: &buf) + FfiConverterString.write(value.url, into: &buf) + FfiConverterData.write(value.salt, into: &buf) + FfiConverterOptionUInt32.write(value.contentLength, into: &buf) + FfiConverterOptionString.write(value.filename, into: &buf) + } +} + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif +public func FfiConverterTypeFfiRemoteAttachmentInfo_lift(_ buf: RustBuffer) throws -> FfiRemoteAttachmentInfo { + return try FfiConverterTypeFfiRemoteAttachmentInfo.lift(buf) +} + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif +public func FfiConverterTypeFfiRemoteAttachmentInfo_lower(_ value: FfiRemoteAttachmentInfo) -> RustBuffer { + return FfiConverterTypeFfiRemoteAttachmentInfo.lower(value) +} + public struct FfiV2BatchQueryRequest { public var requests: [FfiV2QueryRequest] @@ -7406,8 +7568,6 @@ public enum GenericError { case Storage(message: String) - case ApiError(message: String) - case GroupError(message: String) case Signature(message: String) @@ -7437,6 +7597,10 @@ public enum GenericError { case IoError(message: String) case Subscription(message: String) + + case ApiClientBuild(message: String) + + case Grpc(message: String) } #if swift(>=5.8) @@ -7460,67 +7624,71 @@ public struct FfiConverterTypeGenericError: FfiConverterRustBuffer { message: FfiConverterString.read(from: &buf) ) - case 4: return try .ApiError( + case 4: return try .GroupError( + message: FfiConverterString.read(from: &buf) + ) + + case 5: return try .Signature( message: FfiConverterString.read(from: &buf) ) - case 5: return try .GroupError( + case 6: return try .GroupMetadata( message: FfiConverterString.read(from: &buf) ) - case 6: return try .Signature( + case 7: return try .GroupMutablePermissions( message: FfiConverterString.read(from: &buf) ) - case 7: return try .GroupMetadata( + case 8: return try .Generic( message: FfiConverterString.read(from: &buf) ) - case 8: return try .GroupMutablePermissions( + case 9: return try .SignatureRequestError( message: FfiConverterString.read(from: &buf) ) - case 9: return try .Generic( + case 10: return try .Erc1271SignatureError( message: FfiConverterString.read(from: &buf) ) - case 10: return try .SignatureRequestError( + case 11: return try .Verifier( message: FfiConverterString.read(from: &buf) ) - case 11: return try .Erc1271SignatureError( + case 12: return try .FailedToConvertToU32( message: FfiConverterString.read(from: &buf) ) - case 12: return try .Verifier( + case 13: return try .Association( message: FfiConverterString.read(from: &buf) ) - case 13: return try .FailedToConvertToU32( + case 14: return try .DeviceSync( message: FfiConverterString.read(from: &buf) ) - case 14: return try .Association( + case 15: return try .Identity( message: FfiConverterString.read(from: &buf) ) - case 15: return try .DeviceSync( + case 16: return try .JoinError( message: FfiConverterString.read(from: &buf) ) - case 16: return try .Identity( + case 17: return try .IoError( message: FfiConverterString.read(from: &buf) ) - case 17: return try .JoinError( + case 18: return try .Subscription( message: FfiConverterString.read(from: &buf) ) - case 18: return try .IoError( + case 19: return try .ApiClientBuild( message: FfiConverterString.read(from: &buf) ) - case 19: return try .Subscription( + case 20: return try .Grpc( message: FfiConverterString.read(from: &buf) ) @@ -7536,38 +7704,40 @@ public struct FfiConverterTypeGenericError: FfiConverterRustBuffer { writeInt(&buf, Int32(2)) case .Storage(_ /* message is ignored*/ ): writeInt(&buf, Int32(3)) - case .ApiError(_ /* message is ignored*/ ): - writeInt(&buf, Int32(4)) case .GroupError(_ /* message is ignored*/ ): - writeInt(&buf, Int32(5)) + writeInt(&buf, Int32(4)) case .Signature(_ /* message is ignored*/ ): - writeInt(&buf, Int32(6)) + writeInt(&buf, Int32(5)) case .GroupMetadata(_ /* message is ignored*/ ): - writeInt(&buf, Int32(7)) + writeInt(&buf, Int32(6)) case .GroupMutablePermissions(_ /* message is ignored*/ ): - writeInt(&buf, Int32(8)) + writeInt(&buf, Int32(7)) case .Generic(_ /* message is ignored*/ ): - writeInt(&buf, Int32(9)) + writeInt(&buf, Int32(8)) case .SignatureRequestError(_ /* message is ignored*/ ): - writeInt(&buf, Int32(10)) + writeInt(&buf, Int32(9)) case .Erc1271SignatureError(_ /* message is ignored*/ ): - writeInt(&buf, Int32(11)) + writeInt(&buf, Int32(10)) case .Verifier(_ /* message is ignored*/ ): - writeInt(&buf, Int32(12)) + writeInt(&buf, Int32(11)) case .FailedToConvertToU32(_ /* message is ignored*/ ): - writeInt(&buf, Int32(13)) + writeInt(&buf, Int32(12)) case .Association(_ /* message is ignored*/ ): - writeInt(&buf, Int32(14)) + writeInt(&buf, Int32(13)) case .DeviceSync(_ /* message is ignored*/ ): - writeInt(&buf, Int32(15)) + writeInt(&buf, Int32(14)) case .Identity(_ /* message is ignored*/ ): - writeInt(&buf, Int32(16)) + writeInt(&buf, Int32(15)) case .JoinError(_ /* message is ignored*/ ): - writeInt(&buf, Int32(17)) + writeInt(&buf, Int32(16)) case .IoError(_ /* message is ignored*/ ): - writeInt(&buf, Int32(18)) + writeInt(&buf, Int32(17)) case .Subscription(_ /* message is ignored*/ ): + writeInt(&buf, Int32(18)) + case .ApiClientBuild(_ /* message is ignored*/ ): writeInt(&buf, Int32(19)) + case .Grpc(_ /* message is ignored*/ ): + writeInt(&buf, Int32(20)) } } } @@ -7731,6 +7901,30 @@ extension FfiConverterCallbackInterfaceFfiInboxOwner: FfiConverter { } } +#if swift(>=5.8) + @_documentation(visibility: private) +#endif +private struct FfiConverterOptionUInt32: FfiConverterRustBuffer { + typealias SwiftType = UInt32? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterUInt32.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterUInt32.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -8414,6 +8608,31 @@ private struct FfiConverterSequenceTypeFfiMessageWithReactions: FfiConverterRust } } +#if swift(>=5.8) + @_documentation(visibility: private) +#endif +private struct FfiConverterSequenceTypeFfiRemoteAttachmentInfo: FfiConverterRustBuffer { + typealias SwiftType = [FfiRemoteAttachmentInfo] + + public static func write(_ value: [FfiRemoteAttachmentInfo], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeFfiRemoteAttachmentInfo.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [FfiRemoteAttachmentInfo] { + let len: Int32 = try readInt(&buf) + var seq = [FfiRemoteAttachmentInfo]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + try seq.append(FfiConverterTypeFfiRemoteAttachmentInfo.read(from: &buf)) + } + return seq + } +} + #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -8726,6 +8945,14 @@ public func createV2Client(host: String, isSecure: Bool) async throws -> FfiV2Ap ) } +public func decodeMultiRemoteAttachment(bytes: Data) throws -> FfiMultiRemoteAttachment { + return try FfiConverterTypeFfiMultiRemoteAttachment.lift(rustCallWithError(FfiConverterTypeGenericError.lift) { + uniffi_xmtpv3_fn_func_decode_multi_remote_attachment( + FfiConverterData.lower(bytes), $0 + ) + }) +} + public func decodeReaction(bytes: Data) throws -> FfiReaction { return try FfiConverterTypeFfiReaction.lift(rustCallWithError(FfiConverterTypeGenericError.lift) { uniffi_xmtpv3_fn_func_decode_reaction( @@ -8743,6 +8970,14 @@ public func diffieHellmanK256(privateKeyBytes: Data, publicKeyBytes: Data) throw }) } +public func encodeMultiRemoteAttachment(ffiMultiRemoteAttachment: FfiMultiRemoteAttachment) throws -> Data { + return try FfiConverterData.lift(rustCallWithError(FfiConverterTypeGenericError.lift) { + uniffi_xmtpv3_fn_func_encode_multi_remote_attachment( + FfiConverterTypeFfiMultiRemoteAttachment.lower(ffiMultiRemoteAttachment), $0 + ) + }) +} + public func encodeReaction(reaction: FfiReaction) throws -> Data { return try FfiConverterData.lift(rustCallWithError(FfiConverterTypeGenericError.lift) { uniffi_xmtpv3_fn_func_encode_reaction( @@ -8896,12 +9131,18 @@ private var initializationResult: InitializationResult = { if uniffi_xmtpv3_checksum_func_create_v2_client() != 48060 { return InitializationResult.apiChecksumMismatch } + if uniffi_xmtpv3_checksum_func_decode_multi_remote_attachment() != 59746 { + return InitializationResult.apiChecksumMismatch + } if uniffi_xmtpv3_checksum_func_decode_reaction() != 28885 { return InitializationResult.apiChecksumMismatch } if uniffi_xmtpv3_checksum_func_diffie_hellman_k256() != 37475 { return InitializationResult.apiChecksumMismatch } + if uniffi_xmtpv3_checksum_func_encode_multi_remote_attachment() != 28938 { + return InitializationResult.apiChecksumMismatch + } if uniffi_xmtpv3_checksum_func_encode_reaction() != 6548 { return InitializationResult.apiChecksumMismatch } From 35da6e92c58481ed9f25ae6db9f3c4636888cb66 Mon Sep 17 00:00:00 2001 From: cameronvoell Date: Thu, 13 Feb 2025 14:04:36 -0800 Subject: [PATCH 2/2] updates for multi remote attachment content type --- LibXMTP.podspec | 4 ++-- Package.swift | 4 ++-- Sources/LibXMTP/libxmtp-version.txt | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/LibXMTP.podspec b/LibXMTP.podspec index 4bd4aa3..3f4bbe8 100644 --- a/LibXMTP.podspec +++ b/LibXMTP.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'LibXMTP' - s.version = '3.0.25' + s.version = '3.0.26' 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-f5b1089/LibXMTPSwiftFFI.zip", :type => :zip } + s.source = { :http => "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-c57c5fa/LibXMTPSwiftFFI.zip", :type => :zip } s.vendored_frameworks = 'LibXMTPSwiftFFI.xcframework' s.source_files = 'Sources/LibXMTP/**/*' end diff --git a/Package.swift b/Package.swift index 6bea8e8..3e8b429 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-f5b1089/LibXMTPSwiftFFI.zip", - checksum: "b6480d6152862e696dcddea1e3c981639de97962ad339a09deb160e6b55d77ca" + url: "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-c57c5fa/LibXMTPSwiftFFI.zip", + checksum: "2c4eaaca827f92b59214f329ea97a620ceddc0a8b9b98103f8aa25b3e07a378a" ), .testTarget(name: "LibXMTPTests", dependencies: ["LibXMTP"]), ] diff --git a/Sources/LibXMTP/libxmtp-version.txt b/Sources/LibXMTP/libxmtp-version.txt index c8c0179..9e60e44 100644 --- a/Sources/LibXMTP/libxmtp-version.txt +++ b/Sources/LibXMTP/libxmtp-version.txt @@ -1,3 +1,3 @@ -Version: 2063bfb3 -Branch: cv/multi-attachment-content-type -Date: 2025-02-13 15:07:17 +0000 +Version: c57c5faf +Branch: main +Date: 2025-02-13 17:43:45 +0000