Skip to content

Commit

Permalink
Merge pull request #99 from xmtp/np/libxmtp-updates
Browse files Browse the repository at this point in the history
Update swift bindings for consent filtering
  • Loading branch information
nplasterer authored Jan 17, 2025
2 parents 40ccd33 + b1a25f2 commit 6b0166d
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 41 deletions.
4 changes: 2 additions & 2 deletions LibXMTP.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'LibXMTP'
s.version = '3.0.19'
s.version = '3.0.20'
s.summary = 'XMTP shared Rust code that powers cross-platform SDKs'

s.homepage = 'https://github.com/xmtp/libxmtp-swift'
Expand All @@ -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-f04e004/LibXMTPSwiftFFI.zip", :type => :zip }
s.source = { :http => "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-fc37819/LibXMTPSwiftFFI.zip", :type => :zip }
s.vendored_frameworks = 'LibXMTPSwiftFFI.xcframework'
s.source_files = 'Sources/LibXMTP/**/*'
end
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ let package = Package(
),
.binaryTarget(
name: "LibXMTPSwiftFFI",
url: "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-f04e004/LibXMTPSwiftFFI.zip",
checksum: "aecb82c62b34c32396b7612d6bd3eafd0921e25749fa33ac74324c48962706b1"
url: "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-fc37819/LibXMTPSwiftFFI.zip",
checksum: "c20017607695915d34009dd4317b01dcdc052386827730afda6e8076e95df9b7"
),
.testTarget(name: "LibXMTPTests", dependencies: ["LibXMTP"]),
]
Expand Down
4 changes: 2 additions & 2 deletions Sources/LibXMTP/libxmtp-version.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: f04e0049
Version: fc37819c
Branch: main
Date: 2025-01-14 23:09:48 +0000
Date: 2025-01-17 01:38:53 +0000
139 changes: 104 additions & 35 deletions Sources/LibXMTP/xmtpv3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1833,8 +1833,12 @@ public func FfiConverterTypeFfiConversationMetadata_lower(_ value: FfiConversati
public protocol FfiConversationsProtocol: AnyObject {
func createDm(accountAddress: String) async throws -> FfiConversation

func createDmWithInboxId(inboxId: String) async throws -> FfiConversation

func createGroup(accountAddresses: [String], opts: FfiCreateGroupOptions) async throws -> FfiConversation

func createGroupWithInboxIds(inboxIds: [String], opts: FfiCreateGroupOptions) async throws -> FfiConversation

func getHmacKeys() throws -> [Data: [FfiHmacKey]]

func getSyncGroup() throws -> FfiConversation
Expand Down Expand Up @@ -1875,7 +1879,7 @@ public protocol FfiConversationsProtocol: AnyObject {

func sync() async throws

func syncAllConversations(consentState: FfiConsentState?) async throws -> UInt32
func syncAllConversations(consentStates: [FfiConsentState]?) async throws -> UInt32
}

open class FfiConversations:
Expand Down Expand Up @@ -1944,6 +1948,23 @@ open class FfiConversations:
)
}

open func createDmWithInboxId(inboxId: String) async throws -> FfiConversation {
return
try await uniffiRustCallAsync(
rustFutureFunc: {
uniffi_xmtpv3_fn_method_fficonversations_create_dm_with_inbox_id(
self.uniffiClonePointer(),
FfiConverterString.lower(inboxId)
)
},
pollFunc: ffi_xmtpv3_rust_future_poll_pointer,
completeFunc: ffi_xmtpv3_rust_future_complete_pointer,
freeFunc: ffi_xmtpv3_rust_future_free_pointer,
liftFunc: FfiConverterTypeFfiConversation.lift,
errorHandler: FfiConverterTypeGenericError.lift
)
}

open func createGroup(accountAddresses: [String], opts: FfiCreateGroupOptions) async throws -> FfiConversation {
return
try await uniffiRustCallAsync(
Expand All @@ -1961,6 +1982,23 @@ open class FfiConversations:
)
}

open func createGroupWithInboxIds(inboxIds: [String], opts: FfiCreateGroupOptions) async throws -> FfiConversation {
return
try await uniffiRustCallAsync(
rustFutureFunc: {
uniffi_xmtpv3_fn_method_fficonversations_create_group_with_inbox_ids(
self.uniffiClonePointer(),
FfiConverterSequenceString.lower(inboxIds), FfiConverterTypeFfiCreateGroupOptions.lower(opts)
)
},
pollFunc: ffi_xmtpv3_rust_future_poll_pointer,
completeFunc: ffi_xmtpv3_rust_future_complete_pointer,
freeFunc: ffi_xmtpv3_rust_future_free_pointer,
liftFunc: FfiConverterTypeFfiConversation.lift,
errorHandler: FfiConverterTypeGenericError.lift
)
}

open func getHmacKeys() throws -> [Data: [FfiHmacKey]] {
return try FfiConverterDictionaryDataSequenceTypeFfiHmacKey.lift(rustCallWithError(FfiConverterTypeGenericError.lift) {
uniffi_xmtpv3_fn_method_fficonversations_get_hmac_keys(self.uniffiClonePointer(), $0)
Expand Down Expand Up @@ -2188,13 +2226,13 @@ open class FfiConversations:
)
}

open func syncAllConversations(consentState: FfiConsentState?) async throws -> UInt32 {
open func syncAllConversations(consentStates: [FfiConsentState]?) async throws -> UInt32 {
return
try await uniffiRustCallAsync(
rustFutureFunc: {
uniffi_xmtpv3_fn_method_fficonversations_sync_all_conversations(
self.uniffiClonePointer(),
FfiConverterOptionTypeFfiConsentState.lower(consentState)
FfiConverterOptionSequenceTypeFfiConsentState.lower(consentStates)
)
},
pollFunc: ffi_xmtpv3_rust_future_poll_u32,
Expand Down Expand Up @@ -4855,16 +4893,16 @@ public struct FfiListConversationsOptions {
public var createdAfterNs: Int64?
public var createdBeforeNs: Int64?
public var limit: Int64?
public var consentState: FfiConsentState?
public var consentStates: [FfiConsentState]?
public var includeDuplicateDms: Bool

// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(createdAfterNs: Int64?, createdBeforeNs: Int64?, limit: Int64?, consentState: FfiConsentState?, includeDuplicateDms: Bool) {
public init(createdAfterNs: Int64?, createdBeforeNs: Int64?, limit: Int64?, consentStates: [FfiConsentState]?, includeDuplicateDms: Bool) {
self.createdAfterNs = createdAfterNs
self.createdBeforeNs = createdBeforeNs
self.limit = limit
self.consentState = consentState
self.consentStates = consentStates
self.includeDuplicateDms = includeDuplicateDms
}
}
Expand All @@ -4880,7 +4918,7 @@ extension FfiListConversationsOptions: Equatable, Hashable {
if lhs.limit != rhs.limit {
return false
}
if lhs.consentState != rhs.consentState {
if lhs.consentStates != rhs.consentStates {
return false
}
if lhs.includeDuplicateDms != rhs.includeDuplicateDms {
Expand All @@ -4893,7 +4931,7 @@ extension FfiListConversationsOptions: Equatable, Hashable {
hasher.combine(createdAfterNs)
hasher.combine(createdBeforeNs)
hasher.combine(limit)
hasher.combine(consentState)
hasher.combine(consentStates)
hasher.combine(includeDuplicateDms)
}
}
Expand All @@ -4908,7 +4946,7 @@ public struct FfiConverterTypeFfiListConversationsOptions: FfiConverterRustBuffe
createdAfterNs: FfiConverterOptionInt64.read(from: &buf),
createdBeforeNs: FfiConverterOptionInt64.read(from: &buf),
limit: FfiConverterOptionInt64.read(from: &buf),
consentState: FfiConverterOptionTypeFfiConsentState.read(from: &buf),
consentStates: FfiConverterOptionSequenceTypeFfiConsentState.read(from: &buf),
includeDuplicateDms: FfiConverterBool.read(from: &buf)
)
}
Expand All @@ -4917,7 +4955,7 @@ public struct FfiConverterTypeFfiListConversationsOptions: FfiConverterRustBuffe
FfiConverterOptionInt64.write(value.createdAfterNs, into: &buf)
FfiConverterOptionInt64.write(value.createdBeforeNs, into: &buf)
FfiConverterOptionInt64.write(value.limit, into: &buf)
FfiConverterOptionTypeFfiConsentState.write(value.consentState, into: &buf)
FfiConverterOptionSequenceTypeFfiConsentState.write(value.consentStates, into: &buf)
FfiConverterBool.write(value.includeDuplicateDms, into: &buf)
}
}
Expand Down Expand Up @@ -7424,30 +7462,6 @@ private struct FfiConverterOptionTypeFfiPermissionPolicySet: FfiConverterRustBuf
}
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
private struct FfiConverterOptionTypeFfiConsentState: FfiConverterRustBuffer {
typealias SwiftType = FfiConsentState?

public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterTypeFfiConsentState.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 FfiConverterTypeFfiConsentState.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
Expand Down Expand Up @@ -7568,6 +7582,30 @@ private struct FfiConverterOptionTypeFfiMetadataField: FfiConverterRustBuffer {
}
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
private struct FfiConverterOptionSequenceTypeFfiConsentState: FfiConverterRustBuffer {
typealias SwiftType = [FfiConsentState]?

public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterSequenceTypeFfiConsentState.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 FfiConverterSequenceTypeFfiConsentState.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
Expand Down Expand Up @@ -7917,6 +7955,31 @@ private struct FfiConverterSequenceTypeFfiV2QueryResponse: FfiConverterRustBuffe
}
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
private struct FfiConverterSequenceTypeFfiConsentState: FfiConverterRustBuffer {
typealias SwiftType = [FfiConsentState]

public static func write(_ value: [FfiConsentState], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
FfiConverterTypeFfiConsentState.write(item, into: &buf)
}
}

public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [FfiConsentState] {
let len: Int32 = try readInt(&buf)
var seq = [FfiConsentState]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
try seq.append(FfiConverterTypeFfiConsentState.read(from: &buf))
}
return seq
}
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
Expand Down Expand Up @@ -8494,9 +8557,15 @@ private var initializationResult: InitializationResult = {
if uniffi_xmtpv3_checksum_method_fficonversations_create_dm() != 63785 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_fficonversations_create_dm_with_inbox_id() != 25323 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_fficonversations_create_group() != 7282 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_fficonversations_create_group_with_inbox_ids() != 56407 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_fficonversations_get_hmac_keys() != 44064 {
return InitializationResult.apiChecksumMismatch
}
Expand Down Expand Up @@ -8545,7 +8614,7 @@ private var initializationResult: InitializationResult = {
if uniffi_xmtpv3_checksum_method_fficonversations_sync() != 9054 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_fficonversations_sync_all_conversations() != 2613 {
if uniffi_xmtpv3_checksum_method_fficonversations_sync_all_conversations() != 30657 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigrouppermissions_policy_set() != 24928 {
Expand Down

0 comments on commit 6b0166d

Please sign in to comment.